linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@redhat.com>
To: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, hch@infradead.org,
	akpm@linux-foundation.org
Subject: [PATCH 3/6] direct-io: do not merge logically non-contiguous requests
Date: Wed, 19 May 2010 16:24:51 -0400	[thread overview]
Message-ID: <1274300694-8976-3-git-send-email-josef@redhat.com> (raw)
In-Reply-To: <1274300694-8976-1-git-send-email-josef@redhat.com>

Btrfs cannot handle having logically non-contiguous requests submitted.  For
example if you have

Logical:  [0-4095][HOLE][8192-12287]
Physical: [0-4095]      [4096-8191]

Normally the DIO code would put these into the same BIO's.  The problem is we
need to know exactly what offset is associated with what BIO so we can do our
checksumming and unlocking properly, so putting them in the same BIO doesn't
work.  So add another check where we submit the current BIO if the physical
blocks are not contigous OR the logical blocks are not contiguous.

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 fs/direct-io.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 21ec032..03a3ed4 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -623,10 +623,15 @@ static int dio_send_cur_page(struct dio *dio)
 	int ret = 0;
 
 	if (dio->bio) {
+		loff_t cur_offset = dio->block_in_file << dio->blkbits;
+		loff_t bio_next_offset = dio->logical_offset_in_bio +
+			dio->bio->bi_size;
+
 		/*
 		 * See whether this new request is contiguous with the old
 		 */
-		if (dio->final_block_in_bio != dio->cur_page_block)
+		if (dio->final_block_in_bio != dio->cur_page_block ||
+		    cur_offset != bio_next_offset)
 			dio_bio_submit(dio);
 		/*
 		 * Submit now if the underlying fs is about to perform a
-- 
1.6.6.1

  parent reply	other threads:[~2010-05-19 20:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 20:24 [PATCH 1/6] fs: allow short direct-io reads to be completed via buffered IO V2 Josef Bacik
2010-05-19 20:24 ` [PATCH 2/6] direct-io: add a hook for the fs to provide its own submit_bio function V3 Josef Bacik
2010-05-21 15:20   ` Christoph Hellwig
2010-05-19 20:24 ` Josef Bacik [this message]
2010-05-21 15:21   ` [PATCH 3/6] direct-io: do not merge logically non-contiguous requests Christoph Hellwig
2010-05-21 15:37     ` Josef Bacik
2010-05-21 15:35       ` Christoph Hellwig
2010-05-19 20:24 ` [PATCH 4/6] fs: kill blockdev_direct_IO_no_locking Josef Bacik
2010-05-21 15:21   ` Christoph Hellwig
2010-05-19 20:24 ` [PATCH 5/6] Btrfs: add basic DIO read/write support V6 Josef Bacik
2010-05-19 20:24 ` [PATCH 6/6] Btrfs: do aio_write instead of write V2 Josef Bacik
2010-05-21 17:03 [PATCH 1/6] fs: allow short direct-io reads to be completed via buffered IO Josef Bacik
2010-05-21 17:03 ` [PATCH 3/6] direct-io: do not merge logically non-contiguous requests Josef Bacik
2010-05-22  1:47   ` Mike Fedyk
2010-05-22 14:02     ` Josef Bacik

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=1274300694-8976-3-git-send-email-josef@redhat.com \
    --to=josef@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).