Skip to content

Commit 4faa528

Browse files
Zach BrownLinus Torvalds
authored andcommitted
[PATCH] aio: revert lock_kiocb()
lock_kiocb() was introduced to serialize retrying and cancellation. In the process of doing so it tried to sleep waiting for KIF_LOCKED while holding the ctx_lock spinlock. Recent fixes have ensured that multiple concurrent retries won't be attempted for a given iocb. Cancel has other problems and has no significant in-tree users that have been complaining about it. So for the immediate future we'll revert sleeping with the lock held and will address proper cancellation and retry serialization in the future. Signed-off-by: Zach Brown <zach.brown@oracle.com> Acked-by: Benjamin LaHaise <bcrl@kvack.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent e7507ed commit 4faa528

2 files changed

Lines changed: 7 additions & 26 deletions

File tree

‎fs/aio.c‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx)
398398
if (unlikely(!req))
399399
return NULL;
400400

401-
req->ki_flags = 1 << KIF_LOCKED;
401+
req->ki_flags = 0;
402402
req->ki_users = 2;
403403
req->ki_key = 0;
404404
req->ki_ctx = ctx;
@@ -547,25 +547,6 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id)
547547
return ioctx;
548548
}
549549

550-
static int lock_kiocb_action(void *param)
551-
{
552-
schedule();
553-
return 0;
554-
}
555-
556-
static inline void lock_kiocb(struct kiocb *iocb)
557-
{
558-
wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action,
559-
TASK_UNINTERRUPTIBLE);
560-
}
561-
562-
static inline void unlock_kiocb(struct kiocb *iocb)
563-
{
564-
kiocbClearLocked(iocb);
565-
smp_mb__after_clear_bit();
566-
wake_up_bit(&iocb->ki_flags, KIF_LOCKED);
567-
}
568-
569550
/*
570551
* use_mm
571552
* Makes the calling kernel thread take on the specified
@@ -796,9 +777,7 @@ static int __aio_run_iocbs(struct kioctx *ctx)
796777
* Hold an extra reference while retrying i/o.
797778
*/
798779
iocb->ki_users++; /* grab extra reference */
799-
lock_kiocb(iocb);
800780
aio_run_iocb(iocb);
801-
unlock_kiocb(iocb);
802781
if (__aio_put_req(ctx, iocb)) /* drop extra ref */
803782
put_ioctx(ctx);
804783
}
@@ -1542,7 +1521,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
15421521

15431522
spin_lock_irq(&ctx->ctx_lock);
15441523
aio_run_iocb(req);
1545-
unlock_kiocb(req);
15461524
if (!list_empty(&ctx->run_list)) {
15471525
/* drain the run list */
15481526
while (__aio_run_iocbs(ctx))
@@ -1674,7 +1652,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
16741652
if (NULL != cancel) {
16751653
struct io_event tmp;
16761654
pr_debug("calling cancel\n");
1677-
lock_kiocb(kiocb);
16781655
memset(&tmp, 0, sizeof(tmp));
16791656
tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;
16801657
tmp.data = kiocb->ki_user_data;
@@ -1686,7 +1663,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
16861663
if (copy_to_user(result, &tmp, sizeof(tmp)))
16871664
ret = -EFAULT;
16881665
}
1689-
unlock_kiocb(kiocb);
16901666
} else
16911667
ret = -EINVAL;
16921668

‎include/linux/aio.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ struct kioctx;
2424
#define KIOCB_SYNC_KEY (~0U)
2525

2626
/* ki_flags bits */
27-
#define KIF_LOCKED 0
27+
/*
28+
* This may be used for cancel/retry serialization in the future, but
29+
* for now it's unused and we probably don't want modules to even
30+
* think they can use it.
31+
*/
32+
/* #define KIF_LOCKED 0 */
2833
#define KIF_KICKED 1
2934
#define KIF_CANCELLED 2
3035

0 commit comments

Comments
 (0)