[pnfs] [PATCH 1/1] pnfs: Ensure file layout stripe_unit multiple of r/w-size

seattleplus at gmail.com seattleplus at gmail.com
Wed May 14 17:07:03 EDT 2008


From: Dean Hildebrand <dhildeb at rock3.almaden.ibm.com>


Signed-off-by: Dean Hildebrand <dhildeb at rock3.almaden.ibm.com>
---
 fs/nfs/nfs4filelayout.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 89f98a2..d04d808 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -412,6 +412,7 @@ filelayout_free_layout(struct pnfs_layout_type *layoutid)
  *    is wrong.
  * 2) pattern_offset is ignored and must == 0 which is wrong;
  * 3) the pattern_offset needs to be a mutliple of the stripe unit.
+ * 4) stripe unit is multiple of ds_rsize and ds_wsize
 */
 
 static int
@@ -421,6 +422,9 @@ filelayout_check_layout(struct pnfs_layout_type *lo,
 	struct nfs4_filelayout_segment *fl = LSEG_LD_DATA(lseg);
 	struct nfs4_pnfs_dev_item *dev;
 	int status = -EINVAL;
+	struct nfs_server *nfss = NFS_SERVER(PNFS_INODE(lo));
+	u64 tmp1, tmp2;
+	u32 rrem, wrem;
 
 	dprintk("--> %s\n", __func__);
 	dev = nfs4_pnfs_device_item_get(FILE_MT(lo->inode), NFS_FH(lo->inode),
@@ -444,6 +448,16 @@ filelayout_check_layout(struct pnfs_layout_type *lo,
 				__func__, fl->pattern_offset);
 		goto out;
 	}
+
+	tmp1 = fl->stripe_unit;
+	tmp2 = fl->stripe_unit;
+	rrem = do_div(tmp1, nfss->ds_rsize);
+	wrem = do_div(tmp2, nfss->ds_wsize);
+	if (rrem || wrem) {
+		dprintk("%s Stripe unit (%u) not aligned rsize %u wsize %u\n",
+			__func__, fl->stripe_unit, nfss->ds_rsize, nfss->ds_wsize);
+		goto out;
+	}
 	status = 0;
 out:
 	dprintk("--> %s returns %d\n", __func__, status);
-- 
1.5.2.5



More information about the pNFS mailing list