2011-04-22 08:12:08

by Benny Halevy

[permalink] [raw]
Subject: [PATCH] pnfsd-lexp: simulate layout segments

Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/Kconfig | 20 ++++++++++++++++++++
fs/nfsd/pnfsd_lexp.c | 12 +++++++++++-
2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig
index 82f46bb..d0f8527 100644
--- a/fs/nfsd/Kconfig
+++ b/fs/nfsd/Kconfig
@@ -113,3 +113,23 @@ config PNFSD_LOCAL_EXPORT
useful for development and debugging purposes.

If unsure, say N.
+
+config PNFSD_LEXP_LAYOUT_SEGMENTS
+ bool "Simulate layout segments"
+ depends on PNFSD_LOCAL_EXPORT
+ help
+ Say Y here if you want your pNFS server to simulate layout segments
+ when exporting local filesystems for debugging purposes.
+ over the files layout type.
+ This is mostly useful for development and debugging purposes.
+
+ If unsure, say N.
+
+config PNFSD_LEXP_LAYOUT_SEGMENT_SIZE
+ int "Simulated layout segment size"
+ depends on PNFSD_LEXP_LAYOUT_SEGMENTS
+ default 65536
+ help
+ Set simulated layout segment size.
+
+ If unsure, say N.
diff --git a/fs/nfsd/pnfsd_lexp.c b/fs/nfsd/pnfsd_lexp.c
index e9382da..5610490 100644
--- a/fs/nfsd/pnfsd_lexp.c
+++ b/fs/nfsd/pnfsd_lexp.c
@@ -143,8 +143,16 @@ pnfsd_lexp_layout_get(struct inode *inode,
dprintk("--> %s: inode=%p\n", __func__, inode);

res->lg_seg.layout_type = LAYOUT_NFSV4_1_FILES;
+#ifdef CONFIG_PNFSD_LEXP_LAYOUT_SEGMENTS
+#if CONFIG_PNFSD_LEXP_LAYOUT_SEGMENT_SIZE <= 0
+#error CONFIG_PNFSD_LEXP_LAYOUT_SEGMENT_SIZE must be greater than zero
+#endif
+ res->lg_seg.offset -= res->lg_seg.offset % CONFIG_PNFSD_LEXP_LAYOUT_SEGMENT_SIZE;
+ res->lg_seg.length = CONFIG_PNFSD_LEXP_LAYOUT_SEGMENT_SIZE;
+#else /* CONFIG_PNFSD_LEXP_LAYOUT_SEGMENTS */
res->lg_seg.offset = 0;
res->lg_seg.length = NFS4_MAX_UINT64;
+#endif /* CONFIG_PNFSD_LEXP_LAYOUT_SEGMENTS */

layout = kzalloc(sizeof(*layout), GFP_KERNEL);
if (layout == NULL) {
@@ -178,7 +186,9 @@ pnfsd_lexp_layout_get(struct inode *inode,
exit:
kfree(layout);
kfree(fhp);
- dprintk("<-- %s: return %d\n", __func__, rc);
+ dprintk("<-- %s: return %d offset=%llu length=%llu\n", __func__, rc,
+ (unsigned long long)res->lg_seg.offset,
+ (unsigned long long)res->lg_seg.length);
return rc;

error:
--
1.7.3.4