Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * XDR support for nfsd/protocol version 3. |
| 4 | * |
| 5 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
| 6 | * |
| 7 | * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()! |
| 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/namei.h> |
Stanislav Kinsbursky | b9c0ef8 | 2012-12-06 14:23:19 +0300 | [diff] [blame] | 11 | #include <linux/sunrpc/svc_xprt.h> |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 12 | #include "xdr3.h" |
J. Bruce Fields | 2e8138a | 2007-11-15 17:05:43 -0500 | [diff] [blame] | 13 | #include "auth.h" |
Stanislav Kinsbursky | b9c0ef8 | 2012-12-06 14:23:19 +0300 | [diff] [blame] | 14 | #include "netns.h" |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 15 | #include "vfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * Mapping of S_IF* types to NFS file types |
| 22 | */ |
| 23 | static u32 nfs3_ftypes[] = { |
| 24 | NF3NON, NF3FIFO, NF3CHR, NF3BAD, |
| 25 | NF3DIR, NF3BAD, NF3BLK, NF3BAD, |
| 26 | NF3REG, NF3BAD, NF3LNK, NF3BAD, |
| 27 | NF3SOCK, NF3BAD, NF3LNK, NF3BAD, |
| 28 | }; |
| 29 | |
Trond Myklebust | 27c438f | 2019-09-02 13:02:56 -0400 | [diff] [blame] | 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* |
| 32 | * XDR functions for basic NFS types |
| 33 | */ |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 34 | static __be32 * |
Arnd Bergmann | 92c5e46 | 2019-10-31 14:55:32 +0100 | [diff] [blame] | 35 | encode_time3(__be32 *p, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
| 37 | *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); |
| 38 | return p; |
| 39 | } |
| 40 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 41 | static __be32 * |
Arnd Bergmann | 92c5e46 | 2019-10-31 14:55:32 +0100 | [diff] [blame] | 42 | decode_time3(__be32 *p, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
| 44 | time->tv_sec = ntohl(*p++); |
| 45 | time->tv_nsec = ntohl(*p++); |
| 46 | return p; |
| 47 | } |
| 48 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 49 | static __be32 * |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 50 | decode_fh(__be32 *p, struct svc_fh *fhp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
| 52 | unsigned int size; |
| 53 | fh_init(fhp, NFS3_FHSIZE); |
| 54 | size = ntohl(*p++); |
| 55 | if (size > NFS3_FHSIZE) |
| 56 | return NULL; |
| 57 | |
| 58 | memcpy(&fhp->fh_handle.fh_base, p, size); |
| 59 | fhp->fh_handle.fh_size = size; |
| 60 | return p + XDR_QUADLEN(size); |
| 61 | } |
| 62 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 63 | /* Helper function for NFSv3 ACL code */ |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 64 | __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 65 | { |
| 66 | return decode_fh(p, fhp); |
| 67 | } |
| 68 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 69 | static __be32 * |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 70 | encode_fh(__be32 *p, struct svc_fh *fhp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
| 72 | unsigned int size = fhp->fh_handle.fh_size; |
| 73 | *p++ = htonl(size); |
| 74 | if (size) p[XDR_QUADLEN(size)-1]=0; |
| 75 | memcpy(p, &fhp->fh_handle.fh_base, size); |
| 76 | return p + XDR_QUADLEN(size); |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Decode a file name and make sure that the path contains |
| 81 | * no slashes or null bytes. |
| 82 | */ |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 83 | static __be32 * |
Chuck Lever | ee1a95b | 2007-11-01 16:56:58 -0400 | [diff] [blame] | 84 | decode_filename(__be32 *p, char **namp, unsigned int *lenp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
| 86 | char *name; |
Chuck Lever | ee1a95b | 2007-11-01 16:56:58 -0400 | [diff] [blame] | 87 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS3_MAXNAMLEN)) != NULL) { |
| 90 | for (i = 0, name = *namp; i < *lenp; i++, name++) { |
| 91 | if (*name == '\0' || *name == '/') |
| 92 | return NULL; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return p; |
| 97 | } |
| 98 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 99 | static __be32 * |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 100 | decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | u32 tmp; |
| 103 | |
| 104 | iap->ia_valid = 0; |
| 105 | |
| 106 | if (*p++) { |
| 107 | iap->ia_valid |= ATTR_MODE; |
| 108 | iap->ia_mode = ntohl(*p++); |
| 109 | } |
| 110 | if (*p++) { |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 111 | iap->ia_uid = make_kuid(userns, ntohl(*p++)); |
Eric W. Biederman | 458878a | 2013-02-02 04:16:08 -0800 | [diff] [blame] | 112 | if (uid_valid(iap->ia_uid)) |
| 113 | iap->ia_valid |= ATTR_UID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | if (*p++) { |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 116 | iap->ia_gid = make_kgid(userns, ntohl(*p++)); |
Eric W. Biederman | 458878a | 2013-02-02 04:16:08 -0800 | [diff] [blame] | 117 | if (gid_valid(iap->ia_gid)) |
| 118 | iap->ia_valid |= ATTR_GID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | if (*p++) { |
| 121 | u64 newsize; |
| 122 | |
| 123 | iap->ia_valid |= ATTR_SIZE; |
| 124 | p = xdr_decode_hyper(p, &newsize); |
Kinglong Mee | 3c7aa15 | 2014-06-10 18:08:19 +0800 | [diff] [blame] | 125 | iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | if ((tmp = ntohl(*p++)) == 1) { /* set to server time */ |
| 128 | iap->ia_valid |= ATTR_ATIME; |
| 129 | } else if (tmp == 2) { /* set to client time */ |
| 130 | iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; |
| 131 | iap->ia_atime.tv_sec = ntohl(*p++); |
| 132 | iap->ia_atime.tv_nsec = ntohl(*p++); |
| 133 | } |
| 134 | if ((tmp = ntohl(*p++)) == 1) { /* set to server time */ |
| 135 | iap->ia_valid |= ATTR_MTIME; |
| 136 | } else if (tmp == 2) { /* set to client time */ |
| 137 | iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; |
| 138 | iap->ia_mtime.tv_sec = ntohl(*p++); |
| 139 | iap->ia_mtime.tv_nsec = ntohl(*p++); |
| 140 | } |
| 141 | return p; |
| 142 | } |
| 143 | |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 144 | static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp) |
| 145 | { |
| 146 | u64 f; |
| 147 | switch(fsid_source(fhp)) { |
| 148 | default: |
| 149 | case FSIDSOURCE_DEV: |
| 150 | p = xdr_encode_hyper(p, (u64)huge_encode_dev |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 151 | (fhp->fh_dentry->d_sb->s_dev)); |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 152 | break; |
| 153 | case FSIDSOURCE_FSID: |
| 154 | p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); |
| 155 | break; |
| 156 | case FSIDSOURCE_UUID: |
| 157 | f = ((u64*)fhp->fh_export->ex_uuid)[0]; |
| 158 | f ^= ((u64*)fhp->fh_export->ex_uuid)[1]; |
| 159 | p = xdr_encode_hyper(p, f); |
| 160 | break; |
| 161 | } |
| 162 | return p; |
| 163 | } |
| 164 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 165 | static __be32 * |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 166 | encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 167 | struct kstat *stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 169 | struct user_namespace *userns = nfsd_user_namespace(rqstp); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 170 | *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); |
Albert Fluegel | 6e14b46 | 2013-11-18 12:18:01 -0500 | [diff] [blame] | 171 | *p++ = htonl((u32) (stat->mode & S_IALLUGO)); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 172 | *p++ = htonl((u32) stat->nlink); |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 173 | *p++ = htonl((u32) from_kuid_munged(userns, stat->uid)); |
| 174 | *p++ = htonl((u32) from_kgid_munged(userns, stat->gid)); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 175 | if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); |
| 177 | } else { |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 178 | p = xdr_encode_hyper(p, (u64) stat->size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | } |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 180 | p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9); |
| 181 | *p++ = htonl((u32) MAJOR(stat->rdev)); |
| 182 | *p++ = htonl((u32) MINOR(stat->rdev)); |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 183 | p = encode_fsid(p, fhp); |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 184 | p = xdr_encode_hyper(p, stat->ino); |
Arnd Bergmann | 92c5e46 | 2019-10-31 14:55:32 +0100 | [diff] [blame] | 185 | p = encode_time3(p, &stat->atime); |
| 186 | p = encode_time3(p, &stat->mtime); |
| 187 | p = encode_time3(p, &stat->ctime); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| 189 | return p; |
| 190 | } |
| 191 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 192 | static __be32 * |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 193 | encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | /* Attributes to follow */ |
| 196 | *p++ = xdr_one; |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 197 | return encode_fattr3(rqstp, p, fhp, &fhp->fh_post_attr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* |
| 201 | * Encode post-operation attributes. |
| 202 | * The inode may be NULL if the call failed because of a stale file |
| 203 | * handle. In this case, no attributes are returned. |
| 204 | */ |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 205 | static __be32 * |
| 206 | encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
| 208 | struct dentry *dentry = fhp->fh_dentry; |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 209 | if (dentry && d_really_is_positive(dentry)) { |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 210 | __be32 err; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 211 | struct kstat stat; |
| 212 | |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 213 | err = fh_getattr(fhp, &stat); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 214 | if (!err) { |
| 215 | *p++ = xdr_one; /* attributes follow */ |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 216 | lease_get_mtime(d_inode(dentry), &stat.mtime); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 217 | return encode_fattr3(rqstp, p, fhp, &stat); |
| 218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | *p++ = xdr_zero; |
| 221 | return p; |
| 222 | } |
| 223 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 224 | /* Helper for NFSv3 ACLs */ |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 225 | __be32 * |
| 226 | nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 227 | { |
| 228 | return encode_post_op_attr(rqstp, p, fhp); |
| 229 | } |
| 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | /* |
| 232 | * Enocde weak cache consistency data |
| 233 | */ |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 234 | static __be32 * |
| 235 | encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | { |
| 237 | struct dentry *dentry = fhp->fh_dentry; |
| 238 | |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 239 | if (dentry && d_really_is_positive(dentry) && fhp->fh_post_saved) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | if (fhp->fh_pre_saved) { |
| 241 | *p++ = xdr_one; |
| 242 | p = xdr_encode_hyper(p, (u64) fhp->fh_pre_size); |
| 243 | p = encode_time3(p, &fhp->fh_pre_mtime); |
| 244 | p = encode_time3(p, &fhp->fh_pre_ctime); |
| 245 | } else { |
| 246 | *p++ = xdr_zero; |
| 247 | } |
| 248 | return encode_saved_post_attr(rqstp, p, fhp); |
| 249 | } |
| 250 | /* no pre- or post-attrs */ |
| 251 | *p++ = xdr_zero; |
| 252 | return encode_post_op_attr(rqstp, p, fhp); |
| 253 | } |
| 254 | |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 255 | /* |
Amir Goldstein | 39ca1bf | 2018-01-03 17:14:35 +0200 | [diff] [blame] | 256 | * Fill in the pre_op attr for the wcc data |
| 257 | */ |
| 258 | void fill_pre_wcc(struct svc_fh *fhp) |
| 259 | { |
| 260 | struct inode *inode; |
| 261 | struct kstat stat; |
| 262 | __be32 err; |
| 263 | |
| 264 | if (fhp->fh_pre_saved) |
| 265 | return; |
| 266 | |
| 267 | inode = d_inode(fhp->fh_dentry); |
| 268 | err = fh_getattr(fhp, &stat); |
| 269 | if (err) { |
| 270 | /* Grab the times from inode anyway */ |
| 271 | stat.mtime = inode->i_mtime; |
| 272 | stat.ctime = inode->i_ctime; |
| 273 | stat.size = inode->i_size; |
| 274 | } |
| 275 | |
Arnd Bergmann | 92c5e46 | 2019-10-31 14:55:32 +0100 | [diff] [blame] | 276 | fhp->fh_pre_mtime = stat.mtime; |
| 277 | fhp->fh_pre_ctime = stat.ctime; |
Amir Goldstein | 39ca1bf | 2018-01-03 17:14:35 +0200 | [diff] [blame] | 278 | fhp->fh_pre_size = stat.size; |
| 279 | fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); |
| 280 | fhp->fh_pre_saved = true; |
| 281 | } |
| 282 | |
| 283 | /* |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 284 | * Fill in the post_op attr for the wcc data |
| 285 | */ |
| 286 | void fill_post_wcc(struct svc_fh *fhp) |
| 287 | { |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 288 | __be32 err; |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 289 | |
| 290 | if (fhp->fh_post_saved) |
| 291 | printk("nfsd: inode locked twice during operation.\n"); |
| 292 | |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 293 | err = fh_getattr(fhp, &fhp->fh_post_attr); |
Amir Goldstein | 39ca1bf | 2018-01-03 17:14:35 +0200 | [diff] [blame] | 294 | fhp->fh_post_change = nfsd4_change_attribute(&fhp->fh_post_attr, |
| 295 | d_inode(fhp->fh_dentry)); |
Neil Brown | c1ac3ff | 2010-12-02 11:14:30 +1100 | [diff] [blame] | 296 | if (err) { |
Jeff Layton | aaf91ec | 2015-09-17 08:28:39 -0400 | [diff] [blame] | 297 | fhp->fh_post_saved = false; |
Neil Brown | c1ac3ff | 2010-12-02 11:14:30 +1100 | [diff] [blame] | 298 | /* Grab the ctime anyway - set_change_info might use it */ |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 299 | fhp->fh_post_attr.ctime = d_inode(fhp->fh_dentry)->i_ctime; |
Neil Brown | c1ac3ff | 2010-12-02 11:14:30 +1100 | [diff] [blame] | 300 | } else |
Jeff Layton | aaf91ec | 2015-09-17 08:28:39 -0400 | [diff] [blame] | 301 | fhp->fh_post_saved = true; |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 302 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
| 304 | /* |
| 305 | * XDR decode functions |
| 306 | */ |
| 307 | int |
Chuck Lever | dcc4699 | 2020-10-01 18:59:12 -0400 | [diff] [blame] | 308 | nfs3svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) |
| 309 | { |
| 310 | return 1; |
| 311 | } |
| 312 | |
| 313 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 314 | nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 316 | struct nfsd_fhandle *args = rqstp->rq_argp; |
| 317 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 318 | p = decode_fh(p, &args->fh); |
| 319 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | return 0; |
| 321 | return xdr_argsize_check(rqstp, p); |
| 322 | } |
| 323 | |
| 324 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 325 | nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 327 | struct nfsd3_sattrargs *args = rqstp->rq_argp; |
| 328 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 329 | p = decode_fh(p, &args->fh); |
| 330 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | return 0; |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 332 | p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | if ((args->check_guard = ntohl(*p++)) != 0) { |
Arnd Bergmann | 92c5e46 | 2019-10-31 14:55:32 +0100 | [diff] [blame] | 335 | struct timespec64 time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | p = decode_time3(p, &time); |
| 337 | args->guardtime = time.tv_sec; |
| 338 | } |
| 339 | |
| 340 | return xdr_argsize_check(rqstp, p); |
| 341 | } |
| 342 | |
| 343 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 344 | nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 346 | struct nfsd3_diropargs *args = rqstp->rq_argp; |
| 347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | if (!(p = decode_fh(p, &args->fh)) |
| 349 | || !(p = decode_filename(p, &args->name, &args->len))) |
| 350 | return 0; |
| 351 | |
| 352 | return xdr_argsize_check(rqstp, p); |
| 353 | } |
| 354 | |
| 355 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 356 | nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 358 | struct nfsd3_accessargs *args = rqstp->rq_argp; |
| 359 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 360 | p = decode_fh(p, &args->fh); |
| 361 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | return 0; |
| 363 | args->access = ntohl(*p++); |
| 364 | |
| 365 | return xdr_argsize_check(rqstp, p); |
| 366 | } |
| 367 | |
| 368 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 369 | nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 371 | struct nfsd3_readargs *args = rqstp->rq_argp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | unsigned int len; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 373 | int v; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 374 | u32 max_blocksize = svc_max_payload(rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 376 | p = decode_fh(p, &args->fh); |
| 377 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | return 0; |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 379 | p = xdr_decode_hyper(p, &args->offset); |
J. Bruce Fields | 9512a16 | 2017-05-16 15:57:42 -0400 | [diff] [blame] | 380 | |
Kinglong Mee | 3c7aa15 | 2014-06-10 18:08:19 +0800 | [diff] [blame] | 381 | args->count = ntohl(*p++); |
| 382 | len = min(args->count, max_blocksize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
| 384 | /* set up the kvec */ |
| 385 | v=0; |
| 386 | while (len > 0) { |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 387 | struct page *p = *(rqstp->rq_next_page++); |
| 388 | |
| 389 | rqstp->rq_vec[v].iov_base = page_address(p); |
Kinglong Mee | 3c7aa15 | 2014-06-10 18:08:19 +0800 | [diff] [blame] | 390 | rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); |
NeilBrown | 3cc03b1 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 391 | len -= rqstp->rq_vec[v].iov_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | v++; |
| 393 | } |
| 394 | args->vlen = v; |
J. Bruce Fields | 9512a16 | 2017-05-16 15:57:42 -0400 | [diff] [blame] | 395 | return xdr_argsize_check(rqstp, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 399 | nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 401 | struct nfsd3_writeargs *args = rqstp->rq_argp; |
Chuck Lever | 8154ef2 | 2018-03-27 10:54:07 -0400 | [diff] [blame] | 402 | unsigned int len, hdr, dlen; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 403 | u32 max_blocksize = svc_max_payload(rqstp); |
J. Bruce Fields | db44bac | 2017-04-25 16:21:34 -0400 | [diff] [blame] | 404 | struct kvec *head = rqstp->rq_arg.head; |
| 405 | struct kvec *tail = rqstp->rq_arg.tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 407 | p = decode_fh(p, &args->fh); |
| 408 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | return 0; |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 410 | p = xdr_decode_hyper(p, &args->offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
| 412 | args->count = ntohl(*p++); |
| 413 | args->stable = ntohl(*p++); |
| 414 | len = args->len = ntohl(*p++); |
J. Bruce Fields | 13bf9fb | 2017-04-21 15:26:30 -0400 | [diff] [blame] | 415 | if ((void *)p > head->iov_base + head->iov_len) |
| 416 | return 0; |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 417 | /* |
| 418 | * The count must equal the amount of data passed. |
| 419 | */ |
| 420 | if (args->count != args->len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | return 0; |
| 422 | |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 423 | /* |
| 424 | * Check to make sure that we got the right number of |
| 425 | * bytes. |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 426 | */ |
J. Bruce Fields | db44bac | 2017-04-25 16:21:34 -0400 | [diff] [blame] | 427 | hdr = (void*)p - head->iov_base; |
| 428 | dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr; |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 429 | /* |
| 430 | * Round the length of the data which was specified up to |
| 431 | * the next multiple of XDR units and then compare that |
| 432 | * against the length which was actually received. |
NeilBrown | ba67a39 | 2008-01-11 17:06:52 -0500 | [diff] [blame] | 433 | * Note that when RPCSEC/GSS (for example) is used, the |
| 434 | * data buffer can be padded so dlen might be larger |
| 435 | * than required. It must never be smaller. |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 436 | */ |
NeilBrown | ba67a39 | 2008-01-11 17:06:52 -0500 | [diff] [blame] | 437 | if (dlen < XDR_QUADLEN(len)*4) |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 438 | return 0; |
| 439 | |
| 440 | if (args->count > max_blocksize) { |
| 441 | args->count = max_blocksize; |
| 442 | len = args->len = max_blocksize; |
| 443 | } |
Chuck Lever | 8154ef2 | 2018-03-27 10:54:07 -0400 | [diff] [blame] | 444 | |
| 445 | args->first.iov_base = (void *)p; |
| 446 | args->first.iov_len = head->iov_len - hdr; |
Peter Staubach | f34b9568 | 2007-05-09 02:34:48 -0700 | [diff] [blame] | 447 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 451 | nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 453 | struct nfsd3_createargs *args = rqstp->rq_argp; |
| 454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | if (!(p = decode_fh(p, &args->fh)) |
| 456 | || !(p = decode_filename(p, &args->name, &args->len))) |
| 457 | return 0; |
| 458 | |
| 459 | switch (args->createmode = ntohl(*p++)) { |
| 460 | case NFS3_CREATE_UNCHECKED: |
| 461 | case NFS3_CREATE_GUARDED: |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 462 | p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | break; |
| 464 | case NFS3_CREATE_EXCLUSIVE: |
| 465 | args->verf = p; |
| 466 | p += 2; |
| 467 | break; |
| 468 | default: |
| 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | return xdr_argsize_check(rqstp, p); |
| 473 | } |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 474 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 476 | nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 478 | struct nfsd3_createargs *args = rqstp->rq_argp; |
| 479 | |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 480 | if (!(p = decode_fh(p, &args->fh)) || |
| 481 | !(p = decode_filename(p, &args->name, &args->len))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | return 0; |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 483 | p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
| 485 | return xdr_argsize_check(rqstp, p); |
| 486 | } |
| 487 | |
| 488 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 489 | nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 491 | struct nfsd3_symlinkargs *args = rqstp->rq_argp; |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 492 | char *base = (char *)p; |
| 493 | size_t dlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 495 | if (!(p = decode_fh(p, &args->ffh)) || |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 496 | !(p = decode_filename(p, &args->fname, &args->flen))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | return 0; |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 498 | p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 499 | |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 500 | args->tlen = ntohl(*p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 502 | args->first.iov_base = p; |
| 503 | args->first.iov_len = rqstp->rq_arg.head[0].iov_len; |
| 504 | args->first.iov_len -= (char *)p - base; |
| 505 | |
| 506 | dlen = args->first.iov_len + rqstp->rq_arg.page_len + |
| 507 | rqstp->rq_arg.tail[0].iov_len; |
| 508 | if (dlen < XDR_QUADLEN(args->tlen) << 2) |
| 509 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | return 1; |
| 511 | } |
| 512 | |
| 513 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 514 | nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 516 | struct nfsd3_mknodargs *args = rqstp->rq_argp; |
| 517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | if (!(p = decode_fh(p, &args->fh)) |
| 519 | || !(p = decode_filename(p, &args->name, &args->len))) |
| 520 | return 0; |
| 521 | |
| 522 | args->ftype = ntohl(*p++); |
| 523 | |
| 524 | if (args->ftype == NF3BLK || args->ftype == NF3CHR |
NeilBrown | 072f62e | 2007-05-09 02:34:57 -0700 | [diff] [blame] | 525 | || args->ftype == NF3SOCK || args->ftype == NF3FIFO) |
Trond Myklebust | e45d1a1 | 2019-04-09 12:13:42 -0400 | [diff] [blame] | 526 | p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | |
| 528 | if (args->ftype == NF3BLK || args->ftype == NF3CHR) { |
| 529 | args->major = ntohl(*p++); |
| 530 | args->minor = ntohl(*p++); |
| 531 | } |
| 532 | |
| 533 | return xdr_argsize_check(rqstp, p); |
| 534 | } |
| 535 | |
| 536 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 537 | nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 539 | struct nfsd3_renameargs *args = rqstp->rq_argp; |
| 540 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | if (!(p = decode_fh(p, &args->ffh)) |
| 542 | || !(p = decode_filename(p, &args->fname, &args->flen)) |
| 543 | || !(p = decode_fh(p, &args->tfh)) |
| 544 | || !(p = decode_filename(p, &args->tname, &args->tlen))) |
| 545 | return 0; |
| 546 | |
| 547 | return xdr_argsize_check(rqstp, p); |
| 548 | } |
| 549 | |
| 550 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 551 | nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 553 | struct nfsd3_readlinkargs *args = rqstp->rq_argp; |
| 554 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 555 | p = decode_fh(p, &args->fh); |
| 556 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | return 0; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 558 | args->buffer = page_address(*(rqstp->rq_next_page++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
J. Bruce Fields | 9512a16 | 2017-05-16 15:57:42 -0400 | [diff] [blame] | 560 | return xdr_argsize_check(rqstp, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 564 | nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 566 | struct nfsd3_linkargs *args = rqstp->rq_argp; |
| 567 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | if (!(p = decode_fh(p, &args->ffh)) |
| 569 | || !(p = decode_fh(p, &args->tfh)) |
| 570 | || !(p = decode_filename(p, &args->tname, &args->tlen))) |
| 571 | return 0; |
| 572 | |
| 573 | return xdr_argsize_check(rqstp, p); |
| 574 | } |
| 575 | |
| 576 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 577 | nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 579 | struct nfsd3_readdirargs *args = rqstp->rq_argp; |
Murphy Zhou | 3c86794 | 2019-04-04 14:57:11 +0800 | [diff] [blame] | 580 | int len; |
NeilBrown | f875a79 | 2019-03-07 09:49:46 +1100 | [diff] [blame] | 581 | u32 max_blocksize = svc_max_payload(rqstp); |
| 582 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 583 | p = decode_fh(p, &args->fh); |
| 584 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | return 0; |
| 586 | p = xdr_decode_hyper(p, &args->cookie); |
| 587 | args->verf = p; p += 2; |
| 588 | args->dircount = ~0; |
| 589 | args->count = ntohl(*p++); |
Murphy Zhou | 3c86794 | 2019-04-04 14:57:11 +0800 | [diff] [blame] | 590 | len = args->count = min_t(u32, args->count, max_blocksize); |
| 591 | |
| 592 | while (len > 0) { |
| 593 | struct page *p = *(rqstp->rq_next_page++); |
| 594 | if (!args->buffer) |
| 595 | args->buffer = page_address(p); |
| 596 | len -= PAGE_SIZE; |
| 597 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
J. Bruce Fields | 9512a16 | 2017-05-16 15:57:42 -0400 | [diff] [blame] | 599 | return xdr_argsize_check(rqstp, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 603 | nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 605 | struct nfsd3_readdirargs *args = rqstp->rq_argp; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 606 | int len; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 607 | u32 max_blocksize = svc_max_payload(rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 609 | p = decode_fh(p, &args->fh); |
| 610 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | return 0; |
| 612 | p = xdr_decode_hyper(p, &args->cookie); |
| 613 | args->verf = p; p += 2; |
| 614 | args->dircount = ntohl(*p++); |
| 615 | args->count = ntohl(*p++); |
| 616 | |
Kinglong Mee | 3c7aa15 | 2014-06-10 18:08:19 +0800 | [diff] [blame] | 617 | len = args->count = min(args->count, max_blocksize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | while (len > 0) { |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 619 | struct page *p = *(rqstp->rq_next_page++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | if (!args->buffer) |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 621 | args->buffer = page_address(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | len -= PAGE_SIZE; |
| 623 | } |
J. Bruce Fields | 9512a16 | 2017-05-16 15:57:42 -0400 | [diff] [blame] | 624 | |
| 625 | return xdr_argsize_check(rqstp, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | int |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 629 | nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 631 | struct nfsd3_commitargs *args = rqstp->rq_argp; |
Benoit Taine | d40aa33 | 2014-05-22 16:32:30 +0200 | [diff] [blame] | 632 | p = decode_fh(p, &args->fh); |
| 633 | if (!p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | return 0; |
| 635 | p = xdr_decode_hyper(p, &args->offset); |
| 636 | args->count = ntohl(*p++); |
| 637 | |
| 638 | return xdr_argsize_check(rqstp, p); |
| 639 | } |
| 640 | |
| 641 | /* |
| 642 | * XDR encode functions |
| 643 | */ |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 644 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 646 | nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | { |
| 648 | return xdr_ressize_check(rqstp, p); |
| 649 | } |
| 650 | |
| 651 | /* GETATTR */ |
| 652 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 653 | nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 655 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
| 656 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 657 | *p++ = resp->status; |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 658 | if (resp->status == 0) { |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 659 | lease_get_mtime(d_inode(resp->fh.fh_dentry), |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 660 | &resp->stat.mtime); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 661 | p = encode_fattr3(rqstp, p, &resp->fh, &resp->stat); |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 662 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | return xdr_ressize_check(rqstp, p); |
| 664 | } |
| 665 | |
| 666 | /* SETATTR, REMOVE, RMDIR */ |
| 667 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 668 | nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 670 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
| 671 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 672 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | p = encode_wcc_data(rqstp, p, &resp->fh); |
| 674 | return xdr_ressize_check(rqstp, p); |
| 675 | } |
| 676 | |
| 677 | /* LOOKUP */ |
| 678 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 679 | nfs3svc_encode_diropres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 681 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
| 682 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 683 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | if (resp->status == 0) { |
| 685 | p = encode_fh(p, &resp->fh); |
| 686 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 687 | } |
| 688 | p = encode_post_op_attr(rqstp, p, &resp->dirfh); |
| 689 | return xdr_ressize_check(rqstp, p); |
| 690 | } |
| 691 | |
| 692 | /* ACCESS */ |
| 693 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 694 | nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 696 | struct nfsd3_accessres *resp = rqstp->rq_resp; |
| 697 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 698 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 700 | if (resp->status == 0) |
| 701 | *p++ = htonl(resp->access); |
| 702 | return xdr_ressize_check(rqstp, p); |
| 703 | } |
| 704 | |
| 705 | /* READLINK */ |
| 706 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 707 | nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 709 | struct nfsd3_readlinkres *resp = rqstp->rq_resp; |
Chuck Lever | 76e5492 | 2020-11-05 10:24:19 -0500 | [diff] [blame^] | 710 | struct kvec *head = rqstp->rq_res.head; |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 711 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 712 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 714 | if (resp->status == 0) { |
| 715 | *p++ = htonl(resp->len); |
| 716 | xdr_ressize_check(rqstp, p); |
| 717 | rqstp->rq_res.page_len = resp->len; |
| 718 | if (resp->len & 3) { |
| 719 | /* need to pad the tail */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | rqstp->rq_res.tail[0].iov_base = p; |
| 721 | *p = 0; |
| 722 | rqstp->rq_res.tail[0].iov_len = 4 - (resp->len&3); |
| 723 | } |
Chuck Lever | 76e5492 | 2020-11-05 10:24:19 -0500 | [diff] [blame^] | 724 | if (svc_encode_result_payload(rqstp, head->iov_len, resp->len)) |
| 725 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | return 1; |
| 727 | } else |
| 728 | return xdr_ressize_check(rqstp, p); |
| 729 | } |
| 730 | |
| 731 | /* READ */ |
| 732 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 733 | nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 735 | struct nfsd3_readres *resp = rqstp->rq_resp; |
Chuck Lever | 76e5492 | 2020-11-05 10:24:19 -0500 | [diff] [blame^] | 736 | struct kvec *head = rqstp->rq_res.head; |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 737 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 738 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 740 | if (resp->status == 0) { |
| 741 | *p++ = htonl(resp->count); |
| 742 | *p++ = htonl(resp->eof); |
| 743 | *p++ = htonl(resp->count); /* xdr opaque count */ |
| 744 | xdr_ressize_check(rqstp, p); |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 745 | /* now update rqstp->rq_res to reflect data as well */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | rqstp->rq_res.page_len = resp->count; |
| 747 | if (resp->count & 3) { |
| 748 | /* need to pad the tail */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | rqstp->rq_res.tail[0].iov_base = p; |
| 750 | *p = 0; |
| 751 | rqstp->rq_res.tail[0].iov_len = 4 - (resp->count & 3); |
| 752 | } |
Chuck Lever | 76e5492 | 2020-11-05 10:24:19 -0500 | [diff] [blame^] | 753 | if (svc_encode_result_payload(rqstp, head->iov_len, |
| 754 | resp->count)) |
| 755 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | return 1; |
| 757 | } else |
| 758 | return xdr_ressize_check(rqstp, p); |
| 759 | } |
| 760 | |
| 761 | /* WRITE */ |
| 762 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 763 | nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 765 | struct nfsd3_writeres *resp = rqstp->rq_resp; |
Stanislav Kinsbursky | b9c0ef8 | 2012-12-06 14:23:19 +0300 | [diff] [blame] | 766 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 767 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | p = encode_wcc_data(rqstp, p, &resp->fh); |
| 769 | if (resp->status == 0) { |
| 770 | *p++ = htonl(resp->count); |
| 771 | *p++ = htonl(resp->committed); |
Trond Myklebust | 19e0663 | 2020-01-06 13:40:37 -0500 | [diff] [blame] | 772 | *p++ = resp->verf[0]; |
| 773 | *p++ = resp->verf[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | } |
| 775 | return xdr_ressize_check(rqstp, p); |
| 776 | } |
| 777 | |
| 778 | /* CREATE, MKDIR, SYMLINK, MKNOD */ |
| 779 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 780 | nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 782 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
| 783 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 784 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | if (resp->status == 0) { |
| 786 | *p++ = xdr_one; |
| 787 | p = encode_fh(p, &resp->fh); |
| 788 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 789 | } |
| 790 | p = encode_wcc_data(rqstp, p, &resp->dirfh); |
| 791 | return xdr_ressize_check(rqstp, p); |
| 792 | } |
| 793 | |
| 794 | /* RENAME */ |
| 795 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 796 | nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 798 | struct nfsd3_renameres *resp = rqstp->rq_resp; |
| 799 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 800 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | p = encode_wcc_data(rqstp, p, &resp->ffh); |
| 802 | p = encode_wcc_data(rqstp, p, &resp->tfh); |
| 803 | return xdr_ressize_check(rqstp, p); |
| 804 | } |
| 805 | |
| 806 | /* LINK */ |
| 807 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 808 | nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 810 | struct nfsd3_linkres *resp = rqstp->rq_resp; |
| 811 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 812 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 814 | p = encode_wcc_data(rqstp, p, &resp->tfh); |
| 815 | return xdr_ressize_check(rqstp, p); |
| 816 | } |
| 817 | |
| 818 | /* READDIR */ |
| 819 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 820 | nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 822 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
| 823 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 824 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | p = encode_post_op_attr(rqstp, p, &resp->fh); |
| 826 | |
| 827 | if (resp->status == 0) { |
| 828 | /* stupid readdir cookie */ |
| 829 | memcpy(p, resp->verf, 8); p += 2; |
| 830 | xdr_ressize_check(rqstp, p); |
| 831 | if (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE) |
| 832 | return 1; /*No room for trailer */ |
| 833 | rqstp->rq_res.page_len = (resp->count) << 2; |
| 834 | |
| 835 | /* add the 'tail' to the end of the 'head' page - page 0. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | rqstp->rq_res.tail[0].iov_base = p; |
| 837 | *p++ = 0; /* no more entries */ |
| 838 | *p++ = htonl(resp->common.err == nfserr_eof); |
| 839 | rqstp->rq_res.tail[0].iov_len = 2<<2; |
| 840 | return 1; |
| 841 | } else |
| 842 | return xdr_ressize_check(rqstp, p); |
| 843 | } |
| 844 | |
Adrian Bunk | 3ee6f61 | 2006-12-06 20:40:23 -0800 | [diff] [blame] | 845 | static __be32 * |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 846 | encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 847 | int namlen, u64 ino) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | { |
| 849 | *p++ = xdr_one; /* mark entry present */ |
| 850 | p = xdr_encode_hyper(p, ino); /* file id */ |
| 851 | p = xdr_encode_array(p, name, namlen);/* name length & name */ |
| 852 | |
| 853 | cd->offset = p; /* remember pointer */ |
| 854 | p = xdr_encode_hyper(p, NFS_OFFSET_MAX);/* offset of next entry */ |
| 855 | |
| 856 | return p; |
| 857 | } |
| 858 | |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 859 | static __be32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 861 | const char *name, int namlen, u64 ino) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | { |
| 863 | struct svc_export *exp; |
| 864 | struct dentry *dparent, *dchild; |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 865 | __be32 rv = nfserr_noent; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | |
| 867 | dparent = cd->fh.fh_dentry; |
| 868 | exp = cd->fh.fh_export; |
| 869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | if (isdotent(name, namlen)) { |
| 871 | if (namlen == 2) { |
| 872 | dchild = dget_parent(dparent); |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 873 | /* filesystem root - cannot return filehandle for ".." */ |
| 874 | if (dchild == dparent) |
| 875 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | } else |
| 877 | dchild = dget(dparent); |
| 878 | } else |
Al Viro | 6c2d4798 | 2019-10-31 01:21:58 -0400 | [diff] [blame] | 879 | dchild = lookup_positive_unlocked(name, dparent, namlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | if (IS_ERR(dchild)) |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 881 | return rv; |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 882 | if (d_mountpoint(dchild)) |
| 883 | goto out; |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 884 | if (dchild->d_inode->i_ino != ino) |
| 885 | goto out; |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 886 | rv = fh_compose(fhp, exp, dchild, &cd->fh); |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 887 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | dput(dchild); |
| 889 | return rv; |
| 890 | } |
| 891 | |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 892 | static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen, u64 ino) |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 893 | { |
J. Bruce Fields | 068c34c | 2014-01-09 16:24:35 -0500 | [diff] [blame] | 894 | struct svc_fh *fh = &cd->scratch; |
Al Viro | efe3965 | 2012-04-13 00:32:14 -0400 | [diff] [blame] | 895 | __be32 err; |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 896 | |
J. Bruce Fields | 068c34c | 2014-01-09 16:24:35 -0500 | [diff] [blame] | 897 | fh_init(fh, NFS3_FHSIZE); |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 898 | err = compose_entry_fh(cd, fh, name, namlen, ino); |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 899 | if (err) { |
| 900 | *p++ = 0; |
| 901 | *p++ = 0; |
J. Bruce Fields | aed100f | 2009-09-04 14:40:36 -0400 | [diff] [blame] | 902 | goto out; |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 903 | } |
J. Bruce Fields | 068c34c | 2014-01-09 16:24:35 -0500 | [diff] [blame] | 904 | p = encode_post_op_attr(cd->rqstp, p, fh); |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 905 | *p++ = xdr_one; /* yes, a file handle follows */ |
J. Bruce Fields | 068c34c | 2014-01-09 16:24:35 -0500 | [diff] [blame] | 906 | p = encode_fh(p, fh); |
J. Bruce Fields | aed100f | 2009-09-04 14:40:36 -0400 | [diff] [blame] | 907 | out: |
J. Bruce Fields | 068c34c | 2014-01-09 16:24:35 -0500 | [diff] [blame] | 908 | fh_put(fh); |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 909 | return p; |
| 910 | } |
| 911 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | /* |
| 913 | * Encode a directory entry. This one works for both normal readdir |
| 914 | * and readdirplus. |
| 915 | * The normal readdir reply requires 2 (fileid) + 1 (stringlen) |
| 916 | * + string + 2 (cookie) + 1 (next) words, i.e. 6 + strlen. |
| 917 | * |
| 918 | * The readdirplus baggage is 1+21 words for post_op_attr, plus the |
| 919 | * file handle. |
| 920 | */ |
| 921 | |
| 922 | #define NFS3_ENTRY_BAGGAGE (2 + 1 + 2 + 1) |
| 923 | #define NFS3_ENTRYPLUS_BAGGAGE (1 + 21 + 1 + (NFS3_FHSIZE >> 2)) |
| 924 | static int |
NeilBrown | 598b9a5 | 2007-03-26 21:32:08 -0800 | [diff] [blame] | 925 | encode_entry(struct readdir_cd *ccd, const char *name, int namlen, |
Peter Staubach | 40ee5dc | 2007-08-16 12:10:07 -0400 | [diff] [blame] | 926 | loff_t offset, u64 ino, unsigned int d_type, int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | { |
| 928 | struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres, |
| 929 | common); |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 930 | __be32 *p = cd->buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | caddr_t curr_page_addr = NULL; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 932 | struct page ** page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | int slen; /* string (name) length */ |
| 934 | int elen; /* estimated entry length in words */ |
| 935 | int num_entry_words = 0; /* actual number of words */ |
| 936 | |
| 937 | if (cd->offset) { |
| 938 | u64 offset64 = offset; |
| 939 | |
| 940 | if (unlikely(cd->offset1)) { |
| 941 | /* we ended up with offset on a page boundary */ |
| 942 | *cd->offset = htonl(offset64 >> 32); |
| 943 | *cd->offset1 = htonl(offset64 & 0xffffffff); |
| 944 | cd->offset1 = NULL; |
| 945 | } else { |
NeilBrown | 598b9a5 | 2007-03-26 21:32:08 -0800 | [diff] [blame] | 946 | xdr_encode_hyper(cd->offset, offset64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | } |
NeilBrown | b602345 | 2019-03-04 14:08:22 +1100 | [diff] [blame] | 948 | cd->offset = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | /* |
| 952 | dprintk("encode_entry(%.*s @%ld%s)\n", |
| 953 | namlen, name, (long) offset, plus? " plus" : ""); |
| 954 | */ |
| 955 | |
| 956 | /* truncate filename if too long */ |
Kinglong Mee | 3c7aa15 | 2014-06-10 18:08:19 +0800 | [diff] [blame] | 957 | namlen = min(namlen, NFS3_MAXNAMLEN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
| 959 | slen = XDR_QUADLEN(namlen); |
| 960 | elen = slen + NFS3_ENTRY_BAGGAGE |
| 961 | + (plus? NFS3_ENTRYPLUS_BAGGAGE : 0); |
| 962 | |
| 963 | if (cd->buflen < elen) { |
| 964 | cd->common.err = nfserr_toosmall; |
| 965 | return -EINVAL; |
| 966 | } |
| 967 | |
| 968 | /* determine which page in rq_respages[] we are currently filling */ |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 969 | for (page = cd->rqstp->rq_respages + 1; |
| 970 | page < cd->rqstp->rq_next_page; page++) { |
| 971 | curr_page_addr = page_address(*page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | |
| 973 | if (((caddr_t)cd->buffer >= curr_page_addr) && |
| 974 | ((caddr_t)cd->buffer < curr_page_addr + PAGE_SIZE)) |
| 975 | break; |
| 976 | } |
| 977 | |
| 978 | if ((caddr_t)(cd->buffer + elen) < (curr_page_addr + PAGE_SIZE)) { |
| 979 | /* encode entry in current page */ |
| 980 | |
| 981 | p = encode_entry_baggage(cd, p, name, namlen, ino); |
| 982 | |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 983 | if (plus) |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 984 | p = encode_entryplus_baggage(cd, p, name, namlen, ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | num_entry_words = p - cd->buffer; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 986 | } else if (*(page+1) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | /* temporarily encode entry into next page, then move back to |
| 988 | * current and next page in rq_respages[] */ |
Al Viro | 91f0716 | 2006-10-19 23:28:57 -0700 | [diff] [blame] | 989 | __be32 *p1, *tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | int len1, len2; |
| 991 | |
| 992 | /* grab next page for temporary storage of entry */ |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 993 | p1 = tmp = page_address(*(page+1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | |
| 995 | p1 = encode_entry_baggage(cd, p1, name, namlen, ino); |
| 996 | |
J. Bruce Fields | 8177e6d | 2009-09-04 14:13:09 -0400 | [diff] [blame] | 997 | if (plus) |
NeilBrown | 43b0e7e | 2015-05-03 09:16:53 +1000 | [diff] [blame] | 998 | p1 = encode_entryplus_baggage(cd, p1, name, namlen, ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
| 1000 | /* determine entry word length and lengths to go in pages */ |
| 1001 | num_entry_words = p1 - tmp; |
| 1002 | len1 = curr_page_addr + PAGE_SIZE - (caddr_t)cd->buffer; |
| 1003 | if ((num_entry_words << 2) < len1) { |
| 1004 | /* the actual number of words in the entry is less |
| 1005 | * than elen and can still fit in the current page |
| 1006 | */ |
| 1007 | memmove(p, tmp, num_entry_words << 2); |
| 1008 | p += num_entry_words; |
| 1009 | |
| 1010 | /* update offset */ |
| 1011 | cd->offset = cd->buffer + (cd->offset - tmp); |
| 1012 | } else { |
| 1013 | unsigned int offset_r = (cd->offset - tmp) << 2; |
| 1014 | |
| 1015 | /* update pointer to offset location. |
| 1016 | * This is a 64bit quantity, so we need to |
| 1017 | * deal with 3 cases: |
| 1018 | * - entirely in first page |
| 1019 | * - entirely in second page |
| 1020 | * - 4 bytes in each page |
| 1021 | */ |
| 1022 | if (offset_r + 8 <= len1) { |
| 1023 | cd->offset = p + (cd->offset - tmp); |
| 1024 | } else if (offset_r >= len1) { |
| 1025 | cd->offset -= len1 >> 2; |
| 1026 | } else { |
| 1027 | /* sitting on the fence */ |
| 1028 | BUG_ON(offset_r != len1 - 4); |
| 1029 | cd->offset = p + (cd->offset - tmp); |
| 1030 | cd->offset1 = tmp; |
| 1031 | } |
| 1032 | |
| 1033 | len2 = (num_entry_words << 2) - len1; |
| 1034 | |
| 1035 | /* move from temp page to current and next pages */ |
| 1036 | memmove(p, tmp, len1); |
| 1037 | memmove(tmp, (caddr_t)tmp+len1, len2); |
| 1038 | |
| 1039 | p = tmp + (len2 >> 2); |
| 1040 | } |
| 1041 | } |
| 1042 | else { |
| 1043 | cd->common.err = nfserr_toosmall; |
| 1044 | return -EINVAL; |
| 1045 | } |
| 1046 | |
| 1047 | cd->buflen -= num_entry_words; |
| 1048 | cd->buffer = p; |
| 1049 | cd->common.err = nfs_ok; |
| 1050 | return 0; |
| 1051 | |
| 1052 | } |
| 1053 | |
| 1054 | int |
NeilBrown | a0ad13e | 2007-01-26 00:57:10 -0800 | [diff] [blame] | 1055 | nfs3svc_encode_entry(void *cd, const char *name, |
| 1056 | int namlen, loff_t offset, u64 ino, unsigned int d_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | { |
| 1058 | return encode_entry(cd, name, namlen, offset, ino, d_type, 0); |
| 1059 | } |
| 1060 | |
| 1061 | int |
NeilBrown | a0ad13e | 2007-01-26 00:57:10 -0800 | [diff] [blame] | 1062 | nfs3svc_encode_entry_plus(void *cd, const char *name, |
| 1063 | int namlen, loff_t offset, u64 ino, |
| 1064 | unsigned int d_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | { |
| 1066 | return encode_entry(cd, name, namlen, offset, ino, d_type, 1); |
| 1067 | } |
| 1068 | |
| 1069 | /* FSSTAT */ |
| 1070 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1071 | nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1073 | struct nfsd3_fsstatres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | struct kstatfs *s = &resp->stats; |
| 1075 | u64 bs = s->f_bsize; |
| 1076 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 1077 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | *p++ = xdr_zero; /* no post_op_attr */ |
| 1079 | |
| 1080 | if (resp->status == 0) { |
| 1081 | p = xdr_encode_hyper(p, bs * s->f_blocks); /* total bytes */ |
| 1082 | p = xdr_encode_hyper(p, bs * s->f_bfree); /* free bytes */ |
| 1083 | p = xdr_encode_hyper(p, bs * s->f_bavail); /* user available bytes */ |
| 1084 | p = xdr_encode_hyper(p, s->f_files); /* total inodes */ |
| 1085 | p = xdr_encode_hyper(p, s->f_ffree); /* free inodes */ |
| 1086 | p = xdr_encode_hyper(p, s->f_ffree); /* user available inodes */ |
| 1087 | *p++ = htonl(resp->invarsec); /* mean unchanged time */ |
| 1088 | } |
| 1089 | return xdr_ressize_check(rqstp, p); |
| 1090 | } |
| 1091 | |
| 1092 | /* FSINFO */ |
| 1093 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1094 | nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1096 | struct nfsd3_fsinfores *resp = rqstp->rq_resp; |
| 1097 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 1098 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | *p++ = xdr_zero; /* no post_op_attr */ |
| 1100 | |
| 1101 | if (resp->status == 0) { |
| 1102 | *p++ = htonl(resp->f_rtmax); |
| 1103 | *p++ = htonl(resp->f_rtpref); |
| 1104 | *p++ = htonl(resp->f_rtmult); |
| 1105 | *p++ = htonl(resp->f_wtmax); |
| 1106 | *p++ = htonl(resp->f_wtpref); |
| 1107 | *p++ = htonl(resp->f_wtmult); |
| 1108 | *p++ = htonl(resp->f_dtpref); |
| 1109 | p = xdr_encode_hyper(p, resp->f_maxfilesize); |
| 1110 | *p++ = xdr_one; |
| 1111 | *p++ = xdr_zero; |
| 1112 | *p++ = htonl(resp->f_properties); |
| 1113 | } |
| 1114 | |
| 1115 | return xdr_ressize_check(rqstp, p); |
| 1116 | } |
| 1117 | |
| 1118 | /* PATHCONF */ |
| 1119 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1120 | nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1122 | struct nfsd3_pathconfres *resp = rqstp->rq_resp; |
| 1123 | |
Chuck Lever | 1905cac | 2020-10-23 10:41:01 -0400 | [diff] [blame] | 1124 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | *p++ = xdr_zero; /* no post_op_attr */ |
| 1126 | |
| 1127 | if (resp->status == 0) { |
| 1128 | *p++ = htonl(resp->p_link_max); |
| 1129 | *p++ = htonl(resp->p_name_max); |
| 1130 | *p++ = htonl(resp->p_no_trunc); |
| 1131 | *p++ = htonl(resp->p_chown_restricted); |
| 1132 | *p++ = htonl(resp->p_case_insensitive); |
| 1133 | *p++ = htonl(resp->p_case_preserving); |
| 1134 | } |
| 1135 | |
| 1136 | return xdr_ressize_check(rqstp, p); |
| 1137 | } |
| 1138 | |
| 1139 | /* COMMIT */ |
| 1140 | int |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1141 | nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 1143 | struct nfsd3_commitres *resp = rqstp->rq_resp; |
Stanislav Kinsbursky | b9c0ef8 | 2012-12-06 14:23:19 +0300 | [diff] [blame] | 1144 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 1145 | *p++ = resp->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | p = encode_wcc_data(rqstp, p, &resp->fh); |
| 1147 | /* Write verifier */ |
| 1148 | if (resp->status == 0) { |
Trond Myklebust | 524ff1a | 2020-01-06 13:40:36 -0500 | [diff] [blame] | 1149 | *p++ = resp->verf[0]; |
| 1150 | *p++ = resp->verf[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | } |
| 1152 | return xdr_ressize_check(rqstp, p); |
| 1153 | } |
| 1154 | |
| 1155 | /* |
| 1156 | * XDR release functions |
| 1157 | */ |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 1158 | void |
| 1159 | nfs3svc_release_fhandle(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | { |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 1161 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
| 1162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | fh_put(&resp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | } |
| 1165 | |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 1166 | void |
| 1167 | nfs3svc_release_fhandle2(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | { |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 1169 | struct nfsd3_fhandle_pair *resp = rqstp->rq_resp; |
| 1170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | fh_put(&resp->fh1); |
| 1172 | fh_put(&resp->fh2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | } |