[PATCH] dio: call blk_run_address_space() once per op
authorZach Brown <zach.brown@oracle.com>
Sun, 10 Dec 2006 10:20:56 +0000 (02:20 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sun, 10 Dec 2006 17:57:21 +0000 (09:57 -0800)
We only need to call blk_run_address_space() once after all the bios for the
direct IO op have been submitted.  This removes the chance of calling
blk_run_address_space() after spurious wake ups as the sync path waits for
bios to drain.  It's also one less difference betwen the sync and async paths.

In the process we remove a redundant dio_bio_submit() that its caller had
already performed.

Signed-off-by: Zach Brown <zach.brown@oracle.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Suparna Bhattacharya <suparna@in.ibm.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/direct-io.c

index b57b671e1106844ed5e16921a84859ffc08912dc..b296942ff7d5865cc90d107edf6823cc9bd674d8 100644 (file)
@@ -404,7 +404,6 @@ static struct bio *dio_await_one(struct dio *dio)
                if (dio->bio_list == NULL) {
                        dio->waiter = current;
                        spin_unlock_irqrestore(&dio->bio_lock, flags);
-                       blk_run_address_space(dio->inode->i_mapping);
                        io_schedule();
                        spin_lock_irqsave(&dio->bio_lock, flags);
                        dio->waiter = NULL;
@@ -450,9 +449,6 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
  */
 static void dio_await_completion(struct dio *dio)
 {
-       if (dio->bio)
-               dio_bio_submit(dio);
-
        /*
         * The bio_lock is not held for the read of bio_count.
         * This is ok since it is the dio_bio_complete() that changes
@@ -1085,6 +1081,9 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
        if (dio->bio)
                dio_bio_submit(dio);
 
+       /* All IO is now issued, send it on its way */
+       blk_run_address_space(inode->i_mapping);
+
        /*
         * It is possible that, we return short IO due to end of file.
         * In that case, we need to release all the pages we got hold on.
@@ -1113,7 +1112,6 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
                if (ret == 0)
                        ret = dio->result;
                finished_one_bio(dio);          /* This can free the dio */
-               blk_run_address_space(inode->i_mapping);
                if (should_wait) {
                        unsigned long flags;
                        /*