Patchwork [BUG:902,2/4] rpcsvc: Move xdr round up functions to rpc code

login
register
Submitter Shehjar Tikoo
Date 2010-05-10 04:43:53
Message ID <1273466635-16077-2-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/3244/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Shehjar Tikoo - 2010-05-10 04:43:53
From: Shehjar Tikoo <shehjart@zresearch.com>

Signed-off-by: Shehjar Tikoo <shehjart@dev.gluster.com>
Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/lib/src/msg-nfs3.c |   22 ----------------------
 xlators/nfs/lib/src/msg-nfs3.h |    6 ------
 xlators/nfs/lib/src/xdr-rpc.c  |   34 ++++++++++++++++++++++++++++++++++
 xlators/nfs/lib/src/xdr-rpc.h  |    8 ++++++++
 4 files changed, 42 insertions(+), 28 deletions(-)

Patch

diff --git a/xlators/nfs/lib/src/msg-nfs3.c b/xlators/nfs/lib/src/msg-nfs3.c
index 7814660..3eefd4c 100644
--- a/xlators/nfs/lib/src/msg-nfs3.c
+++ b/xlators/nfs/lib/src/msg-nfs3.c
@@ -534,25 +534,3 @@  xdr_serialize_nfsstat3 (struct iovec outmsg, nfsstat3 *s)
 }
 
 
-ssize_t
-xdr_length_round_up (size_t len, size_t bufsize)
-{
-        int     roundup = 0;
-
-        roundup = len % XDR_BYTES_PER_UNIT;
-        if (roundup > 0)
-                roundup = XDR_BYTES_PER_UNIT - roundup;
-
-        if ((roundup > 0) && ((roundup + len) <= bufsize))
-                len += roundup;
-
-        return len;
-}
-
-int
-xdr_bytes_round_up (struct iovec *vec, size_t bufsize)
-{
-        vec->iov_len = xdr_length_round_up (vec->iov_len, bufsize);
-        return 0;
-}
-
diff --git a/xlators/nfs/lib/src/msg-nfs3.h b/xlators/nfs/lib/src/msg-nfs3.h
index 78682bc..047e8df 100644
--- a/xlators/nfs/lib/src/msg-nfs3.h
+++ b/xlators/nfs/lib/src/msg-nfs3.h
@@ -183,10 +183,4 @@  xdr_serialize_mountstat3 (struct iovec outmsg, mountstat3 *m);
 
 extern ssize_t
 xdr_serialize_nfsstat3 (struct iovec outmsg, nfsstat3 *s);
-
-extern int
-xdr_bytes_round_up (struct iovec *vec, size_t bufsize);
-
-extern ssize_t
-xdr_length_round_up (size_t len, size_t bufsize);
 #endif
diff --git a/xlators/nfs/lib/src/xdr-rpc.c b/xlators/nfs/lib/src/xdr-rpc.c
index ac0f8af..5f8521f 100644
--- a/xlators/nfs/lib/src/xdr-rpc.c
+++ b/xlators/nfs/lib/src/xdr-rpc.c
@@ -188,3 +188,37 @@  xdr_to_auth_unix_cred (char *msgbuf, int msglen, struct authunix_parms *au,
         return 0;
 }
 
+ssize_t
+xdr_length_round_up (size_t len, size_t bufsize)
+{
+        int     roundup = 0;
+
+        roundup = len % XDR_BYTES_PER_UNIT;
+        if (roundup > 0)
+                roundup = XDR_BYTES_PER_UNIT - roundup;
+
+        if ((roundup > 0) && ((roundup + len) <= bufsize))
+                len += roundup;
+
+        return len;
+}
+
+int
+xdr_bytes_round_up (struct iovec *vec, size_t bufsize)
+{
+        vec->iov_len = xdr_length_round_up (vec->iov_len, bufsize);
+        return 0;
+}
+
+void
+xdr_vector_round_up (struct iovec *vec, int vcount, uint32_t count)
+{
+        uint32_t round_count = 0;
+
+        round_count = xdr_length_round_up (count, 1048576);
+        round_count -= count;
+        if (round_count == 0)
+                return;
+
+        vec[vcount-1].iov_len += round_count;
+}
diff --git a/xlators/nfs/lib/src/xdr-rpc.h b/xlators/nfs/lib/src/xdr-rpc.h
index 4c0ee69..48acdaa 100644
--- a/xlators/nfs/lib/src/xdr-rpc.h
+++ b/xlators/nfs/lib/src/xdr-rpc.h
@@ -71,4 +71,12 @@  xdr_to_auth_unix_cred (char *msgbuf, int msglen, struct authunix_parms *au,
 #define rpc_call_verf_flavour(call)     (rpc_opaque_auth_flavour ((&(call)->ru.RM_cmb.cb_verf)))
 #define rpc_call_verf_len(call)         (rpc_opaque_auth_len ((&(call)->ru.RM_cmb.cb_verf)))
 
+extern int
+xdr_bytes_round_up (struct iovec *vec, size_t bufsize);
+
+extern ssize_t
+xdr_length_round_up (size_t len, size_t bufsize);
+
+void
+xdr_vector_round_up (struct iovec *vec, int vcount, uint32_t count);
 #endif