linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, Peng Tao <tao.peng@emc.com>
Subject: [PATCH 3/3] pnfsblock: bail out unaligned DIO
Date: Sun, 27 May 2012 13:33:00 +0800	[thread overview]
Message-ID: <1338096780-2763-4-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1338096780-2763-1-git-send-email-bergwolf@gmail.com>

Signed-off-by: Peng Tao <tao.peng@emc.com>
---
 fs/nfs/blocklayout/blocklayout.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 53cb450..cdb87a9 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -1000,7 +1000,27 @@ static bool bl_dio_begin(struct inode *inode, const struct iovec *iov,
 			 unsigned long nr_segs, loff_t pos,
 			 struct blk_plug *plug)
 {
+	unsigned blkmask = NFS_SERVER(inode)->pnfs_blksize - 1;
+	size_t count;
+	int seg;
+	unsigned long addr;
+
 	blk_start_plug(plug);
+
+	/* Only allow blksized DIO for now.
+	 * In theory we can handle page aligned DIO in current block layout
+	 * read/write code, but it would require serialization between
+	 * concurrent writers and it is far less effecient than just send IO
+	 * to MDS.
+	 */
+	if (pos & blkmask)
+		return false;
+	for (seg = 0; seg < nr_segs; seg++) {
+		addr = (unsigned long)iov[seg].iov_base;
+		count = iov[seg].iov_len;
+		if (unlikely((addr & blkmask) || (count & blkmask)))
+			return false;
+	}
 	return true;
 }
 
-- 
1.7.1.262.g5ef3d


  parent reply	other threads:[~2012-05-27  5:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27  5:32 [PATCH 0/3] NFS41: make block layout driver work w/ NFS DIO changes Peng Tao
2012-05-27  5:32 ` [PATCH 1/3] NFS41: add pnfs_dio_begin/dio_end Peng Tao
2012-05-27 16:29   ` Myklebust, Trond
2012-05-28  2:30     ` tao.peng
2012-05-28  3:42       ` Myklebust, Trond
2012-05-28  4:13         ` tao.peng
2012-05-28 10:44           ` Boaz Harrosh
2012-05-28 10:51             ` Boaz Harrosh
2012-05-28 17:14               ` Peng Tao
2012-05-28 17:24                 ` Boaz Harrosh
2012-05-28 17:36                   ` Peng Tao
2012-05-28 17:44                     ` Myklebust, Trond
2012-05-27  5:32 ` [PATCH 2/3] pnfsblock: call block plug in bl_dio_begin/end Peng Tao
2012-05-27  5:33 ` Peng Tao [this message]
2012-05-27 16:38   ` [PATCH 3/3] pnfsblock: bail out unaligned DIO Myklebust, Trond
2012-05-28  2:30     ` tao.peng
2012-05-28  3:45       ` Myklebust, Trond
2012-05-28  4:26         ` tao.peng
2012-05-28 16:33           ` Myklebust, Trond
2012-05-28 17:07             ` Peng Tao
2012-05-28 11:26       ` Boaz Harrosh
2012-05-28 16:50         ` Peng Tao
2012-05-28 17:10           ` Boaz Harrosh

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=1338096780-2763-4-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tao.peng@emc.com \
    /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).