aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:56:20 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:23 -0500
commit9d5a64343925a152e1907c652a0d71d6640868b3 (patch)
tree8c1ed1690895bc60530496406a4aed057a87c65a /fs/nfs
parent499ff710b2fd3a03c8195c82340e5166eed04205 (diff)
NFS: Update xdr_encode_foo() functions that we're keeping
Clean up. Move the timestamp and the sattr encoder to match the placement convention of the other helpers, update their coding style, and refresh their documenting comments. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs3xdr.c111
1 files changed, 55 insertions, 56 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index b0af263e4db9..119844d0b4d5 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -167,14 +167,6 @@ out_overflow:
167 * Encode/decode time. 167 * Encode/decode time.
168 */ 168 */
169static inline __be32 * 169static inline __be32 *
170xdr_encode_time3(__be32 *p, const struct timespec *timep)
171{
172 *p++ = htonl(timep->tv_sec);
173 *p++ = htonl(timep->tv_nsec);
174 return p;
175}
176
177static inline __be32 *
178xdr_decode_time3(__be32 *p, struct timespec *timep) 170xdr_decode_time3(__be32 *p, struct timespec *timep)
179{ 171{
180 timep->tv_sec = ntohl(*p++); 172 timep->tv_sec = ntohl(*p++);
@@ -219,52 +211,6 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
219} 211}
220 212
221static inline __be32 * 213static inline __be32 *
222xdr_encode_sattr(__be32 *p, const struct iattr *attr)
223{
224 if (attr->ia_valid & ATTR_MODE) {
225 *p++ = xdr_one;
226 *p++ = htonl(attr->ia_mode & S_IALLUGO);
227 } else {
228 *p++ = xdr_zero;
229 }
230 if (attr->ia_valid & ATTR_UID) {
231 *p++ = xdr_one;
232 *p++ = htonl(attr->ia_uid);
233 } else {
234 *p++ = xdr_zero;
235 }
236 if (attr->ia_valid & ATTR_GID) {
237 *p++ = xdr_one;
238 *p++ = htonl(attr->ia_gid);
239 } else {
240 *p++ = xdr_zero;
241 }
242 if (attr->ia_valid & ATTR_SIZE) {
243 *p++ = xdr_one;
244 p = xdr_encode_hyper(p, (__u64) attr->ia_size);
245 } else {
246 *p++ = xdr_zero;
247 }
248 if (attr->ia_valid & ATTR_ATIME_SET) {
249 *p++ = xdr_two;
250 p = xdr_encode_time3(p, &attr->ia_atime);
251 } else if (attr->ia_valid & ATTR_ATIME) {
252 *p++ = xdr_one;
253 } else {
254 *p++ = xdr_zero;
255 }
256 if (attr->ia_valid & ATTR_MTIME_SET) {
257 *p++ = xdr_two;
258 p = xdr_encode_time3(p, &attr->ia_mtime);
259 } else if (attr->ia_valid & ATTR_MTIME) {
260 *p++ = xdr_one;
261 } else {
262 *p++ = xdr_zero;
263 }
264 return p;
265}
266
267static inline __be32 *
268xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr) 214xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr)
269{ 215{
270 p = xdr_decode_hyper(p, &fattr->pre_size); 216 p = xdr_decode_hyper(p, &fattr->pre_size);
@@ -453,6 +399,21 @@ static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh)
453} 399}
454 400
455/* 401/*
402 * nfstime3
403 *
404 * struct nfstime3 {
405 * uint32 seconds;
406 * uint32 nseconds;
407 * };
408 */
409static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec *timep)
410{
411 *p++ = cpu_to_be32(timep->tv_sec);
412 *p++ = cpu_to_be32(timep->tv_nsec);
413 return p;
414}
415
416/*
456 * sattr3 417 * sattr3
457 * 418 *
458 * enum time_how { 419 * enum time_how {
@@ -538,7 +499,45 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
538 nbytes += 8; 499 nbytes += 8;
539 p = xdr_reserve_space(xdr, nbytes); 500 p = xdr_reserve_space(xdr, nbytes);
540 501
541 xdr_encode_sattr(p, attr); 502 if (attr->ia_valid & ATTR_MODE) {
503 *p++ = xdr_one;
504 *p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO);
505 } else
506 *p++ = xdr_zero;
507
508 if (attr->ia_valid & ATTR_UID) {
509 *p++ = xdr_one;
510 *p++ = cpu_to_be32(attr->ia_uid);
511 } else
512 *p++ = xdr_zero;
513
514 if (attr->ia_valid & ATTR_GID) {
515 *p++ = xdr_one;
516 *p++ = cpu_to_be32(attr->ia_gid);
517 } else
518 *p++ = xdr_zero;
519
520 if (attr->ia_valid & ATTR_SIZE) {
521 *p++ = xdr_one;
522 p = xdr_encode_hyper(p, (u64)attr->ia_size);
523 } else
524 *p++ = xdr_zero;
525
526 if (attr->ia_valid & ATTR_ATIME_SET) {
527 *p++ = xdr_two;
528 p = xdr_encode_nfstime3(p, &attr->ia_atime);
529 } else if (attr->ia_valid & ATTR_ATIME) {
530 *p++ = xdr_one;
531 } else
532 *p++ = xdr_zero;
533
534 if (attr->ia_valid & ATTR_MTIME_SET) {
535 *p++ = xdr_two;
536 xdr_encode_nfstime3(p, &attr->ia_mtime);
537 } else if (attr->ia_valid & ATTR_MTIME) {
538 *p = xdr_one;
539 } else
540 *p = xdr_zero;
542} 541}
543 542
544/* 543/*
@@ -605,7 +604,7 @@ static void encode_sattrguard3(struct xdr_stream *xdr,
605 if (args->guard) { 604 if (args->guard) {
606 p = xdr_reserve_space(xdr, 4 + 8); 605 p = xdr_reserve_space(xdr, 4 + 8);
607 *p++ = xdr_one; 606 *p++ = xdr_one;
608 xdr_encode_time3(p, &args->guardtime); 607 xdr_encode_nfstime3(p, &args->guardtime);
609 } else { 608 } else {
610 p = xdr_reserve_space(xdr, 4); 609 p = xdr_reserve_space(xdr, 4);
611 *p = xdr_zero; 610 *p = xdr_zero;