summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/nfs3.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/nfs/server/src/nfs3.c')
-rw-r--r--xlators/nfs/server/src/nfs3.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index 1754b5e8a..afb5ba332 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -5137,6 +5137,33 @@ rpcsvc_program_t nfs3prog = {
.min_auth = AUTH_NULL,
};
+/*
+ * This function rounds up the input value to multiple of 4096. If the
+ * value is same as default, then its a NO-OP. Default is already a
+ * multiple of 4096. Min and Max supported I/O size limits are
+ * 4KB (GF_NFS3_FILE_IO_SIZE_MIN) and 1MB (GF_NFS3_FILE_IO_SIZE_MAX).
+ */
+static void
+nfs3_iosize_roundup_4KB (size_t *iosz, size_t iodef)
+{
+ size_t iosize = *iosz;
+ size_t iopages;
+
+ if (iosize == iodef)
+ return;
+
+ iopages = (iosize + GF_NFS3_IO_SIZE -1) >> GF_NFS3_IO_SHIFT;
+ iosize = iopages * GF_NFS3_IO_SIZE;
+
+ /* Double check - boundary conditions */
+ if (iosize < GF_NFS3_FILE_IO_SIZE_MIN) {
+ iosize = GF_NFS3_FILE_IO_SIZE_MIN;
+ } else if (iosize > GF_NFS3_FILE_IO_SIZE_MAX) {
+ iosize = GF_NFS3_FILE_IO_SIZE_MAX;
+ }
+
+ *iosz = iosize;
+}
int
nfs3_init_options (struct nfs3_state *nfs3, xlator_t *nfsx)
@@ -5168,6 +5195,7 @@ nfs3_init_options (struct nfs3_state *nfs3, xlator_t *nfsx)
goto err;
}
}
+ nfs3_iosize_roundup_4KB (&nfs3->readsize, GF_NFS3_RTPREF);
/* nfs3.write-size */
nfs3->writesize = GF_NFS3_WTPREF;
@@ -5189,6 +5217,7 @@ nfs3_init_options (struct nfs3_state *nfs3, xlator_t *nfsx)
goto err;
}
}
+ nfs3_iosize_roundup_4KB (&nfs3->writesize, GF_NFS3_WTPREF);
/* nfs3.readdir.size */
nfs3->readdirsize = GF_NFS3_DTPREF;
@@ -5210,6 +5239,7 @@ nfs3_init_options (struct nfs3_state *nfs3, xlator_t *nfsx)
goto err;
}
}
+ nfs3_iosize_roundup_4KB (&nfs3->readdirsize, GF_NFS3_DTPREF);
/* We want to use the size of the biggest param for the io buffer size.