* [PATCH 1/2] change io_cancel return code for no cancel case
@ 2005-09-07 20:39 Benjamin LaHaise
2005-09-07 20:41 ` [AIO] kiocb locking to serialise retry and cancel Benjamin LaHaise
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin LaHaise @ 2005-09-07 20:39 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel
From: Wendy Cheng <wcheng@redhat.com>
Note that other than few exceptions, most of the current filesystem and/or
drivers do not have aio cancel specifically defined (kiob->ki_cancel field
is mostly NULL). However, sys_io_cancel system call universally sets
return code to -EAGAIN. This gives applications a wrong impression that
this call is implemented but just never works. We have customer inquires
about this issue.
Changed by Benjamin LaHaise to EINVAL instead of ENOSYS
Signed-off-by: S. Wendy Cheng <wcheng@redhat.com>
Acked-by: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
aio.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff -purN --exclude=description 00_linus-git/fs/aio.c 01_aio_enosys/fs/aio.c
--- 00_linus-git/fs/aio.c 2005-09-07 10:59:31.000000000 -0400
+++ 01_aio_enosys/fs/aio.c 2005-09-07 11:03:55.000000000 -0400
@@ -1673,7 +1673,7 @@ asmlinkage long sys_io_cancel(aio_contex
ret = -EFAULT;
}
} else
- printk(KERN_DEBUG "iocb has no cancel operation\n");
+ ret = -EINVAL;
put_ioctx(ctx);
^ permalink raw reply [flat|nested] 2+ messages in thread
* [AIO] kiocb locking to serialise retry and cancel
2005-09-07 20:39 [PATCH 1/2] change io_cancel return code for no cancel case Benjamin LaHaise
@ 2005-09-07 20:41 ` Benjamin LaHaise
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin LaHaise @ 2005-09-07 20:41 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel
[AIO] kiocb locking to serialise retry and cancel
Implement a per-kiocb lock to serialise retry operations and cancel. This
is done using wait_on_bit_lock() on the KIF_LOCKED bit of kiocb->ki_flags.
Also, make the cancellation path lock the kiocb and subsequently release
all references to it if the cancel was successful. This version includes
a fix for the deadlock with __aio_run_iocbs.
Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
aio.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff -purN --exclude=description 01_aio_enosys/fs/aio.c 02_lock_kiocb/fs/aio.c
--- 01_aio_enosys/fs/aio.c 2005-09-07 11:03:55.000000000 -0400
+++ 02_lock_kiocb/fs/aio.c 2005-09-07 11:03:57.000000000 -0400
@@ -546,6 +546,24 @@ struct kioctx *lookup_ioctx(unsigned lon
return ioctx;
}
+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);
+ wake_up_bit(&iocb->ki_flags, KIF_LOCKED);
+}
+
/*
* use_mm
* Makes the calling kernel thread take on the specified
@@ -786,7 +804,9 @@ static int __aio_run_iocbs(struct kioctx
* Hold an extra reference while retrying i/o.
*/
iocb->ki_users++; /* grab extra reference */
+ lock_kiocb(iocb);
aio_run_iocb(iocb);
+ unlock_kiocb(iocb);
if (__aio_put_req(ctx, iocb)) /* drop extra ref */
put_ioctx(ctx);
}
@@ -1527,10 +1547,9 @@ int fastcall io_submit_one(struct kioctx
goto out_put_req;
spin_lock_irq(&ctx->ctx_lock);
- if (likely(list_empty(&ctx->run_list))) {
- aio_run_iocb(req);
- } else {
- list_add_tail(&req->ki_run_list, &ctx->run_list);
+ aio_run_iocb(req);
+ unlock_kiocb(req);
+ if (!list_empty(&ctx->run_list)) {
/* drain the run list */
while (__aio_run_iocbs(ctx))
;
@@ -1661,6 +1680,7 @@ asmlinkage long sys_io_cancel(aio_contex
if (NULL != cancel) {
struct io_event tmp;
pr_debug("calling cancel\n");
+ lock_kiocb(kiocb);
memset(&tmp, 0, sizeof(tmp));
tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;
tmp.data = kiocb->ki_user_data;
@@ -1672,6 +1692,7 @@ asmlinkage long sys_io_cancel(aio_contex
if (copy_to_user(result, &tmp, sizeof(tmp)))
ret = -EFAULT;
}
+ unlock_kiocb(kiocb);
} else
ret = -EINVAL;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-07 20:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-07 20:39 [PATCH 1/2] change io_cancel return code for no cancel case Benjamin LaHaise
2005-09-07 20:41 ` [AIO] kiocb locking to serialise retry and cancel Benjamin LaHaise
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.