From: Zach Brown <zach.brown@oracle.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@linux.intel.com>,
linux-aio@kvack.org
Subject: Re: [PATCH 5/5] Make wait_on_retry_sync_kiocb killable
Date: Thu, 25 Oct 2007 11:31:51 -0700 [thread overview]
Message-ID: <4720E117.8030805@oracle.com> (raw)
In-Reply-To: <11932286982021-git-send-email-matthew@wil.cx>
Matthew Wilcox wrote:
> Use TASK_KILLABLE to allow wait_on_retry_sync_kiocb to return -EINTR.
> All callers then check the return value and break out of their loops.
This won't work because "sync" kiocbs are a nasty hack that don't follow
the (also nasty) refcounting patterns of the aio core.
-EIOCBRETRY means that aio_{read,write}() has taken on the "IO" kiocb
reference and has ensured that call kick_iocb() will be called in the
future.
Usually kick_iocb() would queue the kiocb to have its ki_retry method
called by the kernel aio threads while holding that reference. But
"sync" kiocbs are on-stack and aren't reference counted. kick_iocb() magic:
/* sync iocbs are easy: they can only ever be executing from a
* single context. */
if (is_sync_kiocb(iocb)) {
kiocbSetKicked(iocb);
wake_up_process(iocb->ki_obj.tsk);
return;
}
So, with this patch, if we catch a signal and return from
wait_on_retry_sync_kiocb() and return from do_sync_{read,write}() then
that on-stack sync kiocb is going to be long gone when kick_iocb() goes
to work with it.
So the first step would be to make sync kiocbs real refcounted
structures so that kick_iocb() could find that the sync submitter has
disappeared.
But then we have to worry about leaving retrying operations in flight
after the sync submitter has returned from their system call. They
might be VERY SURPRISED to find that a read() implemented with
do_sync_read() is still writing into their userspace pointer after the
syscall was interrupted by a signal.
This leads us to the possibility of working with the ki_cancel method to
stop a pending operation if a signal is caught from a sync submitter.
In practice, nothing sets ki_cancel.
And finally, this code will not be run in a solely mainline kernel. The
only thing in mainline that returns -EIOCBRETRY is the goofy usb gadget.
It has both ->{read,write} and ->aio_{read,write} file op methods so
vfs_{read,write}() will never call do_sync_{read,write}(). Sure,
out-of-tree aio providers (SDP?) might get caught up in this.
(Ha ha! Welcome to fs/aio.c!)
So I'm not sure where to go with this. It's a mess, but it doesn't seem
like anything is using it. A significant clean up of the retry and
cancelation support in fs/aio.c is in flight. Maybe we can revisit this
once that settles down.
- z
next prev parent reply other threads:[~2007-10-25 18:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-24 12:24 [PATCH 1/5] Use wake_up_locked() in eventpoll Matthew Wilcox
2007-10-24 12:24 ` [PATCH 2/5] Use macros instead of TASK_ flags Matthew Wilcox
2007-10-25 3:31 ` Andrew Morton
2007-10-26 18:45 ` Andrew Morton
2007-10-26 20:39 ` Alexey Dobriyan
2007-10-27 0:33 ` Matthew Wilcox
2007-12-05 12:56 ` Ingo Molnar
2007-12-06 14:42 ` Matthew Wilcox
2007-10-24 12:24 ` [PATCH 3/5] Add TASK_WAKEKILL Matthew Wilcox
2007-10-24 12:24 ` [PATCH 4/5] Add lock_page_killable Matthew Wilcox
2007-10-25 4:11 ` Andrew Morton
2007-10-25 4:13 ` Nick Piggin
2007-10-24 12:24 ` [PATCH 5/5] Make wait_on_retry_sync_kiocb killable Matthew Wilcox
2007-10-25 3:43 ` Andrew Morton
2007-10-25 18:31 ` Zach Brown [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-10-18 22:25 [PATCH 0/5] TASK_KILLABLE Matthew Wilcox
2007-10-18 22:26 ` [PATCH 5/5] Make wait_on_retry_sync_kiocb killable Matthew Wilcox
2007-10-25 3:53 ` Nick Piggin
2007-09-02 2:43 [PATCH] TASK_KILLABLE version 2 Matthew Wilcox
2007-09-02 2:46 ` [PATCH 5/5] Make wait_on_retry_sync_kiocb killable Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4720E117.8030805@oracle.com \
--to=zach.brown@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=torvalds@linux-foundation.org \
--cc=willy@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox