summaryrefslogtreecommitdiff
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-10-10 20:50:11 -0700
committerKent Overstreet <kmo@daterainc.com>2013-10-10 20:50:46 -0700
commit87f98e774776d0f3e1214b61123b34de53e63e94 (patch)
tree7ab1b4f81329487991cb519bc3182bd72cdc6b06 /fs/direct-io.c
parent8613f0c75e242dd806ae7b84c67e1761a0ed6a9d (diff)
block: Bio cancellationaio
If a bio is associated with a kiocb, allow it to be cancelled. This is accomplished by adding a pointer to a kiocb in struct bio, and when we go to dequeue a request we check if its bio has been cancelled - if so, we end the request with -ECANCELED. We don't currently try to cancel bios if IO has already been started - that'd require a per bio callback function, and a way to find all the outstanding bios for a given kiocb. Such a mechanism may or may not be added in the future but this patch tries to start simple. Currently this can only be triggered with aio and io_cancel(), but the mechanism can be used for sync io too. It can also be used for bios created by stacking drivers, and bio clones in general - when cloning a bio, if the bi_iocb pointer is copied as well the clone will then be cancellable. bio_clone() could be modified to do this, but hasn't in this patch because all the bio_clone() users would need to be auditied to make sure that it's safe. We can't blindly make e.g. raid5 writes cancellable without the knowledge of the md code. Initial patch by Anatol Pomazau (anatol@google.com). Signed-off-by: Kent Overstreet <koverstreet@google.com> Cc: Zach Brown <zab@redhat.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Benjamin LaHaise <bcrl@kvack.org>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 24d6cd388649..f1a8cac3919c 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -402,6 +402,7 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
unsigned long flags;
bio->bi_private = dio;
+ bio->bi_iocb = dio->iocb;
spin_lock_irqsave(&dio->bio_lock, flags);
dio->refcount++;