[<prev] [next>] [day] [month] [year] [list]
Message-ID: <201208102037120467864@gmail.com>
Date: Fri, 10 Aug 2012 20:37:14 +0800
From: "Jianpeng Ma" <majianpeng@...il.com>
To: viro <viro@...IV.linux.org.uk>
Cc: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH] fs/direct-io.c: Add REQ_NOIDLE for last bio .
For last bio of dio, there are no bio will come.So set REQ_NOIDLE.
Signed-off-by: Jianpeng Ma <majianpeng@...il.com>
---
fs/direct-io.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1faf4cb..7c6958f 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -127,6 +127,7 @@ struct dio {
int page_errors; /* errno from get_user_pages() */
int is_async; /* is IO async ? */
int io_error; /* IO error in completion path */
+ sector_t end_sector; /* the last sector for this dio */
unsigned long refcount; /* direct_io_worker() and bios */
struct bio *bio_list; /* singly linked via bi_private */
struct task_struct *waiter; /* waiting task (NULL if none) */
@@ -369,21 +370,28 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
{
struct bio *bio = sdio->bio;
unsigned long flags;
-
+ int rw = dio->rw;
bio->bi_private = dio;
spin_lock_irqsave(&dio->bio_lock, flags);
dio->refcount++;
spin_unlock_irqrestore(&dio->bio_lock, flags);
+ /*
+ * If bio is the last for dio,so no bio can arrive for low-level
+ * unless this dio completed.
+ */
+ if (bio->bi_sector + bio_sectors(bio) >= dio->end_sector)
+ rw |= REQ_NOIDLE;
+
if (dio->is_async && dio->rw == READ)
bio_set_pages_dirty(bio);
if (sdio->submit_io)
- sdio->submit_io(dio->rw, bio, dio->inode,
+ sdio->submit_io(rw, bio, dio->inode,
sdio->logical_offset_in_bio);
else
- submit_bio(dio->rw, bio);
+ submit_bio(rw, bio);
sdio->bio = NULL;
sdio->boundary = 0;
@@ -1147,6 +1155,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
dio->inode = inode;
dio->rw = rw;
+ dio->end_sector = end >> 9;
sdio.blkbits = blkbits;
sdio.blkfactor = inode->i_blkbits - blkbits;
sdio.block_in_file = offset >> blkbits;
--
1.7.9.5
Powered by blists - more mailing lists