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 ...
Unified · Split
| @@ -178,11 +178,13 @@ nfsd4_block_proc_layoutcommit(struct inode *inode, · 177 unmodified lines | ||
| 178 | 178 | { |
| 179 | 179 | struct iomap *iomaps; |
| 180 | 180 | int nr_iomaps; |
| 181 | + __be32 nfserr; | |
| 181 | 182 | |
| 182 | − nr_iomaps = nfsd4_block_decode_layoutupdate(lcp->lc_up_layout, | |
| 183 | − lcp->lc_up_len, &iomaps, i_blocksize(inode)); | |
| 184 | − if (nr_iomaps < 0) | |
| 185 | − return nfserrno(nr_iomaps); | |
| 183 | + nfserr = nfsd4_block_decode_layoutupdate(lcp->lc_up_layout, | |
| 184 | + lcp->lc_up_len, &iomaps, &nr_iomaps, | |
| 185 | + i_blocksize(inode)); | |
| 186 | + if (nfserr != nfs_ok) | |
| 187 | + return nfserr; | |
| 186 | 188 | |
| 187 | 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 | 319 | struct iomap *iomaps; |
| 318 | 320 | int nr_iomaps; |
| 321 | + __be32 nfserr; | |
| 319 | 322 | |
| 320 | − nr_iomaps = nfsd4_scsi_decode_layoutupdate(lcp->lc_up_layout, | |
| 321 | − lcp->lc_up_len, &iomaps, i_blocksize(inode)); | |
| 322 | − if (nr_iomaps < 0) | |
| 323 | − return nfserrno(nr_iomaps); | |
| 323 | + nfserr = nfsd4_scsi_decode_layoutupdate(lcp->lc_up_layout, | |
| 324 | + lcp->lc_up_len, &iomaps, &nr_iomaps, | |
| 325 | + i_blocksize(inode)); | |
| 326 | + if (nfserr != nfs_ok) | |
| 327 | + return nfserr; | |
| 324 | 328 | |
| 325 | 329 | return nfsd4_block_commit_blocks(inode, lcp, iomaps, nr_iomaps); |
| 326 | 330 | } |
| @@ -112,35 +112,46 @@ nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr, · 111 unmodified lines | ||
| 112 | 112 | return 0; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | −int | |
| 115 | +/** | |
| 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 | |
| 116 | 136 | nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, |
| 117 | − u32 block_size) | |
| 137 | + int *nr_iomapsp, u32 block_size) | |
| 118 | 138 | { |
| 119 | 139 | struct iomap *iomaps; |
| 120 | 140 | u32 nr_iomaps, i; |
| 121 | 141 | |
| 122 | − if (len < sizeof(u32)) { | |
| 123 | − dprintk("%s: extent array too small: %u\n", __func__, len); | |
| 124 | − return -EINVAL; | |
| 125 | − } | |
| 142 | + if (len < sizeof(u32)) | |
| 143 | + return nfserr_bad_xdr; | |
| 126 | 144 | len -= sizeof(u32); |
| 127 | − if (len % PNFS_BLOCK_EXTENT_SIZE) { | |
| 128 | − dprintk("%s: extent array invalid: %u\n", __func__, len); | |
| 129 | − return -EINVAL; | |
| 130 | − } | |
| 145 | + if (len % PNFS_BLOCK_EXTENT_SIZE) | |
| 146 | + return nfserr_bad_xdr; | |
| 131 | 147 | |
| 132 | 148 | nr_iomaps = be32_to_cpup(p++); |
| 133 | − if (nr_iomaps != len / PNFS_BLOCK_EXTENT_SIZE) { | |
| 134 | − dprintk("%s: extent array size mismatch: %u/%u\n", | |
| 135 | − __func__, len, nr_iomaps); | |
| 136 | − return -EINVAL; | |
| 137 | − } | |
| 149 | + if (nr_iomaps != len / PNFS_BLOCK_EXTENT_SIZE) | |
| 150 | + return nfserr_bad_xdr; | |
| 138 | 151 | |
| 139 | 152 | iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL); |
| 140 | − if (!iomaps) { | |
| 141 | − dprintk("%s: failed to allocate extent array\n", __func__); | |
| 142 | − return -ENOMEM; | |
| 143 | − } | |
| 153 | + if (!iomaps) | |
| 154 | + return nfserr_delay; | |
| 144 | 155 | |
| 145 | 156 | for (i = 0; i < nr_iomaps; i++) { |
| 146 | 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 | 162 | p = xdr_decode_hyper(p, &bex.foff); |
| 152 | 163 | if (bex.foff & (block_size - 1)) { |
| 153 | − dprintk("%s: unaligned offset 0x%llx\n", | |
| 154 | − __func__, bex.foff); | |
| 155 | 164 | goto fail; |
| 156 | 165 | } |
| 157 | 166 | p = xdr_decode_hyper(p, &bex.len); |
| 158 | 167 | if (bex.len & (block_size - 1)) { |
| 159 | − dprintk("%s: unaligned length 0x%llx\n", | |
| 160 | − __func__, bex.foff); | |
| 161 | 168 | goto fail; |
| 162 | 169 | } |
| 163 | 170 | p = xdr_decode_hyper(p, &bex.soff); |
| 164 | 171 | if (bex.soff & (block_size - 1)) { |
| 165 | − dprintk("%s: unaligned disk offset 0x%llx\n", | |
| 166 | − __func__, bex.soff); | |
| 167 | 172 | goto fail; |
| 168 | 173 | } |
| 169 | 174 | bex.es = be32_to_cpup(p++); |
| 170 | 175 | if (bex.es != PNFS_BLOCK_READWRITE_DATA) { |
| 171 | − dprintk("%s: incorrect extent state %d\n", | |
| 172 | − __func__, bex.es); | |
| 173 | 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 | 183 | *iomapp = iomaps; |
| 181 | − return nr_iomaps; | |
| 184 | + *nr_iomapsp = nr_iomaps; | |
| 185 | + return nfs_ok; | |
| 182 | 186 | fail: |
| 183 | 187 | kfree(iomaps); |
| 184 | − return -EINVAL; | |
| 188 | + return nfserr_inval; | |
| 185 | 189 | } |
| 186 | 190 | |
| 187 | −int | |
| 191 | +/** | |
| 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 | |
| 188 | 211 | nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, |
| 189 | − u32 block_size) | |
| 212 | + int *nr_iomapsp, u32 block_size) | |
| 190 | 213 | { |
| 191 | 214 | struct iomap *iomaps; |
| 192 | 215 | u32 nr_iomaps, expected, i; |
| 193 | 216 | |
| 194 | − if (len < sizeof(u32)) { | |
| 195 | − dprintk("%s: extent array too small: %u\n", __func__, len); | |
| 196 | − return -EINVAL; | |
| 197 | − } | |
| 217 | + if (len < sizeof(u32)) | |
| 218 | + return nfserr_bad_xdr; | |
| 198 | 219 | |
| 199 | 220 | nr_iomaps = be32_to_cpup(p++); |
| 200 | 221 | expected = sizeof(__be32) + nr_iomaps * PNFS_SCSI_RANGE_SIZE; |
| 201 | − if (len != expected) { | |
| 202 | − dprintk("%s: extent array size mismatch: %u/%u\n", | |
| 203 | − __func__, len, expected); | |
| 204 | − return -EINVAL; | |
| 205 | − } | |
| 222 | + if (len != expected) | |
| 223 | + return nfserr_bad_xdr; | |
| 206 | 224 | |
| 207 | 225 | iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL); |
| 208 | − if (!iomaps) { | |
| 209 | − dprintk("%s: failed to allocate extent array\n", __func__); | |
| 210 | − return -ENOMEM; | |
| 211 | − } | |
| 226 | + if (!iomaps) | |
| 227 | + return nfserr_delay; | |
| 212 | 228 | |
| 213 | 229 | for (i = 0; i < nr_iomaps; i++) { |
| 214 | 230 | u64 val; |
| 215 | 231 | |
| 216 | 232 | p = xdr_decode_hyper(p, &val); |
| 217 | 233 | if (val & (block_size - 1)) { |
| 218 | − dprintk("%s: unaligned offset 0x%llx\n", __func__, val); | |
| 219 | 234 | goto fail; |
| 220 | 235 | } |
| 221 | 236 | iomaps[i].offset = val; |
| 222 | 237 | |
| 223 | 238 | p = xdr_decode_hyper(p, &val); |
| 224 | 239 | if (val & (block_size - 1)) { |
| 225 | − dprintk("%s: unaligned length 0x%llx\n", __func__, val); | |
| 226 | 240 | goto fail; |
| 227 | 241 | } |
| 228 | 242 | iomaps[i].length = val; |
| 229 | 243 | } |
| 230 | 244 | |
| 231 | 245 | *iomapp = iomaps; |
| 232 | − return nr_iomaps; | |
| 246 | + *nr_iomapsp = nr_iomaps; | |
| 247 | + return nfs_ok; | |
| 233 | 248 | fail: |
| 234 | 249 | kfree(iomaps); |
| 235 | − return -EINVAL; | |
| 250 | + return nfserr_inval; | |
| 236 | 251 | } |
| @@ -54,9 +54,9 @@ __be32 nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr, · 53 unmodified lines | ||
| 54 | 54 | const struct nfsd4_getdeviceinfo *gdp); |
| 55 | 55 | __be32 nfsd4_block_encode_layoutget(struct xdr_stream *xdr, |
| 56 | 56 | const struct nfsd4_layoutget *lgp); |
| 57 | −int nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, | |
| 58 | − u32 block_size); | |
| 59 | −int nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp, | |
| 60 | − u32 block_size); | |
| 57 | +__be32 nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, | |
| 58 | + struct iomap **iomapp, int *nr_iomapsp, u32 block_size); | |
| 59 | +__be32 nfsd4_scsi_decode_layoutupdate(__be32 *p, u32 len, | |
| 60 | + struct iomap **iomapp, int *nr_iomapsp, u32 block_size); | |
| 61 | 61 | |
| 62 | 62 | #endif /* _NFSD_BLOCKLAYOUTXDR_H */ |
| @@ -82,8 +82,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) · 81 unmodified lines | ||
| 82 | 82 | int len; |
| 83 | 83 | struct auth_domain *dom = NULL; |
| 84 | 84 | int err; |
| 85 | − int fsidtype; | |
| 86 | − char *ep; | |
| 85 | + u8 fsidtype; | |
| 87 | 86 | struct svc_expkey key; |
| 88 | 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 | 108 | err = -EINVAL; |
| 110 | 109 | if (qword_get(&mesg, buf, PAGE_SIZE) <= 0) |
| 111 | 110 | goto out; |
| 112 | − fsidtype = simple_strtoul(buf, &ep, 10); | |
| 113 | − if (*ep) | |
| 111 | + if (kstrtou8(buf, 10, &fsidtype)) | |
| 114 | 112 | goto out; |
| 115 | − dprintk("found fsidtype %d\n", fsidtype); | |
| 113 | + dprintk("found fsidtype %u\n", fsidtype); | |
| 116 | 114 | if (key_len(fsidtype)==0) /* invalid type */ |
| 117 | 115 | goto out; |
| 118 | 116 | if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0) |
| @@ -88,7 +88,7 @@ struct svc_expkey { · 87 unmodified lines | ||
| 88 | 88 | struct cache_head h; |
| 89 | 89 | |
| 90 | 90 | struct auth_domain * ek_client; |
| 91 | − int ek_fsidtype; | |
| 91 | + u8 ek_fsidtype; | |
| 92 | 92 | u32 ek_fsid[6]; |
| 93 | 93 | |
| 94 | 94 | struct path ek_path; |
| @@ -372,7 +372,7 @@ nfsd_file_put(struct nfsd_file *nf) · 371 unmodified lines | ||
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * nfsd_file_put_local - put nfsd_file reference and arm nfsd_net_put in caller |
| 375 | − * @nf: nfsd_file of which to put the reference | |
| 375 | + * @pnf: nfsd_file of which to put the reference | |
| 376 | 376 | * |
| 377 | 377 | * First save the associated net to return to caller, then put |
| 378 | 378 | * the reference of the nfsd_file. |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | * @rpc_clnt: rpc_clnt that the client established |
| 33 | 33 | * @cred: cred that the client established |
| 34 | 34 | * @nfs_fh: filehandle to lookup |
| 35 | − * @nfp: place to find the nfsd_file, or store it if it was non-NULL | |
| 35 | + * @pnf: place to find the nfsd_file, or store it if it was non-NULL | |
| 36 | 36 | * @fmode: fmode_t to use for open |
| 37 | 37 | * |
| 38 | 38 | * This function maps a local fh to a path on a local filesystem. |
| @@ -561,7 +561,7 @@ static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, · 560 unmodified lines | ||
| 561 | 561 | buf->pages = rqstp->rq_next_page; |
| 562 | 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 | /* |
| @@ -65,7 +65,7 @@ nfsd4_alloc_devid_map(const struct svc_fh *fhp) · 64 unmodified lines | ||
| 65 | 65 | return; |
| 66 | 66 | |
| 67 | 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 | 70 | spin_lock(&nfsd_devid_lock); |
| 71 | 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 | 75 | list_for_each_entry(old, &nfsd_devid_hash[i], hash) { |
| 76 | 76 | if (old->fsid_type != fh->fh_fsid_type) |
| 77 | 77 | continue; |
| 78 | − if (memcmp(old->fsid, fh->fh_fsid, | |
| 78 | + if (memcmp(old->fsid, fh_fsid(fh), | |
| 79 | 79 | key_len(old->fsid_type))) |
| 80 | 80 | continue; |
| 81 | 81 | |
| @@ -1917,13 +1917,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, · 1916 unmodified lines | ||
| 1917 | 1917 | struct nfsd42_write_res *result; |
| 1918 | 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 | 1920 | result = ©->cp_res; |
| 1928 | 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 | 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 | 2839 | while (!status && resp->opcnt < args->opcnt) { |
| 2847 | 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 | 2843 | * The XDR decode routines may have pre-set op->status; |
| 2861 | 2844 | * for example, if there is a miscellaneous XDR error |
| @@ -2932,7 +2915,7 @@ encode_op: · 70 unmodified lines | ||
| 2932 | 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 | 2919 | status, nfsd4_op_name(op->opnum)); |
| 2937 | 2920 | |
| 2938 | 2921 | nfsd4_cstate_clear_replay(cstate); |
| @@ -633,18 +633,6 @@ find_readable_file(struct nfs4_file *f) · 632 unmodified lines | ||
| 633 | 633 | return ret; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | −static struct nfsd_file * | |
| 637 | −find_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 | − | |
| 648 | 636 | struct nfsd_file * |
| 649 | 637 | find_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 | |
| 1219 | 1207 | static void put_deleg_file(struct nfs4_file *fp) |
| 1220 | 1208 | { |
| 1209 | + struct nfsd_file *rnf = NULL; | |
| 1221 | 1210 | struct nfsd_file *nf = NULL; |
| 1222 | 1211 | |
| 1223 | 1212 | spin_lock(&fp->fi_lock); |
| 1224 | − if (--fp->fi_delegees == 0) | |
| 1213 | + if (--fp->fi_delegees == 0) { | |
| 1225 | 1214 | swap(nf, fp->fi_deleg_file); |
| 1215 | + swap(rnf, fp->fi_rdeleg_file); | |
| 1216 | + } | |
| 1226 | 1217 | spin_unlock(&fp->fi_lock); |
| 1227 | 1218 | |
| 1228 | 1219 | if (nf) |
| 1229 | 1220 | nfsd_file_put(nf); |
| 1221 | + if (rnf) | |
| 1222 | + nfs4_file_put_access(fp, NFS4_SHARE_ACCESS_READ); | |
| 1230 | 1223 | } |
| 1231 | 1224 | |
| 1232 | 1225 | static 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 | 3865 | ca->headerpadsz = 0; |
| 3873 | 3866 | ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc); |
| 3874 | 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 | 3868 | ca->maxresp_cached = min_t(u32, ca->maxresp_cached, |
| 3877 | 3869 | NFSD_SLOT_CACHE_SIZE + NFSD_MIN_HDR_SEQ_SZ); |
| 3878 | 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 | 4690 | status = nfs_ok; |
| 4699 | 4691 | if (conf) { |
| 4700 | − old = unconf; | |
| 4701 | − unhash_client_locked(old); | |
| 4702 | − nfsd4_change_callback(conf, &unconf->cl_cb_conn); | |
| 4703 | − } else { | |
| 4692 | + if (get_client_locked(conf) == nfs_ok) { | |
| 4693 | + old = unconf; | |
| 4694 | + unhash_client_locked(old); | |
| 4695 | + nfsd4_change_callback(conf, &unconf->cl_cb_conn); | |
| 4696 | + } else { | |
| 4697 | + conf = NULL; | |
| 4698 | + } | |
| 4699 | + } | |
| 4700 | + | |
| 4701 | + if (!conf) { | |
| 4704 | 4702 | old = find_confirmed_client_by_name(&unconf->cl_name, nn); |
| 4705 | 4703 | if (old) { |
| 4706 | 4704 | status = nfserr_clid_inuse; |
| @@ -4717,10 +4715,14 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, · 10 unmodified lines | ||
| 4717 | 4715 | } |
| 4718 | 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 | 4723 | move_to_confirmed(unconf); |
| 4721 | 4724 | conf = unconf; |
| 4722 | 4725 | } |
| 4723 | − get_client_locked(conf); | |
| 4724 | 4726 | spin_unlock(&nn->client_lock); |
| 4725 | 4727 | if (conf == unconf) |
| 4726 | 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 | 4752 | INIT_LIST_HEAD(&fp->fi_clnt_odstate); |
| 4751 | 4753 | fh_copy_shallow(&fp->fi_fhandle, &fh->fh_handle); |
| 4752 | 4754 | fp->fi_deleg_file = NULL; |
| 4755 | + fp->fi_rdeleg_file = NULL; | |
| 4753 | 4756 | fp->fi_had_conflict = false; |
| 4754 | 4757 | fp->fi_share_deny = 0; |
| 4755 | 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 | 6003 | * "An OPEN_DELEGATE_WRITE delegation allows the client to handle, |
| 6001 | 6004 | * on its own, all opens." |
| 6002 | 6005 | * |
| 6003 | − * Furthermore the client can use a write delegation for most READ | |
| 6004 | − * operations as well, so we require a O_RDWR file here. | |
| 6006 | + * Furthermore, section 9.1.2 says: | |
| 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 ensure | |
| 6007 | − * we get the O_RDWR descriptor. | |
| 6014 | + * We choose to offer a write delegation for OPEN with the | |
| 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) { | |
| 6010 | − nf = find_rw_file(fp); | |
| 6017 | + if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) { | |
| 6018 | + nf = find_writeable_file(fp); | |
| 6011 | 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 | ||
| 6138 | 6146 | nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, |
| 6139 | 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 | 6150 | struct path path; |
| 6143 | 6151 | int rc; |
| 6144 | 6152 | |
| @@ -6156,6 +6164,34 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, · 11 unmodified lines | ||
| 6156 | 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 | + */ | |
| 6173 | +static bool | |
| 6174 | +nfsd4_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 | 6196 | * The Linux NFS server does not offer write delegations to NFSv4.0 |
| 6161 | 6197 | * 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 | 6217 | * open or lock state. |
| 6182 | 6218 | */ |
| 6183 | 6219 | static void |
| 6184 | −nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, | |
| 6185 | − struct svc_fh *currentfh) | |
| 6220 | +nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open, | |
| 6221 | + struct nfs4_ol_stateid *stp, struct svc_fh *currentfh, | |
| 6222 | + struct svc_fh *fh) | |
| 6186 | 6223 | { |
| 6187 | 6224 | struct nfs4_openowner *oo = openowner(stp->st_stateowner); |
| 6188 | 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 | 6264 | memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); |
| 6228 | 6265 | |
| 6229 | 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 | 6269 | nfs4_put_stid(&dp->dl_stid); |
| 6232 | 6270 | destroy_delegation(dp); |
| 6233 | 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 | 6360 | status = nfs4_check_deleg(cl, open, &dp); |
| 6323 | 6361 | if (status) |
| 6324 | 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 | 6377 | stp = nfsd4_find_and_lock_existing_open(fp, open); |
| 6326 | 6378 | } else { |
| 6327 | 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 | 6435 | * Attempt to hand out a delegation. No error return, because the |
| 6384 | 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 | 6442 | * 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 | 7129 | return_revoked = true; |
| 7077 | 7130 | if (typemask & SC_TYPE_DELEG) |
| 7078 | 7131 | /* Always allow REVOKED for DELEG so we can |
| 7079 | − * retturn the appropriate error. | |
| 7132 | + * return the appropriate error. | |
| 7080 | 7133 | */ |
| 7081 | 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 | 7173 | switch (s->sc_type) { |
| 7121 | 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 | 7175 | case SC_TYPE_OPEN: |
| 7127 | 7176 | case SC_TYPE_LOCK: |
| 7128 | 7177 | if (flags & RD_STATE) |
| @@ -2500,10 +2500,8 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) · 2499 unmodified lines | ||
| 2500 | 2500 | |
| 2501 | 2501 | if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0) |
| 2502 | 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 | 2504 | return false; |
| 2505 | − argp->opcnt = min_t(u32, argp->client_opcnt, | |
| 2506 | − NFSD_MAX_OPS_PER_COMPOUND); | |
| 2507 | 2505 | |
| 2508 | 2506 | if (argp->opcnt > ARRAY_SIZE(argp->iops)) { |
| 2509 | 2507 | argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops)); |
| @@ -1436,7 +1436,7 @@ unsigned int nfsd_net_id; · 1435 unmodified lines | ||
| 1436 | 1436 | |
| 1437 | 1437 | static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb, |
| 1438 | 1438 | struct netlink_callback *cb, |
| 1439 | − struct nfsd_genl_rqstp *rqstp) | |
| 1439 | + struct nfsd_genl_rqstp *genl_rqstp) | |
| 1440 | 1440 | { |
| 1441 | 1441 | void *hdr; |
| 1442 | 1442 | u32 i; |
| @@ -1446,22 +1446,22 @@ static int nfsd_genl_rpc_status_compose_msg(struct sk_buff *skb, · 3 unmodified lines | ||
| 1446 | 1446 | if (!hdr) |
| 1447 | 1447 | return -ENOBUFS; |
| 1448 | 1448 | |
| 1449 | − if (nla_put_be32(skb, NFSD_A_RPC_STATUS_XID, rqstp->rq_xid) || | |
| 1450 | − nla_put_u32(skb, NFSD_A_RPC_STATUS_FLAGS, rqstp->rq_flags) || | |
| 1451 | − nla_put_u32(skb, NFSD_A_RPC_STATUS_PROG, rqstp->rq_prog) || | |
| 1452 | − nla_put_u32(skb, NFSD_A_RPC_STATUS_PROC, rqstp->rq_proc) || | |
| 1453 | − nla_put_u8(skb, NFSD_A_RPC_STATUS_VERSION, rqstp->rq_vers) || | |
| 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, genl_rqstp->rq_flags) || | |
| 1451 | + nla_put_u32(skb, NFSD_A_RPC_STATUS_PROG, genl_rqstp->rq_prog) || | |
| 1452 | + nla_put_u32(skb, NFSD_A_RPC_STATUS_PROC, genl_rqstp->rq_proc) || | |
| 1453 | + nla_put_u8(skb, NFSD_A_RPC_STATUS_VERSION, genl_rqstp->rq_vers) || | |
| 1454 | 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 | 1456 | NFSD_A_RPC_STATUS_PAD)) |
| 1457 | 1457 | return -ENOBUFS; |
| 1458 | 1458 | |
| 1459 | − switch (rqstp->rq_saddr.sa_family) { | |
| 1459 | + switch (genl_rqstp->rq_saddr.sa_family) { | |
| 1460 | 1460 | case AF_INET: { |
| 1461 | 1461 | const struct sockaddr_in *s_in, *d_in; |
| 1462 | 1462 | |
| 1463 | − s_in = (const struct sockaddr_in *)&rqstp->rq_saddr; | |
| 1464 | − d_in = (const struct sockaddr_in *)&rqstp->rq_daddr; | |
| 1463 | + s_in = (const struct sockaddr_in *)&genl_rqstp->rq_saddr; | |
| 1464 | + d_in = (const struct sockaddr_in *)&genl_rqstp->rq_daddr; | |
| 1465 | 1465 | if (nla_put_in_addr(skb, NFSD_A_RPC_STATUS_SADDR4, |
| 1466 | 1466 | s_in->sin_addr.s_addr) || |
| 1467 | 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 | 1476 | case AF_INET6: { |
| 1477 | 1477 | const struct sockaddr_in6 *s_in, *d_in; |
| 1478 | 1478 | |
| 1479 | − s_in = (const struct sockaddr_in6 *)&rqstp->rq_saddr; | |
| 1480 | − d_in = (const struct sockaddr_in6 *)&rqstp->rq_daddr; | |
| 1479 | + s_in = (const struct sockaddr_in6 *)&genl_rqstp->rq_saddr; | |
| 1480 | + d_in = (const struct sockaddr_in6 *)&genl_rqstp->rq_daddr; | |
| 1481 | 1481 | if (nla_put_in6_addr(skb, NFSD_A_RPC_STATUS_SADDR6, |
| 1482 | 1482 | &s_in->sin6_addr) || |
| 1483 | 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 | 1495 | if (nla_put_u32(skb, NFSD_A_RPC_STATUS_COMPOUND_OPS, |
| 1496 | − rqstp->rq_opnum[i])) | |
| 1496 | + genl_rqstp->rq_opnum[i])) | |
| 1497 | 1497 | return -ENOBUFS; |
| 1498 | 1498 | |
| 1499 | 1499 | genlmsg_end(skb, hdr); |
| @@ -1569,7 +1569,8 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb, · 69 unmodified lines | ||
| 1569 | 1569 | int j; |
| 1570 | 1570 | |
| 1571 | 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 | 1574 | for (j = 0; j < genl_rqstp.rq_opcnt; j++) |
| 1574 | 1575 | genl_rqstp.rq_opnum[j] = |
| 1575 | 1576 | args->ops[j].opnum; |
| @@ -57,9 +57,6 @@ struct readdir_cd { · 56 unmodified lines | ||
| 57 | 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 | − | |
| 63 | 60 | struct nfsd_genl_rqstp { |
| 64 | 61 | struct sockaddr rq_daddr; |
| 65 | 62 | struct sockaddr rq_saddr; |
| @@ -72,7 +69,7 @@ struct nfsd_genl_rqstp { · 6 unmodified lines | ||
| 72 | 69 | |
| 73 | 70 | /* NFSv4 compound */ |
| 74 | 71 | u32 rq_opcnt; |
| 75 | − u32 rq_opnum[NFSD_MAX_OPS_PER_COMPOUND]; | |
| 72 | + u32 rq_opnum[16]; | |
| 76 | 73 | }; |
| 77 | 74 | |
| 78 | 75 | extern struct svc_program nfsd_programs[]; |
| @@ -283,6 +280,7 @@ void nfsd_lockd_shutdown(void); · 204 unmodified lines | ||
| 283 | 280 | #define nfserr_cb_path_down cpu_to_be32(NFSERR_CB_PATH_DOWN) |
| 284 | 281 | #define nfserr_locked cpu_to_be32(NFSERR_LOCKED) |
| 285 | 282 | #define nfserr_wrongsec cpu_to_be32(NFSERR_WRONGSEC) |
| 283 | +#define nfserr_delay cpu_to_be32(NFS4ERR_DELAY) | |
| 286 | 284 | #define nfserr_badiomode cpu_to_be32(NFS4ERR_BADIOMODE) |
| 287 | 285 | #define nfserr_badlayout cpu_to_be32(NFS4ERR_BADLAYOUT) |
| 288 | 286 | #define nfserr_bad_session_digest cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST) |
| @@ -172,6 +172,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, · 171 unmodified lines | ||
| 172 | 172 | if (len == 0) |
| 173 | 173 | return error; |
| 174 | 174 | if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { |
| 175 | + u32 *fsid = fh_fsid(fh); | |
| 176 | + | |
| 175 | 177 | /* deprecated, convert to type 3 */ |
| 176 | 178 | len = key_len(FSID_ENCODE_DEV)/4; |
| 177 | 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 | 183 | * confuses sparse, so we must use __force here to |
| 182 | 184 | * keep it from complaining. |
| 183 | 185 | */ |
| 184 | − fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]), | |
| 185 | − ntohl((__force __be32)fh->fh_fsid[1]))); | |
| 186 | − fh->fh_fsid[1] = fh->fh_fsid[2]; | |
| 186 | + fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fsid[0]), | |
| 187 | + ntohl((__force __be32)fsid[1]))); | |
| 188 | + fsid[1] = fsid[2]; | |
| 187 | 189 | } |
| 188 | 190 | data_left -= len; |
| 189 | 191 | if (data_left < 0) |
| 190 | 192 | return error; |
| 191 | 193 | exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL, |
| 192 | 194 | net, client, gssclient, |
| 193 | − fh->fh_fsid_type, fh->fh_fsid); | |
| 194 | − fid = (struct fid *)(fh->fh_fsid + len); | |
| 195 | + fh->fh_fsid_type, fh_fsid(fh)); | |
| 196 | + fid = (struct fid *)(fh_fsid(fh) + len); | |
| 195 | 197 | |
| 196 | 198 | error = nfserr_stale; |
| 197 | 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 | 466 | if (dentry != exp->ex_path.dentry) { |
| 465 | 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 | 469 | int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; |
| 468 | 470 | int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : |
| 469 | 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 | 616 | fhp->fh_handle.fh_auth_type = 0; |
| 615 | 617 | |
| 616 | 618 | mk_fsid(fhp->fh_handle.fh_fsid_type, |
| 617 | − fhp->fh_handle.fh_fsid, | |
| 619 | + fh_fsid(&fhp->fh_handle), | |
| 618 | 620 | ex_dev, |
| 619 | 621 | d_inode(exp->ex_path.dentry)->i_ino, |
| 620 | 622 | exp->ex_fsid, exp->ex_uuid); |
| @@ -49,18 +49,19 @@ struct knfsd_fh { · 48 unmodified lines | ||
| 49 | 49 | * Points to the current size while |
| 50 | 50 | * building a new file handle. |
| 51 | 51 | */ |
| 52 | − union { | |
| 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 | − }; | |
| 52 | + u8 fh_raw[NFS4_FHSIZE]; | |
| 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 | + | |
| 60 | +static inline u32 *fh_fsid(const struct knfsd_fh *fh) | |
| 61 | +{ | |
| 62 | + return (u32 *)&fh->fh_raw[4]; | |
| 63 | +} | |
| 64 | + | |
| 64 | 65 | static inline __u32 ino_t_to_u32(ino_t ino) |
| 65 | 66 | { |
| 66 | 67 | return (__u32) ino; |
| @@ -260,9 +261,12 @@ static inline bool fh_match(const struct knfsd_fh *fh1, · 193 unmodified lines | ||
| 260 | 261 | static inline bool fh_fsid_match(const struct knfsd_fh *fh1, |
| 261 | 262 | const struct knfsd_fh *fh2) |
| 262 | 263 | { |
| 264 | + u32 *fsid1 = fh_fsid(fh1); | |
| 265 | + u32 *fsid2 = fh_fsid(fh2); | |
| 266 | + | |
| 263 | 267 | if (fh1->fh_fsid_type != fh2->fh_fsid_type) |
| 264 | 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 | 270 | return false; |
| 267 | 271 | return true; |
| 268 | 272 | } |
| @@ -575,7 +575,7 @@ static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp, · 574 unmodified lines | ||
| 575 | 575 | buf->pages = rqstp->rq_next_page; |
| 576 | 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 | /* |
| @@ -665,6 +665,7 @@ struct nfs4_file { · 664 unmodified lines | ||
| 665 | 665 | atomic_t fi_access[2]; |
| 666 | 666 | u32 fi_share_deny; |
| 667 | 667 | struct nfsd_file *fi_deleg_file; |
| 668 | + struct nfsd_file *fi_rdeleg_file; | |
| 668 | 669 | int fi_delegees; |
| 669 | 670 | struct knfsd_fh fi_fhandle; |
| 670 | 671 | bool fi_had_conflict; |
| @@ -344,7 +344,7 @@ TRACE_EVENT(nfsd_exp_find_key, · 343 unmodified lines | ||
| 344 | 344 | int status), |
| 345 | 345 | TP_ARGS(key, status), |
| 346 | 346 | TP_STRUCT__entry( |
| 347 | − __field(int, fsidtype) | |
| 347 | + __field(u8, fsidtype) | |
| 348 | 348 | __array(u32, fsid, 6) |
| 349 | 349 | __string(auth_domain, key->ek_client->name) |
| 350 | 350 | __field(int, status) |
| @@ -367,7 +367,7 @@ TRACE_EVENT(nfsd_expkey_update, · 16 unmodified lines | ||
| 367 | 367 | TP_PROTO(const struct svc_expkey *key, const char *exp_path), |
| 368 | 368 | TP_ARGS(key, exp_path), |
| 369 | 369 | TP_STRUCT__entry( |
| 370 | − __field(int, fsidtype) | |
| 370 | + __field(u8, fsidtype) | |
| 371 | 371 | __array(u32, fsid, 6) |
| 372 | 372 | __string(auth_domain, key->ek_client->name) |
| 373 | 373 | __string(path, exp_path) |
| @@ -1108,7 +1108,6 @@ DEFINE_NFSD_FILE_EVENT(nfsd_file_free); · 734 unmodified lines | ||
| 1108 | 1108 | DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash); |
| 1109 | 1109 | DEFINE_NFSD_FILE_EVENT(nfsd_file_put); |
| 1110 | 1110 | DEFINE_NFSD_FILE_EVENT(nfsd_file_closing); |
| 1111 | −DEFINE_NFSD_FILE_EVENT(nfsd_file_unhash_and_queue); | |
| 1112 | 1111 | |
| 1113 | 1112 | TRACE_EVENT(nfsd_file_alloc, |
| 1114 | 1113 | TP_PROTO( |
| @@ -1344,9 +1343,7 @@ DEFINE_EVENT(nfsd_file_gc_class, name, \ · 229 unmodified lines | ||
| 1344 | 1343 | TP_ARGS(nf)) |
| 1345 | 1344 | |
| 1346 | 1345 | DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add); |
| 1347 | −DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_add_disposed); | |
| 1348 | 1346 | DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del); |
| 1349 | −DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_lru_del_disposed); | |
| 1350 | 1347 | DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_in_use); |
| 1351 | 1348 | DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_writeback); |
| 1352 | 1349 | DEFINE_NFSD_FILE_GC_EVENT(nfsd_file_gc_referenced); |
| @@ -1380,7 +1377,6 @@ DEFINE_EVENT(nfsd_file_lruwalk_class, name, \ · 27 unmodified lines | ||
| 1380 | 1377 | TP_ARGS(removed, remaining)) |
| 1381 | 1378 | |
| 1382 | 1379 | DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed); |
| 1383 | −DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_recent); | |
| 1384 | 1380 | DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed); |
| 1385 | 1381 | |
| 1386 | 1382 | TRACE_EVENT(nfsd_file_close, |
| @@ -2103,25 +2099,6 @@ TRACE_EVENT(nfsd_ctl_maxblksize, · 716 unmodified lines | ||
| 2103 | 2099 | ) |
| 2104 | 2100 | ); |
| 2105 | 2101 | |
| 2106 | −TRACE_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 | − | |
| 2125 | 2102 | TRACE_EVENT(nfsd_ctl_time, |
| 2126 | 2103 | TP_PROTO( |
| 2127 | 2104 | const struct net *net, |
| @@ -1086,10 +1086,13 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp, · 1085 unmodified lines | ||
| 1086 | 1086 | { |
| 1087 | 1087 | unsigned long v, total; |
| 1088 | 1088 | struct iov_iter iter; |
| 1089 | − loff_t ppos = offset; | |
| 1089 | + struct kiocb kiocb; | |
| 1090 | 1090 | ssize_t host_err; |
| 1091 | 1091 | size_t len; |
| 1092 | 1092 | |
| 1093 | + init_sync_kiocb(&kiocb, file); | |
| 1094 | + kiocb.ki_pos = offset; | |
| 1095 | + | |
| 1093 | 1096 | v = 0; |
| 1094 | 1097 | total = *count; |
| 1095 | 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 | 1108 | trace_nfsd_read_vector(rqstp, fhp, offset, *count); |
| 1106 | 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 | 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 | 1173 | struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); |
| 1171 | 1174 | struct file *file = nf->nf_file; |
| 1172 | 1175 | struct super_block *sb = file_inode(file)->i_sb; |
| 1176 | + struct kiocb kiocb; | |
| 1173 | 1177 | struct svc_export *exp; |
| 1174 | 1178 | struct iov_iter iter; |
| 1175 | 1179 | errseq_t since; |
| 1176 | 1180 | __be32 nfserr; |
| 1177 | 1181 | int host_err; |
| 1178 | − loff_t pos = offset; | |
| 1179 | 1182 | unsigned long exp_op_flags = 0; |
| 1180 | 1183 | unsigned int pflags = current->flags; |
| 1181 | − rwf_t flags = 0; | |
| 1182 | 1184 | bool restore_flags = false; |
| 1183 | 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 | 1207 | if (!EX_ISSYNC(exp)) |
| 1206 | 1208 | stable = NFS_UNSTABLE; |
| 1207 | − | |
| 1209 | + init_sync_kiocb(&kiocb, file); | |
| 1210 | + kiocb.ki_pos = offset; | |
| 1208 | 1211 | if (stable && !fhp->fh_use_wgather) |
| 1209 | − flags |= RWF_SYNC; | |
| 1212 | + kiocb.ki_flags |= IOCB_DSYNC; | |
| 1210 | 1213 | |
| 1211 | 1214 | nvecs = xdr_buf_to_bvec(rqstp->rq_bvec, rqstp->rq_maxpages, payload); |
| 1212 | 1215 | iov_iter_bvec(&iter, ITER_SOURCE, rqstp->rq_bvec, nvecs, *cnt); |
| 1213 | 1216 | since = READ_ONCE(file->f_wb_err); |
| 1214 | 1217 | if (verf) |
| 1215 | 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 | 1220 | if (host_err < 0) { |
| 1218 | 1221 | commit_reset_write_verifier(nn, rqstp, host_err); |
| 1219 | 1222 | goto out_nfserr; |
| @@ -870,7 +870,6 @@ struct nfsd4_compoundargs { · 869 unmodified lines | ||
| 870 | 870 | char * tag; |
| 871 | 871 | u32 taglen; |
| 872 | 872 | u32 minorversion; |
| 873 | − u32 client_opcnt; | |
| 874 | 873 | u32 opcnt; |
| 875 | 874 | bool splice_ok; |
| 876 | 875 | struct nfsd4_op *ops; |
| @@ -69,15 +69,17 @@ enum rpc_reject_stat { · 68 unmodified lines | ||
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | 71 | enum rpc_auth_stat { |
| 72 | − RPC_AUTH_OK = 0, | |
| 73 | − RPC_AUTH_BADCRED = 1, | |
| 74 | − RPC_AUTH_REJECTEDCRED = 2, | |
| 75 | − RPC_AUTH_BADVERF = 3, | |
| 76 | − RPC_AUTH_REJECTEDVERF = 4, | |
| 77 | − RPC_AUTH_TOOWEAK = 5, | |
| 72 | + RPC_AUTH_OK = 0, /* success */ | |
| 73 | + RPC_AUTH_BADCRED = 1, /* bad credential (seal broken) */ | |
| 74 | + RPC_AUTH_REJECTEDCRED = 2, /* client must begin new session */ | |
| 75 | + RPC_AUTH_BADVERF = 3, /* bad verifier (seal broken) */ | |
| 76 | + RPC_AUTH_REJECTEDVERF = 4, /* verifier expired or replayed */ | |
| 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 | 80 | /* RPCSEC_GSS errors */ |
| 79 | − RPCSEC_GSS_CREDPROBLEM = 13, | |
| 80 | − RPCSEC_GSS_CTXPROBLEM = 14 | |
| 81 | + RPCSEC_GSS_CREDPROBLEM = 13, /* no credentials for user */ | |
| 82 | + RPCSEC_GSS_CTXPROBLEM = 14 /* problem with context */ | |
| 81 | 83 | }; |
| 82 | 84 | |
| 83 | 85 | #define RPC_MAXNETNAMELEN 256 |
| @@ -245,10 +245,10 @@ struct svc_rqst { · 244 unmodified lines | ||
| 245 | 245 | * initialisation success. |
| 246 | 246 | */ |
| 247 | 247 | |
| 248 | − unsigned long bc_to_initval; | |
| 249 | − unsigned int bc_to_retries; | |
| 250 | − void ** rq_lease_breaker; /* The v4 client breaking a lease */ | |
| 248 | + unsigned long bc_to_initval; | |
| 249 | + unsigned int bc_to_retries; | |
| 251 | 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 | 254 | /* bits for rq_flags */ |
| @@ -86,7 +86,6 @@ struct auth_domain { · 85 unmodified lines | ||
| 86 | 86 | |
| 87 | 87 | enum svc_auth_status { |
| 88 | 88 | SVC_GARBAGE = 1, |
| 89 | − SVC_SYSERR, | |
| 90 | 89 | SVC_VALID, |
| 91 | 90 | SVC_NEGATIVE, |
| 92 | 91 | SVC_OK, |
| @@ -119,6 +119,8 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 118 unmodified lines | ||
| 119 | 119 | #define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF) |
| 120 | 120 | #define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF) |
| 121 | 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 | 124 | #define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM) |
| 123 | 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 | |
| 243 | 245 | extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, |
| 244 | 246 | __be32 *p, struct rpc_rqst *rqst); |
| 245 | −extern void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 246 | − struct page **pages, struct rpc_rqst *rqst); | |
| 247 | +void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf); | |
| 247 | 248 | extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); |
| 248 | 249 | extern int xdr_reserve_space_vec(struct xdr_stream *xdr, size_t nbytes); |
| 249 | 250 | extern void __xdr_commit_encode(struct xdr_stream *xdr); |
| @@ -1691,7 +1691,6 @@ SVC_RQST_FLAG_LIST · 1690 unmodified lines | ||
| 1691 | 1691 | __print_flags(flags, "|", SVC_RQST_FLAG_LIST) |
| 1692 | 1692 | |
| 1693 | 1693 | TRACE_DEFINE_ENUM(SVC_GARBAGE); |
| 1694 | −TRACE_DEFINE_ENUM(SVC_SYSERR); | |
| 1695 | 1694 | TRACE_DEFINE_ENUM(SVC_VALID); |
| 1696 | 1695 | TRACE_DEFINE_ENUM(SVC_NEGATIVE); |
| 1697 | 1696 | TRACE_DEFINE_ENUM(SVC_OK); |
| @@ -1704,7 +1703,6 @@ TRACE_DEFINE_ENUM(SVC_COMPLETE); · 6 unmodified lines | ||
| 1704 | 1703 | #define show_svc_auth_status(status) \ |
| 1705 | 1704 | __print_symbolic(status, \ |
| 1706 | 1705 | { SVC_GARBAGE, "SVC_GARBAGE" }, \ |
| 1707 | − { SVC_SYSERR, "SVC_SYSERR" }, \ | |
| 1708 | 1706 | { SVC_VALID, "SVC_VALID" }, \ |
| 1709 | 1707 | { SVC_NEGATIVE, "SVC_NEGATIVE" }, \ |
| 1710 | 1708 | { SVC_OK, "SVC_OK" }, \ |
| @@ -2123,22 +2121,35 @@ TRACE_EVENT(svc_xprt_accept, · 412 unmodified lines | ||
| 2123 | 2121 | ) |
| 2124 | 2122 | ); |
| 2125 | 2123 | |
| 2126 | −TRACE_EVENT(svc_wake_up, | |
| 2127 | − TP_PROTO(int pid), | |
| 2124 | +DECLARE_EVENT_CLASS(svc_pool_thread_event, | |
| 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 | 2129 | TP_STRUCT__entry( |
| 2132 | − __field(int, pid) | |
| 2130 | + __field(unsigned int, pool_id) | |
| 2131 | + __field(pid_t, pid) | |
| 2133 | 2132 | ), |
| 2134 | 2133 | |
| 2135 | 2134 | TP_fast_assign( |
| 2135 | + __entry->pool_id = pool->sp_id; | |
| 2136 | 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 | + | |
| 2149 | +DEFINE_SVC_POOL_THREAD_EVENT(wake); | |
| 2150 | +DEFINE_SVC_POOL_THREAD_EVENT(running); | |
| 2151 | +DEFINE_SVC_POOL_THREAD_EVENT(noidle); | |
| 2152 | + | |
| 2142 | 2153 | TRACE_EVENT(svc_alloc_arg_err, |
| 2143 | 2154 | TP_PROTO( |
| 2144 | 2155 | unsigned int requested, |
| @@ -1628,7 +1628,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp) · 1627 unmodified lines | ||
| 1628 | 1628 | int ret; |
| 1629 | 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 | 1632 | if (!svcdata) |
| 1633 | 1633 | svcdata = kmalloc(sizeof(*svcdata), GFP_KERNEL); |
| 1634 | 1634 | if (!svcdata) |
| @@ -1638,6 +1638,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp) · 3 unmodified lines | ||
| 1638 | 1638 | svcdata->rsci = NULL; |
| 1639 | 1639 | gc = &svcdata->clcred; |
| 1640 | 1640 | |
| 1641 | + rqstp->rq_auth_stat = rpc_autherr_badcred; | |
| 1641 | 1642 | if (!svcauth_gss_decode_credbody(&rqstp->rq_arg_stream, gc, &rpcstart)) |
| 1642 | 1643 | goto auth_err; |
| 1643 | 1644 | if (gc->gc_v != RPC_GSS_VERSION) |
| @@ -27,97 +27,60 @@ · 26 unmodified lines | ||
| 27 | 27 | struct xdr_skb_reader { |
| 28 | 28 | struct sk_buff *skb; |
| 29 | 29 | unsigned int offset; |
| 30 | + bool need_checksum; | |
| 30 | 31 | size_t count; |
| 31 | 32 | __wsum csum; |
| 32 | 33 | }; |
| 33 | 34 | |
| 34 | −typedef size_t (*xdr_skb_read_actor)(struct xdr_skb_reader *desc, void *to, | |
| 35 | − size_t len); | |
| 36 | − | |
| 37 | 35 | /** |
| 38 | 36 | * xdr_skb_read_bits - copy some data bits from skb to internal buffer |
| 39 | 37 | * @desc: sk_buff copy helper |
| 40 | 38 | * @to: copy destination |
| 41 | 39 | * @len: number of bytes to copy |
| 42 | 40 | * |
| 43 | − * Possibly called several times to iterate over an sk_buff and copy | |
| 44 | − * data out of it. | |
| 41 | + * Possibly called several times to iterate over an sk_buff and copy data out of | |
| 42 | + * it. | |
| 45 | 43 | */ |
| 46 | 44 | static size_t |
| 47 | 45 | xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len) |
| 48 | 46 | { |
| 49 | − if (len > desc->count) | |
| 50 | − len = desc->count; | |
| 51 | − if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len))) | |
| 52 | − return 0; | |
| 53 | − desc->count -= len; | |
| 54 | − desc->offset += len; | |
| 55 | − return len; | |
| 56 | −} | |
| 47 | + len = min(len, desc->count); | |
| 48 | + | |
| 49 | + if (desc->need_checksum) { | |
| 50 | + __wsum csum; | |
| 51 | + | |
| 52 | + csum = skb_copy_and_csum_bits(desc->skb, desc->offset, to, len); | |
| 53 | + desc->csum = csum_block_add(desc->csum, csum, desc->offset); | |
| 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 | − */ | |
| 66 | −static 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 | 59 | desc->count -= len; |
| 77 | 60 | desc->offset += len; |
| 78 | 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 | − */ | |
| 89 | 64 | static ssize_t |
| 90 | −xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, struct xdr_skb_reader *desc, xdr_skb_read_actor copy_actor) | |
| 65 | +xdr_partial_copy_from_skb(struct xdr_buf *xdr, struct xdr_skb_reader *desc) | |
| 91 | 66 | { |
| 92 | − struct page **ppage = xdr->pages; | |
| 93 | − unsigned int len, pglen = xdr->page_len; | |
| 94 | − ssize_t copied = 0; | |
| 95 | − size_t ret; | |
| 96 | − | |
| 97 | − len = xdr->head[0].iov_len; | |
| 98 | − if (base < len) { | |
| 99 | − len -= base; | |
| 100 | − ret = copy_actor(desc, (char *)xdr->head[0].iov_base + base, len); | |
| 101 | − copied += ret; | |
| 102 | − if (ret != len || !desc->count) | |
| 103 | − goto out; | |
| 104 | − base = 0; | |
| 105 | − } else | |
| 106 | − base -= len; | |
| 107 | − | |
| 108 | − if (unlikely(pglen == 0)) | |
| 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 { | |
| 67 | + struct page **ppage = xdr->pages + (xdr->page_base >> PAGE_SHIFT); | |
| 68 | + unsigned int poff = xdr->page_base & ~PAGE_MASK; | |
| 69 | + unsigned int pglen = xdr->page_len; | |
| 70 | + ssize_t copied = 0; | |
| 71 | + size_t ret; | |
| 72 | + | |
| 73 | + if (xdr->head[0].iov_len == 0) | |
| 74 | + return 0; | |
| 75 | + | |
| 76 | + ret = xdr_skb_read_bits(desc, xdr->head[0].iov_base, | |
| 77 | + xdr->head[0].iov_len); | |
| 78 | + if (ret != xdr->head[0].iov_len || !desc->count) | |
| 79 | + return ret; | |
| 80 | + copied += ret; | |
| 81 | + | |
| 82 | + while (pglen) { | |
| 83 | + unsigned int len = min(PAGE_SIZE - poff, pglen); | |
| 121 | 84 | char *kaddr; |
| 122 | 85 | |
| 123 | 86 | /* 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 | 89 | *ppage = alloc_page(GFP_NOWAIT | __GFP_NOWARN); |
| 127 | 90 | if (unlikely(*ppage == NULL)) { |
| 128 | 91 | if (copied == 0) |
| 129 | − copied = -ENOMEM; | |
| 130 | − goto out; | |
| 92 | + return -ENOMEM; | |
| 93 | + return copied; | |
| 131 | 94 | } |
| 132 | 95 | } |
| 133 | 96 | |
| 134 | − len = PAGE_SIZE; | |
| 135 | 97 | kaddr = kmap_atomic(*ppage); |
| 136 | − if (base) { | |
| 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 | − } | |
| 98 | + ret = xdr_skb_read_bits(desc, kaddr + poff, len); | |
| 147 | 99 | flush_dcache_page(*ppage); |
| 148 | 100 | kunmap_atomic(kaddr); |
| 101 | + | |
| 149 | 102 | copied += ret; |
| 150 | 103 | if (ret != len || !desc->count) |
| 151 | − goto out; | |
| 104 | + return copied; | |
| 152 | 105 | ppage++; |
| 153 | − } while ((pglen -= len) != 0); | |
| 154 | −copy_tail: | |
| 155 | − len = xdr->tail[0].iov_len; | |
| 156 | − if (base < len) | |
| 157 | − copied += copy_actor(desc, (char *)xdr->tail[0].iov_base + base, len - base); | |
| 158 | −out: | |
| 106 | + pglen -= len; | |
| 107 | + poff = 0; | |
| 108 | + } | |
| 109 | + | |
| 110 | + if (xdr->tail[0].iov_len) { | |
| 111 | + copied += xdr_skb_read_bits(desc, xdr->tail[0].iov_base, | |
| 112 | + xdr->tail[0].iov_len); | |
| 113 | + } | |
| 114 | + | |
| 159 | 115 | return copied; |
| 160 | 116 | } |
| 161 | 117 | |
| @@ -169,17 +125,22 @@ out: · 7 unmodified lines | ||
| 169 | 125 | */ |
| 170 | 126 | int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb) |
| 171 | 127 | { |
| 172 | − struct xdr_skb_reader desc; | |
| 173 | − | |
| 174 | − desc.skb = skb; | |
| 175 | − desc.offset = 0; | |
| 176 | − desc.count = skb->len - desc.offset; | |
| 128 | + struct xdr_skb_reader desc = { | |
| 129 | + .skb = skb, | |
| 130 | + .count = skb->len - desc.offset, | |
| 131 | + }; | |
| 177 | 132 | |
| 178 | − if (skb_csum_unnecessary(skb)) | |
| 179 | − goto no_checksum; | |
| 133 | + if (skb_csum_unnecessary(skb)) { | |
| 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 | 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 | 144 | return -1; |
| 184 | 145 | if (desc.offset != skb->len) { |
| 185 | 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 | 155 | !skb->csum_complete_sw) |
| 195 | 156 | netdev_rx_csum_fault(skb->dev, skb); |
| 196 | 157 | return 0; |
| 197 | −no_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 | } |
| 204 | −EXPORT_SYMBOL_GPL(csum_partial_copy_to_xdr); | |
| 205 | 159 | |
| 206 | 160 | static inline int xprt_sendmsg(struct socket *sock, struct msghdr *msg, |
| 207 | 161 | size_t seek) |
| @@ -751,14 +751,16 @@ void svc_pool_wake_idle_thread(struct svc_pool *pool) · 750 unmodified lines | ||
| 751 | 751 | WRITE_ONCE(rqstp->rq_qtime, ktime_get()); |
| 752 | 752 | if (!task_is_running(rqstp->rq_task)) { |
| 753 | 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 | 755 | percpu_counter_inc(&pool->sp_threads_woken); |
| 756 | + } else { | |
| 757 | + trace_svc_pool_thread_running(pool, rqstp->rq_task->pid); | |
| 756 | 758 | } |
| 757 | 759 | rcu_read_unlock(); |
| 758 | 760 | return; |
| 759 | 761 | } |
| 760 | 762 | rcu_read_unlock(); |
| 761 | − | |
| 763 | + trace_svc_pool_thread_noidle(pool, 0); | |
| 762 | 764 | } |
| 763 | 765 | EXPORT_SYMBOL_GPL(svc_pool_wake_idle_thread); |
| 764 | 766 | |
| @@ -1332,6 +1334,9 @@ svc_process_common(struct svc_rqst *rqstp) · 567 unmodified lines | ||
| 1332 | 1334 | int pr, rc; |
| 1333 | 1335 | __be32 *p; |
| 1334 | 1336 | |
| 1337 | + /* Reset the accept_stat for the RPC */ | |
| 1338 | + rqstp->rq_accept_statp = NULL; | |
| 1339 | + | |
| 1335 | 1340 | /* Will be turned off only when NFSv4 Sessions are used */ |
| 1336 | 1341 | set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); |
| 1337 | 1342 | clear_bit(RQ_DROPME, &rqstp->rq_flags); |
| @@ -1373,8 +1378,6 @@ svc_process_common(struct svc_rqst *rqstp) · 35 unmodified lines | ||
| 1373 | 1378 | case SVC_GARBAGE: |
| 1374 | 1379 | rqstp->rq_auth_stat = rpc_autherr_badcred; |
| 1375 | 1380 | goto err_bad_auth; |
| 1376 | − case SVC_SYSERR: | |
| 1377 | − goto err_system_err; | |
| 1378 | 1381 | case SVC_DENIED: |
| 1379 | 1382 | goto err_bad_auth; |
| 1380 | 1383 | case SVC_CLOSE: |
| @@ -1385,7 +1388,8 @@ svc_process_common(struct svc_rqst *rqstp) · 4 unmodified lines | ||
| 1385 | 1388 | goto sendit; |
| 1386 | 1389 | default: |
| 1387 | 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 | 1395 | if (progp == NULL) |
| @@ -1512,12 +1516,6 @@ err_bad_proc: · 120 unmodified lines | ||
| 1512 | 1516 | serv->sv_stats->rpcbadfmt++; |
| 1513 | 1517 | *rqstp->rq_accept_statp = rpc_proc_unavail; |
| 1514 | 1518 | goto sendit; |
| 1515 | − | |
| 1516 | −err_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 | /* |
| @@ -1197,7 +1197,7 @@ err_noclose: · 1196 unmodified lines | ||
| 1197 | 1197 | * that the pages backing @xdr are unchanging. |
| 1198 | 1198 | */ |
| 1199 | 1199 | static 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 | 1202 | struct msghdr msg = { |
| 1203 | 1203 | .msg_flags = MSG_SPLICE_PAGES, |
| @@ -1247,8 +1247,7 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp) · 43 unmodified lines | ||
| 1247 | 1247 | struct xdr_buf *xdr = &rqstp->rq_res; |
| 1248 | 1248 | rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | |
| 1249 | 1249 | (u32)xdr->len); |
| 1250 | − unsigned int sent; | |
| 1251 | − int err; | |
| 1250 | + int sent, err; | |
| 1252 | 1251 | |
| 1253 | 1252 | svc_tcp_release_ctxt(xprt, rqstp->rq_xprt_ctxt); |
| 1254 | 1253 | rqstp->rq_xprt_ctxt = NULL; |
| @@ -993,21 +993,18 @@ EXPORT_SYMBOL_GPL(xdr_init_encode); · 992 unmodified lines | ||
| 993 | 993 | * xdr_init_encode_pages - Initialize an xdr_stream for encoding into pages |
| 994 | 994 | * @xdr: pointer to xdr_stream struct |
| 995 | 995 | * @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 | */ |
| 1000 | −void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 1001 | − struct page **pages, struct rpc_rqst *rqst) | |
| 998 | +void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf) | |
| 1002 | 999 | { |
| 1003 | 1000 | xdr_reset_scratch_buffer(xdr); |
| 1004 | 1001 | |
| 1005 | 1002 | xdr->buf = buf; |
| 1006 | − xdr->page_ptr = pages; | |
| 1003 | + xdr->page_ptr = buf->pages; | |
| 1007 | 1004 | xdr->iov = NULL; |
| 1008 | − xdr->p = page_address(*pages); | |
| 1005 | + xdr->p = page_address(*xdr->page_ptr); | |
| 1009 | 1006 | xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); |
| 1010 | − xdr->rqst = rqst; | |
| 1007 | + xdr->rqst = NULL; | |
| 1011 | 1008 | } |
| 1012 | 1009 | EXPORT_SYMBOL_GPL(xdr_init_encode_pages); |
| 1013 | 1010 | |