aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:57:02 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:23 -0500
commitf6048709391336cf27fb5c1cfca8e792103e5a73 (patch)
tree6968f15effa7769248faed8938a9aae0ba29a15d /fs/nfs
parentb2cdd9c9c95e0e389a8b75fe25f266fc5267bbb6 (diff)
NFS: Move and update xdr_decode_foo() functions that we're keeping
Clean up. Move the timestamp decoder to match the placement and naming conventions of the other helpers. Fold xdr_decode_fattr() into decode_fattr3(), which is now it's only user. Fold xdr_decode_wcc_attr() into decode_wcc_attr(), which is now it's only user. 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.c136
1 files changed, 67 insertions, 69 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 586587f42fc9..c97d00fe849a 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -127,69 +127,6 @@ static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
127 127
128 128
129/* 129/*
130 * Common NFS XDR functions as inlines
131 */
132
133/*
134 * Encode/decode time.
135 */
136static inline __be32 *
137xdr_decode_time3(__be32 *p, struct timespec *timep)
138{
139 timep->tv_sec = ntohl(*p++);
140 timep->tv_nsec = ntohl(*p++);
141 return p;
142}
143
144static __be32 *
145xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
146{
147 unsigned int type, major, minor;
148 umode_t fmode;
149
150 type = ntohl(*p++);
151 if (type > NF3FIFO)
152 type = NF3NON;
153 fmode = nfs_type2fmt[type];
154 fattr->mode = (ntohl(*p++) & ~S_IFMT) | fmode;
155 fattr->nlink = ntohl(*p++);
156 fattr->uid = ntohl(*p++);
157 fattr->gid = ntohl(*p++);
158 p = xdr_decode_hyper(p, &fattr->size);
159 p = xdr_decode_hyper(p, &fattr->du.nfs3.used);
160
161 /* Turn remote device info into Linux-specific dev_t */
162 major = ntohl(*p++);
163 minor = ntohl(*p++);
164 fattr->rdev = MKDEV(major, minor);
165 if (MAJOR(fattr->rdev) != major || MINOR(fattr->rdev) != minor)
166 fattr->rdev = 0;
167
168 p = xdr_decode_hyper(p, &fattr->fsid.major);
169 fattr->fsid.minor = 0;
170 p = xdr_decode_hyper(p, &fattr->fileid);
171 p = xdr_decode_time3(p, &fattr->atime);
172 p = xdr_decode_time3(p, &fattr->mtime);
173 p = xdr_decode_time3(p, &fattr->ctime);
174
175 /* Update the mode bits */
176 fattr->valid |= NFS_ATTR_FATTR_V3;
177 return p;
178}
179
180static inline __be32 *
181xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr)
182{
183 p = xdr_decode_hyper(p, &fattr->pre_size);
184 p = xdr_decode_time3(p, &fattr->pre_mtime);
185 p = xdr_decode_time3(p, &fattr->pre_ctime);
186 fattr->valid |= NFS_ATTR_FATTR_PRESIZE
187 | NFS_ATTR_FATTR_PREMTIME
188 | NFS_ATTR_FATTR_PRECTIME;
189 return p;
190}
191
192/*
193 * Encode/decode NFSv3 basic data types 130 * Encode/decode NFSv3 basic data types
194 * 131 *
195 * Basic NFSv3 data types are defined in section 2.5 of RFC 1813: 132 * Basic NFSv3 data types are defined in section 2.5 of RFC 1813:
@@ -239,6 +176,11 @@ out_overflow:
239 * 176 *
240 * typedef uint64 fileid3; 177 * typedef uint64 fileid3;
241 */ 178 */
179static __be32 *xdr_decode_fileid3(__be32 *p, u64 *fileid)
180{
181 return xdr_decode_hyper(p, fileid);
182}
183
242static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid) 184static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid)
243{ 185{
244 return decode_uint64(xdr, fileid); 186 return decode_uint64(xdr, fileid);
@@ -452,6 +394,17 @@ static void encode_ftype3(struct xdr_stream *xdr, const u32 type)
452 encode_uint32(xdr, type); 394 encode_uint32(xdr, type);
453} 395}
454 396
397static __be32 *xdr_decode_ftype3(__be32 *p, umode_t *mode)
398{
399 u32 type;
400
401 type = be32_to_cpup(p++);
402 if (type > NF3FIFO)
403 type = NF3NON;
404 *mode = nfs_type2fmt[type];
405 return p;
406}
407
455/* 408/*
456 * specdata3 409 * specdata3
457 * 410 *
@@ -469,6 +422,18 @@ static void encode_specdata3(struct xdr_stream *xdr, const dev_t rdev)
469 *p = cpu_to_be32(MINOR(rdev)); 422 *p = cpu_to_be32(MINOR(rdev));
470} 423}
471 424
425static __be32 *xdr_decode_specdata3(__be32 *p, dev_t *rdev)
426{
427 unsigned int major, minor;
428
429 major = be32_to_cpup(p++);
430 minor = be32_to_cpup(p++);
431 *rdev = MKDEV(major, minor);
432 if (MAJOR(*rdev) != major || MINOR(*rdev) != minor)
433 *rdev = 0;
434 return p;
435}
436
472/* 437/*
473 * nfs_fh3 438 * nfs_fh3
474 * 439 *
@@ -530,6 +495,13 @@ static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec *timep)
530 return p; 495 return p;
531} 496}
532 497
498static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec *timep)
499{
500 timep->tv_sec = be32_to_cpup(p++);
501 timep->tv_nsec = be32_to_cpup(p++);
502 return p;
503}
504
533/* 505/*
534 * sattr3 506 * sattr3
535 * 507 *
@@ -678,12 +650,33 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
678 */ 650 */
679static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) 651static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr)
680{ 652{
653 umode_t fmode;
681 __be32 *p; 654 __be32 *p;
682 655
683 p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2); 656 p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2);
684 if (unlikely(p == NULL)) 657 if (unlikely(p == NULL))
685 goto out_overflow; 658 goto out_overflow;
686 xdr_decode_fattr(p, fattr); 659
660 p = xdr_decode_ftype3(p, &fmode);
661
662 fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode;
663 fattr->nlink = be32_to_cpup(p++);
664 fattr->uid = be32_to_cpup(p++);
665 fattr->gid = be32_to_cpup(p++);
666
667 p = xdr_decode_size3(p, &fattr->size);
668 p = xdr_decode_size3(p, &fattr->du.nfs3.used);
669 p = xdr_decode_specdata3(p, &fattr->rdev);
670
671 p = xdr_decode_hyper(p, &fattr->fsid.major);
672 fattr->fsid.minor = 0;
673
674 p = xdr_decode_fileid3(p, &fattr->fileid);
675 p = xdr_decode_nfstime3(p, &fattr->atime);
676 p = xdr_decode_nfstime3(p, &fattr->mtime);
677 xdr_decode_nfstime3(p, &fattr->ctime);
678
679 fattr->valid |= NFS_ATTR_FATTR_V3;
687 return 0; 680 return 0;
688out_overflow: 681out_overflow:
689 print_overflow_msg(__func__, xdr); 682 print_overflow_msg(__func__, xdr);
@@ -730,7 +723,15 @@ static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
730 p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2); 723 p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2);
731 if (unlikely(p == NULL)) 724 if (unlikely(p == NULL))
732 goto out_overflow; 725 goto out_overflow;
733 xdr_decode_wcc_attr(p, fattr); 726
727 fattr->valid |= NFS_ATTR_FATTR_PRESIZE
728 | NFS_ATTR_FATTR_PREMTIME
729 | NFS_ATTR_FATTR_PRECTIME;
730
731 p = xdr_decode_size3(p, &fattr->pre_size);
732 p = xdr_decode_nfstime3(p, &fattr->pre_mtime);
733 xdr_decode_nfstime3(p, &fattr->pre_ctime);
734
734 return 0; 735 return 0;
735out_overflow: 736out_overflow:
736 print_overflow_msg(__func__, xdr); 737 print_overflow_msg(__func__, xdr);
@@ -1009,10 +1010,7 @@ static void encode_write3args(struct xdr_stream *xdr,
1009 p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4); 1010 p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4);
1010 p = xdr_encode_hyper(p, args->offset); 1011 p = xdr_encode_hyper(p, args->offset);
1011 *p++ = cpu_to_be32(args->count); 1012 *p++ = cpu_to_be32(args->count);
1012
1013 BUG_ON(args->stable > NFS_FILE_SYNC);
1014 *p++ = cpu_to_be32(args->stable); 1013 *p++ = cpu_to_be32(args->stable);
1015
1016 *p = cpu_to_be32(args->count); 1014 *p = cpu_to_be32(args->count);
1017 xdr_write_pages(xdr, args->pages, args->pgbase, args->count); 1015 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1018} 1016}
@@ -2278,7 +2276,7 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr,
2278 result->wtmult = be32_to_cpup(p++); 2276 result->wtmult = be32_to_cpup(p++);
2279 result->dtpref = be32_to_cpup(p++); 2277 result->dtpref = be32_to_cpup(p++);
2280 p = xdr_decode_size3(p, &result->maxfilesize); 2278 p = xdr_decode_size3(p, &result->maxfilesize);
2281 xdr_decode_time3(p, &result->time_delta); 2279 xdr_decode_nfstime3(p, &result->time_delta);
2282 2280
2283 /* ignore properties */ 2281 /* ignore properties */
2284 result->lease_time = 0; 2282 result->lease_time = 0;