diff options
author | Shehjar Tikoo <shehjart@zresearch.com> | 2010-05-09 23:13:53 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-05-10 02:18:00 -0700 |
commit | 80c3061c07c46b4ac11beb5f0ebad08b8af2cafe (patch) | |
tree | c7f3f722065299f4f9400579e53ac8199300d87b /xlators/nfs/lib/src/xdr-rpc.c | |
parent | eba21f8fb6715e3933253b0114f03a153be80649 (diff) |
rpcsvc: Move xdr round up functions to rpc code
Signed-off-by: Shehjar Tikoo <shehjart@dev.gluster.com>
Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 902 (iozone hangs during random read throughput test)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=902
Diffstat (limited to 'xlators/nfs/lib/src/xdr-rpc.c')
-rw-r--r-- | xlators/nfs/lib/src/xdr-rpc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/xlators/nfs/lib/src/xdr-rpc.c b/xlators/nfs/lib/src/xdr-rpc.c index ac0f8afd384..5f8521ff382 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; +} |