History

Merge tag 'nfsd-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd updates from Chuck Lever: "NFSD is finally able to offer write delegations to clients that open files with O_WRONLY, thanks to patches from Dai Ngo. We're expecting this to accelerate a few interesting corner cases. The cap on the number of operations per NFSv4 COMPOUND has been lifted. Now, clients that send COMPOUNDs containing dozens of operations (for example, a long stream of LOOKUP operations to walk a pathname in a single round trip) will no longer be rejected. This release re-enables the ability for NFSD to perform NFSv4.2 COPY operations asynchronously. This feature has been disabled to mitigate the risk of denial-of-service when too many such requests arrive. Many thanks to the contributors, reviewers, testers, and bug reporters who participated during the v6.17 development cycle" * tag 'nfsd-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (32 commits) nfsd: Drop dprintk in blocklayout xdr functions sunrpc: make svc_tcp_sendmsg() take a signed sentp pointer sunrpc: rearrange struct svc_rqst for fewer cachelines sunrpc: return better error in svcauth_gss_accept() on alloc failure sunrpc: reset rq_accept_statp when starting a new RPC sunrpc: remove SVC_SYSERR sunrpc: fix handling of unknown auth status codes NFSD: Simplify struct knfsd_fh NFSD: Access a knfsd_fh's fsid by pointer Revert "NFSD: Force all NFSv4.2 COPY requests to be synchronous" NFSD: Avoid multiple -Wflex-array-member-not-at-end warnings NFSD: Use vfs_iocb_iter_write() NFSD: Use vfs_iocb_iter_read() NFSD: Clean up kdoc for nfsd_open_local_fh() NFSD: Clean up kdoc for nfsd_file_put_local() NFSD: Remove definition for trace_nfsd_ctl_maxconn NFSD: Remove definition for trace_nfsd_file_gc_recent NFSD: Remove definitions for unused trace_nfsd_file_lru trace points NFSD: Remove definition for trace_nfsd_file_unhash_and_queue nfsd: Use correct error code when decoding extents ...

Linus Torvalds committed 1 year ago

Commit ce3f5bb2 parents a90f1b6 e33996731 files · +341 −347Browse files

Unified · Split

31 files
  1. fs/nfsd/blocklayout.c +12 −8
  2. fs/nfsd/blocklayoutxdr.c +63 −48
  3. fs/nfsd/blocklayoutxdr.h +4 −4
  4. fs/nfsd/export.c +3 −5
  5. fs/nfsd/export.h +1 −1
  6. fs/nfsd/filecache.c +1 −1
  7. fs/nfsd/localio.c +1 −1
  8. fs/nfsd/nfs3proc.c +1 −1
  9. fs/nfsd/nfs4layouts.c +2 −2
  10. fs/nfsd/nfs4proc.c +2 −19
  11. fs/nfsd/nfs4state.c +84 −35
  12. fs/nfsd/nfs4xdr.c +1 −3
  13. fs/nfsd/nfsctl.c +16 −15
  14. fs/nfsd/nfsd.h +2 −4
  15. fs/nfsd/nfsfh.c +9 −7
  16. fs/nfsd/nfsfh.h +15 −11
  17. fs/nfsd/nfsproc.c +1 −1
  18. fs/nfsd/state.h +1 −0
  19. fs/nfsd/trace.h +2 −25
  20. fs/nfsd/vfs.c +10 −7
  21. fs/nfsd/xdr4.h +0 −1
  22. include/linux/sunrpc/msg_prot.h +10 −8
  23. include/linux/sunrpc/svc.h +3 −3
  24. include/linux/sunrpc/svcauth.h +0 −1
  25. include/linux/sunrpc/xdr.h +3 −2
  26. include/trace/events/sunrpc.h +18 −7
  27. net/sunrpc/auth_gss/svcauth_gss.c +2 −1
  28. net/sunrpc/socklib.c +59 −105
  29. net/sunrpc/svc.c +9 −11
  30. net/sunrpc/svcsock.c +2 −3
  31. net/sunrpc/xdr.c +4 −7
fs/nfsd/blocklayout.c+12−8
@@ -178,11 +178,13 @@ nfsd4_block_proc_layoutcommit(struct inode *inode, · 177 unmodified lines
178{178{
179 struct iomap *iomaps;179 struct iomap *iomaps;
180 int nr_iomaps;180 int nr_iomaps;
181 __be32 nfserr;
181 182
182 nr_iomaps = nfsd4_block_decode_layoutupdate(lcp->lc_up_layout,183 nfserr = nfsd4_block_decode_layoutupdate(lcp->lc_up_layout,
183 lcp->lc_up_len, &iomaps, i_blocksize(inode));184 lcp->lc_up_len, &iomaps, &nr_iomaps,
184 if (nr_iomaps < 0)185 i_blocksize(inode));
185 return nfserrno(nr_iomaps);186 if (nfserr != nfs_ok)
187 return nfserr;
186 188
187 return nfsd4_block_commit_blocks(inode, lcp, iomaps, nr_iomaps);189 return nfsd4_block_commit_blocks(inode, lcp, iomaps, nr_iomaps);
188}190}
@@ -316,11 +318,13 @@ nfsd4_scsi_proc_layoutcommit(struct inode *inode, · 127 unmodified lines
316{318{
317 struct iomap *iomaps;319 struct iomap *iomaps;
318 int nr_iomaps;320 int nr_iomaps;
321 __be32 nfserr;
319 322
320 nr_iomaps = nfsd4_scsi_decode_layoutupdate(lcp->lc_up_layout,323 nfserr = nfsd4_scsi_decode_layoutupdate(lcp->lc_up_layout,
321 lcp->lc_up_len, &iomaps, i_blocksize(inode));324 lcp->lc_up_len, &iomaps, &nr_iomaps,
322 if (nr_iomaps < 0)325 i_blocksize(inode));
323 return nfserrno(nr_iomaps);326 if (nfserr != nfs_ok)
327 return nfserr;
324 328
325 return nfsd4_block_commit_blocks(inode, lcp, iomaps, nr_iomaps);329 return nfsd4_block_commit_blocks(inode, lcp, iomaps, nr_iomaps);
326}330}
fs/nfsd/blocklayoutxdr.c+63−48
@@ -112,35 +112,46 @@ nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr, · 111 unmodified lines
112 return 0;112 return 0;
113}113}
114 114
115int115/**
116 * nfsd4_block_decode_layoutupdate - decode the block layout extent array
117 * @p: pointer to the xdr data
118 * @len: number of bytes to decode
119 * @iomapp: pointer to store the decoded extent array
120 * @nr_iomapsp: pointer to store the number of extents
121 * @block_size: alignment of extent offset and length
122 *
123 * This function decodes the opaque field of the layoutupdate4 structure
124 * in a layoutcommit request for the block layout driver. The field is
125 * actually an array of extents sent by the client. It also checks that
126 * the file offset, storage offset and length of each extent are aligned
127 * by @block_size.
128 *
129 * Return values:
130 * %nfs_ok: Successful decoding, @iomapp and @nr_iomapsp are valid
131 * %nfserr_bad_xdr: The encoded array in @p is invalid
132 * %nfserr_inval: An unaligned extent found
133 * %nfserr_delay: Failed to allocate memory for @iomapp
134 */
135__be32
116nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,136nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,
117 u32 block_size)137 int *nr_iomapsp, u32 block_size)
118{138{
119 struct iomap *iomaps;139 struct iomap *iomaps;
120 u32 nr_iomaps, i;140 u32 nr_iomaps, i;
121 141
122 if (len < sizeof(u32)) {142 if (len < sizeof(u32))
123 dprintk("%s: extent array too small: %u\n", __func__, len);143 return nfserr_bad_xdr;
124 return -EINVAL;
125 }
126 len -= sizeof(u32);144 len -= sizeof(u32);
127 if (len % PNFS_BLOCK_EXTENT_SIZE) {145 if (len % PNFS_BLOCK_EXTENT_SIZE)
128 dprintk("%s: extent array invalid: %u\n", __func__, len);146 return nfserr_bad_xdr;
129 return -EINVAL;
130 }
131 147
132 nr_iomaps = be32_to_cpup(p++);148 nr_iomaps = be32_to_cpup(p++);
133 if (nr_iomaps != len / PNFS_BLOCK_EXTENT_SIZE) {149 if (nr_iomaps != len / PNFS_BLOCK_EXTENT_SIZE)
134 dprintk("%s: extent array size mismatch: %u/%u\n",150 return nfserr_bad_xdr;
135 __func__, len, nr_iomaps);
136 return -EINVAL;
137 }
138 151
139 iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);152 iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);
140 if (!iomaps) {153 if (!iomaps)
141 dprintk("%s: failed to allocate extent array\n", __func__);154 return nfserr_delay;
142 return -ENOMEM;
143 }
144 155
145 for (i = 0; i < nr_iomaps; i++) {156 for (i = 0; i < nr_iomaps; i++) {
146 struct pnfs_block_extent bex;157 struct pnfs_block_extent bex;
@@ -150,26 +161,18 @@ nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, · 3 unmodified lines
150 161
151 p = xdr_decode_hyper(p, &bex.foff);162 p = xdr_decode_hyper(p, &bex.foff);
152 if (bex.foff & (block_size - 1)) {163 if (bex.foff & (block_size - 1)) {
153 dprintk("%s: unaligned offset 0x%llx\n",
154 __func__, bex.foff);
155 goto fail;164 goto fail;
156 }165 }
157 p = xdr_decode_hyper(p, &bex.len);166 p = xdr_decode_hyper(p, &bex.len);
158 if (bex.len & (block_size - 1)) {167 if (bex.len & (block_size - 1)) {
159 dprintk("%s: unaligned length 0x%llx\n",
160 __func__, bex.foff);
161 goto fail;168 goto fail;
162 }169 }
163 p = xdr_decode_hyper(p, &bex.soff);170 p = xdr_decode_hyper(p, &bex.soff);
164 if (bex.soff & (block_size - 1)) {171 if (bex.soff & (block_size - 1)) {
165 dprintk("%s: unaligned disk offset 0x%llx\n",
166 __func__, bex.soff);
167 goto fail;172 goto fail;
168 }173 }
169 bex.es = be32_to_cpup(p++);174 bex.es = be32_to_cpup(p++);
170 if (bex.es != PNFS_BLOCK_READWRITE_DATA) {175 if (bex.es != PNFS_BLOCK_READWRITE_DATA) {
171 dprintk("%s: incorrect extent state %d\n",
172 __func__, bex.es);
173 goto fail;176 goto fail;
174 }177 }
175 178
@@ -178,59 +181,71 @@ nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, · 2 unmodified lines
178 }181 }
179 182
180 *iomapp = iomaps;183 *iomapp = iomaps;
181 return nr_iomaps;184 *nr_iomapsp = nr_iomaps;
185 return nfs_ok;
182fail:186fail:
183 kfree(iomaps);187 kfree(iomaps);
184 return -EINVAL;188 return nfserr_inval;
185}189}
186 190
187int191/**
192 * nfsd4_scsi_decode_layoutupdate - decode the scsi layout extent array
193 * @p: pointer to the xdr data
194 * @len: number of bytes to decode
195 * @iomapp: pointer to store the decoded extent array
196 * @nr_iomapsp: pointer to store the number of extents
197 * @block_size: alignment of extent offset and length
198 *
199 * This function decodes the opaque field of the layoutupdate4 structure
200 * in a layoutcommit request for the scsi layout driver. The field is
201 * actually an array of extents sent by the client. It also checks that
202 * the offset and length of each extent are aligned by @block_size.
203 *
204 * Return values:
205 * %nfs_ok: Successful decoding, @iomapp and @nr_iomapsp are valid
206 * %nfserr_bad_xdr: The encoded array in @p is invalid
207 * %nfserr_inval: An unaligned extent found
208 * %nfserr_delay: Failed to allocate memory for @iomapp
209 */
210__be32
188nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,211nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,
189 u32 block_size)212 int *nr_iomapsp, u32 block_size)
190{213{
191 struct iomap *iomaps;214 struct iomap *iomaps;
192 u32 nr_iomaps, expected, i;215 u32 nr_iomaps, expected, i;
193 216
194 if (len < sizeof(u32)) {217 if (len < sizeof(u32))
195 dprintk("%s: extent array too small: %u\n", __func__, len);218 return nfserr_bad_xdr;
196 return -EINVAL;
197 }
198 219
199 nr_iomaps = be32_to_cpup(p++);220 nr_iomaps = be32_to_cpup(p++);
200 expected = sizeof(__be32) + nr_iomaps * PNFS_SCSI_RANGE_SIZE;221 expected = sizeof(__be32) + nr_iomaps * PNFS_SCSI_RANGE_SIZE;
201 if (len != expected) {222 if (len != expected)
202 dprintk("%s: extent array size mismatch: %u/%u\n",223 return nfserr_bad_xdr;
203 __func__, len, expected);
204 return -EINVAL;
205 }
206 224
207 iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);225 iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);
208 if (!iomaps) {226 if (!iomaps)
209 dprintk("%s: failed to allocate extent array\n", __func__);227 return nfserr_delay;
210 return -ENOMEM;
211 }
212 228
213 for (i = 0; i < nr_iomaps; i++) {229 for (i = 0; i < nr_iomaps; i++) {
214 u64 val;230 u64 val;
215 231
216 p = xdr_decode_hyper(p, &val);232 p = xdr_decode_hyper(p, &val);
217 if (val & (block_size - 1)) {233 if (val & (block_size - 1)) {
218 dprintk("%s: unaligned offset 0x%llx\n", __func__, val);
219 goto fail;234 goto fail;
220 }235 }
221 iomaps[i].offset = val;236 iomaps[i].offset = val;
222 237
223 p = xdr_decode_hyper(p, &val);238 p = xdr_decode_hyper(p, &val);
224 if (val & (block_size - 1)) {239 if (val & (block_size - 1)) {
225 dprintk("%s: unaligned length 0x%llx\n", __func__, val);
226 goto fail;240 goto fail;
227 }241 }
228 iomaps[i].length = val;242 iomaps[i].length = val;
229 }243 }
230 244
231 *iomapp = iomaps;245 *iomapp = iomaps;
232 return nr_iomaps;246 *nr_iomapsp = nr_iomaps;
247 return nfs_ok;
233fail:248fail:
234 kfree(iomaps);249 kfree(iomaps);
235 return -EINVAL;250 return nfserr_inval;
236}251}
fs/nfsd/blocklayoutxdr.h+4−4
@@ -54,9 +54,9 @@ __be32 nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr, · 53 unmodified lines
54 const struct nfsd4_getdeviceinfo *gdp);54 const struct nfsd4_getdeviceinfo *gdp);
55__be32 nfsd4_block_encode_layoutget(struct xdr_stream *xdr,55__be32 nfsd4_block_encode_layoutget(struct xdr_stream *xdr,
56 const struct nfsd4_layoutget *lgp);56 const struct nfsd4_layoutget *lgp);
57int nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,57__be32 nfsd4_block_decode_layoutupdate(__be32 *p, u32 len,
58 u32 block_size);58 struct iomap **iomapp, int *nr_iomapsp, u32 block_size);
59int nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,59__be32 nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len,
60 u32 block_size);60 struct iomap **iomapp, int *nr_iomapsp, u32 block_size);
61 61
62#endif /* _NFSD_BLOCKLAYOUTXDR_H */62#endif /* _NFSD_BLOCKLAYOUTXDR_H */
fs/nfsd/export.c+3−5
@@ -82,8 +82,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) · 81 unmodified lines
82 int len;82 int len;
83 struct auth_domain *dom = NULL;83 struct auth_domain *dom = NULL;
84 int err;84 int err;
85 int fsidtype;85 u8 fsidtype;
86 char *ep;
87 struct svc_expkey key;86 struct svc_expkey key;
88 struct svc_expkey *ek = NULL;87 struct svc_expkey *ek = NULL;
89 88
@@ -109,10 +108,9 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) · 19 unmodified lines
109 err = -EINVAL;108 err = -EINVAL;
110 if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)109 if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
111 goto out;110 goto out;
112 fsidtype = simple_strtoul(buf, &ep, 10);111 if (kstrtou8(buf, 10, &fsidtype))
113 if (*ep)
114 goto out;112 goto out;
115 dprintk("found fsidtype %d\n", fsidtype);113 dprintk("found fsidtype %u\n", fsidtype);
116 if (key_len(fsidtype)==0) /* invalid type */114 if (key_len(fsidtype)==0) /* invalid type */
117 goto out;115 goto out;
118 if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)116 if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
fs/nfsd/export.h+1−1
@@ -88,7 +88,7 @@ struct svc_expkey { · 87 unmodified lines
88 struct cache_head h;88 struct cache_head h;
89 89
90 struct auth_domain * ek_client;90 struct auth_domain * ek_client;
91 int ek_fsidtype;91 u8 ek_fsidtype;
92 u32 ek_fsid[6];92 u32 ek_fsid[6];
93 93
94 struct path ek_path;94 struct path ek_path;
fs/nfsd/filecache.c+1−1
@@ -372,7 +372,7 @@ nfsd_file_put(struct nfsd_file *nf) · 371 unmodified lines
372 372
373/**373/**
374 * nfsd_file_put_local - put nfsd_file reference and arm nfsd_net_put in caller374 * nfsd_file_put_local - put nfsd_file reference and arm nfsd_net_put in caller
375 * @nf: nfsd_file of which to put the reference375 * @pnf: nfsd_file of which to put the reference
376 *376 *
377 * First save the associated net to return to caller, then put377 * First save the associated net to return to caller, then put
378 * the reference of the nfsd_file.378 * the reference of the nfsd_file.
fs/nfsd/localio.c+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32 * @rpc_clnt: rpc_clnt that the client established32 * @rpc_clnt: rpc_clnt that the client established
33 * @cred: cred that the client established33 * @cred: cred that the client established
34 * @nfs_fh: filehandle to lookup34 * @nfs_fh: filehandle to lookup
35 * @nfp: place to find the nfsd_file, or store it if it was non-NULL35 * @pnf: place to find the nfsd_file, or store it if it was non-NULL
36 * @fmode: fmode_t to use for open36 * @fmode: fmode_t to use for open
37 *37 *
38 * This function maps a local fh to a path on a local filesystem.38 * This function maps a local fh to a path on a local filesystem.
fs/nfsd/nfs3proc.c+1−1
@@ -561,7 +561,7 @@ static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, · 560 unmodified lines
561 buf->pages = rqstp->rq_next_page;561 buf->pages = rqstp->rq_next_page;
562 rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;562 rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
563 563
564 xdr_init_encode_pages(xdr, buf, buf->pages, NULL);564 xdr_init_encode_pages(xdr, buf);
565}565}
566 566
567/*567/*
fs/nfsd/nfs4layouts.c+2−2
@@ -65,7 +65,7 @@ nfsd4_alloc_devid_map(const struct svc_fh *fhp) · 64 unmodified lines
65 return;65 return;
66 66
67 map->fsid_type = fh->fh_fsid_type;67 map->fsid_type = fh->fh_fsid_type;
68 memcpy(&map->fsid, fh->fh_fsid, fsid_len);68 memcpy(&map->fsid, fh_fsid(fh), fsid_len);
69 69
70 spin_lock(&nfsd_devid_lock);70 spin_lock(&nfsd_devid_lock);
71 if (fhp->fh_export->ex_devid_map)71 if (fhp->fh_export->ex_devid_map)
@@ -75,7 +75,7 @@ nfsd4_alloc_devid_map(const struct svc_fh *fhp) · 3 unmodified lines
75 list_for_each_entry(old, &nfsd_devid_hash[i], hash) {75 list_for_each_entry(old, &nfsd_devid_hash[i], hash) {
76 if (old->fsid_type != fh->fh_fsid_type)76 if (old->fsid_type != fh->fh_fsid_type)
77 continue;77 continue;
78 if (memcmp(old->fsid, fh->fh_fsid,78 if (memcmp(old->fsid, fh_fsid(fh),
79 key_len(old->fsid_type)))79 key_len(old->fsid_type)))
80 continue;80 continue;
81 81
fs/nfsd/nfs4proc.c+2−19
@@ -1917,13 +1917,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, · 1916 unmodified lines
1917 struct nfsd42_write_res *result;1917 struct nfsd42_write_res *result;
1918 __be32 status;1918 __be32 status;
1919 1919
1920 /*
1921 * Currently, async COPY is not reliable. Force all COPY
1922 * requests to be synchronous to avoid client application
1923 * hangs waiting for COPY completion.
1924 */
1925 nfsd4_copy_set_sync(copy, true);
1926
1927 result = &copy->cp_res;1920 result = &copy->cp_res;
1928 nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn);1921 nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn);
1929 1922
@@ -2842,20 +2835,10 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) · 912 unmodified lines
2842 2835
2843 rqstp->rq_lease_breaker = (void **)&cstate->clp;2836 rqstp->rq_lease_breaker = (void **)&cstate->clp;
2844 2837
2845 trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt);2838 trace_nfsd_compound(rqstp, args->tag, args->taglen, args->opcnt);
2846 while (!status && resp->opcnt < args->opcnt) {2839 while (!status && resp->opcnt < args->opcnt) {
2847 op = &args->ops[resp->opcnt++];2840 op = &args->ops[resp->opcnt++];
2848 2841
2849 if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) {
2850 /* If there are still more operations to process,
2851 * stop here and report NFS4ERR_RESOURCE. */
2852 if (cstate->minorversion == 0 &&
2853 args->client_opcnt > resp->opcnt) {
2854 op->status = nfserr_resource;
2855 goto encode_op;
2856 }
2857 }
2858
2859 /*2842 /*
2860 * The XDR decode routines may have pre-set op->status;2843 * The XDR decode routines may have pre-set op->status;
2861 * for example, if there is a miscellaneous XDR error2844 * for example, if there is a miscellaneous XDR error
@@ -2932,7 +2915,7 @@ encode_op: · 70 unmodified lines
2932 status = op->status;2915 status = op->status;
2933 }2916 }
2934 2917
2935 trace_nfsd_compound_status(args->client_opcnt, resp->opcnt,2918 trace_nfsd_compound_status(args->opcnt, resp->opcnt,
2936 status, nfsd4_op_name(op->opnum));2919 status, nfsd4_op_name(op->opnum));
2937 2920
2938 nfsd4_cstate_clear_replay(cstate);2921 nfsd4_cstate_clear_replay(cstate);
fs/nfsd/nfs4state.c+84−35
@@ -633,18 +633,6 @@ find_readable_file(struct nfs4_file *f) · 632 unmodified lines
633 return ret;633 return ret;
634}634}
635 635
636static struct nfsd_file *
637find_rw_file(struct nfs4_file *f)
638{
639 struct nfsd_file *ret;
640
641 spin_lock(&f->fi_lock);
642 ret = nfsd_file_get(f->fi_fds[O_RDWR]);
643 spin_unlock(&f->fi_lock);
644
645 return ret;
646}
647
648struct nfsd_file *636struct nfsd_file *
649find_any_file(struct nfs4_file *f)637find_any_file(struct nfs4_file *f)
650{638{
@@ -1218,15 +1206,20 @@ nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid) · 567 unmodified lines
1218 1206
1219static void put_deleg_file(struct nfs4_file *fp)1207static void put_deleg_file(struct nfs4_file *fp)
1220{1208{
1209 struct nfsd_file *rnf = NULL;
1221 struct nfsd_file *nf = NULL;1210 struct nfsd_file *nf = NULL;
1222 1211
1223 spin_lock(&fp->fi_lock);1212 spin_lock(&fp->fi_lock);
1224 if (--fp->fi_delegees == 0)1213 if (--fp->fi_delegees == 0) {
1225 swap(nf, fp->fi_deleg_file);1214 swap(nf, fp->fi_deleg_file);
1215 swap(rnf, fp->fi_rdeleg_file);
1216 }
1226 spin_unlock(&fp->fi_lock);1217 spin_unlock(&fp->fi_lock);
1227 1218
1228 if (nf)1219 if (nf)
1229 nfsd_file_put(nf);1220 nfsd_file_put(nf);
1221 if (rnf)
1222 nfs4_file_put_access(fp, NFS4_SHARE_ACCESS_READ);
1230}1223}
1231 1224
1232static void nfs4_unlock_deleg_lease(struct nfs4_delegation *dp)1225static void nfs4_unlock_deleg_lease(struct nfs4_delegation *dp)
@@ -3872,7 +3865,6 @@ static __be32 check_forechannel_attrs(struct nfsd4_channel_attrs *ca, struct nfs · 2639 unmodified lines
3872 ca->headerpadsz = 0;3865 ca->headerpadsz = 0;
3873 ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc);3866 ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc);
3874 ca->maxresp_sz = min_t(u32, ca->maxresp_sz, maxrpc);3867 ca->maxresp_sz = min_t(u32, ca->maxresp_sz, maxrpc);
3875 ca->maxops = min_t(u32, ca->maxops, NFSD_MAX_OPS_PER_COMPOUND);
3876 ca->maxresp_cached = min_t(u32, ca->maxresp_cached,3868 ca->maxresp_cached = min_t(u32, ca->maxresp_cached,
3877 NFSD_SLOT_CACHE_SIZE + NFSD_MIN_HDR_SEQ_SZ);3869 NFSD_SLOT_CACHE_SIZE + NFSD_MIN_HDR_SEQ_SZ);
3878 ca->maxreqs = min_t(u32, ca->maxreqs, NFSD_MAX_SLOTS_PER_SESSION);3870 ca->maxreqs = min_t(u32, ca->maxreqs, NFSD_MAX_SLOTS_PER_SESSION);
@@ -4697,10 +4689,16 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, · 818 unmodified lines
4697 }4689 }
4698 status = nfs_ok;4690 status = nfs_ok;
4699 if (conf) {4691 if (conf) {
4700 old = unconf;4692 if (get_client_locked(conf) == nfs_ok) {
4701 unhash_client_locked(old);4693 old = unconf;
4702 nfsd4_change_callback(conf, &unconf->cl_cb_conn);4694 unhash_client_locked(old);
4703 } else {4695 nfsd4_change_callback(conf, &unconf->cl_cb_conn);
4696 } else {
4697 conf = NULL;
4698 }
4699 }
4700
4701 if (!conf) {
4704 old = find_confirmed_client_by_name(&unconf->cl_name, nn);4702 old = find_confirmed_client_by_name(&unconf->cl_name, nn);
4705 if (old) {4703 if (old) {
4706 status = nfserr_clid_inuse;4704 status = nfserr_clid_inuse;
@@ -4717,10 +4715,14 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, · 10 unmodified lines
4717 }4715 }
4718 trace_nfsd_clid_replaced(&old->cl_clientid);4716 trace_nfsd_clid_replaced(&old->cl_clientid);
4719 }4717 }
4718 status = get_client_locked(unconf);
4719 if (status != nfs_ok) {
4720 old = NULL;
4721 goto out;
4722 }
4720 move_to_confirmed(unconf);4723 move_to_confirmed(unconf);
4721 conf = unconf;4724 conf = unconf;
4722 }4725 }
4723 get_client_locked(conf);
4724 spin_unlock(&nn->client_lock);4726 spin_unlock(&nn->client_lock);
4725 if (conf == unconf)4727 if (conf == unconf)
4726 fsnotify_dentry(conf->cl_nfsd_info_dentry, FS_MODIFY);4728 fsnotify_dentry(conf->cl_nfsd_info_dentry, FS_MODIFY);
@@ -4750,6 +4752,7 @@ static void nfsd4_file_init(const struct svc_fh *fh, struct nfs4_file *fp) · 23 unmodified lines
4750 INIT_LIST_HEAD(&fp->fi_clnt_odstate);4752 INIT_LIST_HEAD(&fp->fi_clnt_odstate);
4751 fh_copy_shallow(&fp->fi_fhandle, &fh->fh_handle);4753 fh_copy_shallow(&fp->fi_fhandle, &fh->fh_handle);
4752 fp->fi_deleg_file = NULL;4754 fp->fi_deleg_file = NULL;
4755 fp->fi_rdeleg_file = NULL;
4753 fp->fi_had_conflict = false;4756 fp->fi_had_conflict = false;
4754 fp->fi_share_deny = 0;4757 fp->fi_share_deny = 0;
4755 memset(fp->fi_fds, 0, sizeof(fp->fi_fds));4758 memset(fp->fi_fds, 0, sizeof(fp->fi_fds));
@@ -6000,14 +6003,19 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, · 1244 unmodified lines
6000 * "An OPEN_DELEGATE_WRITE delegation allows the client to handle,6003 * "An OPEN_DELEGATE_WRITE delegation allows the client to handle,
6001 * on its own, all opens."6004 * on its own, all opens."
6002 *6005 *
6003 * Furthermore the client can use a write delegation for most READ6006 * Furthermore, section 9.1.2 says:
6004 * operations as well, so we require a O_RDWR file here.6007 *
6008 * "In the case of READ, the server may perform the corresponding
6009 * check on the access mode, or it may choose to allow READ for
6010 * OPEN4_SHARE_ACCESS_WRITE, to accommodate clients whose WRITE
6011 * implementation may unavoidably do reads (e.g., due to buffer
6012 * cache constraints)."
6005 *6013 *
6006 * Offer a write delegation in the case of a BOTH open, and ensure6014 * We choose to offer a write delegation for OPEN with the
6007 * we get the O_RDWR descriptor.6015 * OPEN4_SHARE_ACCESS_WRITE access mode to accommodate such clients.
6008 */6016 */
6009 if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) == NFS4_SHARE_ACCESS_BOTH) {6017 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) {
6010 nf = find_rw_file(fp);6018 nf = find_writeable_file(fp);
6011 dl_type = deleg_ts ? OPEN_DELEGATE_WRITE_ATTRS_DELEG : OPEN_DELEGATE_WRITE;6019 dl_type = deleg_ts ? OPEN_DELEGATE_WRITE_ATTRS_DELEG : OPEN_DELEGATE_WRITE;
6012 }6020 }
6013 6021
@@ -6138,7 +6146,7 @@ static bool · 124 unmodified lines
6138nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,6146nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
6139 struct kstat *stat)6147 struct kstat *stat)
6140{6148{
6141 struct nfsd_file *nf = find_rw_file(dp->dl_stid.sc_file);6149 struct nfsd_file *nf = find_writeable_file(dp->dl_stid.sc_file);
6142 struct path path;6150 struct path path;
6143 int rc;6151 int rc;
6144 6152
@@ -6156,6 +6164,34 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, · 11 unmodified lines
6156 return rc == 0;6164 return rc == 0;
6157}6165}
6158 6166
6167/*
6168 * Add NFS4_SHARE_ACCESS_READ to the write delegation granted on OPEN
6169 * with NFS4_SHARE_ACCESS_WRITE by allocating separate nfsd_file and
6170 * struct file to be used for read with delegation stateid.
6171 *
6172 */
6173static bool
6174nfsd4_add_rdaccess_to_wrdeleg(struct svc_rqst *rqstp, struct nfsd4_open *open,
6175 struct svc_fh *fh, struct nfs4_ol_stateid *stp)
6176{
6177 struct nfs4_file *fp;
6178 struct nfsd_file *nf = NULL;
6179
6180 if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) ==
6181 NFS4_SHARE_ACCESS_WRITE) {
6182 if (nfsd_file_acquire_opened(rqstp, fh, NFSD_MAY_READ, NULL, &nf))
6183 return (false);
6184 fp = stp->st_stid.sc_file;
6185 spin_lock(&fp->fi_lock);
6186 __nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ);
6187 fp = stp->st_stid.sc_file;
6188 fp->fi_fds[O_RDONLY] = nf;
6189 fp->fi_rdeleg_file = nf;
6190 spin_unlock(&fp->fi_lock);
6191 }
6192 return true;
6193}
6194
6159/*6195/*
6160 * The Linux NFS server does not offer write delegations to NFSv4.06196 * The Linux NFS server does not offer write delegations to NFSv4.0
6161 * clients in order to avoid conflicts between write delegations and6197 * clients in order to avoid conflicts between write delegations and
@@ -6181,8 +6217,9 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, · 19 unmodified lines
6181 * open or lock state.6217 * open or lock state.
6182 */6218 */
6183static void6219static void
6184nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,6220nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open,
6185 struct svc_fh *currentfh)6221 struct nfs4_ol_stateid *stp, struct svc_fh *currentfh,
6222 struct svc_fh *fh)
6186{6223{
6187 struct nfs4_openowner *oo = openowner(stp->st_stateowner);6224 struct nfs4_openowner *oo = openowner(stp->st_stateowner);
6188 bool deleg_ts = nfsd4_want_deleg_timestamps(open);6225 bool deleg_ts = nfsd4_want_deleg_timestamps(open);
@@ -6227,7 +6264,8 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, · 38 unmodified lines
6227 memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid));6264 memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid));
6228 6265
6229 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) {6266 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) {
6230 if (!nfs4_delegation_stat(dp, currentfh, &stat)) {6267 if (!nfsd4_add_rdaccess_to_wrdeleg(rqstp, open, fh, stp) ||
6268 !nfs4_delegation_stat(dp, currentfh, &stat)) {
6231 nfs4_put_stid(&dp->dl_stid);6269 nfs4_put_stid(&dp->dl_stid);
6232 destroy_delegation(dp);6270 destroy_delegation(dp);
6233 goto out_no_deleg;6271 goto out_no_deleg;
@@ -6322,6 +6360,20 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf · 88 unmodified lines
6322 status = nfs4_check_deleg(cl, open, &dp);6360 status = nfs4_check_deleg(cl, open, &dp);
6323 if (status)6361 if (status)
6324 goto out;6362 goto out;
6363 if (dp && nfsd4_is_deleg_cur(open) &&
6364 (dp->dl_stid.sc_file != fp)) {
6365 /*
6366 * RFC8881 section 8.2.4 mandates the server to return
6367 * NFS4ERR_BAD_STATEID if the selected table entry does
6368 * not match the current filehandle. However returning
6369 * NFS4ERR_BAD_STATEID in the OPEN can cause the client
6370 * to repeatedly retry the operation with the same
6371 * stateid, since the stateid itself is valid. To avoid
6372 * this situation NFSD returns NFS4ERR_INVAL instead.
6373 */
6374 status = nfserr_inval;
6375 goto out;
6376 }
6325 stp = nfsd4_find_and_lock_existing_open(fp, open);6377 stp = nfsd4_find_and_lock_existing_open(fp, open);
6326 } else {6378 } else {
6327 open->op_file = NULL;6379 open->op_file = NULL;
@@ -6383,7 +6435,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf · 55 unmodified lines
6383 * Attempt to hand out a delegation. No error return, because the6435 * Attempt to hand out a delegation. No error return, because the
6384 * OPEN succeeds even if we fail.6436 * OPEN succeeds even if we fail.
6385 */6437 */
6386 nfs4_open_delegation(open, stp, &resp->cstate.current_fh);6438 nfs4_open_delegation(rqstp, open, stp,
6439 &resp->cstate.current_fh, current_fh);
6387 6440
6388 /*6441 /*
6389 * If there is an existing open stateid, it must be updated and6442 * If there is an existing open stateid, it must be updated and
@@ -7076,7 +7129,7 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, · 686 unmodified lines
7076 return_revoked = true;7129 return_revoked = true;
7077 if (typemask & SC_TYPE_DELEG)7130 if (typemask & SC_TYPE_DELEG)
7078 /* Always allow REVOKED for DELEG so we can7131 /* Always allow REVOKED for DELEG so we can
7079 * retturn the appropriate error.7132 * return the appropriate error.
7080 */7133 */
7081 statusmask |= SC_STATUS_REVOKED;7134 statusmask |= SC_STATUS_REVOKED;
7082 7135
@@ -7119,10 +7172,6 @@ nfs4_find_file(struct nfs4_stid *s, int flags) · 36 unmodified lines
7119 7172
7120 switch (s->sc_type) {7173 switch (s->sc_type) {
7121 case SC_TYPE_DELEG:7174 case SC_TYPE_DELEG:
7122 spin_lock(&s->sc_file->fi_lock);
7123 ret = nfsd_file_get(s->sc_file->fi_deleg_file);
7124 spin_unlock(&s->sc_file->fi_lock);
7125 break;
7126 case SC_TYPE_OPEN:7175 case SC_TYPE_OPEN:
7127 case SC_TYPE_LOCK:7176 case SC_TYPE_LOCK:
7128 if (flags & RD_STATE)7177 if (flags & RD_STATE)
fs/nfsd/nfs4xdr.c+1−3
@@ -2500,10 +2500,8 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) · 2499 unmodified lines
2500 2500
2501 if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0)2501 if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0)
2502 return false;2502 return false;
2503 if (xdr_stream_decode_u32(argp->xdr, &argp->client_opcnt) < 0)2503 if (xdr_stream_decode_u32(argp->xdr, &argp->opcnt) < 0)
2504 return false;2504 return false;
2505 argp->opcnt = min_t(u32, argp->client_opcnt,
2506 NFSD_MAX_OPS_PER_COMPOUND);
2507 2505
2508 if (argp->opcnt > ARRAY_SIZE(argp->iops)) {2506 if (argp->opcnt > ARRAY_SIZE(argp->iops)) {
2509 argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops));2507 argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops));
fs/nfsd/nfsctl.c+16−15
@@ -1436,7 +1436,7 @@ unsigned int nfsd_net_id; · 1435 unmodified lines
1436 1436
1437static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb,1437static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb,
1438 struct netlink_callback *cb,1438 struct netlink_callback *cb,
1439 struct nfsd_genl_rqstp *rqstp)1439 struct nfsd_genl_rqstp *genl_rqstp)
1440{1440{
1441 void *hdr;1441 void *hdr;
1442 u32 i;1442 u32 i;
@@ -1446,22 +1446,22 @@ static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb, · 3 unmodified lines
1446 if (!hdr)1446 if (!hdr)
1447 return -ENOBUFS;1447 return -ENOBUFS;
1448 1448
1449 if (nla_put_be32(skb, NFSD_A_RPC_STATUS_XID, rqstp->rq_xid) ||1449 if (nla_put_be32(skb, NFSD_A_RPC_STATUS_XID, genl_rqstp->rq_xid) ||
1450 nla_put_u32(skb, NFSD_A_RPC_STATUS_FLAGS, rqstp->rq_flags) ||1450 nla_put_u32(skb, NFSD_A_RPC_STATUS_FLAGS, genl_rqstp->rq_flags) ||
1451 nla_put_u32(skb, NFSD_A_RPC_STATUS_PROG, rqstp->rq_prog) ||1451 nla_put_u32(skb, NFSD_A_RPC_STATUS_PROG, genl_rqstp->rq_prog) ||
1452 nla_put_u32(skb, NFSD_A_RPC_STATUS_PROC, rqstp->rq_proc) ||1452 nla_put_u32(skb, NFSD_A_RPC_STATUS_PROC, genl_rqstp->rq_proc) ||
1453 nla_put_u8(skb, NFSD_A_RPC_STATUS_VERSION, rqstp->rq_vers) ||1453 nla_put_u8(skb, NFSD_A_RPC_STATUS_VERSION, genl_rqstp->rq_vers) ||
1454 nla_put_s64(skb, NFSD_A_RPC_STATUS_SERVICE_TIME,1454 nla_put_s64(skb, NFSD_A_RPC_STATUS_SERVICE_TIME,
1455 ktime_to_us(rqstp->rq_stime),1455 ktime_to_us(genl_rqstp->rq_stime),
1456 NFSD_A_RPC_STATUS_PAD))1456 NFSD_A_RPC_STATUS_PAD))
1457 return -ENOBUFS;1457 return -ENOBUFS;
1458 1458
1459 switch (rqstp->rq_saddr.sa_family) {1459 switch (genl_rqstp->rq_saddr.sa_family) {
1460 case AF_INET: {1460 case AF_INET: {
1461 const struct sockaddr_in *s_in, *d_in;1461 const struct sockaddr_in *s_in, *d_in;
1462 1462
1463 s_in = (const struct sockaddr_in *)&rqstp->rq_saddr;1463 s_in = (const struct sockaddr_in *)&genl_rqstp->rq_saddr;
1464 d_in = (const struct sockaddr_in *)&rqstp->rq_daddr;1464 d_in = (const struct sockaddr_in *)&genl_rqstp->rq_daddr;
1465 if (nla_put_in_addr(skb, NFSD_A_RPC_STATUS_SADDR4,1465 if (nla_put_in_addr(skb, NFSD_A_RPC_STATUS_SADDR4,
1466 s_in->sin_addr.s_addr) ||1466 s_in->sin_addr.s_addr) ||
1467 nla_put_in_addr(skb, NFSD_A_RPC_STATUS_DADDR4,1467 nla_put_in_addr(skb, NFSD_A_RPC_STATUS_DADDR4,
@@ -1476,8 +1476,8 @@ static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb, · 8 unmodified lines
1476 case AF_INET6: {1476 case AF_INET6: {
1477 const struct sockaddr_in6 *s_in, *d_in;1477 const struct sockaddr_in6 *s_in, *d_in;
1478 1478
1479 s_in = (const struct sockaddr_in6 *)&rqstp->rq_saddr;1479 s_in = (const struct sockaddr_in6 *)&genl_rqstp->rq_saddr;
1480 d_in = (const struct sockaddr_in6 *)&rqstp->rq_daddr;1480 d_in = (const struct sockaddr_in6 *)&genl_rqstp->rq_daddr;
1481 if (nla_put_in6_addr(skb, NFSD_A_RPC_STATUS_SADDR6,1481 if (nla_put_in6_addr(skb, NFSD_A_RPC_STATUS_SADDR6,
1482 &s_in->sin6_addr) ||1482 &s_in->sin6_addr) ||
1483 nla_put_in6_addr(skb, NFSD_A_RPC_STATUS_DADDR6,1483 nla_put_in6_addr(skb, NFSD_A_RPC_STATUS_DADDR6,
@@ -1491,9 +1491,9 @@ static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb, · 7 unmodified lines
1491 }1491 }
1492 }1492 }
1493 1493
1494 for (i = 0; i < rqstp->rq_opcnt; i++)1494 for (i = 0; i < genl_rqstp->rq_opcnt; i++)
1495 if (nla_put_u32(skb, NFSD_A_RPC_STATUS_COMPOUND_OPS,1495 if (nla_put_u32(skb, NFSD_A_RPC_STATUS_COMPOUND_OPS,
1496 rqstp->rq_opnum[i]))1496 genl_rqstp->rq_opnum[i]))
1497 return -ENOBUFS;1497 return -ENOBUFS;
1498 1498
1499 genlmsg_end(skb, hdr);1499 genlmsg_end(skb, hdr);
@@ -1569,7 +1569,8 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb, · 69 unmodified lines
1569 int j;1569 int j;
1570 1570
1571 args = rqstp->rq_argp;1571 args = rqstp->rq_argp;
1572 genl_rqstp.rq_opcnt = args->opcnt;1572 genl_rqstp.rq_opcnt = min_t(u32, args->opcnt,
1573 ARRAY_SIZE(genl_rqstp.rq_opnum));
1573 for (j = 0; j < genl_rqstp.rq_opcnt; j++)1574 for (j = 0; j < genl_rqstp.rq_opcnt; j++)
1574 genl_rqstp.rq_opnum[j] =1575 genl_rqstp.rq_opnum[j] =
1575 args->ops[j].opnum;1576 args->ops[j].opnum;
fs/nfsd/nfsd.h+2−4
@@ -57,9 +57,6 @@ struct readdir_cd { · 56 unmodified lines
57 __be32 err; /* 0, nfserr, or nfserr_eof */57 __be32 err; /* 0, nfserr, or nfserr_eof */
58};58};
59 59
60/* Maximum number of operations per session compound */
61#define NFSD_MAX_OPS_PER_COMPOUND 50
62
63struct nfsd_genl_rqstp {60struct nfsd_genl_rqstp {
64 struct sockaddr rq_daddr;61 struct sockaddr rq_daddr;
65 struct sockaddr rq_saddr;62 struct sockaddr rq_saddr;
@@ -72,7 +69,7 @@ struct nfsd_genl_rqstp { · 6 unmodified lines
72 69
73 /* NFSv4 compound */70 /* NFSv4 compound */
74 u32 rq_opcnt;71 u32 rq_opcnt;
75 u32 rq_opnum[NFSD_MAX_OPS_PER_COMPOUND];72 u32 rq_opnum[16];
76};73};
77 74
78extern struct svc_program nfsd_programs[];75extern struct svc_program nfsd_programs[];
@@ -283,6 +280,7 @@ void nfsd_lockd_shutdown(void); · 204 unmodified lines
283#define nfserr_cb_path_down cpu_to_be32(NFSERR_CB_PATH_DOWN)280#define nfserr_cb_path_down cpu_to_be32(NFSERR_CB_PATH_DOWN)
284#define nfserr_locked cpu_to_be32(NFSERR_LOCKED)281#define nfserr_locked cpu_to_be32(NFSERR_LOCKED)
285#define nfserr_wrongsec cpu_to_be32(NFSERR_WRONGSEC)282#define nfserr_wrongsec cpu_to_be32(NFSERR_WRONGSEC)
283#define nfserr_delay cpu_to_be32(NFS4ERR_DELAY)
286#define nfserr_badiomode cpu_to_be32(NFS4ERR_BADIOMODE)284#define nfserr_badiomode cpu_to_be32(NFS4ERR_BADIOMODE)
287#define nfserr_badlayout cpu_to_be32(NFS4ERR_BADLAYOUT)285#define nfserr_badlayout cpu_to_be32(NFS4ERR_BADLAYOUT)
288#define nfserr_bad_session_digest cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST)286#define nfserr_bad_session_digest cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST)
fs/nfsd/nfsfh.c+9−7
@@ -172,6 +172,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, · 171 unmodified lines
172 if (len == 0)172 if (len == 0)
173 return error;173 return error;
174 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) {174 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) {
175 u32 *fsid = fh_fsid(fh);
176
175 /* deprecated, convert to type 3 */177 /* deprecated, convert to type 3 */
176 len = key_len(FSID_ENCODE_DEV)/4;178 len = key_len(FSID_ENCODE_DEV)/4;
177 fh->fh_fsid_type = FSID_ENCODE_DEV;179 fh->fh_fsid_type = FSID_ENCODE_DEV;
@@ -181,17 +183,17 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, · 3 unmodified lines
181 * confuses sparse, so we must use __force here to183 * confuses sparse, so we must use __force here to
182 * keep it from complaining.184 * keep it from complaining.
183 */185 */
184 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]),186 fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fsid[0]),
185 ntohl((__force __be32)fh->fh_fsid[1])));187 ntohl((__force __be32)fsid[1])));
186 fh->fh_fsid[1] = fh->fh_fsid[2];188 fsid[1] = fsid[2];
187 }189 }
188 data_left -= len;190 data_left -= len;
189 if (data_left < 0)191 if (data_left < 0)
190 return error;192 return error;
191 exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL,193 exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL,
192 net, client, gssclient,194 net, client, gssclient,
193 fh->fh_fsid_type, fh->fh_fsid);195 fh->fh_fsid_type, fh_fsid(fh));
194 fid = (struct fid *)(fh->fh_fsid + len);196 fid = (struct fid *)(fh_fsid(fh) + len);
195 197
196 error = nfserr_stale;198 error = nfserr_stale;
197 if (IS_ERR(exp)) {199 if (IS_ERR(exp)) {
@@ -463,7 +465,7 @@ static void _fh_update(struct svc_fh *fhp, struct svc_export *exp, · 265 unmodified lines
463{465{
464 if (dentry != exp->ex_path.dentry) {466 if (dentry != exp->ex_path.dentry) {
465 struct fid *fid = (struct fid *)467 struct fid *fid = (struct fid *)
466 (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1);468 (fh_fsid(&fhp->fh_handle) + fhp->fh_handle.fh_size/4 - 1);
467 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;469 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
468 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 :470 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 :
469 EXPORT_FH_CONNECTABLE;471 EXPORT_FH_CONNECTABLE;
@@ -614,7 +616,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, · 144 unmodified lines
614 fhp->fh_handle.fh_auth_type = 0;616 fhp->fh_handle.fh_auth_type = 0;
615 617
616 mk_fsid(fhp->fh_handle.fh_fsid_type,618 mk_fsid(fhp->fh_handle.fh_fsid_type,
617 fhp->fh_handle.fh_fsid,619 fh_fsid(&fhp->fh_handle),
618 ex_dev,620 ex_dev,
619 d_inode(exp->ex_path.dentry)->i_ino,621 d_inode(exp->ex_path.dentry)->i_ino,
620 exp->ex_fsid, exp->ex_uuid);622 exp->ex_fsid, exp->ex_uuid);
fs/nfsd/nfsfh.h+15−11
@@ -49,18 +49,19 @@ struct knfsd_fh { · 48 unmodified lines
49 * Points to the current size while49 * Points to the current size while
50 * building a new file handle.50 * building a new file handle.
51 */51 */
52 union {52 u8 fh_raw[NFS4_FHSIZE];
53 char fh_raw[NFS4_FHSIZE];
54 struct {
55 u8 fh_version; /* == 1 */
56 u8 fh_auth_type; /* deprecated */
57 u8 fh_fsid_type;
58 u8 fh_fileid_type;
59 u32 fh_fsid[]; /* flexible-array member */
60 };
61 };
62};53};
63 54
55#define fh_version fh_raw[0]
56#define fh_auth_type fh_raw[1]
57#define fh_fsid_type fh_raw[2]
58#define fh_fileid_type fh_raw[3]
59
60static inline u32 *fh_fsid(const struct knfsd_fh *fh)
61{
62 return (u32 *)&fh->fh_raw[4];
63}
64
64static inline __u32 ino_t_to_u32(ino_t ino)65static inline __u32 ino_t_to_u32(ino_t ino)
65{66{
66 return (__u32) ino;67 return (__u32) ino;
@@ -260,9 +261,12 @@ static inline bool fh_match(const struct knfsd_fh *fh1, · 193 unmodified lines
260static inline bool fh_fsid_match(const struct knfsd_fh *fh1,261static inline bool fh_fsid_match(const struct knfsd_fh *fh1,
261 const struct knfsd_fh *fh2)262 const struct knfsd_fh *fh2)
262{263{
264 u32 *fsid1 = fh_fsid(fh1);
265 u32 *fsid2 = fh_fsid(fh2);
266
263 if (fh1->fh_fsid_type != fh2->fh_fsid_type)267 if (fh1->fh_fsid_type != fh2->fh_fsid_type)
264 return false;268 return false;
265 if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type)) != 0)269 if (memcmp(fsid1, fsid2, key_len(fh1->fh_fsid_type)) != 0)
266 return false;270 return false;
267 return true;271 return true;
268}272}
fs/nfsd/nfsproc.c+1−1
@@ -575,7 +575,7 @@ static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp, · 574 unmodified lines
575 buf->pages = rqstp->rq_next_page;575 buf->pages = rqstp->rq_next_page;
576 rqstp->rq_next_page++;576 rqstp->rq_next_page++;
577 577
578 xdr_init_encode_pages(xdr, buf, buf->pages, NULL);578 xdr_init_encode_pages(xdr, buf);
579}579}
580 580
581/*581/*
fs/nfsd/state.h+1−0
@@ -665,6 +665,7 @@ struct nfs4_file { · 664 unmodified lines
665 atomic_t fi_access[2];665 atomic_t fi_access[2];
666 u32 fi_share_deny;666 u32 fi_share_deny;
667 struct nfsd_file *fi_deleg_file;667 struct nfsd_file *fi_deleg_file;
668 struct nfsd_file *fi_rdeleg_file;
668 int fi_delegees;669 int fi_delegees;
669 struct knfsd_fh fi_fhandle;670 struct knfsd_fh fi_fhandle;
670 bool fi_had_conflict;671 bool fi_had_conflict;
fs/nfsd/trace.h+2−25
@@ -344,7 +344,7 @@ TRACE_EVENT(nfsd_exp_find_key, · 343 unmodified lines
344 int status),344 int status),
345 TP_ARGS(key, status),345 TP_ARGS(key, status),
346 TP_STRUCT__entry(346 TP_STRUCT__entry(
347 __field(int, fsidtype)347 __field(u8, fsidtype)
348 __array(u32, fsid, 6)348 __array(u32, fsid, 6)
349 __string(auth_domain, key->ek_client->name)349 __string(auth_domain, key->ek_client->name)
350 __field(int, status)350 __field(int, status)
@@ -367,7 +367,7 @@ TRACE_EVENT(nfsd_expkey_update, · 16 unmodified lines
367 TP_PROTO(const struct svc_expkey *key, const char *exp_path),367 TP_PROTO(const struct svc_expkey *key, const char *exp_path),
368 TP_ARGS(key, exp_path),368 TP_ARGS(key, exp_path),
369 TP_STRUCT__entry(369 TP_STRUCT__entry(
370 __field(int, fsidtype)370 __field(u8, fsidtype)
371 __array(u32, fsid, 6)371 __array(u32, fsid, 6)
372 __string(auth_domain, key->ek_client->name)372 __string(auth_domain, key->ek_client->name)
373 __string(path, exp_path)373 __string(path, exp_path)
@@ -1108,7 +1108,6 @@ DEFINE_NFSD_FILE_EVENT(nfsd_file_free); · 734 unmodified lines
1108DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);1108DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash);
1109DEFINE_NFSD_FILE_EVENT(nfsd_file_put);1109DEFINE_NFSD_FILE_EVENT(nfsd_file_put);
1110DEFINE_NFSD_FILE_EVENT(nfsd_file_closing);1110DEFINE_NFSD_FILE_EVENT(nfsd_file_closing);
1111DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_queue);
1112 1111
1113TRACE_EVENT(nfsd_file_alloc,1112TRACE_EVENT(nfsd_file_alloc,
1114 TP_PROTO(1113 TP_PROTO(
@@ -1344,9 +1343,7 @@ DEFINE_EVENT(nfsd_file_gc_class, name, \ · 229 unmodified lines
1344 TP_ARGS(nf))1343 TP_ARGS(nf))
1345 1344
1346DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add);1345DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add);
1347DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add_disposed);
1348DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del);1346DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del);
1349DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del_disposed);
1350DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use);1347DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use);
1351DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback);1348DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback);
1352DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced);1349DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced);
@@ -1380,7 +1377,6 @@ DEFINE_EVENT(nfsd_file_lruwalk_class, name, \ · 27 unmodified lines
1380 TP_ARGS(removed, remaining))1377 TP_ARGS(removed, remaining))
1381 1378
1382DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed);1379DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed);
1383DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_recent);
1384DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed);1380DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed);
1385 1381
1386TRACE_EVENT(nfsd_file_close,1382TRACE_EVENT(nfsd_file_close,
@@ -2103,25 +2099,6 @@ TRACE_EVENT(nfsd_ctl_maxblksize, · 716 unmodified lines
2103 )2099 )
2104);2100);
2105 2101
2106TRACE_EVENT(nfsd_ctl_maxconn,
2107 TP_PROTO(
2108 const struct net *net,
2109 int maxconn
2110 ),
2111 TP_ARGS(net, maxconn),
2112 TP_STRUCT__entry(
2113 __field(unsigned int, netns_ino)
2114 __field(int, maxconn)
2115 ),
2116 TP_fast_assign(
2117 __entry->netns_ino = net->ns.inum;
2118 __entry->maxconn = maxconn;
2119 ),
2120 TP_printk("maxconn=%d",
2121 __entry->maxconn
2122 )
2123);
2124
2125TRACE_EVENT(nfsd_ctl_time,2102TRACE_EVENT(nfsd_ctl_time,
2126 TP_PROTO(2103 TP_PROTO(
2127 const struct net *net,2104 const struct net *net,
fs/nfsd/vfs.c+10−7
@@ -1086,10 +1086,13 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp, · 1085 unmodified lines
1086{1086{
1087 unsigned long v, total;1087 unsigned long v, total;
1088 struct iov_iter iter;1088 struct iov_iter iter;
1089 loff_t ppos = offset;1089 struct kiocb kiocb;
1090 ssize_t host_err;1090 ssize_t host_err;
1091 size_t len;1091 size_t len;
1092 1092
1093 init_sync_kiocb(&kiocb, file);
1094 kiocb.ki_pos = offset;
1095
1093 v = 0;1096 v = 0;
1094 total = *count;1097 total = *count;
1095 while (total) {1098 while (total) {
@@ -1104,7 +1107,7 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp, · 8 unmodified lines
1104 1107
1105 trace_nfsd_read_vector(rqstp, fhp, offset, *count);1108 trace_nfsd_read_vector(rqstp, fhp, offset, *count);
1106 iov_iter_bvec(&iter, ITER_DEST, rqstp->rq_bvec, v, *count);1109 iov_iter_bvec(&iter, ITER_DEST, rqstp->rq_bvec, v, *count);
1107 host_err = vfs_iter_read(file, &iter, &ppos, 0);1110 host_err = vfs_iocb_iter_read(file, &kiocb, &iter);
1108 return nfsd_finish_read(rqstp, fhp, file, offset, count, eof, host_err);1111 return nfsd_finish_read(rqstp, fhp, file, offset, count, eof, host_err);
1109}1112}
1110 1113
@@ -1170,15 +1173,14 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, · 59 unmodified lines
1170 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);1173 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
1171 struct file *file = nf->nf_file;1174 struct file *file = nf->nf_file;
1172 struct super_block *sb = file_inode(file)->i_sb;1175 struct super_block *sb = file_inode(file)->i_sb;
1176 struct kiocb kiocb;
1173 struct svc_export *exp;1177 struct svc_export *exp;
1174 struct iov_iter iter;1178 struct iov_iter iter;
1175 errseq_t since;1179 errseq_t since;
1176 __be32 nfserr;1180 __be32 nfserr;
1177 int host_err;1181 int host_err;
1178 loff_t pos = offset;
1179 unsigned long exp_op_flags = 0;1182 unsigned long exp_op_flags = 0;
1180 unsigned int pflags = current->flags;1183 unsigned int pflags = current->flags;
1181 rwf_t flags = 0;
1182 bool restore_flags = false;1184 bool restore_flags = false;
1183 unsigned int nvecs;1185 unsigned int nvecs;
1184 1186
@@ -1204,16 +1206,17 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, · 19 unmodified lines
1204 1206
1205 if (!EX_ISSYNC(exp))1207 if (!EX_ISSYNC(exp))
1206 stable = NFS_UNSTABLE;1208 stable = NFS_UNSTABLE;
1207 1209 init_sync_kiocb(&kiocb, file);
1210 kiocb.ki_pos = offset;
1208 if (stable && !fhp->fh_use_wgather)1211 if (stable && !fhp->fh_use_wgather)
1209 flags |= RWF_SYNC;1212 kiocb.ki_flags |= IOCB_DSYNC;
1210 1213
1211 nvecs = xdr_buf_to_bvec(rqstp->rq_bvec, rqstp->rq_maxpages, payload);1214 nvecs = xdr_buf_to_bvec(rqstp->rq_bvec, rqstp->rq_maxpages, payload);
1212 iov_iter_bvec(&iter, ITER_SOURCE, rqstp->rq_bvec, nvecs, *cnt);1215 iov_iter_bvec(&iter, ITER_SOURCE, rqstp->rq_bvec, nvecs, *cnt);
1213 since = READ_ONCE(file->f_wb_err);1216 since = READ_ONCE(file->f_wb_err);
1214 if (verf)1217 if (verf)
1215 nfsd_copy_write_verifier(verf, nn);1218 nfsd_copy_write_verifier(verf, nn);
1216 host_err = vfs_iter_write(file, &iter, &pos, flags);1219 host_err = vfs_iocb_iter_write(file, &kiocb, &iter);
1217 if (host_err < 0) {1220 if (host_err < 0) {
1218 commit_reset_write_verifier(nn, rqstp, host_err);1221 commit_reset_write_verifier(nn, rqstp, host_err);
1219 goto out_nfserr;1222 goto out_nfserr;
fs/nfsd/xdr4.h+0−1
@@ -870,7 +870,6 @@ struct nfsd4_compoundargs { · 869 unmodified lines
870 char * tag;870 char * tag;
871 u32 taglen;871 u32 taglen;
872 u32 minorversion;872 u32 minorversion;
873 u32 client_opcnt;
874 u32 opcnt;873 u32 opcnt;
875 bool splice_ok;874 bool splice_ok;
876 struct nfsd4_op *ops;875 struct nfsd4_op *ops;
include/linux/sunrpc/msg_prot.h+10−8
@@ -69,15 +69,17 @@ enum rpc_reject_stat { · 68 unmodified lines
69};69};
70 70
71enum rpc_auth_stat {71enum rpc_auth_stat {
72 RPC_AUTH_OK = 0,72 RPC_AUTH_OK = 0, /* success */
73 RPC_AUTH_BADCRED = 1,73 RPC_AUTH_BADCRED = 1, /* bad credential (seal broken) */
74 RPC_AUTH_REJECTEDCRED = 2,74 RPC_AUTH_REJECTEDCRED = 2, /* client must begin new session */
75 RPC_AUTH_BADVERF = 3,75 RPC_AUTH_BADVERF = 3, /* bad verifier (seal broken) */
76 RPC_AUTH_REJECTEDVERF = 4,76 RPC_AUTH_REJECTEDVERF = 4, /* verifier expired or replayed */
77 RPC_AUTH_TOOWEAK = 5,77 RPC_AUTH_TOOWEAK = 5, /* rejected for security reasons */
78 RPC_AUTH_INVALIDRESP = 6, /* bogus response verifier */
79 RPC_AUTH_FAILED = 7, /* reason unknown */
78 /* RPCSEC_GSS errors */80 /* RPCSEC_GSS errors */
79 RPCSEC_GSS_CREDPROBLEM = 13,81 RPCSEC_GSS_CREDPROBLEM = 13, /* no credentials for user */
80 RPCSEC_GSS_CTXPROBLEM = 1482 RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */
81};83};
82 84
83#define RPC_MAXNETNAMELEN 25685#define RPC_MAXNETNAMELEN 256
include/linux/sunrpc/svc.h+3−3
@@ -245,10 +245,10 @@ struct svc_rqst { · 244 unmodified lines
245 * initialisation success.245 * initialisation success.
246 */246 */
247 247
248 unsigned long bc_to_initval;248 unsigned long bc_to_initval;
249 unsigned int bc_to_retries;249 unsigned int bc_to_retries;
250 void ** rq_lease_breaker; /* The v4 client breaking a lease */
251 unsigned int rq_status_counter; /* RPC processing counter */250 unsigned int rq_status_counter; /* RPC processing counter */
251 void **rq_lease_breaker; /* The v4 client breaking a lease */
252};252};
253 253
254/* bits for rq_flags */254/* bits for rq_flags */
include/linux/sunrpc/svcauth.h+0−1
@@ -86,7 +86,6 @@ struct auth_domain { · 85 unmodified lines
86 86
87enum svc_auth_status {87enum svc_auth_status {
88 SVC_GARBAGE = 1,88 SVC_GARBAGE = 1,
89 SVC_SYSERR,
90 SVC_VALID,89 SVC_VALID,
91 SVC_NEGATIVE,90 SVC_NEGATIVE,
92 SVC_OK,91 SVC_OK,
include/linux/sunrpc/xdr.h+3−2
@@ -119,6 +119,8 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 118 unmodified lines
119#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF)119#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF)
120#define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF)120#define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF)
121#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK)121#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK)
122#define rpc_autherr_invalidresp cpu_to_be32(RPC_AUTH_INVALIDRESP)
123#define rpc_autherr_failed cpu_to_be32(RPC_AUTH_FAILED)
122#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM)124#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM)
123#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM)125#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM)
124 126
@@ -242,8 +244,7 @@ typedef int (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr, · 117 unmodified lines
242 244
243extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf,245extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf,
244 __be32 *p, struct rpc_rqst *rqst);246 __be32 *p, struct rpc_rqst *rqst);
245extern void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,247void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf);
246 struct page **pages, struct rpc_rqst *rqst);
247extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);248extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
248extern int xdr_reserve_space_vec(struct xdr_stream *xdr, size_t nbytes);249extern int xdr_reserve_space_vec(struct xdr_stream *xdr, size_t nbytes);
249extern void __xdr_commit_encode(struct xdr_stream *xdr);250extern void __xdr_commit_encode(struct xdr_stream *xdr);
include/trace/events/sunrpc.h+18−7
@@ -1691,7 +1691,6 @@ SVC_RQST_FLAG_LIST · 1690 unmodified lines
1691 __print_flags(flags, "|", SVC_RQST_FLAG_LIST)1691 __print_flags(flags, "|", SVC_RQST_FLAG_LIST)
1692 1692
1693TRACE_DEFINE_ENUM(SVC_GARBAGE);1693TRACE_DEFINE_ENUM(SVC_GARBAGE);
1694TRACE_DEFINE_ENUM(SVC_SYSERR);
1695TRACE_DEFINE_ENUM(SVC_VALID);1694TRACE_DEFINE_ENUM(SVC_VALID);
1696TRACE_DEFINE_ENUM(SVC_NEGATIVE);1695TRACE_DEFINE_ENUM(SVC_NEGATIVE);
1697TRACE_DEFINE_ENUM(SVC_OK);1696TRACE_DEFINE_ENUM(SVC_OK);
@@ -1704,7 +1703,6 @@ TRACE_DEFINE_ENUM(SVC_COMPLETE); · 6 unmodified lines
1704#define show_svc_auth_status(status) \1703#define show_svc_auth_status(status) \
1705 __print_symbolic(status, \1704 __print_symbolic(status, \
1706 { SVC_GARBAGE, "SVC_GARBAGE" }, \1705 { SVC_GARBAGE, "SVC_GARBAGE" }, \
1707 { SVC_SYSERR, "SVC_SYSERR" }, \
1708 { SVC_VALID, "SVC_VALID" }, \1706 { SVC_VALID, "SVC_VALID" }, \
1709 { SVC_NEGATIVE, "SVC_NEGATIVE" }, \1707 { SVC_NEGATIVE, "SVC_NEGATIVE" }, \
1710 { SVC_OK, "SVC_OK" }, \1708 { SVC_OK, "SVC_OK" }, \
@@ -2123,22 +2121,35 @@ TRACE_EVENT(svc_xprt_accept, · 412 unmodified lines
2123 )2121 )
2124);2122);
2125 2123
2126TRACE_EVENT(svc_wake_up,2124DECLARE_EVENT_CLASS(svc_pool_thread_event,
2127 TP_PROTO(int pid),2125 TP_PROTO(const struct svc_pool *pool, pid_t pid),
2128 2126
2129 TP_ARGS(pid),2127 TP_ARGS(pool, pid),
2130 2128
2131 TP_STRUCT__entry(2129 TP_STRUCT__entry(
2132 __field(int, pid)2130 __field(unsigned int, pool_id)
2131 __field(pid_t, pid)
2133 ),2132 ),
2134 2133
2135 TP_fast_assign(2134 TP_fast_assign(
2135 __entry->pool_id = pool->sp_id;
2136 __entry->pid = pid;2136 __entry->pid = pid;
2137 ),2137 ),
2138 2138
2139 TP_printk("pid=%d", __entry->pid)2139 TP_printk("pool=%u pid=%d", __entry->pool_id, __entry->pid)
2140);2140);
2141 2141
2142#define DEFINE_SVC_POOL_THREAD_EVENT(name) \
2143 DEFINE_EVENT(svc_pool_thread_event, svc_pool_thread_##name, \
2144 TP_PROTO( \
2145 const struct svc_pool *pool, pid_t pid \
2146 ), \
2147 TP_ARGS(pool, pid))
2148
2149DEFINE_SVC_POOL_THREAD_EVENT(wake);
2150DEFINE_SVC_POOL_THREAD_EVENT(running);
2151DEFINE_SVC_POOL_THREAD_EVENT(noidle);
2152
2142TRACE_EVENT(svc_alloc_arg_err,2153TRACE_EVENT(svc_alloc_arg_err,
2143 TP_PROTO(2154 TP_PROTO(
2144 unsigned int requested,2155 unsigned int requested,
net/sunrpc/auth_gss/svcauth_gss.c+2−1
@@ -1628,7 +1628,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp) · 1627 unmodified lines
1628 int ret;1628 int ret;
1629 struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id);1629 struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id);
1630 1630
1631 rqstp->rq_auth_stat = rpc_autherr_badcred;1631 rqstp->rq_auth_stat = rpc_autherr_failed;
1632 if (!svcdata)1632 if (!svcdata)
1633 svcdata = kmalloc(sizeof(*svcdata), GFP_KERNEL);1633 svcdata = kmalloc(sizeof(*svcdata), GFP_KERNEL);
1634 if (!svcdata)1634 if (!svcdata)
@@ -1638,6 +1638,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp) · 3 unmodified lines
1638 svcdata->rsci = NULL;1638 svcdata->rsci = NULL;
1639 gc = &svcdata->clcred;1639 gc = &svcdata->clcred;
1640 1640
1641 rqstp->rq_auth_stat = rpc_autherr_badcred;
1641 if (!svcauth_gss_decode_credbody(&rqstp->rq_arg_stream, gc, &rpcstart))1642 if (!svcauth_gss_decode_credbody(&rqstp->rq_arg_stream, gc, &rpcstart))
1642 goto auth_err;1643 goto auth_err;
1643 if (gc->gc_v != RPC_GSS_VERSION)1644 if (gc->gc_v != RPC_GSS_VERSION)
net/sunrpc/socklib.c+59−105
@@ -27,97 +27,60 @@ · 26 unmodified lines
27struct xdr_skb_reader {27struct xdr_skb_reader {
28 struct sk_buff *skb;28 struct sk_buff *skb;
29 unsigned int offset;29 unsigned int offset;
30 bool need_checksum;
30 size_t count;31 size_t count;
31 __wsum csum;32 __wsum csum;
32};33};
33 34
34typedef size_t (*xdr_skb_read_actor)(struct xdr_skb_reader *desc, void *to,
35 size_t len);
36
37/**35/**
38 * xdr_skb_read_bits - copy some data bits from skb to internal buffer36 * xdr_skb_read_bits - copy some data bits from skb to internal buffer
39 * @desc: sk_buff copy helper37 * @desc: sk_buff copy helper
40 * @to: copy destination38 * @to: copy destination
41 * @len: number of bytes to copy39 * @len: number of bytes to copy
42 *40 *
43 * Possibly called several times to iterate over an sk_buff and copy41 * Possibly called several times to iterate over an sk_buff and copy data out of
44 * data out of it.42 * it.
45 */43 */
46static size_t44static size_t
47xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)45xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)
48{46{
49 if (len > desc->count)47 len = min(len, desc->count);
50 len = desc->count;48
51 if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len)))49 if (desc->need_checksum) {
52 return 0;50 __wsum csum;
53 desc->count -= len;51
54 desc->offset += len;52 csum = skb_copy_and_csum_bits(desc->skb, desc->offset, to, len);
55 return len;53 desc->csum = csum_block_add(desc->csum, csum, desc->offset);
56}54 } else {
55 if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len)))
56 return 0;
57 }
57 58
58/**
59 * xdr_skb_read_and_csum_bits - copy and checksum from skb to buffer
60 * @desc: sk_buff copy helper
61 * @to: copy destination
62 * @len: number of bytes to copy
63 *
64 * Same as skb_read_bits, but calculate a checksum at the same time.
65 */
66static size_t xdr_skb_read_and_csum_bits(struct xdr_skb_reader *desc, void *to, size_t len)
67{
68 unsigned int pos;
69 __wsum csum2;
70
71 if (len > desc->count)
72 len = desc->count;
73 pos = desc->offset;
74 csum2 = skb_copy_and_csum_bits(desc->skb, pos, to, len);
75 desc->csum = csum_block_add(desc->csum, csum2, pos);
76 desc->count -= len;59 desc->count -= len;
77 desc->offset += len;60 desc->offset += len;
78 return len;61 return len;
79}62}
80 63
81/**
82 * xdr_partial_copy_from_skb - copy data out of an skb
83 * @xdr: target XDR buffer
84 * @base: starting offset
85 * @desc: sk_buff copy helper
86 * @copy_actor: virtual method for copying data
87 *
88 */
89static ssize_t64static ssize_t
90xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, struct xdr_skb_reader *desc, xdr_skb_read_actor copy_actor)65xdr_partial_copy_from_skb(struct xdr_buf *xdr, struct xdr_skb_reader *desc)
91{66{
92 struct page **ppage = xdr->pages;67 struct page **ppage = xdr->pages + (xdr->page_base >> PAGE_SHIFT);
93 unsigned int len, pglen = xdr->page_len;68 unsigned int poff = xdr->page_base & ~PAGE_MASK;
94 ssize_t copied = 0;69 unsigned int pglen = xdr->page_len;
95 size_t ret;70 ssize_t copied = 0;
96 71 size_t ret;
97 len = xdr->head[0].iov_len;72
98 if (base < len) {73 if (xdr->head[0].iov_len == 0)
99 len -= base;74 return 0;
100 ret = copy_actor(desc, (char *)xdr->head[0].iov_base + base, len);75
101 copied += ret;76 ret = xdr_skb_read_bits(desc, xdr->head[0].iov_base,
102 if (ret != len || !desc->count)77 xdr->head[0].iov_len);
103 goto out;78 if (ret != xdr->head[0].iov_len || !desc->count)
104 base = 0;79 return ret;
105 } else80 copied += ret;
106 base -= len;81
107 82 while (pglen) {
108 if (unlikely(pglen == 0))83 unsigned int len = min(PAGE_SIZE - poff, pglen);
109 goto copy_tail;
110 if (unlikely(base >= pglen)) {
111 base -= pglen;
112 goto copy_tail;
113 }
114 if (base || xdr->page_base) {
115 pglen -= base;
116 base += xdr->page_base;
117 ppage += base >> PAGE_SHIFT;
118 base &= ~PAGE_MASK;
119 }
120 do {
121 char *kaddr;84 char *kaddr;
122 85
123 /* ACL likes to be lazy in allocating pages - ACLs86 /* ACL likes to be lazy in allocating pages - ACLs
@@ -126,36 +89,29 @@ xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, struct xdr_skb · 2 unmodified lines
126 *ppage = alloc_page(GFP_NOWAIT | __GFP_NOWARN);89 *ppage = alloc_page(GFP_NOWAIT | __GFP_NOWARN);
127 if (unlikely(*ppage == NULL)) {90 if (unlikely(*ppage == NULL)) {
128 if (copied == 0)91 if (copied == 0)
129 copied = -ENOMEM;92 return -ENOMEM;
130 goto out;93 return copied;
131 }94 }
132 }95 }
133 96
134 len = PAGE_SIZE;
135 kaddr = kmap_atomic(*ppage);97 kaddr = kmap_atomic(*ppage);
136 if (base) {98 ret = xdr_skb_read_bits(desc, kaddr + poff, len);
137 len -= base;
138 if (pglen < len)
139 len = pglen;
140 ret = copy_actor(desc, kaddr + base, len);
141 base = 0;
142 } else {
143 if (pglen < len)
144 len = pglen;
145 ret = copy_actor(desc, kaddr, len);
146 }
147 flush_dcache_page(*ppage);99 flush_dcache_page(*ppage);
148 kunmap_atomic(kaddr);100 kunmap_atomic(kaddr);
101
149 copied += ret;102 copied += ret;
150 if (ret != len || !desc->count)103 if (ret != len || !desc->count)
151 goto out;104 return copied;
152 ppage++;105 ppage++;
153 } while ((pglen -= len) != 0);106 pglen -= len;
154copy_tail:107 poff = 0;
155 len = xdr->tail[0].iov_len;108 }
156 if (base < len)109
157 copied += copy_actor(desc, (char *)xdr->tail[0].iov_base + base, len - base);110 if (xdr->tail[0].iov_len) {
158out:111 copied += xdr_skb_read_bits(desc, xdr->tail[0].iov_base,
112 xdr->tail[0].iov_len);
113 }
114
159 return copied;115 return copied;
160}116}
161 117
@@ -169,17 +125,22 @@ out: · 7 unmodified lines
169 */125 */
170int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)126int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
171{127{
172 struct xdr_skb_reader desc;128 struct xdr_skb_reader desc = {
173 129 .skb = skb,
174 desc.skb = skb;130 .count = skb->len - desc.offset,
175 desc.offset = 0;131 };
176 desc.count = skb->len - desc.offset;
177 132
178 if (skb_csum_unnecessary(skb))133 if (skb_csum_unnecessary(skb)) {
179 goto no_checksum;134 if (xdr_partial_copy_from_skb(xdr, &desc) < 0)
135 return -1;
136 if (desc.count)
137 return -1;
138 return 0;
139 }
180 140
141 desc.need_checksum = true;
181 desc.csum = csum_partial(skb->data, desc.offset, skb->csum);142 desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
182 if (xdr_partial_copy_from_skb(xdr, 0, &desc, xdr_skb_read_and_csum_bits) < 0)143 if (xdr_partial_copy_from_skb(xdr, &desc) < 0)
183 return -1;144 return -1;
184 if (desc.offset != skb->len) {145 if (desc.offset != skb->len) {
185 __wsum csum2;146 __wsum csum2;
@@ -194,14 +155,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb) · 8 unmodified lines
194 !skb->csum_complete_sw)155 !skb->csum_complete_sw)
195 netdev_rx_csum_fault(skb->dev, skb);156 netdev_rx_csum_fault(skb->dev, skb);
196 return 0;157 return 0;
197no_checksum:
198 if (xdr_partial_copy_from_skb(xdr, 0, &desc, xdr_skb_read_bits) < 0)
199 return -1;
200 if (desc.count)
201 return -1;
202 return 0;
203}158}
204EXPORT_SYMBOL_GPL(csum_partial_copy_to_xdr);
205 159
206static inline int xprt_sendmsg(struct socket *sock, struct msghdr *msg,160static inline int xprt_sendmsg(struct socket *sock, struct msghdr *msg,
207 size_t seek)161 size_t seek)
net/sunrpc/svc.c+9−11
@@ -751,14 +751,16 @@ void svc_pool_wake_idle_thread(struct svc_pool *pool) · 750 unmodified lines
751 WRITE_ONCE(rqstp->rq_qtime, ktime_get());751 WRITE_ONCE(rqstp->rq_qtime, ktime_get());
752 if (!task_is_running(rqstp->rq_task)) {752 if (!task_is_running(rqstp->rq_task)) {
753 wake_up_process(rqstp->rq_task);753 wake_up_process(rqstp->rq_task);
754 trace_svc_wake_up(rqstp->rq_task->pid);754 trace_svc_pool_thread_wake(pool, rqstp->rq_task->pid);
755 percpu_counter_inc(&pool->sp_threads_woken);755 percpu_counter_inc(&pool->sp_threads_woken);
756 } else {
757 trace_svc_pool_thread_running(pool, rqstp->rq_task->pid);
756 }758 }
757 rcu_read_unlock();759 rcu_read_unlock();
758 return;760 return;
759 }761 }
760 rcu_read_unlock();762 rcu_read_unlock();
761 763 trace_svc_pool_thread_noidle(pool, 0);
762}764}
763EXPORT_SYMBOL_GPL(svc_pool_wake_idle_thread);765EXPORT_SYMBOL_GPL(svc_pool_wake_idle_thread);
764 766
@@ -1332,6 +1334,9 @@ svc_process_common(struct svc_rqst *rqstp) · 567 unmodified lines
1332 int pr, rc;1334 int pr, rc;
1333 __be32 *p;1335 __be32 *p;
1334 1336
1337 /* Reset the accept_stat for the RPC */
1338 rqstp->rq_accept_statp = NULL;
1339
1335 /* Will be turned off only when NFSv4 Sessions are used */1340 /* Will be turned off only when NFSv4 Sessions are used */
1336 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);1341 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags);
1337 clear_bit(RQ_DROPME, &rqstp->rq_flags);1342 clear_bit(RQ_DROPME, &rqstp->rq_flags);
@@ -1373,8 +1378,6 @@ svc_process_common(struct svc_rqst *rqstp) · 35 unmodified lines
1373 case SVC_GARBAGE:1378 case SVC_GARBAGE:
1374 rqstp->rq_auth_stat = rpc_autherr_badcred;1379 rqstp->rq_auth_stat = rpc_autherr_badcred;
1375 goto err_bad_auth;1380 goto err_bad_auth;
1376 case SVC_SYSERR:
1377 goto err_system_err;
1378 case SVC_DENIED:1381 case SVC_DENIED:
1379 goto err_bad_auth;1382 goto err_bad_auth;
1380 case SVC_CLOSE:1383 case SVC_CLOSE:
@@ -1385,7 +1388,8 @@ svc_process_common(struct svc_rqst *rqstp) · 4 unmodified lines
1385 goto sendit;1388 goto sendit;
1386 default:1389 default:
1387 pr_warn_once("Unexpected svc_auth_status (%d)\n", auth_res);1390 pr_warn_once("Unexpected svc_auth_status (%d)\n", auth_res);
1388 goto err_system_err;1391 rqstp->rq_auth_stat = rpc_autherr_failed;
1392 goto err_bad_auth;
1389 }1393 }
1390 1394
1391 if (progp == NULL)1395 if (progp == NULL)
@@ -1512,12 +1516,6 @@ err_bad_proc: · 120 unmodified lines
1512 serv->sv_stats->rpcbadfmt++;1516 serv->sv_stats->rpcbadfmt++;
1513 *rqstp->rq_accept_statp = rpc_proc_unavail;1517 *rqstp->rq_accept_statp = rpc_proc_unavail;
1514 goto sendit;1518 goto sendit;
1515
1516err_system_err:
1517 if (serv->sv_stats)
1518 serv->sv_stats->rpcbadfmt++;
1519 *rqstp->rq_accept_statp = rpc_system_err;
1520 goto sendit;
1521}1519}
1522 1520
1523/*1521/*
net/sunrpc/svcsock.c+2−3
@@ -1197,7 +1197,7 @@ err_noclose: · 1196 unmodified lines
1197 * that the pages backing @xdr are unchanging.1197 * that the pages backing @xdr are unchanging.
1198 */1198 */
1199static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,1199static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
1200 rpc_fraghdr marker, unsigned int *sentp)1200 rpc_fraghdr marker, int *sentp)
1201{1201{
1202 struct msghdr msg = {1202 struct msghdr msg = {
1203 .msg_flags = MSG_SPLICE_PAGES,1203 .msg_flags = MSG_SPLICE_PAGES,
@@ -1247,8 +1247,7 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp) · 43 unmodified lines
1247 struct xdr_buf *xdr = &rqstp->rq_res;1247 struct xdr_buf *xdr = &rqstp->rq_res;
1248 rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |1248 rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |
1249 (u32)xdr->len);1249 (u32)xdr->len);
1250 unsigned int sent;1250 int sent, err;
1251 int err;
1252 1251
1253 svc_tcp_release_ctxt(xprt, rqstp->rq_xprt_ctxt);1252 svc_tcp_release_ctxt(xprt, rqstp->rq_xprt_ctxt);
1254 rqstp->rq_xprt_ctxt = NULL;1253 rqstp->rq_xprt_ctxt = NULL;
net/sunrpc/xdr.c+4−7
@@ -993,21 +993,18 @@ EXPORT_SYMBOL_GPL(xdr_init_encode); · 992 unmodified lines
993 * xdr_init_encode_pages - Initialize an xdr_stream for encoding into pages993 * xdr_init_encode_pages - Initialize an xdr_stream for encoding into pages
994 * @xdr: pointer to xdr_stream struct994 * @xdr: pointer to xdr_stream struct
995 * @buf: pointer to XDR buffer into which to encode data995 * @buf: pointer to XDR buffer into which to encode data
996 * @pages: list of pages to decode into
997 * @rqst: pointer to controlling rpc_rqst, for debugging
998 *996 *
999 */997 */
1000void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,998void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf)
1001 struct page **pages, struct rpc_rqst *rqst)
1002{999{
1003 xdr_reset_scratch_buffer(xdr);1000 xdr_reset_scratch_buffer(xdr);
1004 1001
1005 xdr->buf = buf;1002 xdr->buf = buf;
1006 xdr->page_ptr = pages;1003 xdr->page_ptr = buf->pages;
1007 xdr->iov = NULL;1004 xdr->iov = NULL;
1008 xdr->p = page_address(*pages);1005 xdr->p = page_address(*xdr->page_ptr);
1009 xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);1006 xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
1010 xdr->rqst = rqst;1007 xdr->rqst = NULL;
1011}1008}
1012EXPORT_SYMBOL_GPL(xdr_init_encode_pages);1009EXPORT_SYMBOL_GPL(xdr_init_encode_pages);
1013 1010

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t