[PATCH-v2 1/3] pnfsblock: bail out partial block direct write

[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 |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index dd392ed..bab432f 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -572,10 +572,13 @@ bl_write_pagelist(struct nfs_write_data *wdata, int sync)
 	u64 temp;
 	int npg_per_block =
 	    NFS_SERVER(header->inode)->pnfs_blksize >> PAGE_CACHE_SHIFT;
+	unsigned long blkmask = PAGE_CACHE_MASK;
 
 	dprintk("%s enter, %Zu@%lld\n", __func__, count, offset);
 	/* Check for alignment first */
-	if (!bl_check_alignment(offset, count, PAGE_CACHE_MASK))
+	if (header->dreq)
+		blkmask = NFS_SERVER(header->inode)->pnfs_blksize - 1;
+	if (!bl_check_alignment(offset, count, blkmask))
 		goto out_mds;
 
 	/* At this point, wdata->pages is a (sequential) list of nfs_pages.
@@ -1023,7 +1026,15 @@ bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
 static void
 bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
 {
-	if (!bl_check_alignment(req->wb_offset, req->wb_bytes, PAGE_CACHE_MASK))
+	if (pgio->pg_dreq) {
+		/* Direct write should be blksize aligned */
+		unsigned blkmask = NFS_SERVER(pgio->pg_inode)->pnfs_blksize - 1;
+		u64 pos = (req->wb_index << PAGE_CACHE_SHIFT) + req->wb_bytes;
+		if (!bl_check_alignment(pos, 0, blkmask) ||
+		    req->wb_bytes != PAGE_CACHE_SIZE)
+			nfs_pageio_reset_write_mds(pgio);
+	} else if (!bl_check_alignment(req->wb_offset, req->wb_bytes,
+				       PAGE_CACHE_MASK))
 		nfs_pageio_reset_write_mds(pgio);
 	else
 		pnfs_generic_pg_init_write(pgio, req);
-- 
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