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>
if (unlikely(!req))
return NULL;
if (unlikely(!req))
return NULL;
- req->ki_flags = 1 << KIF_LOCKED;
req->ki_users = 2;
req->ki_key = 0;
req->ki_ctx = ctx;
req->ki_users = 2;
req->ki_key = 0;
req->ki_ctx = ctx;
-static int lock_kiocb_action(void *param)
-{
- schedule();
- return 0;
-}
-
-static inline void lock_kiocb(struct kiocb *iocb)
-{
- wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action,
- TASK_UNINTERRUPTIBLE);
-}
-
-static inline void unlock_kiocb(struct kiocb *iocb)
-{
- kiocbClearLocked(iocb);
- smp_mb__after_clear_bit();
- wake_up_bit(&iocb->ki_flags, KIF_LOCKED);
-}
-
/*
* use_mm
* Makes the calling kernel thread take on the specified
/*
* use_mm
* Makes the calling kernel thread take on the specified
* Hold an extra reference while retrying i/o.
*/
iocb->ki_users++; /* grab extra reference */
* Hold an extra reference while retrying i/o.
*/
iocb->ki_users++; /* grab extra reference */
if (__aio_put_req(ctx, iocb)) /* drop extra ref */
put_ioctx(ctx);
}
if (__aio_put_req(ctx, iocb)) /* drop extra ref */
put_ioctx(ctx);
}
spin_lock_irq(&ctx->ctx_lock);
aio_run_iocb(req);
spin_lock_irq(&ctx->ctx_lock);
aio_run_iocb(req);
if (!list_empty(&ctx->run_list)) {
/* drain the run list */
while (__aio_run_iocbs(ctx))
if (!list_empty(&ctx->run_list)) {
/* drain the run list */
while (__aio_run_iocbs(ctx))
if (NULL != cancel) {
struct io_event tmp;
pr_debug("calling cancel\n");
if (NULL != cancel) {
struct io_event tmp;
pr_debug("calling cancel\n");
memset(&tmp, 0, sizeof(tmp));
tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;
tmp.data = kiocb->ki_user_data;
memset(&tmp, 0, sizeof(tmp));
tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;
tmp.data = kiocb->ki_user_data;
if (copy_to_user(result, &tmp, sizeof(tmp)))
ret = -EFAULT;
}
if (copy_to_user(result, &tmp, sizeof(tmp)))
ret = -EFAULT;
}
#define KIOCB_SYNC_KEY (~0U)
/* ki_flags bits */
#define KIOCB_SYNC_KEY (~0U)
/* ki_flags bits */
+/*
+ * This may be used for cancel/retry serialization in the future, but
+ * for now it's unused and we probably don't want modules to even
+ * think they can use it.
+ */
+/* #define KIF_LOCKED 0 */
#define KIF_KICKED 1
#define KIF_CANCELLED 2
#define KIF_KICKED 1
#define KIF_CANCELLED 2