[PATCH 3/3] pnfsblock: bail out unaligned DIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Peng Tao <tao.peng@xxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux