linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jianpeng Ma" <majianpeng@gmail.com>
To: viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH] fs/direct-io.c: Add REQ_NOIDLE for last bio .
Date: Fri, 10 Aug 2012 20:37:14 +0800	[thread overview]
Message-ID: <201208102037120467864@gmail.com> (raw)

For last bio of dio, there are no bio will come.So set REQ_NOIDLE.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.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

                 reply	other threads:[~2012-08-10 12:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201208102037120467864@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).