Pull NFS client updates from Trond Myklebust: "Highlights include: Stable fixes: - Fixes for NFS I/O request leakages - Fix error handling paths in the NFS I/O recoalescing code - Reinitialise NFSv4.1 sequence results before retransmitting a request - Fix a soft lockup in the delegation recovery code - Bulk destroy of layouts needs to be safe w.r.t. umount - Prevent thundering herd issues when the SUNRPC socket is not connected - Respect RPC call timeouts when retrying transmission Features: - Convert rpc auth layer to use xdr_streams - Config option to disable insecure RPCSEC_GSS crypto types - Reduce size of RPC receive buffers - Readdirplus optimization by cache mechanism - Convert SUNRPC socket send code to use iov_iter() - SUNRPC micro-optimisations to avoid indirect calls - Add support for the pNFS LAYOUTERROR operation and use it with the pNFS/flexfiles driver - Add trace events to report non-zero NFS status codes - Various removals of unnecessary dprintks Bugfixes and cleanups: - Fix a number of sparse warnings and documentation format warnings - Fix nfs_parse_devname to not modify it's argument - Fix potential corruption of page being written through pNFS/blocks - fix xfstest generic/099 failures on nfsv3 - Avoid NFSv4.1 "false retries" when RPC calls are interrupted - Abort I/O early if the pNFS/flexfiles layout segment was invalidated - Avoid unnecessary pNFS/flexfiles layout invalidations" * tag 'nfs-for-5.1-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (90 commits) SUNRPC: Take the transport send lock before binding+connecting SUNRPC: Micro-optimise when the task is known not to be sleeping SUNRPC: Check whether the task was transmitted before rebind/reconnect SUNRPC: Remove redundant calls to RPC_IS_QUEUED() SUNRPC: Clean up SUNRPC: Respect RPC call timeouts when retrying transmission SUNRPC: Fix up RPC back channel transmission SUNRPC: Prevent thundering herd when the socket is not connected SUNRPC: Allow dynamic allocation of back channel slots NFSv4.1: Bump the default callback session slot count to 16 SUNRPC: Convert remaining GFP_NOIO, and GFP_NOWAIT sites in sunrpc NFS/flexfiles: Clean up mirror DS initialisation NFS/flexfiles: Remove dead code in ff_layout_mirror_valid() NFS/flexfile: Simplify nfs4_ff_layout_select_ds_stateid() NFS/flexfile: Simplify nfs4_ff_layout_ds_version() NFS/flexfiles: Simplify ff_layout_get_ds_cred() NFS/flexfiles: Simplify nfs4_ff_find_or_create_ds_client() NFS/flexfiles: Simplify nfs4_ff_layout_select_ds_fh() NFS/flexfiles: Speed up read failover when DSes are down NFS/flexfiles: Don't invalidate DS deviceids for being unresponsive ...
Unified · Split
| @@ -74,17 +74,6 @@ static void nlm4_compute_offsets(const struct nlm_lock *lock, · 73 unmodified lines | ||
| 74 | 74 | *l_len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | −/* | |
| 78 | − * Handle decode buffer overflows out-of-line. | |
| 79 | − */ | |
| 80 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 81 | −{ | |
| 82 | − dprintk("lockd: %s prematurely hit the end of our receive buffer. " | |
| 83 | − "Remaining buffer length is %tu words.\n", | |
| 84 | − func, xdr->end - xdr->p); | |
| 85 | −} | |
| 86 | − | |
| 87 | − | |
| 88 | 77 | /* |
| 89 | 78 | * Encode/decode NLMv4 basic data types |
| 90 | 79 | * |
| @@ -176,7 +165,6 @@ out_size: · 85 unmodified lines | ||
| 176 | 165 | dprintk("NFS: returned cookie was too long: %u\n", length); |
| 177 | 166 | return -EIO; |
| 178 | 167 | out_overflow: |
| 179 | − print_overflow_msg(__func__, xdr); | |
| 180 | 168 | return -EIO; |
| 181 | 169 | } |
| 182 | 170 | |
| @@ -236,7 +224,6 @@ out_bad_xdr: · 53 unmodified lines | ||
| 236 | 224 | __func__, be32_to_cpup(p)); |
| 237 | 225 | return -EIO; |
| 238 | 226 | out_overflow: |
| 239 | − print_overflow_msg(__func__, xdr); | |
| 240 | 227 | return -EIO; |
| 241 | 228 | } |
| 242 | 229 | |
| @@ -309,7 +296,6 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) · 66 unmodified lines | ||
| 309 | 296 | out: |
| 310 | 297 | return error; |
| 311 | 298 | out_overflow: |
| 312 | − print_overflow_msg(__func__, xdr); | |
| 313 | 299 | return -EIO; |
| 314 | 300 | } |
| 315 | 301 | |
| @@ -70,17 +70,6 @@ static void nlm_compute_offsets(const struct nlm_lock *lock, · 69 unmodified lines | ||
| 70 | 70 | *l_len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | −/* | |
| 74 | − * Handle decode buffer overflows out-of-line. | |
| 75 | − */ | |
| 76 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 77 | −{ | |
| 78 | − dprintk("lockd: %s prematurely hit the end of our receive buffer. " | |
| 79 | − "Remaining buffer length is %tu words.\n", | |
| 80 | − func, xdr->end - xdr->p); | |
| 81 | −} | |
| 82 | − | |
| 83 | − | |
| 84 | 73 | /* |
| 85 | 74 | * Encode/decode NLMv3 basic data types |
| 86 | 75 | * |
| @@ -173,7 +162,6 @@ out_size: · 86 unmodified lines | ||
| 173 | 162 | dprintk("NFS: returned cookie was too long: %u\n", length); |
| 174 | 163 | return -EIO; |
| 175 | 164 | out_overflow: |
| 176 | − print_overflow_msg(__func__, xdr); | |
| 177 | 165 | return -EIO; |
| 178 | 166 | } |
| 179 | 167 | |
| @@ -231,7 +219,6 @@ out_enum: · 51 unmodified lines | ||
| 231 | 219 | __func__, be32_to_cpup(p)); |
| 232 | 220 | return -EIO; |
| 233 | 221 | out_overflow: |
| 234 | − print_overflow_msg(__func__, xdr); | |
| 235 | 222 | return -EIO; |
| 236 | 223 | } |
| 237 | 224 | |
| @@ -303,7 +290,6 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) · 65 unmodified lines | ||
| 303 | 290 | out: |
| 304 | 291 | return error; |
| 305 | 292 | out_overflow: |
| 306 | − print_overflow_msg(__func__, xdr); | |
| 307 | 293 | return -EIO; |
| 308 | 294 | } |
| 309 | 295 | |
| @@ -72,16 +72,6 @@ static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p) · 71 unmodified lines | ||
| 72 | 72 | return xdr_ressize_check(rqstp, p); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | −static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes) | |
| 76 | −{ | |
| 77 | − __be32 *p; | |
| 78 | − | |
| 79 | − p = xdr_inline_decode(xdr, nbytes); | |
| 80 | − if (unlikely(p == NULL)) | |
| 81 | − printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n"); | |
| 82 | − return p; | |
| 83 | −} | |
| 84 | − | |
| 85 | 75 | static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, |
| 86 | 76 | const char **str, size_t maxlen) |
| 87 | 77 | { |
| @@ -98,13 +88,13 @@ static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh) · 10 unmodified lines | ||
| 98 | 88 | { |
| 99 | 89 | __be32 *p; |
| 100 | 90 | |
| 101 | − p = read_buf(xdr, 4); | |
| 91 | + p = xdr_inline_decode(xdr, 4); | |
| 102 | 92 | if (unlikely(p == NULL)) |
| 103 | 93 | return htonl(NFS4ERR_RESOURCE); |
| 104 | 94 | fh->size = ntohl(*p); |
| 105 | 95 | if (fh->size > NFS4_FHSIZE) |
| 106 | 96 | return htonl(NFS4ERR_BADHANDLE); |
| 107 | − p = read_buf(xdr, fh->size); | |
| 97 | + p = xdr_inline_decode(xdr, fh->size); | |
| 108 | 98 | if (unlikely(p == NULL)) |
| 109 | 99 | return htonl(NFS4ERR_RESOURCE); |
| 110 | 100 | memcpy(&fh->data[0], p, fh->size); |
| @@ -117,11 +107,11 @@ static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) · 6 unmodified lines | ||
| 117 | 107 | __be32 *p; |
| 118 | 108 | unsigned int attrlen; |
| 119 | 109 | |
| 120 | − p = read_buf(xdr, 4); | |
| 110 | + p = xdr_inline_decode(xdr, 4); | |
| 121 | 111 | if (unlikely(p == NULL)) |
| 122 | 112 | return htonl(NFS4ERR_RESOURCE); |
| 123 | 113 | attrlen = ntohl(*p); |
| 124 | − p = read_buf(xdr, attrlen << 2); | |
| 114 | + p = xdr_inline_decode(xdr, attrlen << 2); | |
| 125 | 115 | if (unlikely(p == NULL)) |
| 126 | 116 | return htonl(NFS4ERR_RESOURCE); |
| 127 | 117 | if (likely(attrlen > 0)) |
| @@ -135,7 +125,7 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) · 7 unmodified lines | ||
| 135 | 125 | { |
| 136 | 126 | __be32 *p; |
| 137 | 127 | |
| 138 | − p = read_buf(xdr, NFS4_STATEID_SIZE); | |
| 128 | + p = xdr_inline_decode(xdr, NFS4_STATEID_SIZE); | |
| 139 | 129 | if (unlikely(p == NULL)) |
| 140 | 130 | return htonl(NFS4ERR_RESOURCE); |
| 141 | 131 | memcpy(stateid->data, p, NFS4_STATEID_SIZE); |
| @@ -156,7 +146,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · 14 unmodified lines | ||
| 156 | 146 | status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ); |
| 157 | 147 | if (unlikely(status != 0)) |
| 158 | 148 | return status; |
| 159 | − p = read_buf(xdr, 12); | |
| 149 | + p = xdr_inline_decode(xdr, 12); | |
| 160 | 150 | if (unlikely(p == NULL)) |
| 161 | 151 | return htonl(NFS4ERR_RESOURCE); |
| 162 | 152 | hdr->minorversion = ntohl(*p++); |
| @@ -176,7 +166,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · 13 unmodified lines | ||
| 176 | 166 | static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op) |
| 177 | 167 | { |
| 178 | 168 | __be32 *p; |
| 179 | − p = read_buf(xdr, 4); | |
| 169 | + p = xdr_inline_decode(xdr, 4); | |
| 180 | 170 | if (unlikely(p == NULL)) |
| 181 | 171 | return htonl(NFS4ERR_RESOURCE_HDR); |
| 182 | 172 | *op = ntohl(*p); |
| @@ -205,7 +195,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, · 22 unmodified lines | ||
| 205 | 195 | status = decode_delegation_stateid(xdr, &args->stateid); |
| 206 | 196 | if (unlikely(status != 0)) |
| 207 | 197 | return status; |
| 208 | − p = read_buf(xdr, 4); | |
| 198 | + p = xdr_inline_decode(xdr, 4); | |
| 209 | 199 | if (unlikely(p == NULL)) |
| 210 | 200 | return htonl(NFS4ERR_RESOURCE); |
| 211 | 201 | args->truncate = ntohl(*p); |
| @@ -227,7 +217,7 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, · 15 unmodified lines | ||
| 227 | 217 | __be32 status = 0; |
| 228 | 218 | uint32_t iomode; |
| 229 | 219 | |
| 230 | − p = read_buf(xdr, 4 * sizeof(uint32_t)); | |
| 220 | + p = xdr_inline_decode(xdr, 4 * sizeof(uint32_t)); | |
| 231 | 221 | if (unlikely(p == NULL)) |
| 232 | 222 | return htonl(NFS4ERR_BADXDR); |
| 233 | 223 | |
| @@ -245,14 +235,14 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, · 11 unmodified lines | ||
| 245 | 235 | if (unlikely(status != 0)) |
| 246 | 236 | return status; |
| 247 | 237 | |
| 248 | − p = read_buf(xdr, 2 * sizeof(uint64_t)); | |
| 238 | + p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t)); | |
| 249 | 239 | if (unlikely(p == NULL)) |
| 250 | 240 | return htonl(NFS4ERR_BADXDR); |
| 251 | 241 | p = xdr_decode_hyper(p, &args->cbl_range.offset); |
| 252 | 242 | p = xdr_decode_hyper(p, &args->cbl_range.length); |
| 253 | 243 | return decode_layout_stateid(xdr, &args->cbl_stateid); |
| 254 | 244 | } else if (args->cbl_recall_type == RETURN_FSID) { |
| 255 | − p = read_buf(xdr, 2 * sizeof(uint64_t)); | |
| 245 | + p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t)); | |
| 256 | 246 | if (unlikely(p == NULL)) |
| 257 | 247 | return htonl(NFS4ERR_BADXDR); |
| 258 | 248 | p = xdr_decode_hyper(p, &args->cbl_fsid.major); |
| @@ -275,7 +265,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 16 unmodified lines | ||
| 275 | 265 | args->ndevs = 0; |
| 276 | 266 | |
| 277 | 267 | /* Num of device notifications */ |
| 278 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 268 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 279 | 269 | if (unlikely(p == NULL)) { |
| 280 | 270 | status = htonl(NFS4ERR_BADXDR); |
| 281 | 271 | goto out; |
| @@ -298,7 +288,8 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 16 unmodified lines | ||
| 298 | 288 | for (i = 0; i < n; i++) { |
| 299 | 289 | struct cb_devicenotifyitem *dev = &args->devs[i]; |
| 300 | 290 | |
| 301 | − p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE); | |
| 291 | + p = xdr_inline_decode(xdr, (4 * sizeof(uint32_t)) + | |
| 292 | + NFS4_DEVICEID4_SIZE); | |
| 302 | 293 | if (unlikely(p == NULL)) { |
| 303 | 294 | status = htonl(NFS4ERR_BADXDR); |
| 304 | 295 | goto err; |
| @@ -329,7 +320,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 24 unmodified lines | ||
| 329 | 320 | p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); |
| 330 | 321 | |
| 331 | 322 | if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) { |
| 332 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 323 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 333 | 324 | if (unlikely(p == NULL)) { |
| 334 | 325 | status = htonl(NFS4ERR_BADXDR); |
| 335 | 326 | goto err; |
| @@ -359,7 +350,7 @@ static __be32 decode_sessionid(struct xdr_stream *xdr, · 23 unmodified lines | ||
| 359 | 350 | { |
| 360 | 351 | __be32 *p; |
| 361 | 352 | |
| 362 | − p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN); | |
| 353 | + p = xdr_inline_decode(xdr, NFS4_MAX_SESSIONID_LEN); | |
| 363 | 354 | if (unlikely(p == NULL)) |
| 364 | 355 | return htonl(NFS4ERR_RESOURCE); |
| 365 | 356 | |
| @@ -379,13 +370,13 @@ static __be32 decode_rc_list(struct xdr_stream *xdr, · 13 unmodified lines | ||
| 379 | 370 | goto out; |
| 380 | 371 | |
| 381 | 372 | status = htonl(NFS4ERR_RESOURCE); |
| 382 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 373 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 383 | 374 | if (unlikely(p == NULL)) |
| 384 | 375 | goto out; |
| 385 | 376 | |
| 386 | 377 | rc_list->rcl_nrefcalls = ntohl(*p++); |
| 387 | 378 | if (rc_list->rcl_nrefcalls) { |
| 388 | − p = read_buf(xdr, | |
| 379 | + p = xdr_inline_decode(xdr, | |
| 389 | 380 | rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)); |
| 390 | 381 | if (unlikely(p == NULL)) |
| 391 | 382 | goto out; |
| @@ -418,7 +409,7 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp, · 26 unmodified lines | ||
| 418 | 409 | if (status) |
| 419 | 410 | return status; |
| 420 | 411 | |
| 421 | − p = read_buf(xdr, 5 * sizeof(uint32_t)); | |
| 412 | + p = xdr_inline_decode(xdr, 5 * sizeof(uint32_t)); | |
| 422 | 413 | if (unlikely(p == NULL)) |
| 423 | 414 | return htonl(NFS4ERR_RESOURCE); |
| 424 | 415 | |
| @@ -461,7 +452,7 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp, · 36 unmodified lines | ||
| 461 | 452 | uint32_t bitmap[2]; |
| 462 | 453 | __be32 *p, status; |
| 463 | 454 | |
| 464 | − p = read_buf(xdr, 4); | |
| 455 | + p = xdr_inline_decode(xdr, 4); | |
| 465 | 456 | if (unlikely(p == NULL)) |
| 466 | 457 | return htonl(NFS4ERR_BADXDR); |
| 467 | 458 | args->craa_objs_to_keep = ntohl(*p++); |
| @@ -480,7 +471,7 @@ static __be32 decode_recallslot_args(struct svc_rqst *rqstp, · 12 unmodified lines | ||
| 480 | 471 | struct cb_recallslotargs *args = argp; |
| 481 | 472 | __be32 *p; |
| 482 | 473 | |
| 483 | − p = read_buf(xdr, 4); | |
| 474 | + p = xdr_inline_decode(xdr, 4); | |
| 484 | 475 | if (unlikely(p == NULL)) |
| 485 | 476 | return htonl(NFS4ERR_BADXDR); |
| 486 | 477 | args->crsa_target_highest_slotid = ntohl(*p++); |
| @@ -492,14 +483,14 @@ static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_arg · 5 unmodified lines | ||
| 492 | 483 | __be32 *p; |
| 493 | 484 | unsigned int len; |
| 494 | 485 | |
| 495 | − p = read_buf(xdr, 12); | |
| 486 | + p = xdr_inline_decode(xdr, 12); | |
| 496 | 487 | if (unlikely(p == NULL)) |
| 497 | 488 | return htonl(NFS4ERR_BADXDR); |
| 498 | 489 | |
| 499 | 490 | p = xdr_decode_hyper(p, &args->cbnl_owner.clientid); |
| 500 | 491 | len = be32_to_cpu(*p); |
| 501 | 492 | |
| 502 | − p = read_buf(xdr, len); | |
| 493 | + p = xdr_inline_decode(xdr, len); | |
| 503 | 494 | if (unlikely(p == NULL)) |
| 504 | 495 | return htonl(NFS4ERR_BADXDR); |
| 505 | 496 | |
| @@ -537,7 +528,7 @@ static __be32 decode_write_response(struct xdr_stream *xdr, · 31 unmodified lines | ||
| 537 | 528 | __be32 *p; |
| 538 | 529 | |
| 539 | 530 | /* skip the always zero field */ |
| 540 | − p = read_buf(xdr, 4); | |
| 531 | + p = xdr_inline_decode(xdr, 4); | |
| 541 | 532 | if (unlikely(!p)) |
| 542 | 533 | goto out; |
| 543 | 534 | p++; |
| @@ -577,7 +568,7 @@ static __be32 decode_offload_args(struct svc_rqst *rqstp, · 33 unmodified lines | ||
| 577 | 568 | return status; |
| 578 | 569 | |
| 579 | 570 | /* decode status */ |
| 580 | − p = read_buf(xdr, 4); | |
| 571 | + p = xdr_inline_decode(xdr, 4); | |
| 581 | 572 | if (unlikely(!p)) |
| 582 | 573 | goto out; |
| 583 | 574 | args->error = ntohl(*p++); |
| @@ -943,10 +934,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp) · 359 unmodified lines | ||
| 943 | 934 | }; |
| 944 | 935 | unsigned int nops = 0; |
| 945 | 936 | |
| 946 | − xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base); | |
| 937 | + xdr_init_decode(&xdr_in, &rqstp->rq_arg, | |
| 938 | + rqstp->rq_arg.head[0].iov_base, NULL); | |
| 947 | 939 | |
| 948 | 940 | p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); |
| 949 | − xdr_init_encode(&xdr_out, &rqstp->rq_res, p); | |
| 941 | + xdr_init_encode(&xdr_out, &rqstp->rq_res, p, NULL); | |
| 950 | 942 | |
| 951 | 943 | status = decode_compound_hdr_arg(&xdr_in, &hdr_arg); |
| 952 | 944 | if (status == htonl(NFS4ERR_RESOURCE)) |
| @@ -229,6 +229,8 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation · 228 unmodified lines | ||
| 229 | 229 | spin_lock(&delegation->lock); |
| 230 | 230 | if (delegation->inode != NULL) |
| 231 | 231 | inode = igrab(delegation->inode); |
| 232 | + if (!inode) | |
| 233 | + set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); | |
| 232 | 234 | spin_unlock(&delegation->lock); |
| 233 | 235 | return inode; |
| 234 | 236 | } |
| @@ -681,7 +683,7 @@ void nfs_expire_all_delegations(struct nfs_client *clp) · 446 unmodified lines | ||
| 681 | 683 | |
| 682 | 684 | /** |
| 683 | 685 | * nfs_super_return_all_delegations - return delegations for one superblock |
| 684 | − * @sb: sb to process | |
| 686 | + * @server: pointer to nfs_server to process | |
| 685 | 687 | * |
| 686 | 688 | */ |
| 687 | 689 | void nfs_server_return_all_delegations(struct nfs_server *server) |
| @@ -944,10 +946,11 @@ restart: · 256 unmodified lines | ||
| 944 | 946 | list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { |
| 945 | 947 | list_for_each_entry_rcu(delegation, &server->delegations, |
| 946 | 948 | super_list) { |
| 947 | − if (test_bit(NFS_DELEGATION_RETURNING, | |
| 948 | − &delegation->flags)) | |
| 949 | − continue; | |
| 950 | − if (test_bit(NFS_DELEGATION_NEED_RECLAIM, | |
| 949 | + if (test_bit(NFS_DELEGATION_INODE_FREEING, | |
| 950 | + &delegation->flags) || | |
| 951 | + test_bit(NFS_DELEGATION_RETURNING, | |
| 952 | + &delegation->flags) || | |
| 953 | + test_bit(NFS_DELEGATION_NEED_RECLAIM, | |
| 951 | 954 | &delegation->flags) == 0) |
| 952 | 955 | continue; |
| 953 | 956 | if (!nfs_sb_active(server->super)) |
| @@ -1053,10 +1056,11 @@ restart: · 99 unmodified lines | ||
| 1053 | 1056 | list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { |
| 1054 | 1057 | list_for_each_entry_rcu(delegation, &server->delegations, |
| 1055 | 1058 | super_list) { |
| 1056 | − if (test_bit(NFS_DELEGATION_RETURNING, | |
| 1057 | − &delegation->flags)) | |
| 1058 | − continue; | |
| 1059 | − if (test_bit(NFS_DELEGATION_TEST_EXPIRED, | |
| 1059 | + if (test_bit(NFS_DELEGATION_INODE_FREEING, | |
| 1060 | + &delegation->flags) || | |
| 1061 | + test_bit(NFS_DELEGATION_RETURNING, | |
| 1062 | + &delegation->flags) || | |
| 1063 | + test_bit(NFS_DELEGATION_TEST_EXPIRED, | |
| 1060 | 1064 | &delegation->flags) == 0) |
| 1061 | 1065 | continue; |
| 1062 | 1066 | if (!nfs_sb_active(server->super)) |
| @@ -34,6 +34,7 @@ enum { · 33 unmodified lines | ||
| 34 | 34 | NFS_DELEGATION_RETURNING, |
| 35 | 35 | NFS_DELEGATION_REVOKED, |
| 36 | 36 | NFS_DELEGATION_TEST_EXPIRED, |
| 37 | + NFS_DELEGATION_INODE_FREEING, | |
| 37 | 38 | }; |
| 38 | 39 | |
| 39 | 40 | int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, |
| @@ -139,12 +139,19 @@ struct nfs_cache_array { · 138 unmodified lines | ||
| 139 | 139 | struct nfs_cache_array_entry array[0]; |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | +struct readdirvec { | |
| 143 | + unsigned long nr; | |
| 144 | + unsigned long index; | |
| 145 | + struct page *pages[NFS_MAX_READDIR_RAPAGES]; | |
| 146 | +}; | |
| 147 | + | |
| 142 | 148 | typedef int (*decode_dirent_t)(struct xdr_stream *, struct nfs_entry *, bool); |
| 143 | 149 | typedef struct { |
| 144 | 150 | struct file *file; |
| 145 | 151 | struct page *page; |
| 146 | 152 | struct dir_context *ctx; |
| 147 | 153 | unsigned long page_index; |
| 154 | + struct readdirvec pvec; | |
| 148 | 155 | u64 *dir_cookie; |
| 149 | 156 | u64 last_cookie; |
| 150 | 157 | loff_t current_index; |
| @@ -524,6 +531,10 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en · 373 unmodified lines | ||
| 524 | 531 | struct nfs_cache_array *array; |
| 525 | 532 | unsigned int count = 0; |
| 526 | 533 | int status; |
| 534 | + int max_rapages = NFS_MAX_READDIR_RAPAGES; | |
| 535 | + | |
| 536 | + desc->pvec.index = desc->page_index; | |
| 537 | + desc->pvec.nr = 0; | |
| 527 | 538 | |
| 528 | 539 | scratch = alloc_page(GFP_KERNEL); |
| 529 | 540 | if (scratch == NULL) |
| @@ -548,20 +559,40 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en · 18 unmodified lines | ||
| 548 | 559 | if (desc->plus) |
| 549 | 560 | nfs_prime_dcache(file_dentry(desc->file), entry); |
| 550 | 561 | |
| 551 | − status = nfs_readdir_add_to_array(entry, page); | |
| 562 | + status = nfs_readdir_add_to_array(entry, desc->pvec.pages[desc->pvec.nr]); | |
| 563 | + if (status == -ENOSPC) { | |
| 564 | + desc->pvec.nr++; | |
| 565 | + if (desc->pvec.nr == max_rapages) | |
| 566 | + break; | |
| 567 | + status = nfs_readdir_add_to_array(entry, desc->pvec.pages[desc->pvec.nr]); | |
| 568 | + } | |
| 552 | 569 | if (status != 0) |
| 553 | 570 | break; |
| 554 | 571 | } while (!entry->eof); |
| 555 | 572 | |
| 573 | + /* | |
| 574 | + * page and desc->pvec.pages[0] are valid, don't need to check | |
| 575 | + * whether or not to be NULL. | |
| 576 | + */ | |
| 577 | + copy_highpage(page, desc->pvec.pages[0]); | |
| 578 | + | |
| 556 | 579 | out_nopages: |
| 557 | 580 | if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) { |
| 558 | − array = kmap(page); | |
| 581 | + array = kmap_atomic(desc->pvec.pages[desc->pvec.nr]); | |
| 559 | 582 | array->eof_index = array->size; |
| 560 | 583 | status = 0; |
| 561 | − kunmap(page); | |
| 584 | + kunmap_atomic(array); | |
| 562 | 585 | } |
| 563 | 586 | |
| 564 | 587 | put_page(scratch); |
| 588 | + | |
| 589 | + /* | |
| 590 | + * desc->pvec.nr > 0 means at least one page was completely filled, | |
| 591 | + * we should return -ENOSPC. Otherwise function | |
| 592 | + * nfs_readdir_xdr_to_array will enter infinite loop. | |
| 593 | + */ | |
| 594 | + if (desc->pvec.nr > 0) | |
| 595 | + return -ENOSPC; | |
| 565 | 596 | return status; |
| 566 | 597 | } |
| 567 | 598 | |
| @@ -574,8 +605,8 @@ void nfs_readdir_free_pages(struct page **pages, unsigned int npages) · 6 unmodified lines | ||
| 574 | 605 | } |
| 575 | 606 | |
| 576 | 607 | /* |
| 577 | − * nfs_readdir_large_page will allocate pages that must be freed with a call | |
| 578 | − * to nfs_readdir_free_pagearray | |
| 608 | + * nfs_readdir_alloc_pages() will allocate pages that must be freed with a call | |
| 609 | + * to nfs_readdir_free_pages() | |
| 579 | 610 | */ |
| 580 | 611 | static |
| 581 | 612 | int nfs_readdir_alloc_pages(struct page **pages, unsigned int npages) |
| @@ -595,6 +626,24 @@ out_freepages: · 13 unmodified lines | ||
| 595 | 626 | return -ENOMEM; |
| 596 | 627 | } |
| 597 | 628 | |
| 629 | +/* | |
| 630 | + * nfs_readdir_rapages_init initialize rapages by nfs_cache_array structure. | |
| 631 | + */ | |
| 632 | +static | |
| 633 | +void nfs_readdir_rapages_init(nfs_readdir_descriptor_t *desc) | |
| 634 | +{ | |
| 635 | + struct nfs_cache_array *array; | |
| 636 | + int max_rapages = NFS_MAX_READDIR_RAPAGES; | |
| 637 | + int index; | |
| 638 | + | |
| 639 | + for (index = 0; index < max_rapages; index++) { | |
| 640 | + array = kmap_atomic(desc->pvec.pages[index]); | |
| 641 | + memset(array, 0, sizeof(struct nfs_cache_array)); | |
| 642 | + array->eof_index = -1; | |
| 643 | + kunmap_atomic(array); | |
| 644 | + } | |
| 645 | +} | |
| 646 | + | |
| 598 | 647 | static |
| 599 | 648 | int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, struct inode *inode) |
| 600 | 649 | { |
| @@ -605,6 +654,12 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, · 4 unmodified lines | ||
| 605 | 654 | int status = -ENOMEM; |
| 606 | 655 | unsigned int array_size = ARRAY_SIZE(pages); |
| 607 | 656 | |
| 657 | + /* | |
| 658 | + * This means we hit readdir rdpages miss, the preallocated rdpages | |
| 659 | + * are useless, the preallocate rdpages should be reinitialized. | |
| 660 | + */ | |
| 661 | + nfs_readdir_rapages_init(desc); | |
| 662 | + | |
| 608 | 663 | entry.prev_cookie = 0; |
| 609 | 664 | entry.cookie = desc->last_cookie; |
| 610 | 665 | entry.eof = 0; |
| @@ -664,9 +719,24 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page) · 53 unmodified lines | ||
| 664 | 719 | struct inode *inode = file_inode(desc->file); |
| 665 | 720 | int ret; |
| 666 | 721 | |
| 667 | − ret = nfs_readdir_xdr_to_array(desc, page, inode); | |
| 668 | − if (ret < 0) | |
| 669 | − goto error; | |
| 722 | + /* | |
| 723 | + * If desc->page_index in range desc->pvec.index and | |
| 724 | + * desc->pvec.index + desc->pvec.nr, we get readdir cache hit. | |
| 725 | + */ | |
| 726 | + if (desc->page_index >= desc->pvec.index && | |
| 727 | + desc->page_index < (desc->pvec.index + desc->pvec.nr)) { | |
| 728 | + /* | |
| 729 | + * page and desc->pvec.pages[x] are valid, don't need to check | |
| 730 | + * whether or not to be NULL. | |
| 731 | + */ | |
| 732 | + copy_highpage(page, desc->pvec.pages[desc->page_index - desc->pvec.index]); | |
| 733 | + ret = 0; | |
| 734 | + } else { | |
| 735 | + ret = nfs_readdir_xdr_to_array(desc, page, inode); | |
| 736 | + if (ret < 0) | |
| 737 | + goto error; | |
| 738 | + } | |
| 739 | + | |
| 670 | 740 | SetPageUptodate(page); |
| 671 | 741 | |
| 672 | 742 | if (invalidate_inode_pages2_range(inode->i_mapping, page->index + 1, -1) < 0) { |
| @@ -831,6 +901,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) · 158 unmodified lines | ||
| 831 | 901 | *desc = &my_desc; |
| 832 | 902 | struct nfs_open_dir_context *dir_ctx = file->private_data; |
| 833 | 903 | int res = 0; |
| 904 | + int max_rapages = NFS_MAX_READDIR_RAPAGES; | |
| 834 | 905 | |
| 835 | 906 | dfprintk(FILE, "NFS: readdir(%pD2) starting at cookie %llu\n", |
| 836 | 907 | file, (long long)ctx->pos); |
| @@ -850,6 +921,12 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) · 13 unmodified lines | ||
| 850 | 921 | desc->decode = NFS_PROTO(inode)->decode_dirent; |
| 851 | 922 | desc->plus = nfs_use_readdirplus(inode, ctx); |
| 852 | 923 | |
| 924 | + res = nfs_readdir_alloc_pages(desc->pvec.pages, max_rapages); | |
| 925 | + if (res < 0) | |
| 926 | + return -ENOMEM; | |
| 927 | + | |
| 928 | + nfs_readdir_rapages_init(desc); | |
| 929 | + | |
| 853 | 930 | if (ctx->pos == 0 || nfs_attribute_cache_expired(inode)) |
| 854 | 931 | res = nfs_revalidate_mapping(inode, file->f_mapping); |
| 855 | 932 | if (res < 0) |
| @@ -885,6 +962,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) · 29 unmodified lines | ||
| 885 | 962 | break; |
| 886 | 963 | } while (!desc->eof); |
| 887 | 964 | out: |
| 965 | + nfs_readdir_free_pages(desc->pvec.pages, max_rapages); | |
| 888 | 966 | if (res > 0) |
| 889 | 967 | res = 0; |
| 890 | 968 | dfprintk(FILE, "NFS: readdir(%pD2) returns %d\n", file, res); |
| @@ -945,7 +1023,7 @@ static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end, · 54 unmodified lines | ||
| 945 | 1023 | |
| 946 | 1024 | /** |
| 947 | 1025 | * nfs_force_lookup_revalidate - Mark the directory as having changed |
| 948 | − * @dir - pointer to directory inode | |
| 1026 | + * @dir: pointer to directory inode | |
| 949 | 1027 | * |
| 950 | 1028 | * This forces the revalidation code in nfs_lookup_revalidate() to do a |
| 951 | 1029 | * full lookup on all child dentries of 'dir' whenever a change occurs |
| @@ -1649,7 +1727,7 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, · 697 unmodified lines | ||
| 1649 | 1727 | reval_dentry: |
| 1650 | 1728 | if (flags & LOOKUP_RCU) |
| 1651 | 1729 | return -ECHILD; |
| 1652 | − return nfs_lookup_revalidate_dentry(dir, dentry, inode);; | |
| 1730 | + return nfs_lookup_revalidate_dentry(dir, dentry, inode); | |
| 1653 | 1731 | |
| 1654 | 1732 | full_reval: |
| 1655 | 1733 | return nfs_do_lookup_revalidate(dir, dentry, flags); |
| @@ -428,7 +428,7 @@ out_put: · 427 unmodified lines | ||
| 428 | 428 | hdr->release(hdr); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | −static void nfs_read_sync_pgio_error(struct list_head *head) | |
| 431 | +static void nfs_read_sync_pgio_error(struct list_head *head, int error) | |
| 432 | 432 | { |
| 433 | 433 | struct nfs_page *req; |
| 434 | 434 | |
| @@ -664,8 +664,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) · 229 unmodified lines | ||
| 664 | 664 | |
| 665 | 665 | list_for_each_entry_safe(req, tmp, &reqs, wb_list) { |
| 666 | 666 | if (!nfs_pageio_add_request(&desc, req)) { |
| 667 | − nfs_list_remove_request(req); | |
| 668 | − nfs_list_add_request(req, &failed); | |
| 667 | + nfs_list_move_request(req, &failed); | |
| 669 | 668 | spin_lock(&cinfo.inode->i_lock); |
| 670 | 669 | dreq->flags = 0; |
| 671 | 670 | if (desc.pg_error < 0) |
| @@ -821,7 +820,7 @@ out_put: · 149 unmodified lines | ||
| 821 | 820 | hdr->release(hdr); |
| 822 | 821 | } |
| 823 | 822 | |
| 824 | −static void nfs_write_sync_pgio_error(struct list_head *head) | |
| 823 | +static void nfs_write_sync_pgio_error(struct list_head *head, int error) | |
| 825 | 824 | { |
| 826 | 825 | struct nfs_page *req; |
| 827 | 826 | |
| @@ -89,8 +89,8 @@ EXPORT_SYMBOL_GPL(nfs_file_release); · 88 unmodified lines | ||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * nfs_revalidate_size - Revalidate the file size |
| 92 | − * @inode - pointer to inode struct | |
| 93 | − * @file - pointer to struct file | |
| 92 | + * @inode: pointer to inode struct | |
| 93 | + * @filp: pointer to struct file | |
| 94 | 94 | * |
| 95 | 95 | * Revalidates the file length. This is basically a wrapper around |
| 96 | 96 | * nfs_revalidate_inode() that takes into account the fact that we may |
| @@ -276,6 +276,12 @@ EXPORT_SYMBOL_GPL(nfs_file_fsync); · 179 unmodified lines | ||
| 276 | 276 | * then a modify/write/read cycle when writing to a page in the |
| 277 | 277 | * page cache. |
| 278 | 278 | * |
| 279 | + * Some pNFS layout drivers can only read/write at a certain block | |
| 280 | + * granularity like all block devices and therefore we must perform | |
| 281 | + * read/modify/write whenever a page hasn't read yet and the data | |
| 282 | + * to be written there is not aligned to a block boundary and/or | |
| 283 | + * smaller than the block size. | |
| 284 | + * | |
| 279 | 285 | * The modify/write/read cycle may occur if a page is read before |
| 280 | 286 | * being completely filled by the writer. In this situation, the |
| 281 | 287 | * page must be completely written to stable storage on the server |
| @@ -291,26 +297,32 @@ EXPORT_SYMBOL_GPL(nfs_file_fsync); · 9 unmodified lines | ||
| 291 | 297 | * and that the new data won't completely replace the old data in |
| 292 | 298 | * that range of the file. |
| 293 | 299 | */ |
| 294 | −static int nfs_want_read_modify_write(struct file *file, struct page *page, | |
| 295 | − loff_t pos, unsigned len) | |
| 300 | +static bool nfs_full_page_write(struct page *page, loff_t pos, unsigned int len) | |
| 296 | 301 | { |
| 297 | 302 | unsigned int pglen = nfs_page_length(page); |
| 298 | 303 | unsigned int offset = pos & (PAGE_SIZE - 1); |
| 299 | 304 | unsigned int end = offset + len; |
| 300 | 305 | |
| 301 | − if (pnfs_ld_read_whole_page(file->f_mapping->host)) { | |
| 302 | − if (!PageUptodate(page)) | |
| 303 | − return 1; | |
| 304 | − return 0; | |
| 305 | − } | |
| 306 | + return !pglen || (end >= pglen && !offset); | |
| 307 | +} | |
| 306 | 308 | |
| 307 | − if ((file->f_mode & FMODE_READ) && /* open for read? */ | |
| 308 | − !PageUptodate(page) && /* Uptodate? */ | |
| 309 | − !PagePrivate(page) && /* i/o request already? */ | |
| 310 | − pglen && /* valid bytes of file? */ | |
| 311 | − (end < pglen || offset)) /* replace all valid bytes? */ | |
| 312 | − return 1; | |
| 313 | − return 0; | |
| 309 | +static bool nfs_want_read_modify_write(struct file *file, struct page *page, | |
| 310 | + loff_t pos, unsigned int len) | |
| 311 | +{ | |
| 312 | + /* | |
| 313 | + * Up-to-date pages, those with ongoing or full-page write | |
| 314 | + * don't need read/modify/write | |
| 315 | + */ | |
| 316 | + if (PageUptodate(page) || PagePrivate(page) || | |
| 317 | + nfs_full_page_write(page, pos, len)) | |
| 318 | + return false; | |
| 319 | + | |
| 320 | + if (pnfs_ld_read_whole_page(file->f_mapping->host)) | |
| 321 | + return true; | |
| 322 | + /* Open for reading too? */ | |
| 323 | + if (file->f_mode & FMODE_READ) | |
| 324 | + return true; | |
| 325 | + return false; | |
| 314 | 326 | } |
| 315 | 327 | |
| 316 | 328 | /* |
| @@ -410,7 +410,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, · 409 unmodified lines | ||
| 410 | 410 | for (i = 0; i < fls->mirror_array_cnt; i++) { |
| 411 | 411 | struct nfs4_ff_layout_mirror *mirror; |
| 412 | 412 | struct cred *kcred; |
| 413 | − const struct cred *cred; | |
| 413 | + const struct cred __rcu *cred; | |
| 414 | 414 | kuid_t uid; |
| 415 | 415 | kgid_t gid; |
| 416 | 416 | u32 ds_count, fh_count, id; |
| @@ -501,7 +501,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, · 84 unmodified lines | ||
| 501 | 501 | goto out_err_free; |
| 502 | 502 | kcred->fsuid = uid; |
| 503 | 503 | kcred->fsgid = gid; |
| 504 | − cred = kcred; | |
| 504 | + cred = RCU_INITIALIZER(kcred); | |
| 505 | 505 | |
| 506 | 506 | if (lgr->range.iomode == IOMODE_READ) |
| 507 | 507 | rcu_assign_pointer(fls->mirror_array[i]->ro_cred, cred); |
| @@ -788,30 +788,82 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg, · 280 unmodified lines | ||
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | +static void | |
| 792 | +ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, int idx) | |
| 793 | +{ | |
| 794 | + struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx); | |
| 795 | + | |
| 796 | + if (devid) | |
| 797 | + nfs4_mark_deviceid_unavailable(devid); | |
| 798 | +} | |
| 799 | + | |
| 800 | +static void | |
| 801 | +ff_layout_mark_ds_reachable(struct pnfs_layout_segment *lseg, int idx) | |
| 802 | +{ | |
| 803 | + struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx); | |
| 804 | + | |
| 805 | + if (devid) | |
| 806 | + nfs4_mark_deviceid_available(devid); | |
| 807 | +} | |
| 808 | + | |
| 791 | 809 | static struct nfs4_pnfs_ds * |
| 792 | −ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg, | |
| 793 | − int start_idx, | |
| 794 | − int *best_idx) | |
| 810 | +ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg, | |
| 811 | + int start_idx, int *best_idx, | |
| 812 | + bool check_device) | |
| 795 | 813 | { |
| 796 | 814 | struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); |
| 815 | + struct nfs4_ff_layout_mirror *mirror; | |
| 797 | 816 | struct nfs4_pnfs_ds *ds; |
| 798 | 817 | bool fail_return = false; |
| 799 | 818 | int idx; |
| 800 | 819 | |
| 801 | − /* mirrors are sorted by efficiency */ | |
| 820 | + /* mirrors are initially sorted by efficiency */ | |
| 802 | 821 | for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { |
| 803 | 822 | if (idx+1 == fls->mirror_array_cnt) |
| 804 | − fail_return = true; | |
| 805 | − ds = nfs4_ff_layout_prepare_ds(lseg, idx, fail_return); | |
| 806 | − if (ds) { | |
| 807 | − *best_idx = idx; | |
| 808 | − return ds; | |
| 809 | − } | |
| 823 | + fail_return = !check_device; | |
| 824 | + | |
| 825 | + mirror = FF_LAYOUT_COMP(lseg, idx); | |
| 826 | + ds = nfs4_ff_layout_prepare_ds(lseg, mirror, fail_return); | |
| 827 | + if (!ds) | |
| 828 | + continue; | |
| 829 | + | |
| 830 | + if (check_device && | |
| 831 | + nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node)) | |
| 832 | + continue; | |
| 833 | + | |
| 834 | + *best_idx = idx; | |
| 835 | + return ds; | |
| 810 | 836 | } |
| 811 | 837 | |
| 812 | 838 | return NULL; |
| 813 | 839 | } |
| 814 | 840 | |
| 841 | +static struct nfs4_pnfs_ds * | |
| 842 | +ff_layout_choose_any_ds_for_read(struct pnfs_layout_segment *lseg, | |
| 843 | + int start_idx, int *best_idx) | |
| 844 | +{ | |
| 845 | + return ff_layout_choose_ds_for_read(lseg, start_idx, best_idx, false); | |
| 846 | +} | |
| 847 | + | |
| 848 | +static struct nfs4_pnfs_ds * | |
| 849 | +ff_layout_choose_valid_ds_for_read(struct pnfs_layout_segment *lseg, | |
| 850 | + int start_idx, int *best_idx) | |
| 851 | +{ | |
| 852 | + return ff_layout_choose_ds_for_read(lseg, start_idx, best_idx, true); | |
| 853 | +} | |
| 854 | + | |
| 855 | +static struct nfs4_pnfs_ds * | |
| 856 | +ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg, | |
| 857 | + int start_idx, int *best_idx) | |
| 858 | +{ | |
| 859 | + struct nfs4_pnfs_ds *ds; | |
| 860 | + | |
| 861 | + ds = ff_layout_choose_valid_ds_for_read(lseg, start_idx, best_idx); | |
| 862 | + if (ds) | |
| 863 | + return ds; | |
| 864 | + return ff_layout_choose_any_ds_for_read(lseg, start_idx, best_idx); | |
| 865 | +} | |
| 866 | + | |
| 815 | 867 | static void |
| 816 | 868 | ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, |
| 817 | 869 | struct nfs_page *req, |
| @@ -925,7 +977,8 @@ retry: · 107 unmodified lines | ||
| 925 | 977 | goto out_mds; |
| 926 | 978 | |
| 927 | 979 | for (i = 0; i < pgio->pg_mirror_count; i++) { |
| 928 | − ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true); | |
| 980 | + mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); | |
| 981 | + ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, mirror, true); | |
| 929 | 982 | if (!ds) { |
| 930 | 983 | if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg)) |
| 931 | 984 | goto out_mds; |
| @@ -936,7 +989,6 @@ retry: · 4 unmodified lines | ||
| 936 | 989 | goto retry; |
| 937 | 990 | } |
| 938 | 991 | pgm = &pgio->pg_mirrors[i]; |
| 939 | − mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); | |
| 940 | 992 | pgm->pg_bsize = mirror->mirror_ds->ds_versions[0].wsize; |
| 941 | 993 | } |
| 942 | 994 | |
| @@ -1071,6 +1123,8 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task, · 128 unmodified lines | ||
| 1071 | 1123 | break; |
| 1072 | 1124 | case -NFS4ERR_RETRY_UNCACHED_REP: |
| 1073 | 1125 | break; |
| 1126 | + case -EAGAIN: | |
| 1127 | + return -NFS4ERR_RESET_TO_PNFS; | |
| 1074 | 1128 | /* Invalidate Layout errors */ |
| 1075 | 1129 | case -NFS4ERR_PNFS_NO_LAYOUT: |
| 1076 | 1130 | case -ESTALE: /* mapped NFS4ERR_STALE */ |
| @@ -1131,6 +1185,7 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task, · 54 unmodified lines | ||
| 1131 | 1185 | case -EBADHANDLE: |
| 1132 | 1186 | case -ELOOP: |
| 1133 | 1187 | case -ENOSPC: |
| 1188 | + case -EAGAIN: | |
| 1134 | 1189 | break; |
| 1135 | 1190 | case -EJUKEBOX: |
| 1136 | 1191 | nfs_inc_stats(lseg->pls_layout->plh_inode, NFSIOS_DELAY); |
| @@ -1158,8 +1213,10 @@ static int ff_layout_async_handle_error(struct rpc_task *task, · 21 unmodified lines | ||
| 1158 | 1213 | { |
| 1159 | 1214 | int vers = clp->cl_nfs_mod->rpc_vers->number; |
| 1160 | 1215 | |
| 1161 | − if (task->tk_status >= 0) | |
| 1216 | + if (task->tk_status >= 0) { | |
| 1217 | + ff_layout_mark_ds_reachable(lseg, idx); | |
| 1162 | 1218 | return 0; |
| 1219 | + } | |
| 1163 | 1220 | |
| 1164 | 1221 | /* Handle the case of an invalid layout segment */ |
| 1165 | 1222 | if (!pnfs_is_valid_lseg(lseg)) |
| @@ -1222,6 +1279,8 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg, · 56 unmodified lines | ||
| 1222 | 1279 | err = ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), |
| 1223 | 1280 | mirror, offset, length, status, opnum, |
| 1224 | 1281 | GFP_NOIO); |
| 1282 | + if (status == NFS4ERR_NXIO) | |
| 1283 | + ff_layout_mark_ds_unreachable(lseg, idx); | |
| 1225 | 1284 | pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode, lseg); |
| 1226 | 1285 | dprintk("%s: err %d op %d status %u\n", __func__, err, opnum, status); |
| 1227 | 1286 | } |
| @@ -1249,7 +1308,7 @@ static int ff_layout_read_done_cb(struct rpc_task *task, · 21 unmodified lines | ||
| 1249 | 1308 | if (ff_layout_choose_best_ds_for_read(hdr->lseg, |
| 1250 | 1309 | hdr->pgio_mirror_idx + 1, |
| 1251 | 1310 | &hdr->pgio_mirror_idx)) |
| 1252 | − goto out_eagain; | |
| 1311 | + goto out_layouterror; | |
| 1253 | 1312 | set_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags); |
| 1254 | 1313 | return task->tk_status; |
| 1255 | 1314 | case -NFS4ERR_RESET_TO_MDS: |
| @@ -1260,6 +1319,8 @@ static int ff_layout_read_done_cb(struct rpc_task *task, · 4 unmodified lines | ||
| 1260 | 1319 | } |
| 1261 | 1320 | |
| 1262 | 1321 | return 0; |
| 1322 | +out_layouterror: | |
| 1323 | + ff_layout_send_layouterror(hdr->lseg); | |
| 1263 | 1324 | out_eagain: |
| 1264 | 1325 | rpc_restart_call_prepare(task); |
| 1265 | 1326 | return -EAGAIN; |
| @@ -1293,15 +1354,6 @@ ff_layout_set_layoutcommit(struct inode *inode, · 27 unmodified lines | ||
| 1293 | 1354 | (unsigned long long) NFS_I(inode)->layout->plh_lwb); |
| 1294 | 1355 | } |
| 1295 | 1356 | |
| 1296 | −static bool | |
| 1297 | −ff_layout_device_unavailable(struct pnfs_layout_segment *lseg, int idx) | |
| 1298 | −{ | |
| 1299 | − /* No mirroring for now */ | |
| 1300 | − struct nfs4_deviceid_node *node = FF_LAYOUT_DEVID_NODE(lseg, idx); | |
| 1301 | − | |
| 1302 | − return ff_layout_test_devid_unavailable(node); | |
| 1303 | −} | |
| 1304 | − | |
| 1305 | 1357 | static void ff_layout_read_record_layoutstats_start(struct rpc_task *task, |
| 1306 | 1358 | struct nfs_pgio_header *hdr) |
| 1307 | 1359 | { |
| @@ -1332,10 +1384,6 @@ static int ff_layout_read_prepare_common(struct rpc_task *task, · 24 unmodified lines | ||
| 1332 | 1384 | rpc_exit(task, -EIO); |
| 1333 | 1385 | return -EIO; |
| 1334 | 1386 | } |
| 1335 | − if (ff_layout_device_unavailable(hdr->lseg, hdr->pgio_mirror_idx)) { | |
| 1336 | − rpc_exit(task, -EHOSTDOWN); | |
| 1337 | − return -EAGAIN; | |
| 1338 | − } | |
| 1339 | 1387 | |
| 1340 | 1388 | ff_layout_read_record_layoutstats_start(task, hdr); |
| 1341 | 1389 | return 0; |
| @@ -1369,6 +1417,16 @@ static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data) · 27 unmodified lines | ||
| 1369 | 1417 | ff_layout_read_prepare_common(task, hdr); |
| 1370 | 1418 | } |
| 1371 | 1419 | |
| 1420 | +static void | |
| 1421 | +ff_layout_io_prepare_transmit(struct rpc_task *task, | |
| 1422 | + void *data) | |
| 1423 | +{ | |
| 1424 | + struct nfs_pgio_header *hdr = data; | |
| 1425 | + | |
| 1426 | + if (!pnfs_is_valid_lseg(hdr->lseg)) | |
| 1427 | + rpc_exit(task, -EAGAIN); | |
| 1428 | +} | |
| 1429 | + | |
| 1372 | 1430 | static void ff_layout_read_call_done(struct rpc_task *task, void *data) |
| 1373 | 1431 | { |
| 1374 | 1432 | struct nfs_pgio_header *hdr = data; |
| @@ -1399,9 +1457,10 @@ static void ff_layout_read_release(void *data) · 24 unmodified lines | ||
| 1399 | 1457 | struct nfs_pgio_header *hdr = data; |
| 1400 | 1458 | |
| 1401 | 1459 | ff_layout_read_record_layoutstats_done(&hdr->task, hdr); |
| 1402 | − if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags)) | |
| 1460 | + if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags)) { | |
| 1461 | + ff_layout_send_layouterror(hdr->lseg); | |
| 1403 | 1462 | pnfs_read_resend_pnfs(hdr); |
| 1404 | − else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags)) | |
| 1463 | + } else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags)) | |
| 1405 | 1464 | ff_layout_reset_read(hdr); |
| 1406 | 1465 | pnfs_generic_rw_release(data); |
| 1407 | 1466 | } |
| @@ -1513,11 +1572,6 @@ static int ff_layout_write_prepare_common(struct rpc_task *task, · 105 unmodified lines | ||
| 1513 | 1572 | return -EIO; |
| 1514 | 1573 | } |
| 1515 | 1574 | |
| 1516 | − if (ff_layout_device_unavailable(hdr->lseg, hdr->pgio_mirror_idx)) { | |
| 1517 | − rpc_exit(task, -EHOSTDOWN); | |
| 1518 | − return -EAGAIN; | |
| 1519 | − } | |
| 1520 | − | |
| 1521 | 1575 | ff_layout_write_record_layoutstats_start(task, hdr); |
| 1522 | 1576 | return 0; |
| 1523 | 1577 | } |
| @@ -1573,9 +1627,10 @@ static void ff_layout_write_release(void *data) · 49 unmodified lines | ||
| 1573 | 1627 | struct nfs_pgio_header *hdr = data; |
| 1574 | 1628 | |
| 1575 | 1629 | ff_layout_write_record_layoutstats_done(&hdr->task, hdr); |
| 1576 | − if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags)) | |
| 1630 | + if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags)) { | |
| 1631 | + ff_layout_send_layouterror(hdr->lseg); | |
| 1577 | 1632 | ff_layout_reset_write(hdr, true); |
| 1578 | − else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags)) | |
| 1633 | + } else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags)) | |
| 1579 | 1634 | ff_layout_reset_write(hdr, false); |
| 1580 | 1635 | pnfs_generic_rw_release(data); |
| 1581 | 1636 | } |
| @@ -1657,6 +1712,7 @@ static void ff_layout_commit_release(void *data) · 75 unmodified lines | ||
| 1657 | 1712 | |
| 1658 | 1713 | static const struct rpc_call_ops ff_layout_read_call_ops_v3 = { |
| 1659 | 1714 | .rpc_call_prepare = ff_layout_read_prepare_v3, |
| 1715 | + .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit, | |
| 1660 | 1716 | .rpc_call_done = ff_layout_read_call_done, |
| 1661 | 1717 | .rpc_count_stats = ff_layout_read_count_stats, |
| 1662 | 1718 | .rpc_release = ff_layout_read_release, |
| @@ -1664,6 +1720,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v3 = { · 1 unmodified line | ||
| 1664 | 1720 | |
| 1665 | 1721 | static const struct rpc_call_ops ff_layout_read_call_ops_v4 = { |
| 1666 | 1722 | .rpc_call_prepare = ff_layout_read_prepare_v4, |
| 1723 | + .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit, | |
| 1667 | 1724 | .rpc_call_done = ff_layout_read_call_done, |
| 1668 | 1725 | .rpc_count_stats = ff_layout_read_count_stats, |
| 1669 | 1726 | .rpc_release = ff_layout_read_release, |
| @@ -1671,6 +1728,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v4 = { · 1 unmodified line | ||
| 1671 | 1728 | |
| 1672 | 1729 | static const struct rpc_call_ops ff_layout_write_call_ops_v3 = { |
| 1673 | 1730 | .rpc_call_prepare = ff_layout_write_prepare_v3, |
| 1731 | + .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit, | |
| 1674 | 1732 | .rpc_call_done = ff_layout_write_call_done, |
| 1675 | 1733 | .rpc_count_stats = ff_layout_write_count_stats, |
| 1676 | 1734 | .rpc_release = ff_layout_write_release, |
| @@ -1678,6 +1736,7 @@ static const struct rpc_call_ops ff_layout_write_call_ops_v3 = { · 1 unmodified line | ||
| 1678 | 1736 | |
| 1679 | 1737 | static const struct rpc_call_ops ff_layout_write_call_ops_v4 = { |
| 1680 | 1738 | .rpc_call_prepare = ff_layout_write_prepare_v4, |
| 1739 | + .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit, | |
| 1681 | 1740 | .rpc_call_done = ff_layout_write_call_done, |
| 1682 | 1741 | .rpc_count_stats = ff_layout_write_count_stats, |
| 1683 | 1742 | .rpc_release = ff_layout_write_release, |
| @@ -1703,6 +1762,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) · 19 unmodified lines | ||
| 1703 | 1762 | struct pnfs_layout_segment *lseg = hdr->lseg; |
| 1704 | 1763 | struct nfs4_pnfs_ds *ds; |
| 1705 | 1764 | struct rpc_clnt *ds_clnt; |
| 1765 | + struct nfs4_ff_layout_mirror *mirror; | |
| 1706 | 1766 | const struct cred *ds_cred; |
| 1707 | 1767 | loff_t offset = hdr->args.offset; |
| 1708 | 1768 | u32 idx = hdr->pgio_mirror_idx; |
| @@ -1713,20 +1773,21 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) · 4 unmodified lines | ||
| 1713 | 1773 | __func__, hdr->inode->i_ino, |
| 1714 | 1774 | hdr->args.pgbase, (size_t)hdr->args.count, offset); |
| 1715 | 1775 | |
| 1716 | − ds = nfs4_ff_layout_prepare_ds(lseg, idx, false); | |
| 1776 | + mirror = FF_LAYOUT_COMP(lseg, idx); | |
| 1777 | + ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false); | |
| 1717 | 1778 | if (!ds) |
| 1718 | 1779 | goto out_failed; |
| 1719 | 1780 | |
| 1720 | − ds_clnt = nfs4_ff_find_or_create_ds_client(lseg, idx, ds->ds_clp, | |
| 1781 | + ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp, | |
| 1721 | 1782 | hdr->inode); |
| 1722 | 1783 | if (IS_ERR(ds_clnt)) |
| 1723 | 1784 | goto out_failed; |
| 1724 | 1785 | |
| 1725 | − ds_cred = ff_layout_get_ds_cred(lseg, idx, hdr->cred); | |
| 1786 | + ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, hdr->cred); | |
| 1726 | 1787 | if (!ds_cred) |
| 1727 | 1788 | goto out_failed; |
| 1728 | 1789 | |
| 1729 | − vers = nfs4_ff_layout_ds_version(lseg, idx); | |
| 1790 | + vers = nfs4_ff_layout_ds_version(mirror); | |
| 1730 | 1791 | |
| 1731 | 1792 | dprintk("%s USE DS: %s cl_count %d vers %d\n", __func__, |
| 1732 | 1793 | ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count), vers); |
| @@ -1734,13 +1795,11 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) · 1 unmodified line | ||
| 1734 | 1795 | hdr->pgio_done_cb = ff_layout_read_done_cb; |
| 1735 | 1796 | refcount_inc(&ds->ds_clp->cl_count); |
| 1736 | 1797 | hdr->ds_clp = ds->ds_clp; |
| 1737 | − fh = nfs4_ff_layout_select_ds_fh(lseg, idx); | |
| 1798 | + fh = nfs4_ff_layout_select_ds_fh(mirror); | |
| 1738 | 1799 | if (fh) |
| 1739 | 1800 | hdr->args.fh = fh; |
| 1740 | 1801 | |
| 1741 | − if (vers == 4 && | |
| 1742 | − !nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) | |
| 1743 | − goto out_failed; | |
| 1802 | + nfs4_ff_layout_select_ds_stateid(mirror, &hdr->args.stateid); | |
| 1744 | 1803 | |
| 1745 | 1804 | /* |
| 1746 | 1805 | * Note that if we ever decide to split across DSes, |
| @@ -1770,26 +1829,28 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync) · 23 unmodified lines | ||
| 1770 | 1829 | struct pnfs_layout_segment *lseg = hdr->lseg; |
| 1771 | 1830 | struct nfs4_pnfs_ds *ds; |
| 1772 | 1831 | struct rpc_clnt *ds_clnt; |
| 1832 | + struct nfs4_ff_layout_mirror *mirror; | |
| 1773 | 1833 | const struct cred *ds_cred; |
| 1774 | 1834 | loff_t offset = hdr->args.offset; |
| 1775 | 1835 | int vers; |
| 1776 | 1836 | struct nfs_fh *fh; |
| 1777 | 1837 | int idx = hdr->pgio_mirror_idx; |
| 1778 | 1838 | |
| 1779 | − ds = nfs4_ff_layout_prepare_ds(lseg, idx, true); | |
| 1839 | + mirror = FF_LAYOUT_COMP(lseg, idx); | |
| 1840 | + ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true); | |
| 1780 | 1841 | if (!ds) |
| 1781 | 1842 | goto out_failed; |
| 1782 | 1843 | |
| 1783 | − ds_clnt = nfs4_ff_find_or_create_ds_client(lseg, idx, ds->ds_clp, | |
| 1844 | + ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp, | |
| 1784 | 1845 | hdr->inode); |
| 1785 | 1846 | if (IS_ERR(ds_clnt)) |
| 1786 | 1847 | goto out_failed; |
| 1787 | 1848 | |
| 1788 | − ds_cred = ff_layout_get_ds_cred(lseg, idx, hdr->cred); | |
| 1849 | + ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, hdr->cred); | |
| 1789 | 1850 | if (!ds_cred) |
| 1790 | 1851 | goto out_failed; |
| 1791 | 1852 | |
| 1792 | − vers = nfs4_ff_layout_ds_version(lseg, idx); | |
| 1853 | + vers = nfs4_ff_layout_ds_version(mirror); | |
| 1793 | 1854 | |
| 1794 | 1855 | dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d vers %d\n", |
| 1795 | 1856 | __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count, |
| @@ -1800,13 +1861,11 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync) · 4 unmodified lines | ||
| 1800 | 1861 | refcount_inc(&ds->ds_clp->cl_count); |
| 1801 | 1862 | hdr->ds_clp = ds->ds_clp; |
| 1802 | 1863 | hdr->ds_commit_idx = idx; |
| 1803 | − fh = nfs4_ff_layout_select_ds_fh(lseg, idx); | |
| 1864 | + fh = nfs4_ff_layout_select_ds_fh(mirror); | |
| 1804 | 1865 | if (fh) |
| 1805 | 1866 | hdr->args.fh = fh; |
| 1806 | 1867 | |
| 1807 | − if (vers == 4 && | |
| 1808 | − !nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) | |
| 1809 | − goto out_failed; | |
| 1868 | + nfs4_ff_layout_select_ds_stateid(mirror, &hdr->args.stateid); | |
| 1810 | 1869 | |
| 1811 | 1870 | /* |
| 1812 | 1871 | * Note that if we ever decide to split across DSes, |
| @@ -1849,6 +1908,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how) · 36 unmodified lines | ||
| 1849 | 1908 | struct pnfs_layout_segment *lseg = data->lseg; |
| 1850 | 1909 | struct nfs4_pnfs_ds *ds; |
| 1851 | 1910 | struct rpc_clnt *ds_clnt; |
| 1911 | + struct nfs4_ff_layout_mirror *mirror; | |
| 1852 | 1912 | const struct cred *ds_cred; |
| 1853 | 1913 | u32 idx; |
| 1854 | 1914 | int vers, ret; |
| @@ -1859,20 +1919,21 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how) · 4 unmodified lines | ||
| 1859 | 1919 | goto out_err; |
| 1860 | 1920 | |
| 1861 | 1921 | idx = calc_ds_index_from_commit(lseg, data->ds_commit_index); |
| 1862 | − ds = nfs4_ff_layout_prepare_ds(lseg, idx, true); | |
| 1922 | + mirror = FF_LAYOUT_COMP(lseg, idx); | |
| 1923 | + ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true); | |
| 1863 | 1924 | if (!ds) |
| 1864 | 1925 | goto out_err; |
| 1865 | 1926 | |
| 1866 | − ds_clnt = nfs4_ff_find_or_create_ds_client(lseg, idx, ds->ds_clp, | |
| 1927 | + ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp, | |
| 1867 | 1928 | data->inode); |
| 1868 | 1929 | if (IS_ERR(ds_clnt)) |
| 1869 | 1930 | goto out_err; |
| 1870 | 1931 | |
| 1871 | − ds_cred = ff_layout_get_ds_cred(lseg, idx, data->cred); | |
| 1932 | + ds_cred = ff_layout_get_ds_cred(mirror, &lseg->pls_range, data->cred); | |
| 1872 | 1933 | if (!ds_cred) |
| 1873 | 1934 | goto out_err; |
| 1874 | 1935 | |
| 1875 | − vers = nfs4_ff_layout_ds_version(lseg, idx); | |
| 1936 | + vers = nfs4_ff_layout_ds_version(mirror); | |
| 1876 | 1937 | |
| 1877 | 1938 | dprintk("%s ino %lu, how %d cl_count %d vers %d\n", __func__, |
| 1878 | 1939 | data->inode->i_ino, how, refcount_read(&ds->ds_clp->cl_count), |
| @@ -2036,7 +2097,7 @@ ff_layout_encode_layoutreturn(struct xdr_stream *xdr, · 157 unmodified lines | ||
| 2036 | 2097 | |
| 2037 | 2098 | dprintk("%s: Begin\n", __func__); |
| 2038 | 2099 | |
| 2039 | − xdr_init_encode(&tmp_xdr, &tmp_buf, NULL); | |
| 2100 | + xdr_init_encode(&tmp_xdr, &tmp_buf, NULL, NULL); | |
| 2040 | 2101 | |
| 2041 | 2102 | ff_layout_encode_ioerr(&tmp_xdr, args, ff_args); |
| 2042 | 2103 | ff_layout_encode_iostats_array(&tmp_xdr, args, ff_args); |
| @@ -2102,6 +2163,52 @@ out_nomem: · 59 unmodified lines | ||
| 2102 | 2163 | return -ENOMEM; |
| 2103 | 2164 | } |
| 2104 | 2165 | |
| 2166 | +#ifdef CONFIG_NFS_V4_2 | |
| 2167 | +void | |
| 2168 | +ff_layout_send_layouterror(struct pnfs_layout_segment *lseg) | |
| 2169 | +{ | |
| 2170 | + struct pnfs_layout_hdr *lo = lseg->pls_layout; | |
| 2171 | + struct nfs42_layout_error *errors; | |
| 2172 | + LIST_HEAD(head); | |
| 2173 | + | |
| 2174 | + if (!nfs_server_capable(lo->plh_inode, NFS_CAP_LAYOUTERROR)) | |
| 2175 | + return; | |
| 2176 | + ff_layout_fetch_ds_ioerr(lo, &lseg->pls_range, &head, -1); | |
| 2177 | + if (list_empty(&head)) | |
| 2178 | + return; | |
| 2179 | + | |
| 2180 | + errors = kmalloc_array(NFS42_LAYOUTERROR_MAX, | |
| 2181 | + sizeof(*errors), GFP_NOFS); | |
| 2182 | + if (errors != NULL) { | |
| 2183 | + const struct nfs4_ff_layout_ds_err *pos; | |
| 2184 | + size_t n = 0; | |
| 2185 | + | |
| 2186 | + list_for_each_entry(pos, &head, list) { | |
| 2187 | + errors[n].offset = pos->offset; | |
| 2188 | + errors[n].length = pos->length; | |
| 2189 | + nfs4_stateid_copy(&errors[n].stateid, &pos->stateid); | |
| 2190 | + errors[n].errors[0].dev_id = pos->deviceid; | |
| 2191 | + errors[n].errors[0].status = pos->status; | |
| 2192 | + errors[n].errors[0].opnum = pos->opnum; | |
| 2193 | + n++; | |
| 2194 | + if (!list_is_last(&pos->list, &head) && | |
| 2195 | + n < NFS42_LAYOUTERROR_MAX) | |
| 2196 | + continue; | |
| 2197 | + if (nfs42_proc_layouterror(lseg, errors, n) < 0) | |
| 2198 | + break; | |
| 2199 | + n = 0; | |
| 2200 | + } | |
| 2201 | + kfree(errors); | |
| 2202 | + } | |
| 2203 | + ff_layout_free_ds_ioerr(&head); | |
| 2204 | +} | |
| 2205 | +#else | |
| 2206 | +void | |
| 2207 | +ff_layout_send_layouterror(struct pnfs_layout_segment *lseg) | |
| 2208 | +{ | |
| 2209 | +} | |
| 2210 | +#endif | |
| 2211 | + | |
| 2105 | 2212 | static int |
| 2106 | 2213 | ff_layout_ntop4(const struct sockaddr *sap, char *buf, const size_t buflen) |
| 2107 | 2214 | { |
| @@ -132,16 +132,6 @@ FF_LAYOUT_LSEG(struct pnfs_layout_segment *lseg) · 131 unmodified lines | ||
| 132 | 132 | generic_hdr); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | −static inline struct nfs4_deviceid_node * | |
| 136 | −FF_LAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg, u32 idx) | |
| 137 | −{ | |
| 138 | − if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt || | |
| 139 | − FF_LAYOUT_LSEG(lseg)->mirror_array[idx] == NULL || | |
| 140 | − FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds == NULL) | |
| 141 | − return NULL; | |
| 142 | − return &FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds->id_node; | |
| 143 | −} | |
| 144 | − | |
| 145 | 135 | static inline struct nfs4_ff_layout_ds * |
| 146 | 136 | FF_LAYOUT_MIRROR_DS(struct nfs4_deviceid_node *node) |
| 147 | 137 | { |
| @@ -151,9 +141,25 @@ FF_LAYOUT_MIRROR_DS(struct nfs4_deviceid_node *node) · 3 unmodified lines | ||
| 151 | 141 | static inline struct nfs4_ff_layout_mirror * |
| 152 | 142 | FF_LAYOUT_COMP(struct pnfs_layout_segment *lseg, u32 idx) |
| 153 | 143 | { |
| 154 | − if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt) | |
| 155 | − return NULL; | |
| 156 | − return FF_LAYOUT_LSEG(lseg)->mirror_array[idx]; | |
| 144 | + struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); | |
| 145 | + | |
| 146 | + if (idx < fls->mirror_array_cnt) | |
| 147 | + return fls->mirror_array[idx]; | |
| 148 | + return NULL; | |
| 149 | +} | |
| 150 | + | |
| 151 | +static inline struct nfs4_deviceid_node * | |
| 152 | +FF_LAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg, u32 idx) | |
| 153 | +{ | |
| 154 | + struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, idx); | |
| 155 | + | |
| 156 | + if (mirror != NULL) { | |
| 157 | + struct nfs4_ff_layout_ds *mirror_ds = mirror->mirror_ds; | |
| 158 | + | |
| 159 | + if (!IS_ERR_OR_NULL(mirror_ds)) | |
| 160 | + return &mirror_ds->id_node; | |
| 161 | + } | |
| 162 | + return NULL; | |
| 157 | 163 | } |
| 158 | 164 | |
| 159 | 165 | static inline u32 |
| @@ -174,28 +180,10 @@ ff_layout_no_read_on_rw(struct pnfs_layout_segment *lseg) · 14 unmodified lines | ||
| 174 | 180 | return FF_LAYOUT_LSEG(lseg)->flags & FF_FLAGS_NO_READ_IO; |
| 175 | 181 | } |
| 176 | 182 | |
| 177 | −static inline bool | |
| 178 | −ff_layout_test_devid_unavailable(struct nfs4_deviceid_node *node) | |
| 179 | −{ | |
| 180 | − /* | |
| 181 | − * Flexfiles should never mark a DS unavailable, but if it does | |
| 182 | − * print a (ratelimited) warning as this can affect performance. | |
| 183 | − */ | |
| 184 | − if (nfs4_test_deviceid_unavailable(node)) { | |
| 185 | − u32 *p = (u32 *)node->deviceid.data; | |
| 186 | − | |
| 187 | − pr_warn_ratelimited("NFS: flexfiles layout referencing an " | |
| 188 | − "unavailable device [%x%x%x%x]\n", | |
| 189 | − p[0], p[1], p[2], p[3]); | |
| 190 | − return true; | |
| 191 | − } | |
| 192 | − return false; | |
| 193 | −} | |
| 194 | − | |
| 195 | 183 | static inline int |
| 196 | −nfs4_ff_layout_ds_version(struct pnfs_layout_segment *lseg, u32 ds_idx) | |
| 184 | +nfs4_ff_layout_ds_version(const struct nfs4_ff_layout_mirror *mirror) | |
| 197 | 185 | { |
| 198 | − return FF_LAYOUT_COMP(lseg, ds_idx)->mirror_ds->ds_versions[0].version; | |
| 186 | + return mirror->mirror_ds->ds_versions[0].version; | |
| 199 | 187 | } |
| 200 | 188 | |
| 201 | 189 | struct nfs4_ff_layout_ds * |
| @@ -207,6 +195,7 @@ int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo, · 5 unmodified lines | ||
| 207 | 195 | struct nfs4_ff_layout_mirror *mirror, u64 offset, |
| 208 | 196 | u64 length, int status, enum nfs_opnum4 opnum, |
| 209 | 197 | gfp_t gfp_flags); |
| 198 | +void ff_layout_send_layouterror(struct pnfs_layout_segment *lseg); | |
| 210 | 199 | int ff_layout_encode_ds_ioerr(struct xdr_stream *xdr, const struct list_head *head); |
| 211 | 200 | void ff_layout_free_ds_ioerr(struct list_head *head); |
| 212 | 201 | unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo, |
| @@ -214,23 +203,23 @@ unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo, · 1 unmodified line | ||
| 214 | 203 | struct list_head *head, |
| 215 | 204 | unsigned int maxnum); |
| 216 | 205 | struct nfs_fh * |
| 217 | −nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx); | |
| 218 | −int | |
| 219 | −nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, | |
| 220 | − u32 mirror_idx, | |
| 221 | − nfs4_stateid *stateid); | |
| 206 | +nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror); | |
| 207 | +void | |
| 208 | +nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror, | |
| 209 | + nfs4_stateid *stateid); | |
| 222 | 210 | |
| 223 | 211 | struct nfs4_pnfs_ds * |
| 224 | −nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, | |
| 212 | +nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, | |
| 213 | + struct nfs4_ff_layout_mirror *mirror, | |
| 225 | 214 | bool fail_return); |
| 226 | 215 | |
| 227 | 216 | struct rpc_clnt * |
| 228 | −nfs4_ff_find_or_create_ds_client(struct pnfs_layout_segment *lseg, | |
| 229 | − u32 ds_idx, | |
| 217 | +nfs4_ff_find_or_create_ds_client(struct nfs4_ff_layout_mirror *mirror, | |
| 230 | 218 | struct nfs_client *ds_clp, |
| 231 | 219 | struct inode *inode); |
| 232 | −const struct cred *ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, | |
| 233 | − u32 ds_idx, const struct cred *mdscred); | |
| 220 | +const struct cred *ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror, | |
| 221 | + const struct pnfs_layout_range *range, | |
| 222 | + const struct cred *mdscred); | |
| 234 | 223 | bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment *lseg); |
| 235 | 224 | bool ff_layout_avoid_read_on_rw(struct pnfs_layout_segment *lseg); |
| 236 | 225 | |
| @@ -183,56 +183,6 @@ out_err: · 182 unmodified lines | ||
| 183 | 183 | return NULL; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | −static void ff_layout_mark_devid_invalid(struct pnfs_layout_segment *lseg, | |
| 187 | − struct nfs4_deviceid_node *devid) | |
| 188 | −{ | |
| 189 | − nfs4_delete_deviceid(devid->ld, devid->nfs_client, &devid->deviceid); | |
| 190 | − if (!ff_layout_has_available_ds(lseg)) | |
| 191 | − pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode, | |
| 192 | − lseg); | |
| 193 | −} | |
| 194 | − | |
| 195 | −static bool ff_layout_mirror_valid(struct pnfs_layout_segment *lseg, | |
| 196 | − struct nfs4_ff_layout_mirror *mirror, | |
| 197 | − bool create) | |
| 198 | −{ | |
| 199 | − if (mirror == NULL || IS_ERR(mirror->mirror_ds)) | |
| 200 | − goto outerr; | |
| 201 | − if (mirror->mirror_ds == NULL) { | |
| 202 | − if (create) { | |
| 203 | − struct nfs4_deviceid_node *node; | |
| 204 | − struct pnfs_layout_hdr *lh = lseg->pls_layout; | |
| 205 | − struct nfs4_ff_layout_ds *mirror_ds = ERR_PTR(-ENODEV); | |
| 206 | − | |
| 207 | − node = nfs4_find_get_deviceid(NFS_SERVER(lh->plh_inode), | |
| 208 | − &mirror->devid, lh->plh_lc_cred, | |
| 209 | − GFP_KERNEL); | |
| 210 | − if (node) | |
| 211 | − mirror_ds = FF_LAYOUT_MIRROR_DS(node); | |
| 212 | − | |
| 213 | − /* check for race with another call to this function */ | |
| 214 | − if (cmpxchg(&mirror->mirror_ds, NULL, mirror_ds) && | |
| 215 | − mirror_ds != ERR_PTR(-ENODEV)) | |
| 216 | − nfs4_put_deviceid_node(node); | |
| 217 | − } else | |
| 218 | − goto outerr; | |
| 219 | − } | |
| 220 | − | |
| 221 | − if (IS_ERR(mirror->mirror_ds)) | |
| 222 | − goto outerr; | |
| 223 | − | |
| 224 | − if (mirror->mirror_ds->ds == NULL) { | |
| 225 | − struct nfs4_deviceid_node *devid; | |
| 226 | − devid = &mirror->mirror_ds->id_node; | |
| 227 | − ff_layout_mark_devid_invalid(lseg, devid); | |
| 228 | − return false; | |
| 229 | − } | |
| 230 | − return true; | |
| 231 | −outerr: | |
| 232 | − pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode, lseg); | |
| 233 | − return false; | |
| 234 | −} | |
| 235 | − | |
| 236 | 186 | static void extend_ds_error(struct nfs4_ff_layout_ds_err *err, |
| 237 | 187 | u64 offset, u64 length) |
| 238 | 188 | { |
| @@ -326,7 +276,6 @@ int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo, · 87 unmodified lines | ||
| 326 | 276 | spin_lock(&flo->generic_hdr.plh_inode->i_lock); |
| 327 | 277 | ff_layout_add_ds_error_locked(flo, dserr); |
| 328 | 278 | spin_unlock(&flo->generic_hdr.plh_inode->i_lock); |
| 329 | − | |
| 330 | 279 | return 0; |
| 331 | 280 | } |
| 332 | 281 | |
| @@ -353,46 +302,54 @@ ff_layout_get_mirror_cred(struct nfs4_ff_layout_mirror *mirror, u32 iomode) · 20 unmodified lines | ||
| 353 | 302 | } |
| 354 | 303 | |
| 355 | 304 | struct nfs_fh * |
| 356 | −nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx) | |
| 305 | +nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror) | |
| 357 | 306 | { |
| 358 | − struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx); | |
| 359 | − struct nfs_fh *fh = NULL; | |
| 360 | − | |
| 361 | − if (!ff_layout_mirror_valid(lseg, mirror, false)) { | |
| 362 | − pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n", | |
| 363 | − __func__, mirror_idx); | |
| 364 | − goto out; | |
| 365 | − } | |
| 366 | − | |
| 367 | 307 | /* FIXME: For now assume there is only 1 version available for the DS */ |
| 368 | − fh = &mirror->fh_versions[0]; | |
| 369 | −out: | |
| 370 | − return fh; | |
| 308 | + return &mirror->fh_versions[0]; | |
| 371 | 309 | } |
| 372 | 310 | |
| 373 | −int | |
| 374 | −nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, | |
| 375 | − u32 mirror_idx, | |
| 376 | − nfs4_stateid *stateid) | |
| 311 | +void | |
| 312 | +nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror, | |
| 313 | + nfs4_stateid *stateid) | |
| 377 | 314 | { |
| 378 | − struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx); | |
| 315 | + if (nfs4_ff_layout_ds_version(mirror) == 4) | |
| 316 | + nfs4_stateid_copy(stateid, &mirror->stateid); | |
| 317 | +} | |
| 379 | 318 | |
| 380 | − if (!ff_layout_mirror_valid(lseg, mirror, false)) { | |
| 381 | − pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n", | |
| 382 | − __func__, mirror_idx); | |
| 383 | − goto out; | |
| 319 | +static bool | |
| 320 | +ff_layout_init_mirror_ds(struct pnfs_layout_hdr *lo, | |
| 321 | + struct nfs4_ff_layout_mirror *mirror) | |
| 322 | +{ | |
| 323 | + if (mirror == NULL) | |
| 324 | + goto outerr; | |
| 325 | + if (mirror->mirror_ds == NULL) { | |
| 326 | + struct nfs4_deviceid_node *node; | |
| 327 | + struct nfs4_ff_layout_ds *mirror_ds = ERR_PTR(-ENODEV); | |
| 328 | + | |
| 329 | + node = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), | |
| 330 | + &mirror->devid, lo->plh_lc_cred, | |
| 331 | + GFP_KERNEL); | |
| 332 | + if (node) | |
| 333 | + mirror_ds = FF_LAYOUT_MIRROR_DS(node); | |
| 334 | + | |
| 335 | + /* check for race with another call to this function */ | |
| 336 | + if (cmpxchg(&mirror->mirror_ds, NULL, mirror_ds) && | |
| 337 | + mirror_ds != ERR_PTR(-ENODEV)) | |
| 338 | + nfs4_put_deviceid_node(node); | |
| 384 | 339 | } |
| 385 | 340 | |
| 386 | − nfs4_stateid_copy(stateid, &mirror->stateid); | |
| 387 | − return 1; | |
| 388 | −out: | |
| 389 | − return 0; | |
| 341 | + if (IS_ERR(mirror->mirror_ds)) | |
| 342 | + goto outerr; | |
| 343 | + | |
| 344 | + return true; | |
| 345 | +outerr: | |
| 346 | + return false; | |
| 390 | 347 | } |
| 391 | 348 | |
| 392 | 349 | /** |
| 393 | 350 | * nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call |
| 394 | 351 | * @lseg: the layout segment we're operating on |
| 395 | − * @ds_idx: index of the DS to use | |
| 352 | + * @mirror: layout mirror describing the DS to use | |
| 396 | 353 | * @fail_return: return layout on connect failure? |
| 397 | 354 | * |
| 398 | 355 | * Try to prepare a DS connection to accept an RPC call. This involves |
| @@ -407,26 +364,18 @@ out: · 8 unmodified lines | ||
| 407 | 364 | * Returns a pointer to a connected DS object on success or NULL on failure. |
| 408 | 365 | */ |
| 409 | 366 | struct nfs4_pnfs_ds * |
| 410 | −nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, | |
| 367 | +nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, | |
| 368 | + struct nfs4_ff_layout_mirror *mirror, | |
| 411 | 369 | bool fail_return) |
| 412 | 370 | { |
| 413 | − struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx); | |
| 414 | 371 | struct nfs4_pnfs_ds *ds = NULL; |
| 415 | − struct nfs4_deviceid_node *devid; | |
| 416 | 372 | struct inode *ino = lseg->pls_layout->plh_inode; |
| 417 | 373 | struct nfs_server *s = NFS_SERVER(ino); |
| 418 | 374 | unsigned int max_payload; |
| 419 | 375 | int status; |
| 420 | 376 | |
| 421 | − if (!ff_layout_mirror_valid(lseg, mirror, true)) { | |
| 422 | − pr_err_ratelimited("NFS: %s: No data server for offset index %d\n", | |
| 423 | − __func__, ds_idx); | |
| 424 | − goto out; | |
| 425 | − } | |
| 426 | − | |
| 427 | − devid = &mirror->mirror_ds->id_node; | |
| 428 | − if (ff_layout_test_devid_unavailable(devid)) | |
| 429 | − goto out_fail; | |
| 377 | + if (!ff_layout_init_mirror_ds(lseg->pls_layout, mirror)) | |
| 378 | + goto noconnect; | |
| 430 | 379 | |
| 431 | 380 | ds = mirror->mirror_ds->ds; |
| 432 | 381 | /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */ |
| @@ -437,8 +386,8 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, · 4 unmodified lines | ||
| 437 | 386 | /* FIXME: For now we assume the server sent only one version of NFS |
| 438 | 387 | * to use for the DS. |
| 439 | 388 | */ |
| 440 | − status = nfs4_pnfs_ds_connect(s, ds, devid, dataserver_timeo, | |
| 441 | − dataserver_retrans, | |
| 389 | + status = nfs4_pnfs_ds_connect(s, ds, &mirror->mirror_ds->id_node, | |
| 390 | + dataserver_timeo, dataserver_retrans, | |
| 442 | 391 | mirror->mirror_ds->ds_versions[0].version, |
| 443 | 392 | mirror->mirror_ds->ds_versions[0].minor_version); |
| 444 | 393 | |
| @@ -453,11 +402,12 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, · 8 unmodified lines | ||
| 453 | 402 | mirror->mirror_ds->ds_versions[0].wsize = max_payload; |
| 454 | 403 | goto out; |
| 455 | 404 | } |
| 456 | −out_fail: | |
| 405 | +noconnect: | |
| 457 | 406 | ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), |
| 458 | 407 | mirror, lseg->pls_range.offset, |
| 459 | 408 | lseg->pls_range.length, NFS4ERR_NXIO, |
| 460 | 409 | OP_ILLEGAL, GFP_NOIO); |
| 410 | + ff_layout_send_layouterror(lseg); | |
| 461 | 411 | if (fail_return || !ff_layout_has_available_ds(lseg)) |
| 462 | 412 | pnfs_error_mark_layout_for_return(ino, lseg); |
| 463 | 413 | ds = NULL; |
| @@ -466,14 +416,14 @@ out: · 2 unmodified lines | ||
| 466 | 416 | } |
| 467 | 417 | |
| 468 | 418 | const struct cred * |
| 469 | −ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, u32 ds_idx, | |
| 419 | +ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror, | |
| 420 | + const struct pnfs_layout_range *range, | |
| 470 | 421 | const struct cred *mdscred) |
| 471 | 422 | { |
| 472 | − struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx); | |
| 473 | 423 | const struct cred *cred; |
| 474 | 424 | |
| 475 | 425 | if (mirror && !mirror->mirror_ds->ds_versions[0].tightly_coupled) { |
| 476 | − cred = ff_layout_get_mirror_cred(mirror, lseg->pls_range.iomode); | |
| 426 | + cred = ff_layout_get_mirror_cred(mirror, range->iomode); | |
| 477 | 427 | if (!cred) |
| 478 | 428 | cred = get_cred(mdscred); |
| 479 | 429 | } else { |
| @@ -483,15 +433,18 @@ ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, u32 ds_idx, · 3 unmodified lines | ||
| 483 | 433 | } |
| 484 | 434 | |
| 485 | 435 | /** |
| 486 | −* Find or create a DS rpc client with th MDS server rpc client auth flavor | |
| 487 | −* in the nfs_client cl_ds_clients list. | |
| 488 | −*/ | |
| 436 | + * nfs4_ff_find_or_create_ds_client - Find or create a DS rpc client | |
| 437 | + * @mirror: pointer to the mirror | |
| 438 | + * @ds_clp: nfs_client for the DS | |
| 439 | + * @inode: pointer to inode | |
| 440 | + * | |
| 441 | + * Find or create a DS rpc client with th MDS server rpc client auth flavor | |
| 442 | + * in the nfs_client cl_ds_clients list. | |
| 443 | + */ | |
| 489 | 444 | struct rpc_clnt * |
| 490 | −nfs4_ff_find_or_create_ds_client(struct pnfs_layout_segment *lseg, u32 ds_idx, | |
| 445 | +nfs4_ff_find_or_create_ds_client(struct nfs4_ff_layout_mirror *mirror, | |
| 491 | 446 | struct nfs_client *ds_clp, struct inode *inode) |
| 492 | 447 | { |
| 493 | − struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx); | |
| 494 | − | |
| 495 | 448 | switch (mirror->mirror_ds->ds_versions[0].version) { |
| 496 | 449 | case 3: |
| 497 | 450 | /* For NFSv3 DS, flavor is set when creating DS connections */ |
| @@ -608,7 +561,7 @@ static bool ff_read_layout_has_available_ds(struct pnfs_layout_segment *lseg) · 110 unmodified lines | ||
| 608 | 561 | if (IS_ERR(mirror->mirror_ds)) |
| 609 | 562 | continue; |
| 610 | 563 | devid = &mirror->mirror_ds->id_node; |
| 611 | − if (!ff_layout_test_devid_unavailable(devid)) | |
| 564 | + if (!nfs4_test_deviceid_unavailable(devid)) | |
| 612 | 565 | return true; |
| 613 | 566 | } |
| 614 | 567 | } |
| @@ -629,7 +582,7 @@ static bool ff_rw_layout_has_available_ds(struct pnfs_layout_segment *lseg) · 14 unmodified lines | ||
| 629 | 582 | if (!mirror->mirror_ds) |
| 630 | 583 | continue; |
| 631 | 584 | devid = &mirror->mirror_ds->id_node; |
| 632 | − if (ff_layout_test_devid_unavailable(devid)) | |
| 585 | + if (nfs4_test_deviceid_unavailable(devid)) | |
| 633 | 586 | return false; |
| 634 | 587 | } |
| 635 | 588 | |
| @@ -143,6 +143,7 @@ EXPORT_SYMBOL_GPL(nfs_sync_inode); · 142 unmodified lines | ||
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * nfs_sync_mapping - helper to flush all mmapped dirty data to disk |
| 146 | + * @mapping: pointer to struct address_space | |
| 146 | 147 | */ |
| 147 | 148 | int nfs_sync_mapping(struct address_space *mapping) |
| 148 | 149 | { |
| @@ -1184,8 +1185,8 @@ int nfs_attribute_cache_expired(struct inode *inode) · 1035 unmodified lines | ||
| 1184 | 1185 | |
| 1185 | 1186 | /** |
| 1186 | 1187 | * nfs_revalidate_inode - Revalidate the inode attributes |
| 1187 | − * @server - pointer to nfs_server struct | |
| 1188 | − * @inode - pointer to inode struct | |
| 1188 | + * @server: pointer to nfs_server struct | |
| 1189 | + * @inode: pointer to inode struct | |
| 1189 | 1190 | * |
| 1190 | 1191 | * Updates inode attribute information by retrieving the data from the server. |
| 1191 | 1192 | */ |
| @@ -1255,8 +1256,8 @@ out: · 63 unmodified lines | ||
| 1255 | 1256 | |
| 1256 | 1257 | /** |
| 1257 | 1258 | * nfs_revalidate_mapping - Revalidate the pagecache |
| 1258 | − * @inode - pointer to host inode | |
| 1259 | − * @mapping - pointer to mapping | |
| 1259 | + * @inode: pointer to host inode | |
| 1260 | + * @mapping: pointer to mapping | |
| 1260 | 1261 | */ |
| 1261 | 1262 | int nfs_revalidate_mapping(struct inode *inode, |
| 1262 | 1263 | struct address_space *mapping) |
| @@ -1371,8 +1372,8 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) · 108 unmodified lines | ||
| 1371 | 1372 | |
| 1372 | 1373 | /** |
| 1373 | 1374 | * nfs_check_inode_attributes - verify consistency of the inode attribute cache |
| 1374 | − * @inode - pointer to inode | |
| 1375 | − * @fattr - updated attributes | |
| 1375 | + * @inode: pointer to inode | |
| 1376 | + * @fattr: updated attributes | |
| 1376 | 1377 | * |
| 1377 | 1378 | * Verifies the attribute cache. If we have just changed the attributes, |
| 1378 | 1379 | * so that fattr carries weak cache consistency data, then it may |
| @@ -1572,8 +1573,8 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle); · 193 unmodified lines | ||
| 1572 | 1573 | |
| 1573 | 1574 | /** |
| 1574 | 1575 | * nfs_inode_attrs_need_update - check if the inode attributes need updating |
| 1575 | − * @inode - pointer to inode | |
| 1576 | − * @fattr - attributes | |
| 1576 | + * @inode: pointer to inode | |
| 1577 | + * @fattr: attributes | |
| 1577 | 1578 | * |
| 1578 | 1579 | * Attempt to divine whether or not an RPC call reply carrying stale |
| 1579 | 1580 | * attributes got scheduled after another call carrying updated ones. |
| @@ -1614,8 +1615,8 @@ static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr · 34 unmodified lines | ||
| 1614 | 1615 | |
| 1615 | 1616 | /** |
| 1616 | 1617 | * nfs_refresh_inode - try to update the inode attribute cache |
| 1617 | − * @inode - pointer to inode | |
| 1618 | − * @fattr - updated attributes | |
| 1618 | + * @inode: pointer to inode | |
| 1619 | + * @fattr: updated attributes | |
| 1619 | 1620 | * |
| 1620 | 1621 | * Check that an RPC call that returned attributes has not overlapped with |
| 1621 | 1622 | * other recent updates of the inode metadata, then decide whether it is |
| @@ -1649,8 +1650,8 @@ static int nfs_post_op_update_inode_locked(struct inode *inode, · 27 unmodified lines | ||
| 1649 | 1650 | |
| 1650 | 1651 | /** |
| 1651 | 1652 | * nfs_post_op_update_inode - try to update the inode attribute cache |
| 1652 | − * @inode - pointer to inode | |
| 1653 | − * @fattr - updated attributes | |
| 1653 | + * @inode: pointer to inode | |
| 1654 | + * @fattr: updated attributes | |
| 1654 | 1655 | * |
| 1655 | 1656 | * After an operation that has changed the inode metadata, mark the |
| 1656 | 1657 | * attribute cache as being invalid, then try to update it. |
| @@ -1679,8 +1680,8 @@ EXPORT_SYMBOL_GPL(nfs_post_op_update_inode); · 22 unmodified lines | ||
| 1679 | 1680 | |
| 1680 | 1681 | /** |
| 1681 | 1682 | * nfs_post_op_update_inode_force_wcc_locked - update the inode attribute cache |
| 1682 | − * @inode - pointer to inode | |
| 1683 | − * @fattr - updated attributes | |
| 1683 | + * @inode: pointer to inode | |
| 1684 | + * @fattr: updated attributes | |
| 1684 | 1685 | * |
| 1685 | 1686 | * After an operation that has changed the inode metadata, mark the |
| 1686 | 1687 | * attribute cache as being invalid, then try to update it. Fake up |
| @@ -1731,8 +1732,8 @@ out_noforce: · 44 unmodified lines | ||
| 1731 | 1732 | |
| 1732 | 1733 | /** |
| 1733 | 1734 | * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache |
| 1734 | − * @inode - pointer to inode | |
| 1735 | − * @fattr - updated attributes | |
| 1735 | + * @inode: pointer to inode | |
| 1736 | + * @fattr: updated attributes | |
| 1736 | 1737 | * |
| 1737 | 1738 | * After an operation that has changed the inode metadata, mark the |
| 1738 | 1739 | * attribute cache as being invalid, then try to update it. Fake up |
| @@ -69,7 +69,8 @@ struct nfs_clone_mount { · 68 unmodified lines | ||
| 69 | 69 | * Maximum number of pages that readdir can use for creating |
| 70 | 70 | * a vmapped array of pages. |
| 71 | 71 | */ |
| 72 | −#define NFS_MAX_READDIR_PAGES 8 | |
| 72 | +#define NFS_MAX_READDIR_PAGES 64 | |
| 73 | +#define NFS_MAX_READDIR_RAPAGES 8 | |
| 73 | 74 | |
| 74 | 75 | struct nfs_client_initdata { |
| 75 | 76 | unsigned long init_flags; |
| @@ -755,6 +756,7 @@ static inline bool nfs_error_is_fatal(int err) · 679 unmodified lines | ||
| 755 | 756 | { |
| 756 | 757 | switch (err) { |
| 757 | 758 | case -ERESTARTSYS: |
| 759 | + case -EINTR: | |
| 758 | 760 | case -EACCES: |
| 759 | 761 | case -EDQUOT: |
| 760 | 762 | case -EFBIG: |
| @@ -763,6 +765,7 @@ static inline bool nfs_error_is_fatal(int err) · 2 unmodified lines | ||
| 763 | 765 | case -EROFS: |
| 764 | 766 | case -ESTALE: |
| 765 | 767 | case -E2BIG: |
| 768 | + case -ENOMEM: | |
| 766 | 769 | return true; |
| 767 | 770 | default: |
| 768 | 771 | return false; |
| @@ -25,7 +25,7 @@ static void nfs_block_o_direct(struct nfs_inode *nfsi, struct inode *inode) · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * nfs_start_io_read - declare the file is being used for buffered reads |
| 28 | − * @inode - file inode | |
| 28 | + * @inode: file inode | |
| 29 | 29 | * |
| 30 | 30 | * Declare that a buffered read operation is about to start, and ensure |
| 31 | 31 | * that we block all direct I/O. |
| @@ -56,7 +56,7 @@ nfs_start_io_read(struct inode *inode) · 24 unmodified lines | ||
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * nfs_end_io_read - declare that the buffered read operation is done |
| 59 | − * @inode - file inode | |
| 59 | + * @inode: file inode | |
| 60 | 60 | * |
| 61 | 61 | * Declare that a buffered read operation is done, and release the shared |
| 62 | 62 | * lock on inode->i_rwsem. |
| @@ -69,7 +69,7 @@ nfs_end_io_read(struct inode *inode) · 6 unmodified lines | ||
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * nfs_start_io_write - declare the file is being used for buffered writes |
| 72 | − * @inode - file inode | |
| 72 | + * @inode: file inode | |
| 73 | 73 | * |
| 74 | 74 | * Declare that a buffered read operation is about to start, and ensure |
| 75 | 75 | * that we block all direct I/O. |
| @@ -83,7 +83,7 @@ nfs_start_io_write(struct inode *inode) · 7 unmodified lines | ||
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * nfs_end_io_write - declare that the buffered write operation is done |
| 86 | − * @inode - file inode | |
| 86 | + * @inode: file inode | |
| 87 | 87 | * |
| 88 | 88 | * Declare that a buffered write operation is done, and release the |
| 89 | 89 | * lock on inode->i_rwsem. |
| @@ -105,7 +105,7 @@ static void nfs_block_buffered(struct nfs_inode *nfsi, struct inode *inode) · 15 unmodified lines | ||
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * nfs_end_io_direct - declare the file is being used for direct i/o |
| 108 | − * @inode - file inode | |
| 108 | + * @inode: file inode | |
| 109 | 109 | * |
| 110 | 110 | * Declare that a direct I/O operation is about to start, and ensure |
| 111 | 111 | * that we block all buffered I/O. |
| @@ -136,7 +136,7 @@ nfs_start_io_direct(struct inode *inode) · 24 unmodified lines | ||
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * nfs_end_io_direct - declare that the direct i/o operation is done |
| 139 | − * @inode - file inode | |
| 139 | + * @inode: file inode | |
| 140 | 140 | * |
| 141 | 141 | * Declare that a direct I/O operation is done, and release the shared |
| 142 | 142 | * lock on inode->i_rwsem. |
| @@ -221,10 +221,10 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server, · 220 unmodified lines | ||
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * nfs_do_submount - set up mountpoint when crossing a filesystem boundary |
| 224 | − * @dentry - parent directory | |
| 225 | − * @fh - filehandle for new root dentry | |
| 226 | − * @fattr - attributes for new root inode | |
| 227 | − * @authflavor - security flavor to use when performing the mount | |
| 224 | + * @dentry: parent directory | |
| 225 | + * @fh: filehandle for new root dentry | |
| 226 | + * @fattr: attributes for new root inode | |
| 227 | + * @authflavor: security flavor to use when performing the mount | |
| 228 | 228 | * |
| 229 | 229 | */ |
| 230 | 230 | struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh, |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/nfs.h> |
| 23 | 23 | #include <linux/nfs2.h> |
| 24 | 24 | #include <linux/nfs_fs.h> |
| 25 | +#include "nfstrace.h" | |
| 25 | 26 | #include "internal.h" |
| 26 | 27 | |
| 27 | 28 | #define NFSDBG_FACILITY NFSDBG_XDR |
| @@ -55,41 +56,15 @@ · 27 unmodified lines | ||
| 55 | 56 | |
| 56 | 57 | #define NFS_attrstat_sz (1+NFS_fattr_sz) |
| 57 | 58 | #define NFS_diropres_sz (1+NFS_fhandle_sz+NFS_fattr_sz) |
| 58 | −#define NFS_readlinkres_sz (2) | |
| 59 | −#define NFS_readres_sz (1+NFS_fattr_sz+1) | |
| 59 | +#define NFS_readlinkres_sz (2+1) | |
| 60 | +#define NFS_readres_sz (1+NFS_fattr_sz+1+1) | |
| 60 | 61 | #define NFS_writeres_sz (NFS_attrstat_sz) |
| 61 | 62 | #define NFS_stat_sz (1) |
| 62 | −#define NFS_readdirres_sz (1) | |
| 63 | +#define NFS_readdirres_sz (1+1) | |
| 63 | 64 | #define NFS_statfsres_sz (1+NFS_info_sz) |
| 64 | 65 | |
| 65 | 66 | static int nfs_stat_to_errno(enum nfs_stat); |
| 66 | 67 | |
| 67 | −/* | |
| 68 | − * While encoding arguments, set up the reply buffer in advance to | |
| 69 | − * receive reply data directly into the page cache. | |
| 70 | − */ | |
| 71 | −static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, | |
| 72 | − unsigned int base, unsigned int len, | |
| 73 | − unsigned int bufsize) | |
| 74 | −{ | |
| 75 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 76 | − unsigned int replen; | |
| 77 | − | |
| 78 | − replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; | |
| 79 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); | |
| 80 | −} | |
| 81 | − | |
| 82 | −/* | |
| 83 | − * Handle decode buffer overflows out-of-line. | |
| 84 | − */ | |
| 85 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 86 | −{ | |
| 87 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 88 | − "Remaining buffer length is %tu words.\n", | |
| 89 | − func, xdr->end - xdr->p); | |
| 90 | −} | |
| 91 | − | |
| 92 | − | |
| 93 | 68 | /* |
| 94 | 69 | * Encode/decode NFSv2 basic data types |
| 95 | 70 | * |
| @@ -110,8 +85,8 @@ static int decode_nfsdata(struct xdr_stream *xdr, struct nfs_pgio_res *result) · 14 unmodified lines | ||
| 110 | 85 | __be32 *p; |
| 111 | 86 | |
| 112 | 87 | p = xdr_inline_decode(xdr, 4); |
| 113 | − if (unlikely(p == NULL)) | |
| 114 | − goto out_overflow; | |
| 88 | + if (unlikely(!p)) | |
| 89 | + return -EIO; | |
| 115 | 90 | count = be32_to_cpup(p); |
| 116 | 91 | recvd = xdr_read_pages(xdr, count); |
| 117 | 92 | if (unlikely(count > recvd)) |
| @@ -125,9 +100,6 @@ out_cheating: · 7 unmodified lines | ||
| 125 | 100 | "count %u > recvd %u\n", count, recvd); |
| 126 | 101 | count = recvd; |
| 127 | 102 | goto out; |
| 128 | −out_overflow: | |
| 129 | − print_overflow_msg(__func__, xdr); | |
| 130 | − return -EIO; | |
| 131 | 103 | } |
| 132 | 104 | |
| 133 | 105 | /* |
| @@ -157,13 +129,16 @@ static int decode_stat(struct xdr_stream *xdr, enum nfs_stat *status) · 23 unmodified lines | ||
| 157 | 129 | __be32 *p; |
| 158 | 130 | |
| 159 | 131 | p = xdr_inline_decode(xdr, 4); |
| 160 | − if (unlikely(p == NULL)) | |
| 161 | − goto out_overflow; | |
| 132 | + if (unlikely(!p)) | |
| 133 | + return -EIO; | |
| 134 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) | |
| 135 | + goto out_status; | |
| 136 | + *status = 0; | |
| 137 | + return 0; | |
| 138 | +out_status: | |
| 162 | 139 | *status = be32_to_cpup(p); |
| 140 | + trace_nfs_xdr_status((int)*status); | |
| 163 | 141 | return 0; |
| 164 | −out_overflow: | |
| 165 | − print_overflow_msg(__func__, xdr); | |
| 166 | − return -EIO; | |
| 167 | 142 | } |
| 168 | 143 | |
| 169 | 144 | /* |
| @@ -205,14 +180,11 @@ static int decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh) · 35 unmodified lines | ||
| 205 | 180 | __be32 *p; |
| 206 | 181 | |
| 207 | 182 | p = xdr_inline_decode(xdr, NFS2_FHSIZE); |
| 208 | − if (unlikely(p == NULL)) | |
| 209 | − goto out_overflow; | |
| 183 | + if (unlikely(!p)) | |
| 184 | + return -EIO; | |
| 210 | 185 | fh->size = NFS2_FHSIZE; |
| 211 | 186 | memcpy(fh->data, p, NFS2_FHSIZE); |
| 212 | 187 | return 0; |
| 213 | −out_overflow: | |
| 214 | − print_overflow_msg(__func__, xdr); | |
| 215 | − return -EIO; | |
| 216 | 188 | } |
| 217 | 189 | |
| 218 | 190 | /* |
| @@ -282,8 +254,8 @@ static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 63 unmodified lines | ||
| 282 | 254 | __be32 *p; |
| 283 | 255 | |
| 284 | 256 | p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); |
| 285 | − if (unlikely(p == NULL)) | |
| 286 | − goto out_overflow; | |
| 257 | + if (unlikely(!p)) | |
| 258 | + return -EIO; | |
| 287 | 259 | |
| 288 | 260 | fattr->valid |= NFS_ATTR_FATTR_V2; |
| 289 | 261 | |
| @@ -325,9 +297,6 @@ out_uid: · 35 unmodified lines | ||
| 325 | 297 | out_gid: |
| 326 | 298 | dprintk("NFS: returned invalid gid\n"); |
| 327 | 299 | return -EINVAL; |
| 328 | −out_overflow: | |
| 329 | − print_overflow_msg(__func__, xdr); | |
| 330 | − return -EIO; | |
| 331 | 300 | } |
| 332 | 301 | |
| 333 | 302 | /* |
| @@ -416,23 +385,20 @@ static int decode_filename_inline(struct xdr_stream *xdr, · 82 unmodified lines | ||
| 416 | 385 | u32 count; |
| 417 | 386 | |
| 418 | 387 | p = xdr_inline_decode(xdr, 4); |
| 419 | − if (unlikely(p == NULL)) | |
| 420 | − goto out_overflow; | |
| 388 | + if (unlikely(!p)) | |
| 389 | + return -EIO; | |
| 421 | 390 | count = be32_to_cpup(p); |
| 422 | 391 | if (count > NFS3_MAXNAMLEN) |
| 423 | 392 | goto out_nametoolong; |
| 424 | 393 | p = xdr_inline_decode(xdr, count); |
| 425 | − if (unlikely(p == NULL)) | |
| 426 | − goto out_overflow; | |
| 394 | + if (unlikely(!p)) | |
| 395 | + return -EIO; | |
| 427 | 396 | *name = (const char *)p; |
| 428 | 397 | *length = count; |
| 429 | 398 | return 0; |
| 430 | 399 | out_nametoolong: |
| 431 | 400 | dprintk("NFS: returned filename too long: %u\n", count); |
| 432 | 401 | return -ENAMETOOLONG; |
| 433 | −out_overflow: | |
| 434 | − print_overflow_msg(__func__, xdr); | |
| 435 | − return -EIO; | |
| 436 | 402 | } |
| 437 | 403 | |
| 438 | 404 | /* |
| @@ -455,8 +421,8 @@ static int decode_path(struct xdr_stream *xdr) · 16 unmodified lines | ||
| 455 | 421 | __be32 *p; |
| 456 | 422 | |
| 457 | 423 | p = xdr_inline_decode(xdr, 4); |
| 458 | − if (unlikely(p == NULL)) | |
| 459 | − goto out_overflow; | |
| 424 | + if (unlikely(!p)) | |
| 425 | + return -EIO; | |
| 460 | 426 | length = be32_to_cpup(p); |
| 461 | 427 | if (unlikely(length >= xdr->buf->page_len || length > NFS_MAXPATHLEN)) |
| 462 | 428 | goto out_size; |
| @@ -472,9 +438,6 @@ out_cheating: · 9 unmodified lines | ||
| 472 | 438 | dprintk("NFS: server cheating in pathname result: " |
| 473 | 439 | "length %u > received %u\n", length, recvd); |
| 474 | 440 | return -EIO; |
| 475 | −out_overflow: | |
| 476 | − print_overflow_msg(__func__, xdr); | |
| 477 | − return -EIO; | |
| 478 | 441 | } |
| 479 | 442 | |
| 480 | 443 | /* |
| @@ -615,8 +578,8 @@ static void nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req, · 134 unmodified lines | ||
| 615 | 578 | const struct nfs_readlinkargs *args = data; |
| 616 | 579 | |
| 617 | 580 | encode_fhandle(xdr, args->fh); |
| 618 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 619 | − args->pglen, NFS_readlinkres_sz); | |
| 581 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 582 | + args->pglen, NFS_readlinkres_sz); | |
| 620 | 583 | } |
| 621 | 584 | |
| 622 | 585 | /* |
| @@ -651,8 +614,8 @@ static void nfs2_xdr_enc_readargs(struct rpc_rqst *req, · 28 unmodified lines | ||
| 651 | 614 | const struct nfs_pgio_args *args = data; |
| 652 | 615 | |
| 653 | 616 | encode_readargs(xdr, args); |
| 654 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 655 | − args->count, NFS_readres_sz); | |
| 617 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 618 | + args->count, NFS_readres_sz); | |
| 656 | 619 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 657 | 620 | } |
| 658 | 621 | |
| @@ -809,8 +772,8 @@ static void nfs2_xdr_enc_readdirargs(struct rpc_rqst *req, · 150 unmodified lines | ||
| 809 | 772 | const struct nfs_readdirargs *args = data; |
| 810 | 773 | |
| 811 | 774 | encode_readdirargs(xdr, args); |
| 812 | − prepare_reply_buffer(req, args->pages, 0, | |
| 813 | − args->count, NFS_readdirres_sz); | |
| 775 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 776 | + args->count, NFS_readdirres_sz); | |
| 814 | 777 | } |
| 815 | 778 | |
| 816 | 779 | /* |
| @@ -951,12 +914,12 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 134 unmodified lines | ||
| 951 | 914 | int error; |
| 952 | 915 | |
| 953 | 916 | p = xdr_inline_decode(xdr, 4); |
| 954 | − if (unlikely(p == NULL)) | |
| 955 | − goto out_overflow; | |
| 917 | + if (unlikely(!p)) | |
| 918 | + return -EAGAIN; | |
| 956 | 919 | if (*p++ == xdr_zero) { |
| 957 | 920 | p = xdr_inline_decode(xdr, 4); |
| 958 | − if (unlikely(p == NULL)) | |
| 959 | − goto out_overflow; | |
| 921 | + if (unlikely(!p)) | |
| 922 | + return -EAGAIN; | |
| 960 | 923 | if (*p++ == xdr_zero) |
| 961 | 924 | return -EAGAIN; |
| 962 | 925 | entry->eof = 1; |
| @@ -964,8 +927,8 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 1 unmodified line | ||
| 964 | 927 | } |
| 965 | 928 | |
| 966 | 929 | p = xdr_inline_decode(xdr, 4); |
| 967 | − if (unlikely(p == NULL)) | |
| 968 | − goto out_overflow; | |
| 930 | + if (unlikely(!p)) | |
| 931 | + return -EAGAIN; | |
| 969 | 932 | entry->ino = be32_to_cpup(p); |
| 970 | 933 | |
| 971 | 934 | error = decode_filename_inline(xdr, &entry->name, &entry->len); |
| @@ -978,17 +941,13 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 6 unmodified lines | ||
| 978 | 941 | */ |
| 979 | 942 | entry->prev_cookie = entry->cookie; |
| 980 | 943 | p = xdr_inline_decode(xdr, 4); |
| 981 | − if (unlikely(p == NULL)) | |
| 982 | − goto out_overflow; | |
| 944 | + if (unlikely(!p)) | |
| 945 | + return -EAGAIN; | |
| 983 | 946 | entry->cookie = be32_to_cpup(p); |
| 984 | 947 | |
| 985 | 948 | entry->d_type = DT_UNKNOWN; |
| 986 | 949 | |
| 987 | 950 | return 0; |
| 988 | − | |
| 989 | −out_overflow: | |
| 990 | − print_overflow_msg(__func__, xdr); | |
| 991 | − return -EAGAIN; | |
| 992 | 951 | } |
| 993 | 952 | |
| 994 | 953 | /* |
| @@ -1052,17 +1011,14 @@ static int decode_info(struct xdr_stream *xdr, struct nfs2_fsstat *result) · 57 unmodified lines | ||
| 1052 | 1011 | __be32 *p; |
| 1053 | 1012 | |
| 1054 | 1013 | p = xdr_inline_decode(xdr, NFS_info_sz << 2); |
| 1055 | − if (unlikely(p == NULL)) | |
| 1056 | − goto out_overflow; | |
| 1014 | + if (unlikely(!p)) | |
| 1015 | + return -EIO; | |
| 1057 | 1016 | result->tsize = be32_to_cpup(p++); |
| 1058 | 1017 | result->bsize = be32_to_cpup(p++); |
| 1059 | 1018 | result->blocks = be32_to_cpup(p++); |
| 1060 | 1019 | result->bfree = be32_to_cpup(p++); |
| 1061 | 1020 | result->bavail = be32_to_cpup(p); |
| 1062 | 1021 | return 0; |
| 1063 | −out_overflow: | |
| 1064 | − print_overflow_msg(__func__, xdr); | |
| 1065 | − return -EIO; | |
| 1066 | 1022 | } |
| 1067 | 1023 | |
| 1068 | 1024 | static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -222,8 +222,6 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, · 221 unmodified lines | ||
| 222 | 222 | switch (status) { |
| 223 | 223 | case 0: |
| 224 | 224 | status = nfs_refresh_inode(inode, fattr); |
| 225 | − set_cached_acl(inode, ACL_TYPE_ACCESS, acl); | |
| 226 | − set_cached_acl(inode, ACL_TYPE_DEFAULT, dfacl); | |
| 227 | 225 | break; |
| 228 | 226 | case -EPFNOSUPPORT: |
| 229 | 227 | case -EPROTONOSUPPORT: |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <linux/nfs3.h> |
| 22 | 22 | #include <linux/nfs_fs.h> |
| 23 | 23 | #include <linux/nfsacl.h> |
| 24 | +#include "nfstrace.h" | |
| 24 | 25 | #include "internal.h" |
| 25 | 26 | |
| 26 | 27 | #define NFSDBG_FACILITY NFSDBG_XDR |
| @@ -68,13 +69,13 @@ · 41 unmodified lines | ||
| 68 | 69 | #define NFS3_removeres_sz (NFS3_setattrres_sz) |
| 69 | 70 | #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)) |
| 70 | 71 | #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1) |
| 71 | −#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1) | |
| 72 | −#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3) | |
| 72 | +#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1+1) | |
| 73 | +#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3+1) | |
| 73 | 74 | #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4) |
| 74 | 75 | #define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) |
| 75 | 76 | #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz)) |
| 76 | 77 | #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) |
| 77 | −#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2) | |
| 78 | +#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2+1) | |
| 78 | 79 | #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13) |
| 79 | 80 | #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12) |
| 80 | 81 | #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6) |
| @@ -84,7 +85,7 @@ · 3 unmodified lines | ||
| 84 | 85 | #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \ |
| 85 | 86 | XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)) |
| 86 | 87 | #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \ |
| 87 | − XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)) | |
| 88 | + XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)+1) | |
| 88 | 89 | #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz) |
| 89 | 90 | |
| 90 | 91 | static int nfs3_stat_to_errno(enum nfs_stat); |
| @@ -103,32 +104,6 @@ static const umode_t nfs_type2fmt[] = { · 12 unmodified lines | ||
| 103 | 104 | [NF3FIFO] = S_IFIFO, |
| 104 | 105 | }; |
| 105 | 106 | |
| 106 | −/* | |
| 107 | − * While encoding arguments, set up the reply buffer in advance to | |
| 108 | − * receive reply data directly into the page cache. | |
| 109 | − */ | |
| 110 | −static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, | |
| 111 | − unsigned int base, unsigned int len, | |
| 112 | − unsigned int bufsize) | |
| 113 | −{ | |
| 114 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 115 | − unsigned int replen; | |
| 116 | − | |
| 117 | − replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; | |
| 118 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); | |
| 119 | −} | |
| 120 | − | |
| 121 | −/* | |
| 122 | − * Handle decode buffer overflows out-of-line. | |
| 123 | − */ | |
| 124 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 125 | −{ | |
| 126 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 127 | − "Remaining buffer length is %tu words.\n", | |
| 128 | − func, xdr->end - xdr->p); | |
| 129 | −} | |
| 130 | − | |
| 131 | − | |
| 132 | 107 | /* |
| 133 | 108 | * Encode/decode NFSv3 basic data types |
| 134 | 109 | * |
| @@ -151,13 +126,10 @@ static int decode_uint32(struct xdr_stream *xdr, u32 *value) · 16 unmodified lines | ||
| 151 | 126 | __be32 *p; |
| 152 | 127 | |
| 153 | 128 | p = xdr_inline_decode(xdr, 4); |
| 154 | − if (unlikely(p == NULL)) | |
| 155 | − goto out_overflow; | |
| 129 | + if (unlikely(!p)) | |
| 130 | + return -EIO; | |
| 156 | 131 | *value = be32_to_cpup(p); |
| 157 | 132 | return 0; |
| 158 | −out_overflow: | |
| 159 | − print_overflow_msg(__func__, xdr); | |
| 160 | − return -EIO; | |
| 161 | 133 | } |
| 162 | 134 | |
| 163 | 135 | static int decode_uint64(struct xdr_stream *xdr, u64 *value) |
| @@ -165,13 +137,10 @@ static int decode_uint64(struct xdr_stream *xdr, u64 *value) · 1 unmodified line | ||
| 165 | 137 | __be32 *p; |
| 166 | 138 | |
| 167 | 139 | p = xdr_inline_decode(xdr, 8); |
| 168 | − if (unlikely(p == NULL)) | |
| 169 | − goto out_overflow; | |
| 140 | + if (unlikely(!p)) | |
| 141 | + return -EIO; | |
| 170 | 142 | xdr_decode_hyper(p, value); |
| 171 | 143 | return 0; |
| 172 | −out_overflow: | |
| 173 | − print_overflow_msg(__func__, xdr); | |
| 174 | − return -EIO; | |
| 175 | 144 | } |
| 176 | 145 | |
| 177 | 146 | /* |
| @@ -211,14 +180,14 @@ static int decode_inline_filename3(struct xdr_stream *xdr, · 33 unmodified lines | ||
| 211 | 180 | u32 count; |
| 212 | 181 | |
| 213 | 182 | p = xdr_inline_decode(xdr, 4); |
| 214 | − if (unlikely(p == NULL)) | |
| 215 | − goto out_overflow; | |
| 183 | + if (unlikely(!p)) | |
| 184 | + return -EIO; | |
| 216 | 185 | count = be32_to_cpup(p); |
| 217 | 186 | if (count > NFS3_MAXNAMLEN) |
| 218 | 187 | goto out_nametoolong; |
| 219 | 188 | p = xdr_inline_decode(xdr, count); |
| 220 | − if (unlikely(p == NULL)) | |
| 221 | − goto out_overflow; | |
| 189 | + if (unlikely(!p)) | |
| 190 | + return -EIO; | |
| 222 | 191 | *name = (const char *)p; |
| 223 | 192 | *length = count; |
| 224 | 193 | return 0; |
| @@ -226,9 +195,6 @@ static int decode_inline_filename3(struct xdr_stream *xdr, · 1 unmodified line | ||
| 226 | 195 | out_nametoolong: |
| 227 | 196 | dprintk("NFS: returned filename too long: %u\n", count); |
| 228 | 197 | return -ENAMETOOLONG; |
| 229 | −out_overflow: | |
| 230 | − print_overflow_msg(__func__, xdr); | |
| 231 | − return -EIO; | |
| 232 | 198 | } |
| 233 | 199 | |
| 234 | 200 | /* |
| @@ -249,8 +215,8 @@ static int decode_nfspath3(struct xdr_stream *xdr) · 14 unmodified lines | ||
| 249 | 215 | __be32 *p; |
| 250 | 216 | |
| 251 | 217 | p = xdr_inline_decode(xdr, 4); |
| 252 | − if (unlikely(p == NULL)) | |
| 253 | − goto out_overflow; | |
| 218 | + if (unlikely(!p)) | |
| 219 | + return -EIO; | |
| 254 | 220 | count = be32_to_cpup(p); |
| 255 | 221 | if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN)) |
| 256 | 222 | goto out_nametoolong; |
| @@ -267,9 +233,6 @@ out_cheating: · 10 unmodified lines | ||
| 267 | 233 | dprintk("NFS: server cheating in pathname result: " |
| 268 | 234 | "count %u > recvd %u\n", count, recvd); |
| 269 | 235 | return -EIO; |
| 270 | −out_overflow: | |
| 271 | − print_overflow_msg(__func__, xdr); | |
| 272 | − return -EIO; | |
| 273 | 236 | } |
| 274 | 237 | |
| 275 | 238 | /* |
| @@ -303,13 +266,10 @@ static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier) · 27 unmodified lines | ||
| 303 | 266 | __be32 *p; |
| 304 | 267 | |
| 305 | 268 | p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE); |
| 306 | − if (unlikely(p == NULL)) | |
| 307 | − goto out_overflow; | |
| 269 | + if (unlikely(!p)) | |
| 270 | + return -EIO; | |
| 308 | 271 | memcpy(verifier, p, NFS3_COOKIEVERFSIZE); |
| 309 | 272 | return 0; |
| 310 | −out_overflow: | |
| 311 | − print_overflow_msg(__func__, xdr); | |
| 312 | − return -EIO; | |
| 313 | 273 | } |
| 314 | 274 | |
| 315 | 275 | /* |
| @@ -330,13 +290,10 @@ static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier * · 14 unmodified lines | ||
| 330 | 290 | __be32 *p; |
| 331 | 291 | |
| 332 | 292 | p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE); |
| 333 | − if (unlikely(p == NULL)) | |
| 334 | − goto out_overflow; | |
| 293 | + if (unlikely(!p)) | |
| 294 | + return -EIO; | |
| 335 | 295 | memcpy(verifier->data, p, NFS3_WRITEVERFSIZE); |
| 336 | 296 | return 0; |
| 337 | −out_overflow: | |
| 338 | − print_overflow_msg(__func__, xdr); | |
| 339 | − return -EIO; | |
| 340 | 297 | } |
| 341 | 298 | |
| 342 | 299 | /* |
| @@ -364,13 +321,16 @@ static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status) · 21 unmodified lines | ||
| 364 | 321 | __be32 *p; |
| 365 | 322 | |
| 366 | 323 | p = xdr_inline_decode(xdr, 4); |
| 367 | − if (unlikely(p == NULL)) | |
| 368 | − goto out_overflow; | |
| 324 | + if (unlikely(!p)) | |
| 325 | + return -EIO; | |
| 326 | + if (unlikely(*p != cpu_to_be32(NFS3_OK))) | |
| 327 | + goto out_status; | |
| 328 | + *status = 0; | |
| 329 | + return 0; | |
| 330 | +out_status: | |
| 369 | 331 | *status = be32_to_cpup(p); |
| 332 | + trace_nfs_xdr_status((int)*status); | |
| 370 | 333 | return 0; |
| 371 | −out_overflow: | |
| 372 | − print_overflow_msg(__func__, xdr); | |
| 373 | − return -EIO; | |
| 374 | 334 | } |
| 375 | 335 | |
| 376 | 336 | /* |
| @@ -453,23 +413,20 @@ static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) · 76 unmodified lines | ||
| 453 | 413 | __be32 *p; |
| 454 | 414 | |
| 455 | 415 | p = xdr_inline_decode(xdr, 4); |
| 456 | − if (unlikely(p == NULL)) | |
| 457 | − goto out_overflow; | |
| 416 | + if (unlikely(!p)) | |
| 417 | + return -EIO; | |
| 458 | 418 | length = be32_to_cpup(p++); |
| 459 | 419 | if (unlikely(length > NFS3_FHSIZE)) |
| 460 | 420 | goto out_toobig; |
| 461 | 421 | p = xdr_inline_decode(xdr, length); |
| 462 | − if (unlikely(p == NULL)) | |
| 463 | − goto out_overflow; | |
| 422 | + if (unlikely(!p)) | |
| 423 | + return -EIO; | |
| 464 | 424 | fh->size = length; |
| 465 | 425 | memcpy(fh->data, p, length); |
| 466 | 426 | return 0; |
| 467 | 427 | out_toobig: |
| 468 | 428 | dprintk("NFS: file handle size (%u) too big\n", length); |
| 469 | 429 | return -E2BIG; |
| 470 | −out_overflow: | |
| 471 | − print_overflow_msg(__func__, xdr); | |
| 472 | − return -EIO; | |
| 473 | 430 | } |
| 474 | 431 | |
| 475 | 432 | static void zero_nfs_fh3(struct nfs_fh *fh) |
| @@ -655,8 +612,8 @@ static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 179 unmodified lines | ||
| 655 | 612 | __be32 *p; |
| 656 | 613 | |
| 657 | 614 | p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2); |
| 658 | − if (unlikely(p == NULL)) | |
| 659 | − goto out_overflow; | |
| 615 | + if (unlikely(!p)) | |
| 616 | + return -EIO; | |
| 660 | 617 | |
| 661 | 618 | p = xdr_decode_ftype3(p, &fmode); |
| 662 | 619 | |
| @@ -690,9 +647,6 @@ out_uid: · 27 unmodified lines | ||
| 690 | 647 | out_gid: |
| 691 | 648 | dprintk("NFS: returned invalid gid\n"); |
| 692 | 649 | return -EINVAL; |
| 693 | −out_overflow: | |
| 694 | − print_overflow_msg(__func__, xdr); | |
| 695 | − return -EIO; | |
| 696 | 650 | } |
| 697 | 651 | |
| 698 | 652 | /* |
| @@ -710,14 +664,11 @@ static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 11 unmodified lines | ||
| 710 | 664 | __be32 *p; |
| 711 | 665 | |
| 712 | 666 | p = xdr_inline_decode(xdr, 4); |
| 713 | − if (unlikely(p == NULL)) | |
| 714 | − goto out_overflow; | |
| 667 | + if (unlikely(!p)) | |
| 668 | + return -EIO; | |
| 715 | 669 | if (*p != xdr_zero) |
| 716 | 670 | return decode_fattr3(xdr, fattr); |
| 717 | 671 | return 0; |
| 718 | −out_overflow: | |
| 719 | − print_overflow_msg(__func__, xdr); | |
| 720 | − return -EIO; | |
| 721 | 672 | } |
| 722 | 673 | |
| 723 | 674 | /* |
| @@ -733,8 +684,8 @@ static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 9 unmodified lines | ||
| 733 | 684 | __be32 *p; |
| 734 | 685 | |
| 735 | 686 | p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2); |
| 736 | − if (unlikely(p == NULL)) | |
| 737 | − goto out_overflow; | |
| 687 | + if (unlikely(!p)) | |
| 688 | + return -EIO; | |
| 738 | 689 | |
| 739 | 690 | fattr->valid |= NFS_ATTR_FATTR_PRESIZE |
| 740 | 691 | | NFS_ATTR_FATTR_PRECHANGE |
| @@ -747,9 +698,6 @@ static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 6 unmodified lines | ||
| 747 | 698 | fattr->pre_change_attr = nfs_timespec_to_change_attr(&fattr->pre_ctime); |
| 748 | 699 | |
| 749 | 700 | return 0; |
| 750 | −out_overflow: | |
| 751 | − print_overflow_msg(__func__, xdr); | |
| 752 | − return -EIO; | |
| 753 | 701 | } |
| 754 | 702 | |
| 755 | 703 | /* |
| @@ -773,14 +721,11 @@ static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 17 unmodified lines | ||
| 773 | 721 | __be32 *p; |
| 774 | 722 | |
| 775 | 723 | p = xdr_inline_decode(xdr, 4); |
| 776 | − if (unlikely(p == NULL)) | |
| 777 | − goto out_overflow; | |
| 724 | + if (unlikely(!p)) | |
| 725 | + return -EIO; | |
| 778 | 726 | if (*p != xdr_zero) |
| 779 | 727 | return decode_wcc_attr(xdr, fattr); |
| 780 | 728 | return 0; |
| 781 | −out_overflow: | |
| 782 | − print_overflow_msg(__func__, xdr); | |
| 783 | − return -EIO; | |
| 784 | 729 | } |
| 785 | 730 | |
| 786 | 731 | static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr) |
| @@ -808,15 +753,12 @@ out: · 21 unmodified lines | ||
| 808 | 753 | static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 809 | 754 | { |
| 810 | 755 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 811 | − if (unlikely(p == NULL)) | |
| 812 | − goto out_overflow; | |
| 756 | + if (unlikely(!p)) | |
| 757 | + return -EIO; | |
| 813 | 758 | if (*p != xdr_zero) |
| 814 | 759 | return decode_nfs_fh3(xdr, fh); |
| 815 | 760 | zero_nfs_fh3(fh); |
| 816 | 761 | return 0; |
| 817 | −out_overflow: | |
| 818 | − print_overflow_msg(__func__, xdr); | |
| 819 | − return -EIO; | |
| 820 | 762 | } |
| 821 | 763 | |
| 822 | 764 | /* |
| @@ -953,8 +895,8 @@ static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req, · 130 unmodified lines | ||
| 953 | 895 | const struct nfs3_readlinkargs *args = data; |
| 954 | 896 | |
| 955 | 897 | encode_nfs_fh3(xdr, args->fh); |
| 956 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 957 | − args->pglen, NFS3_readlinkres_sz); | |
| 898 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 899 | + args->pglen, NFS3_readlinkres_sz); | |
| 958 | 900 | } |
| 959 | 901 | |
| 960 | 902 | /* |
| @@ -986,8 +928,8 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req, · 25 unmodified lines | ||
| 986 | 928 | unsigned int replen = args->replen ? args->replen : NFS3_readres_sz; |
| 987 | 929 | |
| 988 | 930 | encode_read3args(xdr, args); |
| 989 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 990 | − args->count, replen); | |
| 931 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 932 | + args->count, replen); | |
| 991 | 933 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 992 | 934 | } |
| 993 | 935 | |
| @@ -1279,7 +1221,7 @@ static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req, · 285 unmodified lines | ||
| 1279 | 1221 | const struct nfs3_readdirargs *args = data; |
| 1280 | 1222 | |
| 1281 | 1223 | encode_readdir3args(xdr, args); |
| 1282 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1224 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1283 | 1225 | args->count, NFS3_readdirres_sz); |
| 1284 | 1226 | } |
| 1285 | 1227 | |
| @@ -1321,7 +1263,7 @@ static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req, · 35 unmodified lines | ||
| 1321 | 1263 | const struct nfs3_readdirargs *args = data; |
| 1322 | 1264 | |
| 1323 | 1265 | encode_readdirplus3args(xdr, args); |
| 1324 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1266 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1325 | 1267 | args->count, NFS3_readdirres_sz); |
| 1326 | 1268 | } |
| 1327 | 1269 | |
| @@ -1366,7 +1308,7 @@ static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req, · 38 unmodified lines | ||
| 1366 | 1308 | encode_nfs_fh3(xdr, args->fh); |
| 1367 | 1309 | encode_uint32(xdr, args->mask); |
| 1368 | 1310 | if (args->mask & (NFS_ACL | NFS_DFACL)) { |
| 1369 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1311 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1370 | 1312 | NFSACL_MAXPAGES << PAGE_SHIFT, |
| 1371 | 1313 | ACL3_getaclres_sz); |
| 1372 | 1314 | req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES; |
| @@ -1643,8 +1585,8 @@ static int decode_read3resok(struct xdr_stream *xdr, · 270 unmodified lines | ||
| 1643 | 1585 | __be32 *p; |
| 1644 | 1586 | |
| 1645 | 1587 | p = xdr_inline_decode(xdr, 4 + 4 + 4); |
| 1646 | − if (unlikely(p == NULL)) | |
| 1647 | − goto out_overflow; | |
| 1588 | + if (unlikely(!p)) | |
| 1589 | + return -EIO; | |
| 1648 | 1590 | count = be32_to_cpup(p++); |
| 1649 | 1591 | eof = be32_to_cpup(p++); |
| 1650 | 1592 | ocount = be32_to_cpup(p++); |
| @@ -1667,9 +1609,6 @@ out_cheating: · 16 unmodified lines | ||
| 1667 | 1609 | count = recvd; |
| 1668 | 1610 | eof = 0; |
| 1669 | 1611 | goto out; |
| 1670 | −out_overflow: | |
| 1671 | − print_overflow_msg(__func__, xdr); | |
| 1672 | − return -EIO; | |
| 1673 | 1612 | } |
| 1674 | 1613 | |
| 1675 | 1614 | static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -1690,7 +1629,7 @@ static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, · 14 unmodified lines | ||
| 1690 | 1629 | result->op_status = status; |
| 1691 | 1630 | if (status != NFS3_OK) |
| 1692 | 1631 | goto out_status; |
| 1693 | − result->replen = 3 + ((xdr_stream_pos(xdr) - pos) >> 2); | |
| 1632 | + result->replen = 4 + ((xdr_stream_pos(xdr) - pos) >> 2); | |
| 1694 | 1633 | error = decode_read3resok(xdr, result); |
| 1695 | 1634 | out: |
| 1696 | 1635 | return error; |
| @@ -1731,22 +1670,18 @@ static int decode_write3resok(struct xdr_stream *xdr, · 34 unmodified lines | ||
| 1731 | 1670 | __be32 *p; |
| 1732 | 1671 | |
| 1733 | 1672 | p = xdr_inline_decode(xdr, 4 + 4); |
| 1734 | − if (unlikely(p == NULL)) | |
| 1735 | − goto out_overflow; | |
| 1673 | + if (unlikely(!p)) | |
| 1674 | + return -EIO; | |
| 1736 | 1675 | result->count = be32_to_cpup(p++); |
| 1737 | 1676 | result->verf->committed = be32_to_cpup(p++); |
| 1738 | 1677 | if (unlikely(result->verf->committed > NFS_FILE_SYNC)) |
| 1739 | 1678 | goto out_badvalue; |
| 1740 | 1679 | if (decode_writeverf3(xdr, &result->verf->verifier)) |
| 1741 | − goto out_eio; | |
| 1680 | + return -EIO; | |
| 1742 | 1681 | return result->count; |
| 1743 | 1682 | out_badvalue: |
| 1744 | 1683 | dprintk("NFS: bad stable_how value: %u\n", result->verf->committed); |
| 1745 | 1684 | return -EIO; |
| 1746 | −out_overflow: | |
| 1747 | − print_overflow_msg(__func__, xdr); | |
| 1748 | −out_eio: | |
| 1749 | − return -EIO; | |
| 1750 | 1685 | } |
| 1751 | 1686 | |
| 1752 | 1687 | static int nfs3_xdr_dec_write3res(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -2010,12 +1945,12 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 257 unmodified lines | ||
| 2010 | 1945 | u64 new_cookie; |
| 2011 | 1946 | |
| 2012 | 1947 | p = xdr_inline_decode(xdr, 4); |
| 2013 | − if (unlikely(p == NULL)) | |
| 2014 | − goto out_overflow; | |
| 1948 | + if (unlikely(!p)) | |
| 1949 | + return -EAGAIN; | |
| 2015 | 1950 | if (*p == xdr_zero) { |
| 2016 | 1951 | p = xdr_inline_decode(xdr, 4); |
| 2017 | − if (unlikely(p == NULL)) | |
| 2018 | − goto out_overflow; | |
| 1952 | + if (unlikely(!p)) | |
| 1953 | + return -EAGAIN; | |
| 2019 | 1954 | if (*p == xdr_zero) |
| 2020 | 1955 | return -EAGAIN; |
| 2021 | 1956 | entry->eof = 1; |
| @@ -2051,8 +1986,8 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 29 unmodified lines | ||
| 2051 | 1986 | |
| 2052 | 1987 | /* In fact, a post_op_fh3: */ |
| 2053 | 1988 | p = xdr_inline_decode(xdr, 4); |
| 2054 | − if (unlikely(p == NULL)) | |
| 2055 | − goto out_overflow; | |
| 1989 | + if (unlikely(!p)) | |
| 1990 | + return -EAGAIN; | |
| 2056 | 1991 | if (*p != xdr_zero) { |
| 2057 | 1992 | error = decode_nfs_fh3(xdr, entry->fh); |
| 2058 | 1993 | if (unlikely(error)) { |
| @@ -2069,9 +2004,6 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 10 unmodified lines | ||
| 2069 | 2004 | |
| 2070 | 2005 | return 0; |
| 2071 | 2006 | |
| 2072 | −out_overflow: | |
| 2073 | − print_overflow_msg(__func__, xdr); | |
| 2074 | − return -EAGAIN; | |
| 2075 | 2007 | out_truncated: |
| 2076 | 2008 | dprintk("NFS: directory entry contains invalid file handle\n"); |
| 2077 | 2009 | *entry = old; |
| @@ -2183,8 +2115,8 @@ static int decode_fsstat3resok(struct xdr_stream *xdr, · 105 unmodified lines | ||
| 2183 | 2115 | __be32 *p; |
| 2184 | 2116 | |
| 2185 | 2117 | p = xdr_inline_decode(xdr, 8 * 6 + 4); |
| 2186 | − if (unlikely(p == NULL)) | |
| 2187 | − goto out_overflow; | |
| 2118 | + if (unlikely(!p)) | |
| 2119 | + return -EIO; | |
| 2188 | 2120 | p = xdr_decode_size3(p, &result->tbytes); |
| 2189 | 2121 | p = xdr_decode_size3(p, &result->fbytes); |
| 2190 | 2122 | p = xdr_decode_size3(p, &result->abytes); |
| @@ -2193,9 +2125,6 @@ static int decode_fsstat3resok(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 2193 | 2125 | xdr_decode_size3(p, &result->afiles); |
| 2194 | 2126 | /* ignore invarsec */ |
| 2195 | 2127 | return 0; |
| 2196 | −out_overflow: | |
| 2197 | − print_overflow_msg(__func__, xdr); | |
| 2198 | − return -EIO; | |
| 2199 | 2128 | } |
| 2200 | 2129 | |
| 2201 | 2130 | static int nfs3_xdr_dec_fsstat3res(struct rpc_rqst *req, |
| @@ -2255,8 +2184,8 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr, · 53 unmodified lines | ||
| 2255 | 2184 | __be32 *p; |
| 2256 | 2185 | |
| 2257 | 2186 | p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4); |
| 2258 | − if (unlikely(p == NULL)) | |
| 2259 | − goto out_overflow; | |
| 2187 | + if (unlikely(!p)) | |
| 2188 | + return -EIO; | |
| 2260 | 2189 | result->rtmax = be32_to_cpup(p++); |
| 2261 | 2190 | result->rtpref = be32_to_cpup(p++); |
| 2262 | 2191 | result->rtmult = be32_to_cpup(p++); |
| @@ -2270,9 +2199,6 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 2270 | 2199 | /* ignore properties */ |
| 2271 | 2200 | result->lease_time = 0; |
| 2272 | 2201 | return 0; |
| 2273 | −out_overflow: | |
| 2274 | − print_overflow_msg(__func__, xdr); | |
| 2275 | − return -EIO; | |
| 2276 | 2202 | } |
| 2277 | 2203 | |
| 2278 | 2204 | static int nfs3_xdr_dec_fsinfo3res(struct rpc_rqst *req, |
| @@ -2328,15 +2254,12 @@ static int decode_pathconf3resok(struct xdr_stream *xdr, · 49 unmodified lines | ||
| 2328 | 2254 | __be32 *p; |
| 2329 | 2255 | |
| 2330 | 2256 | p = xdr_inline_decode(xdr, 4 * 6); |
| 2331 | − if (unlikely(p == NULL)) | |
| 2332 | − goto out_overflow; | |
| 2257 | + if (unlikely(!p)) | |
| 2258 | + return -EIO; | |
| 2333 | 2259 | result->max_link = be32_to_cpup(p++); |
| 2334 | 2260 | result->max_namelen = be32_to_cpup(p); |
| 2335 | 2261 | /* ignore remaining fields */ |
| 2336 | 2262 | return 0; |
| 2337 | −out_overflow: | |
| 2338 | − print_overflow_msg(__func__, xdr); | |
| 2339 | − return -EIO; | |
| 2340 | 2263 | } |
| 2341 | 2264 | |
| 2342 | 2265 | static int nfs3_xdr_dec_pathconf3res(struct rpc_rqst *req, |
| @@ -20,5 +20,8 @@ loff_t nfs42_proc_llseek(struct file *, loff_t, int); · 19 unmodified lines | ||
| 20 | 20 | int nfs42_proc_layoutstats_generic(struct nfs_server *, |
| 21 | 21 | struct nfs42_layoutstat_data *); |
| 22 | 22 | int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t); |
| 23 | +int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg, | |
| 24 | + const struct nfs42_layout_error *errors, | |
| 25 | + size_t n); | |
| 23 | 26 | |
| 24 | 27 | #endif /* __LINUX_FS_NFS_NFS4_2_H */ |
| @@ -672,6 +672,170 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server, · 671 unmodified lines | ||
| 672 | 672 | return 0; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | +static struct nfs42_layouterror_data * | |
| 676 | +nfs42_alloc_layouterror_data(struct pnfs_layout_segment *lseg, gfp_t gfp_flags) | |
| 677 | +{ | |
| 678 | + struct nfs42_layouterror_data *data; | |
| 679 | + struct inode *inode = lseg->pls_layout->plh_inode; | |
| 680 | + | |
| 681 | + data = kzalloc(sizeof(*data), gfp_flags); | |
| 682 | + if (data) { | |
| 683 | + data->args.inode = data->inode = nfs_igrab_and_active(inode); | |
| 684 | + if (data->inode) { | |
| 685 | + data->lseg = pnfs_get_lseg(lseg); | |
| 686 | + if (data->lseg) | |
| 687 | + return data; | |
| 688 | + nfs_iput_and_deactive(data->inode); | |
| 689 | + } | |
| 690 | + kfree(data); | |
| 691 | + } | |
| 692 | + return NULL; | |
| 693 | +} | |
| 694 | + | |
| 695 | +static void | |
| 696 | +nfs42_free_layouterror_data(struct nfs42_layouterror_data *data) | |
| 697 | +{ | |
| 698 | + pnfs_put_lseg(data->lseg); | |
| 699 | + nfs_iput_and_deactive(data->inode); | |
| 700 | + kfree(data); | |
| 701 | +} | |
| 702 | + | |
| 703 | +static void | |
| 704 | +nfs42_layouterror_prepare(struct rpc_task *task, void *calldata) | |
| 705 | +{ | |
| 706 | + struct nfs42_layouterror_data *data = calldata; | |
| 707 | + struct inode *inode = data->inode; | |
| 708 | + struct nfs_server *server = NFS_SERVER(inode); | |
| 709 | + struct pnfs_layout_hdr *lo = data->lseg->pls_layout; | |
| 710 | + unsigned i; | |
| 711 | + | |
| 712 | + spin_lock(&inode->i_lock); | |
| 713 | + if (!pnfs_layout_is_valid(lo)) { | |
| 714 | + spin_unlock(&inode->i_lock); | |
| 715 | + rpc_exit(task, 0); | |
| 716 | + return; | |
| 717 | + } | |
| 718 | + for (i = 0; i < data->args.num_errors; i++) | |
| 719 | + nfs4_stateid_copy(&data->args.errors[i].stateid, | |
| 720 | + &lo->plh_stateid); | |
| 721 | + spin_unlock(&inode->i_lock); | |
| 722 | + nfs4_setup_sequence(server->nfs_client, &data->args.seq_args, | |
| 723 | + &data->res.seq_res, task); | |
| 724 | +} | |
| 725 | + | |
| 726 | +static void | |
| 727 | +nfs42_layouterror_done(struct rpc_task *task, void *calldata) | |
| 728 | +{ | |
| 729 | + struct nfs42_layouterror_data *data = calldata; | |
| 730 | + struct inode *inode = data->inode; | |
| 731 | + struct pnfs_layout_hdr *lo = data->lseg->pls_layout; | |
| 732 | + | |
| 733 | + if (!nfs4_sequence_done(task, &data->res.seq_res)) | |
| 734 | + return; | |
| 735 | + | |
| 736 | + switch (task->tk_status) { | |
| 737 | + case 0: | |
| 738 | + break; | |
| 739 | + case -NFS4ERR_BADHANDLE: | |
| 740 | + case -ESTALE: | |
| 741 | + pnfs_destroy_layout(NFS_I(inode)); | |
| 742 | + break; | |
| 743 | + case -NFS4ERR_EXPIRED: | |
| 744 | + case -NFS4ERR_ADMIN_REVOKED: | |
| 745 | + case -NFS4ERR_DELEG_REVOKED: | |
| 746 | + case -NFS4ERR_STALE_STATEID: | |
| 747 | + case -NFS4ERR_BAD_STATEID: | |
| 748 | + spin_lock(&inode->i_lock); | |
| 749 | + if (pnfs_layout_is_valid(lo) && | |
| 750 | + nfs4_stateid_match(&data->args.errors[0].stateid, | |
| 751 | + &lo->plh_stateid)) { | |
| 752 | + LIST_HEAD(head); | |
| 753 | + | |
| 754 | + /* | |
| 755 | + * Mark the bad layout state as invalid, then retry | |
| 756 | + * with the current stateid. | |
| 757 | + */ | |
| 758 | + pnfs_mark_layout_stateid_invalid(lo, &head); | |
| 759 | + spin_unlock(&inode->i_lock); | |
| 760 | + pnfs_free_lseg_list(&head); | |
| 761 | + nfs_commit_inode(inode, 0); | |
| 762 | + } else | |
| 763 | + spin_unlock(&inode->i_lock); | |
| 764 | + break; | |
| 765 | + case -NFS4ERR_OLD_STATEID: | |
| 766 | + spin_lock(&inode->i_lock); | |
| 767 | + if (pnfs_layout_is_valid(lo) && | |
| 768 | + nfs4_stateid_match_other(&data->args.errors[0].stateid, | |
| 769 | + &lo->plh_stateid)) { | |
| 770 | + /* Do we need to delay before resending? */ | |
| 771 | + if (!nfs4_stateid_is_newer(&lo->plh_stateid, | |
| 772 | + &data->args.errors[0].stateid)) | |
| 773 | + rpc_delay(task, HZ); | |
| 774 | + rpc_restart_call_prepare(task); | |
| 775 | + } | |
| 776 | + spin_unlock(&inode->i_lock); | |
| 777 | + break; | |
| 778 | + case -ENOTSUPP: | |
| 779 | + case -EOPNOTSUPP: | |
| 780 | + NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTERROR; | |
| 781 | + } | |
| 782 | +} | |
| 783 | + | |
| 784 | +static void | |
| 785 | +nfs42_layouterror_release(void *calldata) | |
| 786 | +{ | |
| 787 | + struct nfs42_layouterror_data *data = calldata; | |
| 788 | + | |
| 789 | + nfs42_free_layouterror_data(data); | |
| 790 | +} | |
| 791 | + | |
| 792 | +static const struct rpc_call_ops nfs42_layouterror_ops = { | |
| 793 | + .rpc_call_prepare = nfs42_layouterror_prepare, | |
| 794 | + .rpc_call_done = nfs42_layouterror_done, | |
| 795 | + .rpc_release = nfs42_layouterror_release, | |
| 796 | +}; | |
| 797 | + | |
| 798 | +int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg, | |
| 799 | + const struct nfs42_layout_error *errors, size_t n) | |
| 800 | +{ | |
| 801 | + struct inode *inode = lseg->pls_layout->plh_inode; | |
| 802 | + struct nfs42_layouterror_data *data; | |
| 803 | + struct rpc_task *task; | |
| 804 | + struct rpc_message msg = { | |
| 805 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LAYOUTERROR], | |
| 806 | + }; | |
| 807 | + struct rpc_task_setup task_setup = { | |
| 808 | + .rpc_message = &msg, | |
| 809 | + .callback_ops = &nfs42_layouterror_ops, | |
| 810 | + .flags = RPC_TASK_ASYNC, | |
| 811 | + }; | |
| 812 | + unsigned int i; | |
| 813 | + | |
| 814 | + if (!nfs_server_capable(inode, NFS_CAP_LAYOUTERROR)) | |
| 815 | + return -EOPNOTSUPP; | |
| 816 | + if (n > NFS42_LAYOUTERROR_MAX) | |
| 817 | + return -EINVAL; | |
| 818 | + data = nfs42_alloc_layouterror_data(lseg, GFP_NOFS); | |
| 819 | + if (!data) | |
| 820 | + return -ENOMEM; | |
| 821 | + for (i = 0; i < n; i++) { | |
| 822 | + data->args.errors[i] = errors[i]; | |
| 823 | + data->args.num_errors++; | |
| 824 | + data->res.num_errors++; | |
| 825 | + } | |
| 826 | + msg.rpc_argp = &data->args; | |
| 827 | + msg.rpc_resp = &data->res; | |
| 828 | + task_setup.callback_data = data; | |
| 829 | + task_setup.rpc_client = NFS_SERVER(inode)->client; | |
| 830 | + nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0); | |
| 831 | + task = rpc_run_task(&task_setup); | |
| 832 | + if (IS_ERR(task)) | |
| 833 | + return PTR_ERR(task); | |
| 834 | + rpc_put_task(task); | |
| 835 | + return 0; | |
| 836 | +} | |
| 837 | +EXPORT_SYMBOL_GPL(nfs42_proc_layouterror); | |
| 838 | + | |
| 675 | 839 | static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f, |
| 676 | 840 | struct file *dst_f, struct nfs_lock_context *src_lock, |
| 677 | 841 | struct nfs_lock_context *dst_lock, loff_t src_offset, |
| @@ -51,6 +51,15 @@ · 50 unmodified lines | ||
| 51 | 51 | 1 /* opaque devaddr4 length */ + \ |
| 52 | 52 | XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE)) |
| 53 | 53 | #define decode_layoutstats_maxsz (op_decode_hdr_maxsz) |
| 54 | +#define encode_device_error_maxsz (XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ | |
| 55 | + 1 /* status */ + 1 /* opnum */) | |
| 56 | +#define encode_layouterror_maxsz (op_decode_hdr_maxsz + \ | |
| 57 | + 2 /* offset */ + \ | |
| 58 | + 2 /* length */ + \ | |
| 59 | + encode_stateid_maxsz + \ | |
| 60 | + 1 /* Array size */ + \ | |
| 61 | + encode_device_error_maxsz) | |
| 62 | +#define decode_layouterror_maxsz (op_decode_hdr_maxsz) | |
| 54 | 63 | #define encode_clone_maxsz (encode_stateid_maxsz + \ |
| 55 | 64 | encode_stateid_maxsz + \ |
| 56 | 65 | 2 /* src offset */ + \ |
| @@ -59,43 +68,53 @@ · 2 unmodified lines | ||
| 59 | 68 | #define decode_clone_maxsz (op_decode_hdr_maxsz) |
| 60 | 69 | |
| 61 | 70 | #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \ |
| 71 | + encode_sequence_maxsz + \ | |
| 62 | 72 | encode_putfh_maxsz + \ |
| 63 | 73 | encode_allocate_maxsz + \ |
| 64 | 74 | encode_getattr_maxsz) |
| 65 | 75 | #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \ |
| 76 | + decode_sequence_maxsz + \ | |
| 66 | 77 | decode_putfh_maxsz + \ |
| 67 | 78 | decode_allocate_maxsz + \ |
| 68 | 79 | decode_getattr_maxsz) |
| 69 | 80 | #define NFS4_enc_copy_sz (compound_encode_hdr_maxsz + \ |
| 81 | + encode_sequence_maxsz + \ | |
| 70 | 82 | encode_putfh_maxsz + \ |
| 71 | 83 | encode_savefh_maxsz + \ |
| 72 | 84 | encode_putfh_maxsz + \ |
| 73 | 85 | encode_copy_maxsz + \ |
| 74 | 86 | encode_commit_maxsz) |
| 75 | 87 | #define NFS4_dec_copy_sz (compound_decode_hdr_maxsz + \ |
| 88 | + decode_sequence_maxsz + \ | |
| 76 | 89 | decode_putfh_maxsz + \ |
| 77 | 90 | decode_savefh_maxsz + \ |
| 78 | 91 | decode_putfh_maxsz + \ |
| 79 | 92 | decode_copy_maxsz + \ |
| 80 | 93 | decode_commit_maxsz) |
| 81 | 94 | #define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \ |
| 95 | + encode_sequence_maxsz + \ | |
| 82 | 96 | encode_putfh_maxsz + \ |
| 83 | 97 | encode_offload_cancel_maxsz) |
| 84 | 98 | #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \ |
| 99 | + decode_sequence_maxsz + \ | |
| 85 | 100 | decode_putfh_maxsz + \ |
| 86 | 101 | decode_offload_cancel_maxsz) |
| 87 | 102 | #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \ |
| 103 | + encode_sequence_maxsz + \ | |
| 88 | 104 | encode_putfh_maxsz + \ |
| 89 | 105 | encode_deallocate_maxsz + \ |
| 90 | 106 | encode_getattr_maxsz) |
| 91 | 107 | #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \ |
| 108 | + decode_sequence_maxsz + \ | |
| 92 | 109 | decode_putfh_maxsz + \ |
| 93 | 110 | decode_deallocate_maxsz + \ |
| 94 | 111 | decode_getattr_maxsz) |
| 95 | 112 | #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ |
| 113 | + encode_sequence_maxsz + \ | |
| 96 | 114 | encode_putfh_maxsz + \ |
| 97 | 115 | encode_seek_maxsz) |
| 98 | 116 | #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \ |
| 117 | + decode_sequence_maxsz + \ | |
| 99 | 118 | decode_putfh_maxsz + \ |
| 100 | 119 | decode_seek_maxsz) |
| 101 | 120 | #define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \ |
| @@ -106,6 +125,16 @@ · 4 unmodified lines | ||
| 106 | 125 | decode_sequence_maxsz + \ |
| 107 | 126 | decode_putfh_maxsz + \ |
| 108 | 127 | PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz) |
| 128 | +#define NFS4_enc_layouterror_sz (compound_encode_hdr_maxsz + \ | |
| 129 | + encode_sequence_maxsz + \ | |
| 130 | + encode_putfh_maxsz + \ | |
| 131 | + NFS42_LAYOUTERROR_MAX * \ | |
| 132 | + encode_layouterror_maxsz) | |
| 133 | +#define NFS4_dec_layouterror_sz (compound_decode_hdr_maxsz + \ | |
| 134 | + decode_sequence_maxsz + \ | |
| 135 | + decode_putfh_maxsz + \ | |
| 136 | + NFS42_LAYOUTERROR_MAX * \ | |
| 137 | + decode_layouterror_maxsz) | |
| 109 | 138 | #define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \ |
| 110 | 139 | encode_sequence_maxsz + \ |
| 111 | 140 | encode_putfh_maxsz + \ |
| @@ -223,6 +252,34 @@ static void encode_clone(struct xdr_stream *xdr, · 111 unmodified lines | ||
| 223 | 252 | xdr_encode_hyper(p, args->count); |
| 224 | 253 | } |
| 225 | 254 | |
| 255 | +static void encode_device_error(struct xdr_stream *xdr, | |
| 256 | + const struct nfs42_device_error *error) | |
| 257 | +{ | |
| 258 | + __be32 *p; | |
| 259 | + | |
| 260 | + p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 2*4); | |
| 261 | + p = xdr_encode_opaque_fixed(p, error->dev_id.data, | |
| 262 | + NFS4_DEVICEID4_SIZE); | |
| 263 | + *p++ = cpu_to_be32(error->status); | |
| 264 | + *p = cpu_to_be32(error->opnum); | |
| 265 | +} | |
| 266 | + | |
| 267 | +static void encode_layouterror(struct xdr_stream *xdr, | |
| 268 | + const struct nfs42_layout_error *args, | |
| 269 | + struct compound_hdr *hdr) | |
| 270 | +{ | |
| 271 | + __be32 *p; | |
| 272 | + | |
| 273 | + encode_op_hdr(xdr, OP_LAYOUTERROR, decode_layouterror_maxsz, hdr); | |
| 274 | + p = reserve_space(xdr, 8 + 8); | |
| 275 | + p = xdr_encode_hyper(p, args->offset); | |
| 276 | + p = xdr_encode_hyper(p, args->length); | |
| 277 | + encode_nfs4_stateid(xdr, &args->stateid); | |
| 278 | + p = reserve_space(xdr, 4); | |
| 279 | + *p = cpu_to_be32(1); | |
| 280 | + encode_device_error(xdr, &args->errors[0]); | |
| 281 | +} | |
| 282 | + | |
| 226 | 283 | /* |
| 227 | 284 | * Encode ALLOCATE request |
| 228 | 285 | */ |
| @@ -381,6 +438,27 @@ static void nfs4_xdr_enc_clone(struct rpc_rqst *req, · 152 unmodified lines | ||
| 381 | 438 | encode_nops(&hdr); |
| 382 | 439 | } |
| 383 | 440 | |
| 441 | +/* | |
| 442 | + * Encode LAYOUTERROR request | |
| 443 | + */ | |
| 444 | +static void nfs4_xdr_enc_layouterror(struct rpc_rqst *req, | |
| 445 | + struct xdr_stream *xdr, | |
| 446 | + const void *data) | |
| 447 | +{ | |
| 448 | + const struct nfs42_layouterror_args *args = data; | |
| 449 | + struct compound_hdr hdr = { | |
| 450 | + .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
| 451 | + }; | |
| 452 | + int i; | |
| 453 | + | |
| 454 | + encode_compound_hdr(xdr, req, &hdr); | |
| 455 | + encode_sequence(xdr, &args->seq_args, &hdr); | |
| 456 | + encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
| 457 | + for (i = 0; i < args->num_errors; i++) | |
| 458 | + encode_layouterror(xdr, &args->errors[i], &hdr); | |
| 459 | + encode_nops(&hdr); | |
| 460 | +} | |
| 461 | + | |
| 384 | 462 | static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) |
| 385 | 463 | { |
| 386 | 464 | return decode_op_hdr(xdr, OP_ALLOCATE); |
| @@ -394,7 +472,7 @@ static int decode_write_response(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 394 | 472 | |
| 395 | 473 | p = xdr_inline_decode(xdr, 4); |
| 396 | 474 | if (unlikely(!p)) |
| 397 | − goto out_overflow; | |
| 475 | + return -EIO; | |
| 398 | 476 | count = be32_to_cpup(p); |
| 399 | 477 | if (count > 1) |
| 400 | 478 | return -EREMOTEIO; |
| @@ -402,18 +480,14 @@ static int decode_write_response(struct xdr_stream *xdr, · 1 unmodified line | ||
| 402 | 480 | status = decode_opaque_fixed(xdr, &res->stateid, |
| 403 | 481 | NFS4_STATEID_SIZE); |
| 404 | 482 | if (unlikely(status)) |
| 405 | − goto out_overflow; | |
| 483 | + return -EIO; | |
| 406 | 484 | } |
| 407 | 485 | p = xdr_inline_decode(xdr, 8 + 4); |
| 408 | 486 | if (unlikely(!p)) |
| 409 | − goto out_overflow; | |
| 487 | + return -EIO; | |
| 410 | 488 | p = xdr_decode_hyper(p, &res->count); |
| 411 | 489 | res->verifier.committed = be32_to_cpup(p); |
| 412 | 490 | return decode_verifier(xdr, &res->verifier.verifier); |
| 413 | − | |
| 414 | −out_overflow: | |
| 415 | − print_overflow_msg(__func__, xdr); | |
| 416 | − return -EIO; | |
| 417 | 491 | } |
| 418 | 492 | |
| 419 | 493 | static int decode_copy_requirements(struct xdr_stream *xdr, |
| @@ -422,14 +496,11 @@ static int decode_copy_requirements(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 422 | 496 | |
| 423 | 497 | p = xdr_inline_decode(xdr, 4 + 4); |
| 424 | 498 | if (unlikely(!p)) |
| 425 | − goto out_overflow; | |
| 499 | + return -EIO; | |
| 426 | 500 | |
| 427 | 501 | res->consecutive = be32_to_cpup(p++); |
| 428 | 502 | res->synchronous = be32_to_cpup(p++); |
| 429 | 503 | return 0; |
| 430 | −out_overflow: | |
| 431 | − print_overflow_msg(__func__, xdr); | |
| 432 | − return -EIO; | |
| 433 | 504 | } |
| 434 | 505 | |
| 435 | 506 | static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res) |
| @@ -474,15 +545,11 @@ static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) · 38 unmodified lines | ||
| 474 | 545 | |
| 475 | 546 | p = xdr_inline_decode(xdr, 4 + 8); |
| 476 | 547 | if (unlikely(!p)) |
| 477 | − goto out_overflow; | |
| 548 | + return -EIO; | |
| 478 | 549 | |
| 479 | 550 | res->sr_eof = be32_to_cpup(p++); |
| 480 | 551 | p = xdr_decode_hyper(p, &res->sr_offset); |
| 481 | 552 | return 0; |
| 482 | − | |
| 483 | −out_overflow: | |
| 484 | − print_overflow_msg(__func__, xdr); | |
| 485 | − return -EIO; | |
| 486 | 553 | } |
| 487 | 554 | |
| 488 | 555 | static int decode_layoutstats(struct xdr_stream *xdr) |
| @@ -495,6 +562,11 @@ static int decode_clone(struct xdr_stream *xdr) · 6 unmodified lines | ||
| 495 | 562 | return decode_op_hdr(xdr, OP_CLONE); |
| 496 | 563 | } |
| 497 | 564 | |
| 565 | +static int decode_layouterror(struct xdr_stream *xdr) | |
| 566 | +{ | |
| 567 | + return decode_op_hdr(xdr, OP_LAYOUTERROR); | |
| 568 | +} | |
| 569 | + | |
| 498 | 570 | /* |
| 499 | 571 | * Decode ALLOCATE request |
| 500 | 572 | */ |
| @@ -704,4 +776,30 @@ out: · 203 unmodified lines | ||
| 704 | 776 | return status; |
| 705 | 777 | } |
| 706 | 778 | |
| 779 | +/* | |
| 780 | + * Decode LAYOUTERROR request | |
| 781 | + */ | |
| 782 | +static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp, | |
| 783 | + struct xdr_stream *xdr, | |
| 784 | + void *data) | |
| 785 | +{ | |
| 786 | + struct nfs42_layouterror_res *res = data; | |
| 787 | + struct compound_hdr hdr; | |
| 788 | + int status, i; | |
| 789 | + | |
| 790 | + status = decode_compound_hdr(xdr, &hdr); | |
| 791 | + if (status) | |
| 792 | + goto out; | |
| 793 | + status = decode_sequence(xdr, &res->seq_res, rqstp); | |
| 794 | + if (status) | |
| 795 | + goto out; | |
| 796 | + status = decode_putfh(xdr); | |
| 797 | + | |
| 798 | + for (i = 0; i < res->num_errors && status == 0; i++) | |
| 799 | + status = decode_layouterror(xdr); | |
| 800 | +out: | |
| 801 | + res->rpc_status = status; | |
| 802 | + return status; | |
| 803 | +} | |
| 804 | + | |
| 707 | 805 | #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */ |
| @@ -42,7 +42,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) · 41 unmodified lines | ||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | #ifdef CONFIG_NFS_V4_1 |
| 45 | −/** | |
| 45 | +/* | |
| 46 | 46 | * Per auth flavor data server rpc clients |
| 47 | 47 | */ |
| 48 | 48 | struct nfs4_ds_server { |
| @@ -51,7 +51,9 @@ struct nfs4_ds_server { · 2 unmodified lines | ||
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | − * Common lookup case for DS I/O | |
| 54 | + * nfs4_find_ds_client - Common lookup case for DS I/O | |
| 55 | + * @ds_clp: pointer to the DS's nfs_client | |
| 56 | + * @flavor: rpc auth flavour to match | |
| 55 | 57 | */ |
| 56 | 58 | static struct nfs4_ds_server * |
| 57 | 59 | nfs4_find_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor) |
| @@ -118,9 +120,13 @@ nfs4_free_ds_server(struct nfs4_ds_server *dss) · 60 unmodified lines | ||
| 118 | 120 | } |
| 119 | 121 | |
| 120 | 122 | /** |
| 121 | −* Find or create a DS rpc client with th MDS server rpc client auth flavor | |
| 122 | −* in the nfs_client cl_ds_clients list. | |
| 123 | −*/ | |
| 123 | + * nfs4_find_or_create_ds_client - Find or create a DS rpc client | |
| 124 | + * @ds_clp: pointer to the DS's nfs_client | |
| 125 | + * @inode: pointer to the inode | |
| 126 | + * | |
| 127 | + * Find or create a DS rpc client with th MDS server rpc client auth flavor | |
| 128 | + * in the nfs_client cl_ds_clients list. | |
| 129 | + */ | |
| 124 | 130 | struct rpc_clnt * |
| 125 | 131 | nfs4_find_or_create_ds_client(struct nfs_client *ds_clp, struct inode *inode) |
| 126 | 132 | { |
| @@ -145,7 +151,6 @@ static void · 18 unmodified lines | ||
| 145 | 151 | nfs4_shutdown_ds_clients(struct nfs_client *clp) |
| 146 | 152 | { |
| 147 | 153 | struct nfs4_ds_server *dss; |
| 148 | − LIST_HEAD(shutdown_list); | |
| 149 | 154 | |
| 150 | 155 | while (!list_empty(&clp->cl_ds_clients)) { |
| 151 | 156 | dss = list_entry(clp->cl_ds_clients.next, |
| @@ -284,7 +289,7 @@ static int nfs4_init_callback(struct nfs_client *clp) · 132 unmodified lines | ||
| 284 | 289 | |
| 285 | 290 | /** |
| 286 | 291 | * nfs40_init_client - nfs_client initialization tasks for NFSv4.0 |
| 287 | − * @clp - nfs_client to initialize | |
| 292 | + * @clp: nfs_client to initialize | |
| 288 | 293 | * |
| 289 | 294 | * Returns zero on success, or a negative errno if some error occurred. |
| 290 | 295 | */ |
| @@ -312,7 +317,7 @@ int nfs40_init_client(struct nfs_client *clp) · 21 unmodified lines | ||
| 312 | 317 | |
| 313 | 318 | /** |
| 314 | 319 | * nfs41_init_client - nfs_client initialization tasks for NFSv4.1+ |
| 315 | − * @clp - nfs_client to initialize | |
| 320 | + * @clp: nfs_client to initialize | |
| 316 | 321 | * |
| 317 | 322 | * Returns zero on success, or a negative errno if some error occurred. |
| 318 | 323 | */ |
| @@ -360,9 +365,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) · 41 unmodified lines | ||
| 360 | 365 | * nfs4_init_client - Initialise an NFS4 client record |
| 361 | 366 | * |
| 362 | 367 | * @clp: nfs_client to initialise |
| 363 | − * @timeparms: timeout parameters for underlying RPC transport | |
| 364 | − * @ip_addr: callback IP address in presentation format | |
| 365 | − * @authflavor: authentication flavor for underlying RPC transport | |
| 368 | + * @cl_init: pointer to nfs_client_initdata | |
| 366 | 369 | * |
| 367 | 370 | * Returns pointer to an NFS client, or an ERR_PTR value. |
| 368 | 371 | */ |
| @@ -649,13 +652,13 @@ nfs4_check_server_scope(struct nfs41_server_scope *s1, · 280 unmodified lines | ||
| 649 | 652 | |
| 650 | 653 | /** |
| 651 | 654 | * nfs4_detect_session_trunking - Checks for session trunking. |
| 652 | − * | |
| 653 | − * Called after a successful EXCHANGE_ID on a multi-addr connection. | |
| 654 | − * Upon success, add the transport. | |
| 655 | − * | |
| 656 | 655 | * @clp: original mount nfs_client |
| 657 | 656 | * @res: result structure from an exchange_id using the original mount |
| 658 | 657 | * nfs_client with a new multi_addr transport |
| 658 | + * @xprt: pointer to the transport to add. | |
| 659 | + * | |
| 660 | + * Called after a successful EXCHANGE_ID on a multi-addr connection. | |
| 661 | + * Upon success, add the transport. | |
| 659 | 662 | * |
| 660 | 663 | * Returns zero on success, otherwise -EINVAL |
| 661 | 664 | * |
| @@ -137,6 +137,7 @@ static size_t nfs_parse_server_name(char *string, size_t len, · 136 unmodified lines | ||
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * nfs_find_best_sec - Find a security mechanism supported locally |
| 140 | + * @clnt: pointer to rpc_clnt | |
| 140 | 141 | * @server: NFS server struct |
| 141 | 142 | * @flavors: List of security tuples returned by SECINFO procedure |
| 142 | 143 | * |
| @@ -288,8 +289,8 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, · 145 unmodified lines | ||
| 288 | 289 | |
| 289 | 290 | /** |
| 290 | 291 | * nfs_follow_referral - set up mountpoint when hitting a referral on moved error |
| 291 | − * @dentry - parent directory | |
| 292 | − * @locations - array of NFSv4 server location information | |
| 292 | + * @dentry: parent directory | |
| 293 | + * @locations: array of NFSv4 server location information | |
| 293 | 294 | * |
| 294 | 295 | */ |
| 295 | 296 | static struct vfsmount *nfs_follow_referral(struct dentry *dentry, |
| @@ -730,33 +730,41 @@ static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res) · 729 unmodified lines | ||
| 730 | 730 | res->sr_slot = NULL; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | +static void nfs4_slot_sequence_record_sent(struct nfs4_slot *slot, | |
| 734 | + u32 seqnr) | |
| 735 | +{ | |
| 736 | + if ((s32)(seqnr - slot->seq_nr_highest_sent) > 0) | |
| 737 | + slot->seq_nr_highest_sent = seqnr; | |
| 738 | +} | |
| 739 | +static void nfs4_slot_sequence_acked(struct nfs4_slot *slot, | |
| 740 | + u32 seqnr) | |
| 741 | +{ | |
| 742 | + slot->seq_nr_highest_sent = seqnr; | |
| 743 | + slot->seq_nr_last_acked = seqnr; | |
| 744 | +} | |
| 745 | + | |
| 733 | 746 | static int nfs41_sequence_process(struct rpc_task *task, |
| 734 | 747 | struct nfs4_sequence_res *res) |
| 735 | 748 | { |
| 736 | 749 | struct nfs4_session *session; |
| 737 | 750 | struct nfs4_slot *slot = res->sr_slot; |
| 738 | 751 | struct nfs_client *clp; |
| 739 | − bool interrupted = false; | |
| 740 | 752 | int ret = 1; |
| 741 | 753 | |
| 742 | 754 | if (slot == NULL) |
| 743 | 755 | goto out_noaction; |
| 744 | 756 | /* don't increment the sequence number if the task wasn't sent */ |
| 745 | − if (!RPC_WAS_SENT(task)) | |
| 757 | + if (!RPC_WAS_SENT(task) || slot->seq_done) | |
| 746 | 758 | goto out; |
| 747 | 759 | |
| 748 | 760 | session = slot->table->session; |
| 749 | 761 | |
| 750 | − if (slot->interrupted) { | |
| 751 | − if (res->sr_status != -NFS4ERR_DELAY) | |
| 752 | − slot->interrupted = 0; | |
| 753 | − interrupted = true; | |
| 754 | − } | |
| 755 | − | |
| 756 | 762 | trace_nfs4_sequence_done(session, res); |
| 757 | 763 | /* Check the SEQUENCE operation status */ |
| 758 | 764 | switch (res->sr_status) { |
| 759 | 765 | case 0: |
| 766 | + /* Mark this sequence number as having been acked */ | |
| 767 | + nfs4_slot_sequence_acked(slot, slot->seq_nr); | |
| 760 | 768 | /* Update the slot's sequence and clientid lease timer */ |
| 761 | 769 | slot->seq_done = 1; |
| 762 | 770 | clp = session->clp; |
| @@ -771,9 +779,9 @@ static int nfs41_sequence_process(struct rpc_task *task, · 8 unmodified lines | ||
| 771 | 779 | * sr_status remains 1 if an RPC level error occurred. |
| 772 | 780 | * The server may or may not have processed the sequence |
| 773 | 781 | * operation.. |
| 774 | − * Mark the slot as having hosted an interrupted RPC call. | |
| 775 | 782 | */ |
| 776 | − slot->interrupted = 1; | |
| 783 | + nfs4_slot_sequence_record_sent(slot, slot->seq_nr); | |
| 784 | + slot->seq_done = 1; | |
| 777 | 785 | goto out; |
| 778 | 786 | case -NFS4ERR_DELAY: |
| 779 | 787 | /* The server detected a resend of the RPC call and |
| @@ -784,6 +792,7 @@ static int nfs41_sequence_process(struct rpc_task *task, · 4 unmodified lines | ||
| 784 | 792 | __func__, |
| 785 | 793 | slot->slot_nr, |
| 786 | 794 | slot->seq_nr); |
| 795 | + nfs4_slot_sequence_acked(slot, slot->seq_nr); | |
| 787 | 796 | goto out_retry; |
| 788 | 797 | case -NFS4ERR_RETRY_UNCACHED_REP: |
| 789 | 798 | case -NFS4ERR_SEQ_FALSE_RETRY: |
| @@ -791,6 +800,7 @@ static int nfs41_sequence_process(struct rpc_task *task, · 1 unmodified line | ||
| 791 | 800 | * The server thinks we tried to replay a request. |
| 792 | 801 | * Retry the call after bumping the sequence ID. |
| 793 | 802 | */ |
| 803 | + nfs4_slot_sequence_acked(slot, slot->seq_nr); | |
| 794 | 804 | goto retry_new_seq; |
| 795 | 805 | case -NFS4ERR_BADSLOT: |
| 796 | 806 | /* |
| @@ -801,21 +811,28 @@ static int nfs41_sequence_process(struct rpc_task *task, · 4 unmodified lines | ||
| 801 | 811 | goto session_recover; |
| 802 | 812 | goto retry_nowait; |
| 803 | 813 | case -NFS4ERR_SEQ_MISORDERED: |
| 814 | + nfs4_slot_sequence_record_sent(slot, slot->seq_nr); | |
| 804 | 815 | /* |
| 805 | − * Was the last operation on this sequence interrupted? | |
| 806 | − * If so, retry after bumping the sequence number. | |
| 807 | − */ | |
| 808 | − if (interrupted) | |
| 809 | − goto retry_new_seq; | |
| 810 | − /* | |
| 811 | − * Could this slot have been previously retired? | |
| 812 | − * If so, then the server may be expecting seq_nr = 1! | |
| 816 | + * Were one or more calls using this slot interrupted? | |
| 817 | + * If the server never received the request, then our | |
| 818 | + * transmitted slot sequence number may be too high. | |
| 813 | 819 | */ |
| 814 | − if (slot->seq_nr != 1) { | |
| 815 | − slot->seq_nr = 1; | |
| 820 | + if ((s32)(slot->seq_nr - slot->seq_nr_last_acked) > 1) { | |
| 821 | + slot->seq_nr--; | |
| 816 | 822 | goto retry_nowait; |
| 817 | 823 | } |
| 818 | − goto session_recover; | |
| 824 | + /* | |
| 825 | + * RFC5661: | |
| 826 | + * A retry might be sent while the original request is | |
| 827 | + * still in progress on the replier. The replier SHOULD | |
| 828 | + * deal with the issue by returning NFS4ERR_DELAY as the | |
| 829 | + * reply to SEQUENCE or CB_SEQUENCE operation, but | |
| 830 | + * implementations MAY return NFS4ERR_SEQ_MISORDERED. | |
| 831 | + * | |
| 832 | + * Restart the search after a delay. | |
| 833 | + */ | |
| 834 | + slot->seq_nr = slot->seq_nr_highest_sent; | |
| 835 | + goto out_retry; | |
| 819 | 836 | default: |
| 820 | 837 | /* Just update the slot sequence no. */ |
| 821 | 838 | slot->seq_done = 1; |
| @@ -906,17 +923,6 @@ static const struct rpc_call_ops nfs41_call_sync_ops = { · 84 unmodified lines | ||
| 906 | 923 | .rpc_call_done = nfs41_call_sync_done, |
| 907 | 924 | }; |
| 908 | 925 | |
| 909 | −static void | |
| 910 | −nfs4_sequence_process_interrupted(struct nfs_client *client, | |
| 911 | − struct nfs4_slot *slot, const struct cred *cred) | |
| 912 | −{ | |
| 913 | − struct rpc_task *task; | |
| 914 | − | |
| 915 | − task = _nfs41_proc_sequence(client, cred, slot, true); | |
| 916 | − if (!IS_ERR(task)) | |
| 917 | − rpc_put_task_async(task); | |
| 918 | −} | |
| 919 | − | |
| 920 | 926 | #else /* !CONFIG_NFS_V4_1 */ |
| 921 | 927 | |
| 922 | 928 | static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res) |
| @@ -937,16 +943,15 @@ int nfs4_sequence_done(struct rpc_task *task, · 14 unmodified lines | ||
| 937 | 943 | } |
| 938 | 944 | EXPORT_SYMBOL_GPL(nfs4_sequence_done); |
| 939 | 945 | |
| 940 | −static void | |
| 941 | −nfs4_sequence_process_interrupted(struct nfs_client *client, | |
| 942 | − struct nfs4_slot *slot, const struct cred *cred) | |
| 946 | +#endif /* !CONFIG_NFS_V4_1 */ | |
| 947 | + | |
| 948 | +static void nfs41_sequence_res_init(struct nfs4_sequence_res *res) | |
| 943 | 949 | { |
| 944 | − WARN_ON_ONCE(1); | |
| 945 | − slot->interrupted = 0; | |
| 950 | + res->sr_timestamp = jiffies; | |
| 951 | + res->sr_status_flags = 0; | |
| 952 | + res->sr_status = 1; | |
| 946 | 953 | } |
| 947 | 954 | |
| 948 | −#endif /* !CONFIG_NFS_V4_1 */ | |
| 949 | − | |
| 950 | 955 | static |
| 951 | 956 | void nfs4_sequence_attach_slot(struct nfs4_sequence_args *args, |
| 952 | 957 | struct nfs4_sequence_res *res, |
| @@ -958,10 +963,6 @@ void nfs4_sequence_attach_slot(struct nfs4_sequence_args *args, · 5 unmodified lines | ||
| 958 | 963 | args->sa_slot = slot; |
| 959 | 964 | |
| 960 | 965 | res->sr_slot = slot; |
| 961 | − res->sr_timestamp = jiffies; | |
| 962 | − res->sr_status_flags = 0; | |
| 963 | − res->sr_status = 1; | |
| 964 | − | |
| 965 | 966 | } |
| 966 | 967 | |
| 967 | 968 | int nfs4_setup_sequence(struct nfs_client *client, |
| @@ -982,31 +983,25 @@ int nfs4_setup_sequence(struct nfs_client *client, · 14 unmodified lines | ||
| 982 | 983 | task->tk_timeout = 0; |
| 983 | 984 | } |
| 984 | 985 | |
| 985 | − for (;;) { | |
| 986 | − spin_lock(&tbl->slot_tbl_lock); | |
| 987 | − /* The state manager will wait until the slot table is empty */ | |
| 988 | − if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) | |
| 989 | − goto out_sleep; | |
| 990 | − | |
| 991 | − slot = nfs4_alloc_slot(tbl); | |
| 992 | − if (IS_ERR(slot)) { | |
| 993 | − /* Try again in 1/4 second */ | |
| 994 | − if (slot == ERR_PTR(-ENOMEM)) | |
| 995 | − task->tk_timeout = HZ >> 2; | |
| 996 | − goto out_sleep; | |
| 997 | − } | |
| 998 | − spin_unlock(&tbl->slot_tbl_lock); | |
| 986 | + spin_lock(&tbl->slot_tbl_lock); | |
| 987 | + /* The state manager will wait until the slot table is empty */ | |
| 988 | + if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) | |
| 989 | + goto out_sleep; | |
| 999 | 990 | |
| 1000 | − if (likely(!slot->interrupted)) | |
| 1001 | − break; | |
| 1002 | − nfs4_sequence_process_interrupted(client, | |
| 1003 | − slot, task->tk_msg.rpc_cred); | |
| 991 | + slot = nfs4_alloc_slot(tbl); | |
| 992 | + if (IS_ERR(slot)) { | |
| 993 | + /* Try again in 1/4 second */ | |
| 994 | + if (slot == ERR_PTR(-ENOMEM)) | |
| 995 | + task->tk_timeout = HZ >> 2; | |
| 996 | + goto out_sleep; | |
| 1004 | 997 | } |
| 998 | + spin_unlock(&tbl->slot_tbl_lock); | |
| 1005 | 999 | |
| 1006 | 1000 | nfs4_sequence_attach_slot(args, res, slot); |
| 1007 | 1001 | |
| 1008 | 1002 | trace_nfs4_setup_sequence(session, args); |
| 1009 | 1003 | out_start: |
| 1004 | + nfs41_sequence_res_init(res); | |
| 1010 | 1005 | rpc_call_start(task); |
| 1011 | 1006 | return 0; |
| 1012 | 1007 | |
| @@ -1555,6 +1550,10 @@ static void nfs_clear_open_stateid(struct nfs4_state *state, · 542 unmodified lines | ||
| 1555 | 1550 | |
| 1556 | 1551 | static void nfs_set_open_stateid_locked(struct nfs4_state *state, |
| 1557 | 1552 | const nfs4_stateid *stateid, nfs4_stateid *freeme) |
| 1553 | + __must_hold(&state->owner->so_lock) | |
| 1554 | + __must_hold(&state->seqlock) | |
| 1555 | + __must_hold(RCU) | |
| 1556 | + | |
| 1558 | 1557 | { |
| 1559 | 1558 | DEFINE_WAIT(wait); |
| 1560 | 1559 | int status = 0; |
| @@ -5963,7 +5962,7 @@ out: · 4402 unmodified lines | ||
| 5963 | 5962 | /** |
| 5964 | 5963 | * nfs4_proc_setclientid_confirm - Confirm client ID |
| 5965 | 5964 | * @clp: state data structure |
| 5966 | − * @res: result of a previous SETCLIENTID | |
| 5965 | + * @arg: result of a previous SETCLIENTID | |
| 5967 | 5966 | * @cred: credential to use for this call |
| 5968 | 5967 | * |
| 5969 | 5968 | * Returns zero, a negative errno, or a negative NFS4ERR status code. |
| @@ -7527,7 +7526,7 @@ int nfs4_proc_fsid_present(struct inode *inode, const struct cred *cred) · 1557 unmodified lines | ||
| 7527 | 7526 | return status; |
| 7528 | 7527 | } |
| 7529 | 7528 | |
| 7530 | −/** | |
| 7529 | +/* | |
| 7531 | 7530 | * If 'use_integrity' is true and the state managment nfs_client |
| 7532 | 7531 | * cl_rpcclient is using krb5i/p, use the integrity protected cl_rpcclient |
| 7533 | 7532 | * and the machine credential as per RFC3530bis and RFC5661 Security |
| @@ -8937,10 +8936,12 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout) · 1403 unmodified lines | ||
| 8937 | 8936 | if (status != 0) |
| 8938 | 8937 | goto out; |
| 8939 | 8938 | |
| 8940 | − /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */ | |
| 8941 | − if (task->tk_status < 0 || lgp->res.layoutp->len == 0) { | |
| 8939 | + if (task->tk_status < 0) { | |
| 8942 | 8940 | status = nfs4_layoutget_handle_exception(task, lgp, &exception); |
| 8943 | 8941 | *timeout = exception.timeout; |
| 8942 | + } else if (lgp->res.layoutp->len == 0) { | |
| 8943 | + status = -EAGAIN; | |
| 8944 | + *timeout = nfs4_update_delay(&exception.timeout); | |
| 8944 | 8945 | } else |
| 8945 | 8946 | lseg = pnfs_layout_process(lgp); |
| 8946 | 8947 | out: |
| @@ -9219,7 +9220,7 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) · 272 unmodified lines | ||
| 9219 | 9220 | return status; |
| 9220 | 9221 | } |
| 9221 | 9222 | |
| 9222 | −/** | |
| 9223 | +/* | |
| 9223 | 9224 | * Use the state managment nfs_client cl_rpcclient, which uses krb5i (if |
| 9224 | 9225 | * possible) as per RFC3530bis and RFC5661 Security Considerations sections |
| 9225 | 9226 | */ |
| @@ -9484,7 +9485,7 @@ static const struct rpc_call_ops nfs41_free_stateid_ops = { · 258 unmodified lines | ||
| 9484 | 9485 | * @server: server / transport on which to perform the operation |
| 9485 | 9486 | * @stateid: state ID to release |
| 9486 | 9487 | * @cred: credential |
| 9487 | − * @is_recovery: set to true if this call needs to be privileged | |
| 9488 | + * @privileged: set to true if this call needs to be privileged | |
| 9488 | 9489 | * |
| 9489 | 9490 | * Note: this function is always asynchronous. |
| 9490 | 9491 | */ |
| @@ -9691,7 +9692,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { · 200 unmodified lines | ||
| 9691 | 9692 | | NFS_CAP_DEALLOCATE |
| 9692 | 9693 | | NFS_CAP_SEEK |
| 9693 | 9694 | | NFS_CAP_LAYOUTSTATS |
| 9694 | − | NFS_CAP_CLONE, | |
| 9695 | + | NFS_CAP_CLONE | |
| 9696 | + | NFS_CAP_LAYOUTERROR, | |
| 9695 | 9697 | .init_client = nfs41_init_client, |
| 9696 | 9698 | .shutdown_client = nfs41_shutdown_client, |
| 9697 | 9699 | .match_stateid = nfs41_match_stateid, |
| @@ -55,7 +55,7 @@ static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize) · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * nfs4_slot_tbl_drain_complete - wake waiters when drain is complete |
| 58 | − * @tbl - controlling slot table | |
| 58 | + * @tbl: controlling slot table | |
| 59 | 59 | * |
| 60 | 60 | */ |
| 61 | 61 | void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl) |
| @@ -110,6 +110,8 @@ static struct nfs4_slot *nfs4_new_slot(struct nfs4_slot_table *tbl, · 48 unmodified lines | ||
| 110 | 110 | slot->table = tbl; |
| 111 | 111 | slot->slot_nr = slotid; |
| 112 | 112 | slot->seq_nr = seq_init; |
| 113 | + slot->seq_nr_highest_sent = seq_init; | |
| 114 | + slot->seq_nr_last_acked = seq_init - 1; | |
| 113 | 115 | } |
| 114 | 116 | return slot; |
| 115 | 117 | } |
| @@ -276,7 +278,8 @@ static void nfs4_reset_slot_table(struct nfs4_slot_table *tbl, · 160 unmodified lines | ||
| 276 | 278 | p = &tbl->slots; |
| 277 | 279 | while (*p) { |
| 278 | 280 | (*p)->seq_nr = ivalue; |
| 279 | − (*p)->interrupted = 0; | |
| 281 | + (*p)->seq_nr_highest_sent = ivalue; | |
| 282 | + (*p)->seq_nr_last_acked = ivalue - 1; | |
| 280 | 283 | p = &(*p)->next; |
| 281 | 284 | } |
| 282 | 285 | tbl->highest_used_slotid = NFS4_NO_SLOT; |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | /* maximum number of slots to use */ |
| 12 | 12 | #define NFS4_DEF_SLOT_TABLE_SIZE (64U) |
| 13 | −#define NFS4_DEF_CB_SLOT_TABLE_SIZE (1U) | |
| 13 | +#define NFS4_DEF_CB_SLOT_TABLE_SIZE (16U) | |
| 14 | 14 | #define NFS4_MAX_SLOT_TABLE (1024U) |
| 15 | 15 | #define NFS4_NO_SLOT ((u32)-1) |
| 16 | 16 | |
| @@ -23,8 +23,9 @@ struct nfs4_slot { · 6 unmodified lines | ||
| 23 | 23 | unsigned long generation; |
| 24 | 24 | u32 slot_nr; |
| 25 | 25 | u32 seq_nr; |
| 26 | − unsigned int interrupted : 1, | |
| 27 | − privileged : 1, | |
| 26 | + u32 seq_nr_last_acked; | |
| 27 | + u32 seq_nr_highest_sent; | |
| 28 | + unsigned int privileged : 1, | |
| 28 | 29 | seq_done : 1; |
| 29 | 30 | }; |
| 30 | 31 | |
| @@ -563,6 +563,7 @@ static void nfs4_gc_state_owners(struct nfs_server *server) · 562 unmodified lines | ||
| 563 | 563 | * nfs4_get_state_owner - Look up a state owner given a credential |
| 564 | 564 | * @server: nfs_server to search |
| 565 | 565 | * @cred: RPC credential to match |
| 566 | + * @gfp_flags: allocation mode | |
| 566 | 567 | * |
| 567 | 568 | * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL. |
| 568 | 569 | */ |
| @@ -524,6 +524,31 @@ TRACE_EVENT(nfs4_setup_sequence, · 523 unmodified lines | ||
| 524 | 524 | ) |
| 525 | 525 | ); |
| 526 | 526 | |
| 527 | +TRACE_EVENT(nfs4_xdr_status, | |
| 528 | + TP_PROTO( | |
| 529 | + u32 op, | |
| 530 | + int error | |
| 531 | + ), | |
| 532 | + | |
| 533 | + TP_ARGS(op, error), | |
| 534 | + | |
| 535 | + TP_STRUCT__entry( | |
| 536 | + __field(u32, op) | |
| 537 | + __field(int, error) | |
| 538 | + ), | |
| 539 | + | |
| 540 | + TP_fast_assign( | |
| 541 | + __entry->op = op; | |
| 542 | + __entry->error = -error; | |
| 543 | + ), | |
| 544 | + | |
| 545 | + TP_printk( | |
| 546 | + "operation %d: nfs status %d (%s)", | |
| 547 | + __entry->op, | |
| 548 | + __entry->error, show_nfsv4_errors(__entry->error) | |
| 549 | + ) | |
| 550 | +); | |
| 551 | + | |
| 527 | 552 | DECLARE_EVENT_CLASS(nfs4_open_event, |
| 528 | 553 | TP_PROTO( |
| 529 | 554 | const struct nfs_open_context *ctx, |
| @@ -54,6 +54,7 @@ · 53 unmodified lines | ||
| 54 | 54 | #include <linux/nfs_fs.h> |
| 55 | 55 | |
| 56 | 56 | #include "nfs4_fs.h" |
| 57 | +#include "nfs4trace.h" | |
| 57 | 58 | #include "internal.h" |
| 58 | 59 | #include "nfs4idmap.h" |
| 59 | 60 | #include "nfs4session.h" |
| @@ -214,14 +215,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 154 unmodified lines | ||
| 214 | 215 | nfs4_fattr_bitmap_maxsz) |
| 215 | 216 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 216 | 217 | encode_stateid_maxsz + 3) |
| 217 | −#define decode_read_maxsz (op_decode_hdr_maxsz + 2) | |
| 218 | +#define decode_read_maxsz (op_decode_hdr_maxsz + 2 + 1) | |
| 218 | 219 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
| 219 | 220 | 2 + encode_verifier_maxsz + 5 + \ |
| 220 | 221 | nfs4_label_maxsz) |
| 221 | 222 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
| 222 | − decode_verifier_maxsz) | |
| 223 | + decode_verifier_maxsz + 1) | |
| 223 | 224 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 224 | −#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) | |
| 225 | +#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1 + 1) | |
| 225 | 226 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 226 | 227 | encode_stateid_maxsz + 4) |
| 227 | 228 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| @@ -283,14 +284,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 55 unmodified lines | ||
| 283 | 284 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
| 284 | 285 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 285 | 286 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 286 | − nfs4_fattr_bitmap_maxsz + 1) | |
| 287 | + nfs4_fattr_bitmap_maxsz + 1 + 1) | |
| 287 | 288 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 288 | 289 | encode_stateid_maxsz + 3) |
| 289 | 290 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
| 290 | 291 | #define encode_fs_locations_maxsz \ |
| 291 | 292 | (encode_getattr_maxsz) |
| 292 | 293 | #define decode_fs_locations_maxsz \ |
| 293 | − (0) | |
| 294 | + (1) | |
| 294 | 295 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 295 | 296 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
| 296 | 297 | |
| @@ -391,12 +392,13 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 94 unmodified lines | ||
| 391 | 392 | 1 /* opaque devaddr4 length */ + \ |
| 392 | 393 | /* devaddr4 payload is read into page */ \ |
| 393 | 394 | 1 /* notification bitmap length */ + \ |
| 394 | − 1 /* notification bitmap, word 0 */) | |
| 395 | + 1 /* notification bitmap, word 0 */ + \ | |
| 396 | + 1 /* possible XDR padding */) | |
| 395 | 397 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 396 | 398 | encode_stateid_maxsz) |
| 397 | 399 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 398 | 400 | decode_stateid_maxsz + \ |
| 399 | − XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) | |
| 401 | + XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + 1) | |
| 400 | 402 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 401 | 403 | 2 /* offset */ + \ |
| 402 | 404 | 2 /* length */ + \ |
| @@ -1015,12 +1017,11 @@ static void encode_compound_hdr(struct xdr_stream *xdr, · 612 unmodified lines | ||
| 1015 | 1017 | struct compound_hdr *hdr) |
| 1016 | 1018 | { |
| 1017 | 1019 | __be32 *p; |
| 1018 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 1019 | 1020 | |
| 1020 | 1021 | /* initialize running count of expected bytes in reply. |
| 1021 | 1022 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 1022 | 1023 | * but this is not required as a MUST for the server to do so. */ |
| 1023 | − hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; | |
| 1024 | + hdr->replen = 3 + hdr->taglen; | |
| 1024 | 1025 | |
| 1025 | 1026 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
| 1026 | 1027 | encode_string(xdr, hdr->taglen, hdr->tag); |
| @@ -2340,9 +2341,9 @@ static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, · 1313 unmodified lines | ||
| 2340 | 2341 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
| 2341 | 2342 | if (args->lg_args) { |
| 2342 | 2343 | encode_layoutget(xdr, args->lg_args, &hdr); |
| 2343 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 2344 | − args->lg_args->layout.pages, | |
| 2345 | − 0, args->lg_args->layout.pglen); | |
| 2344 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, | |
| 2345 | + args->lg_args->layout.pglen, | |
| 2346 | + hdr.replen); | |
| 2346 | 2347 | } |
| 2347 | 2348 | encode_nops(&hdr); |
| 2348 | 2349 | } |
| @@ -2386,9 +2387,9 @@ static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, · 37 unmodified lines | ||
| 2386 | 2387 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
| 2387 | 2388 | if (args->lg_args) { |
| 2388 | 2389 | encode_layoutget(xdr, args->lg_args, &hdr); |
| 2389 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 2390 | − args->lg_args->layout.pages, | |
| 2391 | − 0, args->lg_args->layout.pglen); | |
| 2390 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, | |
| 2391 | + args->lg_args->layout.pglen, | |
| 2392 | + hdr.replen); | |
| 2392 | 2393 | } |
| 2393 | 2394 | encode_nops(&hdr); |
| 2394 | 2395 | } |
| @@ -2498,8 +2499,8 @@ static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, · 103 unmodified lines | ||
| 2498 | 2499 | encode_putfh(xdr, args->fh, &hdr); |
| 2499 | 2500 | encode_readlink(xdr, args, req, &hdr); |
| 2500 | 2501 | |
| 2501 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | |
| 2502 | − args->pgbase, args->pglen); | |
| 2502 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2503 | + args->pglen, hdr.replen); | |
| 2503 | 2504 | encode_nops(&hdr); |
| 2504 | 2505 | } |
| 2505 | 2506 | |
| @@ -2519,11 +2520,8 @@ static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, · 13 unmodified lines | ||
| 2519 | 2520 | encode_putfh(xdr, args->fh, &hdr); |
| 2520 | 2521 | encode_readdir(xdr, args, req, &hdr); |
| 2521 | 2522 | |
| 2522 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | |
| 2523 | − args->pgbase, args->count); | |
| 2524 | − dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", | |
| 2525 | − __func__, hdr.replen << 2, args->pages, | |
| 2526 | − args->pgbase, args->count); | |
| 2523 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2524 | + args->count, hdr.replen); | |
| 2527 | 2525 | encode_nops(&hdr); |
| 2528 | 2526 | } |
| 2529 | 2527 | |
| @@ -2543,8 +2541,8 @@ static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, · 13 unmodified lines | ||
| 2543 | 2541 | encode_putfh(xdr, args->fh, &hdr); |
| 2544 | 2542 | encode_read(xdr, args, &hdr); |
| 2545 | 2543 | |
| 2546 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 2547 | − args->pages, args->pgbase, args->count); | |
| 2544 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2545 | + args->count, hdr.replen); | |
| 2548 | 2546 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 2549 | 2547 | encode_nops(&hdr); |
| 2550 | 2548 | } |
| @@ -2590,9 +2588,8 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, · 39 unmodified lines | ||
| 2590 | 2588 | encode_getattr(xdr, nfs4_acl_bitmap, NULL, |
| 2591 | 2589 | ARRAY_SIZE(nfs4_acl_bitmap), &hdr); |
| 2592 | 2590 | |
| 2593 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | |
| 2594 | − args->acl_pages, 0, args->acl_len); | |
| 2595 | − | |
| 2591 | + rpc_prepare_reply_pages(req, args->acl_pages, 0, | |
| 2592 | + args->acl_len, replen); | |
| 2596 | 2593 | encode_nops(&hdr); |
| 2597 | 2594 | } |
| 2598 | 2595 | |
| @@ -2813,9 +2810,8 @@ static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, · 214 unmodified lines | ||
| 2813 | 2810 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2814 | 2811 | } |
| 2815 | 2812 | |
| 2816 | − /* Set up reply kvec to capture returned fs_locations array. */ | |
| 2817 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | |
| 2818 | − (struct page **)&args->page, 0, PAGE_SIZE); | |
| 2813 | + rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, | |
| 2814 | + PAGE_SIZE, replen); | |
| 2819 | 2815 | encode_nops(&hdr); |
| 2820 | 2816 | } |
| 2821 | 2817 | |
| @@ -3017,10 +3013,8 @@ static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, · 195 unmodified lines | ||
| 3017 | 3013 | |
| 3018 | 3014 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 3019 | 3015 | * so that notification bitmap is put in xdr_buf tail */ |
| 3020 | − xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, | |
| 3021 | − args->pdev->pages, args->pdev->pgbase, | |
| 3022 | − args->pdev->pglen); | |
| 3023 | − | |
| 3016 | + rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase, | |
| 3017 | + args->pdev->pglen, hdr.replen - 2); | |
| 3024 | 3018 | encode_nops(&hdr); |
| 3025 | 3019 | } |
| 3026 | 3020 | |
| @@ -3041,9 +3035,8 @@ static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, · 14 unmodified lines | ||
| 3041 | 3035 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3042 | 3036 | encode_layoutget(xdr, args, &hdr); |
| 3043 | 3037 | |
| 3044 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 3045 | − args->layout.pages, 0, args->layout.pglen); | |
| 3046 | − | |
| 3038 | + rpc_prepare_reply_pages(req, args->layout.pages, 0, | |
| 3039 | + args->layout.pglen, hdr.replen); | |
| 3047 | 3040 | encode_nops(&hdr); |
| 3048 | 3041 | } |
| 3049 | 3042 | |
| @@ -3144,22 +3137,12 @@ static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, · 94 unmodified lines | ||
| 3144 | 3137 | } |
| 3145 | 3138 | #endif /* CONFIG_NFS_V4_1 */ |
| 3146 | 3139 | |
| 3147 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 3148 | −{ | |
| 3149 | − dprintk("nfs: %s: prematurely hit end of receive buffer. " | |
| 3150 | − "Remaining buffer length is %tu words.\n", | |
| 3151 | − func, xdr->end - xdr->p); | |
| 3152 | −} | |
| 3153 | − | |
| 3154 | 3140 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
| 3155 | 3141 | { |
| 3156 | 3142 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
| 3157 | 3143 | NFS4_OPAQUE_LIMIT); |
| 3158 | − if (unlikely(ret < 0)) { | |
| 3159 | − if (ret == -EBADMSG) | |
| 3160 | − print_overflow_msg(__func__, xdr); | |
| 3144 | + if (unlikely(ret < 0)) | |
| 3161 | 3145 | return -EIO; |
| 3162 | − } | |
| 3163 | 3146 | *len = ret; |
| 3164 | 3147 | return 0; |
| 3165 | 3148 | } |
| @@ -3170,22 +3153,19 @@ static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) · 4 unmodified lines | ||
| 3170 | 3153 | |
| 3171 | 3154 | p = xdr_inline_decode(xdr, 8); |
| 3172 | 3155 | if (unlikely(!p)) |
| 3173 | − goto out_overflow; | |
| 3156 | + return -EIO; | |
| 3174 | 3157 | hdr->status = be32_to_cpup(p++); |
| 3175 | 3158 | hdr->taglen = be32_to_cpup(p); |
| 3176 | 3159 | |
| 3177 | 3160 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3178 | 3161 | if (unlikely(!p)) |
| 3179 | − goto out_overflow; | |
| 3162 | + return -EIO; | |
| 3180 | 3163 | hdr->tag = (char *)p; |
| 3181 | 3164 | p += XDR_QUADLEN(hdr->taglen); |
| 3182 | 3165 | hdr->nops = be32_to_cpup(p); |
| 3183 | 3166 | if (unlikely(hdr->nops < 1)) |
| 3184 | 3167 | return nfs4_stat_to_errno(hdr->status); |
| 3185 | 3168 | return 0; |
| 3186 | −out_overflow: | |
| 3187 | − print_overflow_msg(__func__, xdr); | |
| 3188 | − return -EIO; | |
| 3189 | 3169 | } |
| 3190 | 3170 | |
| 3191 | 3171 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| @@ -3201,11 +3181,14 @@ static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, · 9 unmodified lines | ||
| 3201 | 3181 | opnum = be32_to_cpup(p++); |
| 3202 | 3182 | if (unlikely(opnum != expected)) |
| 3203 | 3183 | goto out_bad_operation; |
| 3184 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) | |
| 3185 | + goto out_status; | |
| 3186 | + *nfs_retval = 0; | |
| 3187 | + return true; | |
| 3188 | +out_status: | |
| 3204 | 3189 | nfserr = be32_to_cpup(p); |
| 3205 | − if (nfserr == NFS_OK) | |
| 3206 | − *nfs_retval = 0; | |
| 3207 | − else | |
| 3208 | − *nfs_retval = nfs4_stat_to_errno(nfserr); | |
| 3190 | + trace_nfs4_xdr_status(opnum, nfserr); | |
| 3191 | + *nfs_retval = nfs4_stat_to_errno(nfserr); | |
| 3209 | 3192 | return true; |
| 3210 | 3193 | out_bad_operation: |
| 3211 | 3194 | dprintk("nfs: Server returned operation" |
| @@ -3214,7 +3197,6 @@ out_bad_operation: · 2 unmodified lines | ||
| 3214 | 3197 | *nfs_retval = -EREMOTEIO; |
| 3215 | 3198 | return false; |
| 3216 | 3199 | out_overflow: |
| 3217 | − print_overflow_msg(__func__, xdr); | |
| 3218 | 3200 | *nfs_retval = -EIO; |
| 3219 | 3201 | return false; |
| 3220 | 3202 | } |
| @@ -3235,10 +3217,9 @@ static int decode_ace(struct xdr_stream *xdr, void *ace) · 14 unmodified lines | ||
| 3235 | 3217 | char *str; |
| 3236 | 3218 | |
| 3237 | 3219 | p = xdr_inline_decode(xdr, 12); |
| 3238 | − if (likely(p)) | |
| 3239 | − return decode_opaque_inline(xdr, &strlen, &str); | |
| 3240 | − print_overflow_msg(__func__, xdr); | |
| 3241 | − return -EIO; | |
| 3220 | + if (unlikely(!p)) | |
| 3221 | + return -EIO; | |
| 3222 | + return decode_opaque_inline(xdr, &strlen, &str); | |
| 3242 | 3223 | } |
| 3243 | 3224 | |
| 3244 | 3225 | static ssize_t |
| @@ -3249,10 +3230,9 @@ decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz) · 4 unmodified lines | ||
| 3249 | 3230 | ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz); |
| 3250 | 3231 | if (likely(ret >= 0)) |
| 3251 | 3232 | return ret; |
| 3252 | − if (ret == -EMSGSIZE) | |
| 3253 | − return sz; | |
| 3254 | − print_overflow_msg(__func__, xdr); | |
| 3255 | − return -EIO; | |
| 3233 | + if (ret != -EMSGSIZE) | |
| 3234 | + return -EIO; | |
| 3235 | + return sz; | |
| 3256 | 3236 | } |
| 3257 | 3237 | |
| 3258 | 3238 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| @@ -3268,13 +3248,10 @@ static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigne · 9 unmodified lines | ||
| 3268 | 3248 | |
| 3269 | 3249 | p = xdr_inline_decode(xdr, 4); |
| 3270 | 3250 | if (unlikely(!p)) |
| 3271 | − goto out_overflow; | |
| 3251 | + return -EIO; | |
| 3272 | 3252 | *attrlen = be32_to_cpup(p); |
| 3273 | 3253 | *savep = xdr_stream_pos(xdr); |
| 3274 | 3254 | return 0; |
| 3275 | −out_overflow: | |
| 3276 | − print_overflow_msg(__func__, xdr); | |
| 3277 | − return -EIO; | |
| 3278 | 3255 | } |
| 3279 | 3256 | |
| 3280 | 3257 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| @@ -3303,7 +3280,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t * · 22 unmodified lines | ||
| 3303 | 3280 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
| 3304 | 3281 | p = xdr_inline_decode(xdr, 4); |
| 3305 | 3282 | if (unlikely(!p)) |
| 3306 | − goto out_overflow; | |
| 3283 | + return -EIO; | |
| 3307 | 3284 | *type = be32_to_cpup(p); |
| 3308 | 3285 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
| 3309 | 3286 | dprintk("%s: bad type %d\n", __func__, *type); |
| @@ -3314,9 +3291,6 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t * · 4 unmodified lines | ||
| 3314 | 3291 | } |
| 3315 | 3292 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
| 3316 | 3293 | return ret; |
| 3317 | −out_overflow: | |
| 3318 | − print_overflow_msg(__func__, xdr); | |
| 3319 | − return -EIO; | |
| 3320 | 3294 | } |
| 3321 | 3295 | |
| 3322 | 3296 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| @@ -3330,15 +3304,12 @@ static int decode_attr_fh_expire_type(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 3330 | 3304 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3331 | 3305 | p = xdr_inline_decode(xdr, 4); |
| 3332 | 3306 | if (unlikely(!p)) |
| 3333 | − goto out_overflow; | |
| 3307 | + return -EIO; | |
| 3334 | 3308 | *type = be32_to_cpup(p); |
| 3335 | 3309 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3336 | 3310 | } |
| 3337 | 3311 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3338 | 3312 | return 0; |
| 3339 | −out_overflow: | |
| 3340 | − print_overflow_msg(__func__, xdr); | |
| 3341 | − return -EIO; | |
| 3342 | 3313 | } |
| 3343 | 3314 | |
| 3344 | 3315 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| @@ -3352,7 +3323,7 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 7 unmodified lines | ||
| 3352 | 3323 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
| 3353 | 3324 | p = xdr_inline_decode(xdr, 8); |
| 3354 | 3325 | if (unlikely(!p)) |
| 3355 | − goto out_overflow; | |
| 3326 | + return -EIO; | |
| 3356 | 3327 | xdr_decode_hyper(p, change); |
| 3357 | 3328 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
| 3358 | 3329 | ret = NFS_ATTR_FATTR_CHANGE; |
| @@ -3360,9 +3331,6 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 1 unmodified line | ||
| 3360 | 3331 | dprintk("%s: change attribute=%Lu\n", __func__, |
| 3361 | 3332 | (unsigned long long)*change); |
| 3362 | 3333 | return ret; |
| 3363 | −out_overflow: | |
| 3364 | − print_overflow_msg(__func__, xdr); | |
| 3365 | − return -EIO; | |
| 3366 | 3334 | } |
| 3367 | 3335 | |
| 3368 | 3336 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| @@ -3376,16 +3344,13 @@ static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t * · 7 unmodified lines | ||
| 3376 | 3344 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
| 3377 | 3345 | p = xdr_inline_decode(xdr, 8); |
| 3378 | 3346 | if (unlikely(!p)) |
| 3379 | − goto out_overflow; | |
| 3347 | + return -EIO; | |
| 3380 | 3348 | xdr_decode_hyper(p, size); |
| 3381 | 3349 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
| 3382 | 3350 | ret = NFS_ATTR_FATTR_SIZE; |
| 3383 | 3351 | } |
| 3384 | 3352 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
| 3385 | 3353 | return ret; |
| 3386 | −out_overflow: | |
| 3387 | − print_overflow_msg(__func__, xdr); | |
| 3388 | − return -EIO; | |
| 3389 | 3354 | } |
| 3390 | 3355 | |
| 3391 | 3356 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3398,15 +3363,12 @@ static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, ui · 6 unmodified lines | ||
| 3398 | 3363 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
| 3399 | 3364 | p = xdr_inline_decode(xdr, 4); |
| 3400 | 3365 | if (unlikely(!p)) |
| 3401 | − goto out_overflow; | |
| 3366 | + return -EIO; | |
| 3402 | 3367 | *res = be32_to_cpup(p); |
| 3403 | 3368 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3404 | 3369 | } |
| 3405 | 3370 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3406 | 3371 | return 0; |
| 3407 | −out_overflow: | |
| 3408 | − print_overflow_msg(__func__, xdr); | |
| 3409 | − return -EIO; | |
| 3410 | 3372 | } |
| 3411 | 3373 | |
| 3412 | 3374 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3419,15 +3381,12 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, · 6 unmodified lines | ||
| 3419 | 3381 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
| 3420 | 3382 | p = xdr_inline_decode(xdr, 4); |
| 3421 | 3383 | if (unlikely(!p)) |
| 3422 | − goto out_overflow; | |
| 3384 | + return -EIO; | |
| 3423 | 3385 | *res = be32_to_cpup(p); |
| 3424 | 3386 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3425 | 3387 | } |
| 3426 | 3388 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3427 | 3389 | return 0; |
| 3428 | −out_overflow: | |
| 3429 | − print_overflow_msg(__func__, xdr); | |
| 3430 | − return -EIO; | |
| 3431 | 3390 | } |
| 3432 | 3391 | |
| 3433 | 3392 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
| @@ -3442,7 +3401,7 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs · 8 unmodified lines | ||
| 3442 | 3401 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
| 3443 | 3402 | p = xdr_inline_decode(xdr, 16); |
| 3444 | 3403 | if (unlikely(!p)) |
| 3445 | − goto out_overflow; | |
| 3404 | + return -EIO; | |
| 3446 | 3405 | p = xdr_decode_hyper(p, &fsid->major); |
| 3447 | 3406 | xdr_decode_hyper(p, &fsid->minor); |
| 3448 | 3407 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
| @@ -3452,9 +3411,6 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs · 3 unmodified lines | ||
| 3452 | 3411 | (unsigned long long)fsid->major, |
| 3453 | 3412 | (unsigned long long)fsid->minor); |
| 3454 | 3413 | return ret; |
| 3455 | −out_overflow: | |
| 3456 | − print_overflow_msg(__func__, xdr); | |
| 3457 | − return -EIO; | |
| 3458 | 3414 | } |
| 3459 | 3415 | |
| 3460 | 3416 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3467,15 +3423,12 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint · 6 unmodified lines | ||
| 3467 | 3423 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
| 3468 | 3424 | p = xdr_inline_decode(xdr, 4); |
| 3469 | 3425 | if (unlikely(!p)) |
| 3470 | − goto out_overflow; | |
| 3426 | + return -EIO; | |
| 3471 | 3427 | *res = be32_to_cpup(p); |
| 3472 | 3428 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3473 | 3429 | } |
| 3474 | 3430 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
| 3475 | 3431 | return 0; |
| 3476 | −out_overflow: | |
| 3477 | − print_overflow_msg(__func__, xdr); | |
| 3478 | − return -EIO; | |
| 3479 | 3432 | } |
| 3480 | 3433 | |
| 3481 | 3434 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
| @@ -3487,14 +3440,11 @@ static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t * · 5 unmodified lines | ||
| 3487 | 3440 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3488 | 3441 | p = xdr_inline_decode(xdr, 4); |
| 3489 | 3442 | if (unlikely(!p)) |
| 3490 | − goto out_overflow; | |
| 3443 | + return -EIO; | |
| 3491 | 3444 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
| 3492 | 3445 | *res = -be32_to_cpup(p); |
| 3493 | 3446 | } |
| 3494 | 3447 | return 0; |
| 3495 | −out_overflow: | |
| 3496 | − print_overflow_msg(__func__, xdr); | |
| 3497 | − return -EIO; | |
| 3498 | 3448 | } |
| 3499 | 3449 | |
| 3500 | 3450 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
| @@ -3526,13 +3476,13 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru · 25 unmodified lines | ||
| 3526 | 3476 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3527 | 3477 | p = xdr_inline_decode(xdr, 4); |
| 3528 | 3478 | if (unlikely(!p)) |
| 3529 | − goto out_overflow; | |
| 3479 | + return -EIO; | |
| 3530 | 3480 | len = be32_to_cpup(p); |
| 3531 | 3481 | if (len > NFS4_FHSIZE) |
| 3532 | 3482 | return -EIO; |
| 3533 | 3483 | p = xdr_inline_decode(xdr, len); |
| 3534 | 3484 | if (unlikely(!p)) |
| 3535 | − goto out_overflow; | |
| 3485 | + return -EIO; | |
| 3536 | 3486 | if (fh != NULL) { |
| 3537 | 3487 | memcpy(fh->data, p, len); |
| 3538 | 3488 | fh->size = len; |
| @@ -3540,9 +3490,6 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru · 1 unmodified line | ||
| 3540 | 3490 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3541 | 3491 | } |
| 3542 | 3492 | return 0; |
| 3543 | −out_overflow: | |
| 3544 | − print_overflow_msg(__func__, xdr); | |
| 3545 | − return -EIO; | |
| 3546 | 3493 | } |
| 3547 | 3494 | |
| 3548 | 3495 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3555,15 +3502,12 @@ static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint · 6 unmodified lines | ||
| 3555 | 3502 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
| 3556 | 3503 | p = xdr_inline_decode(xdr, 4); |
| 3557 | 3504 | if (unlikely(!p)) |
| 3558 | − goto out_overflow; | |
| 3505 | + return -EIO; | |
| 3559 | 3506 | *res = be32_to_cpup(p); |
| 3560 | 3507 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3561 | 3508 | } |
| 3562 | 3509 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
| 3563 | 3510 | return 0; |
| 3564 | −out_overflow: | |
| 3565 | − print_overflow_msg(__func__, xdr); | |
| 3566 | − return -EIO; | |
| 3567 | 3511 | } |
| 3568 | 3512 | |
| 3569 | 3513 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| @@ -3577,16 +3521,13 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 7 unmodified lines | ||
| 3577 | 3521 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
| 3578 | 3522 | p = xdr_inline_decode(xdr, 8); |
| 3579 | 3523 | if (unlikely(!p)) |
| 3580 | − goto out_overflow; | |
| 3524 | + return -EIO; | |
| 3581 | 3525 | xdr_decode_hyper(p, fileid); |
| 3582 | 3526 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
| 3583 | 3527 | ret = NFS_ATTR_FATTR_FILEID; |
| 3584 | 3528 | } |
| 3585 | 3529 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
| 3586 | 3530 | return ret; |
| 3587 | −out_overflow: | |
| 3588 | − print_overflow_msg(__func__, xdr); | |
| 3589 | − return -EIO; | |
| 3590 | 3531 | } |
| 3591 | 3532 | |
| 3592 | 3533 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| @@ -3600,16 +3541,13 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitma · 7 unmodified lines | ||
| 3600 | 3541 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
| 3601 | 3542 | p = xdr_inline_decode(xdr, 8); |
| 3602 | 3543 | if (unlikely(!p)) |
| 3603 | − goto out_overflow; | |
| 3544 | + return -EIO; | |
| 3604 | 3545 | xdr_decode_hyper(p, fileid); |
| 3605 | 3546 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
| 3606 | 3547 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
| 3607 | 3548 | } |
| 3608 | 3549 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
| 3609 | 3550 | return ret; |
| 3610 | −out_overflow: | |
| 3611 | − print_overflow_msg(__func__, xdr); | |
| 3612 | − return -EIO; | |
| 3613 | 3551 | } |
| 3614 | 3552 | |
| 3615 | 3553 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3623,15 +3561,12 @@ static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 3623 | 3561 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
| 3624 | 3562 | p = xdr_inline_decode(xdr, 8); |
| 3625 | 3563 | if (unlikely(!p)) |
| 3626 | − goto out_overflow; | |
| 3564 | + return -EIO; | |
| 3627 | 3565 | xdr_decode_hyper(p, res); |
| 3628 | 3566 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3629 | 3567 | } |
| 3630 | 3568 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
| 3631 | 3569 | return status; |
| 3632 | −out_overflow: | |
| 3633 | − print_overflow_msg(__func__, xdr); | |
| 3634 | − return -EIO; | |
| 3635 | 3570 | } |
| 3636 | 3571 | |
| 3637 | 3572 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3645,15 +3580,12 @@ static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 3645 | 3580 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
| 3646 | 3581 | p = xdr_inline_decode(xdr, 8); |
| 3647 | 3582 | if (unlikely(!p)) |
| 3648 | − goto out_overflow; | |
| 3583 | + return -EIO; | |
| 3649 | 3584 | xdr_decode_hyper(p, res); |
| 3650 | 3585 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3651 | 3586 | } |
| 3652 | 3587 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
| 3653 | 3588 | return status; |
| 3654 | −out_overflow: | |
| 3655 | − print_overflow_msg(__func__, xdr); | |
| 3656 | − return -EIO; | |
| 3657 | 3589 | } |
| 3658 | 3590 | |
| 3659 | 3591 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3667,15 +3599,12 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 3667 | 3599 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
| 3668 | 3600 | p = xdr_inline_decode(xdr, 8); |
| 3669 | 3601 | if (unlikely(!p)) |
| 3670 | − goto out_overflow; | |
| 3602 | + return -EIO; | |
| 3671 | 3603 | xdr_decode_hyper(p, res); |
| 3672 | 3604 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3673 | 3605 | } |
| 3674 | 3606 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
| 3675 | 3607 | return status; |
| 3676 | −out_overflow: | |
| 3677 | − print_overflow_msg(__func__, xdr); | |
| 3678 | − return -EIO; | |
| 3679 | 3608 | } |
| 3680 | 3609 | |
| 3681 | 3610 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| @@ -3686,7 +3615,7 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) · 4 unmodified lines | ||
| 3686 | 3615 | |
| 3687 | 3616 | p = xdr_inline_decode(xdr, 4); |
| 3688 | 3617 | if (unlikely(!p)) |
| 3689 | − goto out_overflow; | |
| 3618 | + return -EIO; | |
| 3690 | 3619 | n = be32_to_cpup(p); |
| 3691 | 3620 | if (n == 0) |
| 3692 | 3621 | goto root_path; |
| @@ -3718,9 +3647,6 @@ out_eio: · 25 unmodified lines | ||
| 3718 | 3647 | dprintk(" status %d", status); |
| 3719 | 3648 | status = -EIO; |
| 3720 | 3649 | goto out; |
| 3721 | −out_overflow: | |
| 3722 | − print_overflow_msg(__func__, xdr); | |
| 3723 | − return -EIO; | |
| 3724 | 3650 | } |
| 3725 | 3651 | |
| 3726 | 3652 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) |
| @@ -3745,7 +3671,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 18 unmodified lines | ||
| 3745 | 3671 | goto out; |
| 3746 | 3672 | p = xdr_inline_decode(xdr, 4); |
| 3747 | 3673 | if (unlikely(!p)) |
| 3748 | − goto out_overflow; | |
| 3674 | + goto out_eio; | |
| 3749 | 3675 | n = be32_to_cpup(p); |
| 3750 | 3676 | if (n <= 0) |
| 3751 | 3677 | goto out_eio; |
| @@ -3758,7 +3684,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 6 unmodified lines | ||
| 3758 | 3684 | loc = &res->locations[res->nlocations]; |
| 3759 | 3685 | p = xdr_inline_decode(xdr, 4); |
| 3760 | 3686 | if (unlikely(!p)) |
| 3761 | − goto out_overflow; | |
| 3687 | + goto out_eio; | |
| 3762 | 3688 | m = be32_to_cpup(p); |
| 3763 | 3689 | |
| 3764 | 3690 | dprintk("%s: servers:\n", __func__); |
| @@ -3796,8 +3722,6 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 31 unmodified lines | ||
| 3796 | 3722 | out: |
| 3797 | 3723 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
| 3798 | 3724 | return status; |
| 3799 | −out_overflow: | |
| 3800 | − print_overflow_msg(__func__, xdr); | |
| 3801 | 3725 | out_eio: |
| 3802 | 3726 | status = -EIO; |
| 3803 | 3727 | goto out; |
| @@ -3814,15 +3738,12 @@ static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uin · 10 unmodified lines | ||
| 3814 | 3738 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
| 3815 | 3739 | p = xdr_inline_decode(xdr, 8); |
| 3816 | 3740 | if (unlikely(!p)) |
| 3817 | − goto out_overflow; | |
| 3741 | + return -EIO; | |
| 3818 | 3742 | xdr_decode_hyper(p, res); |
| 3819 | 3743 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3820 | 3744 | } |
| 3821 | 3745 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
| 3822 | 3746 | return status; |
| 3823 | −out_overflow: | |
| 3824 | − print_overflow_msg(__func__, xdr); | |
| 3825 | − return -EIO; | |
| 3826 | 3747 | } |
| 3827 | 3748 | |
| 3828 | 3749 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| @@ -3836,15 +3757,12 @@ static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 7 unmodified lines | ||
| 3836 | 3757 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
| 3837 | 3758 | p = xdr_inline_decode(xdr, 4); |
| 3838 | 3759 | if (unlikely(!p)) |
| 3839 | − goto out_overflow; | |
| 3760 | + return -EIO; | |
| 3840 | 3761 | *maxlink = be32_to_cpup(p); |
| 3841 | 3762 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3842 | 3763 | } |
| 3843 | 3764 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
| 3844 | 3765 | return status; |
| 3845 | −out_overflow: | |
| 3846 | − print_overflow_msg(__func__, xdr); | |
| 3847 | − return -EIO; | |
| 3848 | 3766 | } |
| 3849 | 3767 | |
| 3850 | 3768 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| @@ -3858,15 +3776,12 @@ static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 7 unmodified lines | ||
| 3858 | 3776 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
| 3859 | 3777 | p = xdr_inline_decode(xdr, 4); |
| 3860 | 3778 | if (unlikely(!p)) |
| 3861 | − goto out_overflow; | |
| 3779 | + return -EIO; | |
| 3862 | 3780 | *maxname = be32_to_cpup(p); |
| 3863 | 3781 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3864 | 3782 | } |
| 3865 | 3783 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
| 3866 | 3784 | return status; |
| 3867 | −out_overflow: | |
| 3868 | − print_overflow_msg(__func__, xdr); | |
| 3869 | − return -EIO; | |
| 3870 | 3785 | } |
| 3871 | 3786 | |
| 3872 | 3787 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3881,7 +3796,7 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 8 unmodified lines | ||
| 3881 | 3796 | uint64_t maxread; |
| 3882 | 3797 | p = xdr_inline_decode(xdr, 8); |
| 3883 | 3798 | if (unlikely(!p)) |
| 3884 | − goto out_overflow; | |
| 3799 | + return -EIO; | |
| 3885 | 3800 | xdr_decode_hyper(p, &maxread); |
| 3886 | 3801 | if (maxread > 0x7FFFFFFF) |
| 3887 | 3802 | maxread = 0x7FFFFFFF; |
| @@ -3890,9 +3805,6 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 2 unmodified lines | ||
| 3890 | 3805 | } |
| 3891 | 3806 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
| 3892 | 3807 | return status; |
| 3893 | −out_overflow: | |
| 3894 | − print_overflow_msg(__func__, xdr); | |
| 3895 | − return -EIO; | |
| 3896 | 3808 | } |
| 3897 | 3809 | |
| 3898 | 3810 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3907,7 +3819,7 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32 · 8 unmodified lines | ||
| 3907 | 3819 | uint64_t maxwrite; |
| 3908 | 3820 | p = xdr_inline_decode(xdr, 8); |
| 3909 | 3821 | if (unlikely(!p)) |
| 3910 | − goto out_overflow; | |
| 3822 | + return -EIO; | |
| 3911 | 3823 | xdr_decode_hyper(p, &maxwrite); |
| 3912 | 3824 | if (maxwrite > 0x7FFFFFFF) |
| 3913 | 3825 | maxwrite = 0x7FFFFFFF; |
| @@ -3916,9 +3828,6 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32 · 2 unmodified lines | ||
| 3916 | 3828 | } |
| 3917 | 3829 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
| 3918 | 3830 | return status; |
| 3919 | −out_overflow: | |
| 3920 | − print_overflow_msg(__func__, xdr); | |
| 3921 | − return -EIO; | |
| 3922 | 3831 | } |
| 3923 | 3832 | |
| 3924 | 3833 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) |
| @@ -3933,7 +3842,7 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *m · 8 unmodified lines | ||
| 3933 | 3842 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
| 3934 | 3843 | p = xdr_inline_decode(xdr, 4); |
| 3935 | 3844 | if (unlikely(!p)) |
| 3936 | − goto out_overflow; | |
| 3845 | + return -EIO; | |
| 3937 | 3846 | tmp = be32_to_cpup(p); |
| 3938 | 3847 | *mode = tmp & ~S_IFMT; |
| 3939 | 3848 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
| @@ -3941,9 +3850,6 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *m · 1 unmodified line | ||
| 3941 | 3850 | } |
| 3942 | 3851 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
| 3943 | 3852 | return ret; |
| 3944 | −out_overflow: | |
| 3945 | − print_overflow_msg(__func__, xdr); | |
| 3946 | − return -EIO; | |
| 3947 | 3853 | } |
| 3948 | 3854 | |
| 3949 | 3855 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| @@ -3957,16 +3863,13 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t · 7 unmodified lines | ||
| 3957 | 3863 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
| 3958 | 3864 | p = xdr_inline_decode(xdr, 4); |
| 3959 | 3865 | if (unlikely(!p)) |
| 3960 | − goto out_overflow; | |
| 3866 | + return -EIO; | |
| 3961 | 3867 | *nlink = be32_to_cpup(p); |
| 3962 | 3868 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
| 3963 | 3869 | ret = NFS_ATTR_FATTR_NLINK; |
| 3964 | 3870 | } |
| 3965 | 3871 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
| 3966 | 3872 | return ret; |
| 3967 | −out_overflow: | |
| 3968 | − print_overflow_msg(__func__, xdr); | |
| 3969 | − return -EIO; | |
| 3970 | 3873 | } |
| 3971 | 3874 | |
| 3972 | 3875 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
| @@ -4011,10 +3914,9 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, · 38 unmodified lines | ||
| 4011 | 3914 | return NFS_ATTR_FATTR_OWNER; |
| 4012 | 3915 | } |
| 4013 | 3916 | out: |
| 4014 | − if (len != -EBADMSG) | |
| 4015 | − return 0; | |
| 4016 | − print_overflow_msg(__func__, xdr); | |
| 4017 | − return -EIO; | |
| 3917 | + if (len == -EBADMSG) | |
| 3918 | + return -EIO; | |
| 3919 | + return 0; | |
| 4018 | 3920 | } |
| 4019 | 3921 | |
| 4020 | 3922 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
| @@ -4046,10 +3948,9 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, · 25 unmodified lines | ||
| 4046 | 3948 | return NFS_ATTR_FATTR_GROUP; |
| 4047 | 3949 | } |
| 4048 | 3950 | out: |
| 4049 | − if (len != -EBADMSG) | |
| 4050 | − return 0; | |
| 4051 | − print_overflow_msg(__func__, xdr); | |
| 4052 | − return -EIO; | |
| 3951 | + if (len == -EBADMSG) | |
| 3952 | + return -EIO; | |
| 3953 | + return 0; | |
| 4053 | 3954 | } |
| 4054 | 3955 | |
| 4055 | 3956 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| @@ -4066,7 +3967,7 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde · 10 unmodified lines | ||
| 4066 | 3967 | |
| 4067 | 3968 | p = xdr_inline_decode(xdr, 8); |
| 4068 | 3969 | if (unlikely(!p)) |
| 4069 | − goto out_overflow; | |
| 3970 | + return -EIO; | |
| 4070 | 3971 | major = be32_to_cpup(p++); |
| 4071 | 3972 | minor = be32_to_cpup(p); |
| 4072 | 3973 | tmp = MKDEV(major, minor); |
| @@ -4077,9 +3978,6 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde · 4 unmodified lines | ||
| 4077 | 3978 | } |
| 4078 | 3979 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
| 4079 | 3980 | return ret; |
| 4080 | −out_overflow: | |
| 4081 | − print_overflow_msg(__func__, xdr); | |
| 4082 | − return -EIO; | |
| 4083 | 3981 | } |
| 4084 | 3982 | |
| 4085 | 3983 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4093,15 +3991,12 @@ static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 4093 | 3991 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
| 4094 | 3992 | p = xdr_inline_decode(xdr, 8); |
| 4095 | 3993 | if (unlikely(!p)) |
| 4096 | − goto out_overflow; | |
| 3994 | + return -EIO; | |
| 4097 | 3995 | xdr_decode_hyper(p, res); |
| 4098 | 3996 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4099 | 3997 | } |
| 4100 | 3998 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
| 4101 | 3999 | return status; |
| 4102 | −out_overflow: | |
| 4103 | − print_overflow_msg(__func__, xdr); | |
| 4104 | − return -EIO; | |
| 4105 | 4000 | } |
| 4106 | 4001 | |
| 4107 | 4002 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4115,15 +4010,12 @@ static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 4115 | 4010 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
| 4116 | 4011 | p = xdr_inline_decode(xdr, 8); |
| 4117 | 4012 | if (unlikely(!p)) |
| 4118 | − goto out_overflow; | |
| 4013 | + return -EIO; | |
| 4119 | 4014 | xdr_decode_hyper(p, res); |
| 4120 | 4015 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4121 | 4016 | } |
| 4122 | 4017 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
| 4123 | 4018 | return status; |
| 4124 | −out_overflow: | |
| 4125 | − print_overflow_msg(__func__, xdr); | |
| 4126 | − return -EIO; | |
| 4127 | 4019 | } |
| 4128 | 4020 | |
| 4129 | 4021 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4137,15 +4029,12 @@ static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 4137 | 4029 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
| 4138 | 4030 | p = xdr_inline_decode(xdr, 8); |
| 4139 | 4031 | if (unlikely(!p)) |
| 4140 | − goto out_overflow; | |
| 4032 | + return -EIO; | |
| 4141 | 4033 | xdr_decode_hyper(p, res); |
| 4142 | 4034 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4143 | 4035 | } |
| 4144 | 4036 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
| 4145 | 4037 | return status; |
| 4146 | −out_overflow: | |
| 4147 | − print_overflow_msg(__func__, xdr); | |
| 4148 | − return -EIO; | |
| 4149 | 4038 | } |
| 4150 | 4039 | |
| 4151 | 4040 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| @@ -4159,7 +4048,7 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 4159 | 4048 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
| 4160 | 4049 | p = xdr_inline_decode(xdr, 8); |
| 4161 | 4050 | if (unlikely(!p)) |
| 4162 | − goto out_overflow; | |
| 4051 | + return -EIO; | |
| 4163 | 4052 | xdr_decode_hyper(p, used); |
| 4164 | 4053 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
| 4165 | 4054 | ret = NFS_ATTR_FATTR_SPACE_USED; |
| @@ -4167,9 +4056,6 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint · 1 unmodified line | ||
| 4167 | 4056 | dprintk("%s: space used=%Lu\n", __func__, |
| 4168 | 4057 | (unsigned long long)*used); |
| 4169 | 4058 | return ret; |
| 4170 | −out_overflow: | |
| 4171 | − print_overflow_msg(__func__, xdr); | |
| 4172 | − return -EIO; | |
| 4173 | 4059 | } |
| 4174 | 4060 | |
| 4175 | 4061 | static __be32 * |
| @@ -4189,12 +4075,9 @@ static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) · 13 unmodified lines | ||
| 4189 | 4075 | |
| 4190 | 4076 | p = xdr_inline_decode(xdr, nfstime4_maxsz << 2); |
| 4191 | 4077 | if (unlikely(!p)) |
| 4192 | − goto out_overflow; | |
| 4078 | + return -EIO; | |
| 4193 | 4079 | xdr_decode_nfstime4(p, time); |
| 4194 | 4080 | return 0; |
| 4195 | −out_overflow: | |
| 4196 | − print_overflow_msg(__func__, xdr); | |
| 4197 | − return -EIO; | |
| 4198 | 4081 | } |
| 4199 | 4082 | |
| 4200 | 4083 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| @@ -4265,19 +4148,19 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, · 64 unmodified lines | ||
| 4265 | 4148 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4266 | 4149 | p = xdr_inline_decode(xdr, 4); |
| 4267 | 4150 | if (unlikely(!p)) |
| 4268 | − goto out_overflow; | |
| 4151 | + return -EIO; | |
| 4269 | 4152 | lfs = be32_to_cpup(p++); |
| 4270 | 4153 | p = xdr_inline_decode(xdr, 4); |
| 4271 | 4154 | if (unlikely(!p)) |
| 4272 | − goto out_overflow; | |
| 4155 | + return -EIO; | |
| 4273 | 4156 | pi = be32_to_cpup(p++); |
| 4274 | 4157 | p = xdr_inline_decode(xdr, 4); |
| 4275 | 4158 | if (unlikely(!p)) |
| 4276 | − goto out_overflow; | |
| 4159 | + return -EIO; | |
| 4277 | 4160 | len = be32_to_cpup(p++); |
| 4278 | 4161 | p = xdr_inline_decode(xdr, len); |
| 4279 | 4162 | if (unlikely(!p)) |
| 4280 | − goto out_overflow; | |
| 4163 | + return -EIO; | |
| 4281 | 4164 | if (len < NFS4_MAXLABELLEN) { |
| 4282 | 4165 | if (label) { |
| 4283 | 4166 | memcpy(label->label, p, len); |
| @@ -4295,10 +4178,6 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, · 11 unmodified lines | ||
| 4295 | 4178 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4296 | 4179 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4297 | 4180 | return status; |
| 4298 | − | |
| 4299 | −out_overflow: | |
| 4300 | − print_overflow_msg(__func__, xdr); | |
| 4301 | − return -EIO; | |
| 4302 | 4181 | } |
| 4303 | 4182 | |
| 4304 | 4183 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| @@ -4342,14 +4221,11 @@ static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *c · 37 unmodified lines | ||
| 4342 | 4221 | |
| 4343 | 4222 | p = xdr_inline_decode(xdr, 20); |
| 4344 | 4223 | if (unlikely(!p)) |
| 4345 | − goto out_overflow; | |
| 4224 | + return -EIO; | |
| 4346 | 4225 | cinfo->atomic = be32_to_cpup(p++); |
| 4347 | 4226 | p = xdr_decode_hyper(p, &cinfo->before); |
| 4348 | 4227 | xdr_decode_hyper(p, &cinfo->after); |
| 4349 | 4228 | return 0; |
| 4350 | −out_overflow: | |
| 4351 | − print_overflow_msg(__func__, xdr); | |
| 4352 | − return -EIO; | |
| 4353 | 4229 | } |
| 4354 | 4230 | |
| 4355 | 4231 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
| @@ -4363,24 +4239,19 @@ static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) · 7 unmodified lines | ||
| 4363 | 4239 | return status; |
| 4364 | 4240 | p = xdr_inline_decode(xdr, 8); |
| 4365 | 4241 | if (unlikely(!p)) |
| 4366 | − goto out_overflow; | |
| 4242 | + return -EIO; | |
| 4367 | 4243 | supp = be32_to_cpup(p++); |
| 4368 | 4244 | acc = be32_to_cpup(p); |
| 4369 | 4245 | *supported = supp; |
| 4370 | 4246 | *access = acc; |
| 4371 | 4247 | return 0; |
| 4372 | −out_overflow: | |
| 4373 | − print_overflow_msg(__func__, xdr); | |
| 4374 | − return -EIO; | |
| 4375 | 4248 | } |
| 4376 | 4249 | |
| 4377 | 4250 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
| 4378 | 4251 | { |
| 4379 | 4252 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
| 4380 | − if (unlikely(ret < 0)) { | |
| 4381 | − print_overflow_msg(__func__, xdr); | |
| 4253 | + if (unlikely(ret < 0)) | |
| 4382 | 4254 | return -EIO; |
| 4383 | − } | |
| 4384 | 4255 | return 0; |
| 4385 | 4256 | } |
| 4386 | 4257 | |
| @@ -4460,13 +4331,11 @@ static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) · 73 unmodified lines | ||
| 4460 | 4331 | return status; |
| 4461 | 4332 | p = xdr_inline_decode(xdr, 4); |
| 4462 | 4333 | if (unlikely(!p)) |
| 4463 | − goto out_overflow; | |
| 4334 | + return -EIO; | |
| 4464 | 4335 | bmlen = be32_to_cpup(p); |
| 4465 | 4336 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4466 | 4337 | if (likely(p)) |
| 4467 | 4338 | return 0; |
| 4468 | −out_overflow: | |
| 4469 | − print_overflow_msg(__func__, xdr); | |
| 4470 | 4339 | return -EIO; |
| 4471 | 4340 | } |
| 4472 | 4341 | |
| @@ -4574,13 +4443,10 @@ static int decode_threshold_hint(struct xdr_stream *xdr, · 101 unmodified lines | ||
| 4574 | 4443 | if (likely(bitmap[0] & hint_bit)) { |
| 4575 | 4444 | p = xdr_inline_decode(xdr, 8); |
| 4576 | 4445 | if (unlikely(!p)) |
| 4577 | − goto out_overflow; | |
| 4446 | + return -EIO; | |
| 4578 | 4447 | xdr_decode_hyper(p, res); |
| 4579 | 4448 | } |
| 4580 | 4449 | return 0; |
| 4581 | −out_overflow: | |
| 4582 | − print_overflow_msg(__func__, xdr); | |
| 4583 | − return -EIO; | |
| 4584 | 4450 | } |
| 4585 | 4451 | |
| 4586 | 4452 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| @@ -4593,10 +4459,8 @@ static int decode_first_threshold_item4(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 4593 | 4459 | |
| 4594 | 4460 | /* layout type */ |
| 4595 | 4461 | p = xdr_inline_decode(xdr, 4); |
| 4596 | − if (unlikely(!p)) { | |
| 4597 | − print_overflow_msg(__func__, xdr); | |
| 4462 | + if (unlikely(!p)) | |
| 4598 | 4463 | return -EIO; |
| 4599 | − } | |
| 4600 | 4464 | res->l_type = be32_to_cpup(p); |
| 4601 | 4465 | |
| 4602 | 4466 | /* thi_hintset bitmap */ |
| @@ -4654,7 +4518,7 @@ static int decode_attr_mdsthreshold(struct xdr_stream *xdr, · 51 unmodified lines | ||
| 4654 | 4518 | return -EREMOTEIO; |
| 4655 | 4519 | p = xdr_inline_decode(xdr, 4); |
| 4656 | 4520 | if (unlikely(!p)) |
| 4657 | − goto out_overflow; | |
| 4521 | + return -EIO; | |
| 4658 | 4522 | num = be32_to_cpup(p); |
| 4659 | 4523 | if (num == 0) |
| 4660 | 4524 | return 0; |
| @@ -4667,9 +4531,6 @@ static int decode_attr_mdsthreshold(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 4667 | 4531 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
| 4668 | 4532 | } |
| 4669 | 4533 | return status; |
| 4670 | −out_overflow: | |
| 4671 | − print_overflow_msg(__func__, xdr); | |
| 4672 | − return -EIO; | |
| 4673 | 4534 | } |
| 4674 | 4535 | |
| 4675 | 4536 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| @@ -4857,7 +4718,7 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 181 unmodified lines | ||
| 4857 | 4718 | |
| 4858 | 4719 | p = xdr_inline_decode(xdr, 4); |
| 4859 | 4720 | if (unlikely(!p)) |
| 4860 | − goto out_overflow; | |
| 4721 | + return -EIO; | |
| 4861 | 4722 | fsinfo->nlayouttypes = be32_to_cpup(p); |
| 4862 | 4723 | |
| 4863 | 4724 | /* pNFS is not supported by the underlying file system */ |
| @@ -4867,7 +4728,7 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 3 unmodified lines | ||
| 4867 | 4728 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4868 | 4729 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
| 4869 | 4730 | if (unlikely(!p)) |
| 4870 | − goto out_overflow; | |
| 4731 | + return -EIO; | |
| 4871 | 4732 | |
| 4872 | 4733 | /* If we get too many, then just cap it at the max */ |
| 4873 | 4734 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
| @@ -4879,9 +4740,6 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 5 unmodified lines | ||
| 4879 | 4740 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
| 4880 | 4741 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
| 4881 | 4742 | return 0; |
| 4882 | −out_overflow: | |
| 4883 | − print_overflow_msg(__func__, xdr); | |
| 4884 | − return -EIO; | |
| 4885 | 4743 | } |
| 4886 | 4744 | |
| 4887 | 4745 | /* |
| @@ -4915,10 +4773,8 @@ static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, · 27 unmodified lines | ||
| 4915 | 4773 | *res = 0; |
| 4916 | 4774 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4917 | 4775 | p = xdr_inline_decode(xdr, 4); |
| 4918 | − if (unlikely(!p)) { | |
| 4919 | − print_overflow_msg(__func__, xdr); | |
| 4776 | + if (unlikely(!p)) | |
| 4920 | 4777 | return -EIO; |
| 4921 | − } | |
| 4922 | 4778 | *res = be32_to_cpup(p); |
| 4923 | 4779 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4924 | 4780 | } |
| @@ -4937,10 +4793,8 @@ static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, · 12 unmodified lines | ||
| 4937 | 4793 | *res = 0; |
| 4938 | 4794 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
| 4939 | 4795 | p = xdr_inline_decode(xdr, 4); |
| 4940 | − if (unlikely(!p)) { | |
| 4941 | − print_overflow_msg(__func__, xdr); | |
| 4796 | + if (unlikely(!p)) | |
| 4942 | 4797 | return -EIO; |
| 4943 | − } | |
| 4944 | 4798 | *res = be32_to_cpup(p); |
| 4945 | 4799 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
| 4946 | 4800 | } |
| @@ -5016,19 +4870,16 @@ static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) · 69 unmodified lines | ||
| 5016 | 4870 | |
| 5017 | 4871 | p = xdr_inline_decode(xdr, 4); |
| 5018 | 4872 | if (unlikely(!p)) |
| 5019 | − goto out_overflow; | |
| 4873 | + return -EIO; | |
| 5020 | 4874 | len = be32_to_cpup(p); |
| 5021 | 4875 | if (len > NFS4_FHSIZE) |
| 5022 | 4876 | return -EIO; |
| 5023 | 4877 | fh->size = len; |
| 5024 | 4878 | p = xdr_inline_decode(xdr, len); |
| 5025 | 4879 | if (unlikely(!p)) |
| 5026 | − goto out_overflow; | |
| 4880 | + return -EIO; | |
| 5027 | 4881 | memcpy(fh->data, p, len); |
| 5028 | 4882 | return 0; |
| 5029 | −out_overflow: | |
| 5030 | − print_overflow_msg(__func__, xdr); | |
| 5031 | − return -EIO; | |
| 5032 | 4883 | } |
| 5033 | 4884 | |
| 5034 | 4885 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| @@ -5052,7 +4903,7 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) · 17 unmodified lines | ||
| 5052 | 4903 | |
| 5053 | 4904 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
| 5054 | 4905 | if (unlikely(!p)) |
| 5055 | − goto out_overflow; | |
| 4906 | + return -EIO; | |
| 5056 | 4907 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
| 5057 | 4908 | p = xdr_decode_hyper(p, &length); |
| 5058 | 4909 | type = be32_to_cpup(p++); /* 4 byte read */ |
| @@ -5069,11 +4920,9 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) · 10 unmodified lines | ||
| 5069 | 4920 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 5070 | 4921 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 5071 | 4922 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
| 5072 | − if (likely(p)) | |
| 5073 | − return -NFS4ERR_DENIED; | |
| 5074 | −out_overflow: | |
| 5075 | − print_overflow_msg(__func__, xdr); | |
| 5076 | − return -EIO; | |
| 4923 | + if (likely(!p)) | |
| 4924 | + return -EIO; | |
| 4925 | + return -NFS4ERR_DENIED; | |
| 5077 | 4926 | } |
| 5078 | 4927 | |
| 5079 | 4928 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
| @@ -5142,7 +4991,7 @@ static int decode_space_limit(struct xdr_stream *xdr, · 62 unmodified lines | ||
| 5142 | 4991 | |
| 5143 | 4992 | p = xdr_inline_decode(xdr, 12); |
| 5144 | 4993 | if (unlikely(!p)) |
| 5145 | − goto out_overflow; | |
| 4994 | + return -EIO; | |
| 5146 | 4995 | limit_type = be32_to_cpup(p++); |
| 5147 | 4996 | switch (limit_type) { |
| 5148 | 4997 | case NFS4_LIMIT_SIZE: |
| @@ -5156,9 +5005,6 @@ static int decode_space_limit(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 5156 | 5005 | maxsize >>= PAGE_SHIFT; |
| 5157 | 5006 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
| 5158 | 5007 | return 0; |
| 5159 | −out_overflow: | |
| 5160 | − print_overflow_msg(__func__, xdr); | |
| 5161 | − return -EIO; | |
| 5162 | 5008 | } |
| 5163 | 5009 | |
| 5164 | 5010 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| @@ -5173,7 +5019,7 @@ static int decode_rw_delegation(struct xdr_stream *xdr, · 8 unmodified lines | ||
| 5173 | 5019 | return status; |
| 5174 | 5020 | p = xdr_inline_decode(xdr, 4); |
| 5175 | 5021 | if (unlikely(!p)) |
| 5176 | − goto out_overflow; | |
| 5022 | + return -EIO; | |
| 5177 | 5023 | res->do_recall = be32_to_cpup(p); |
| 5178 | 5024 | |
| 5179 | 5025 | switch (delegation_type) { |
| @@ -5186,9 +5032,6 @@ static int decode_rw_delegation(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 5186 | 5032 | return -EIO; |
| 5187 | 5033 | } |
| 5188 | 5034 | return decode_ace(xdr, NULL); |
| 5189 | −out_overflow: | |
| 5190 | − print_overflow_msg(__func__, xdr); | |
| 5191 | − return -EIO; | |
| 5192 | 5035 | } |
| 5193 | 5036 | |
| 5194 | 5037 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5198,7 +5041,7 @@ static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 3 unmodified lines | ||
| 5198 | 5041 | |
| 5199 | 5042 | p = xdr_inline_decode(xdr, 4); |
| 5200 | 5043 | if (unlikely(!p)) |
| 5201 | − goto out_overflow; | |
| 5044 | + return -EIO; | |
| 5202 | 5045 | why_no_delegation = be32_to_cpup(p); |
| 5203 | 5046 | switch (why_no_delegation) { |
| 5204 | 5047 | case WND4_CONTENTION: |
| @@ -5207,9 +5050,6 @@ static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 2 unmodified lines | ||
| 5207 | 5050 | /* Ignore for now */ |
| 5208 | 5051 | } |
| 5209 | 5052 | return 0; |
| 5210 | −out_overflow: | |
| 5211 | − print_overflow_msg(__func__, xdr); | |
| 5212 | − return -EIO; | |
| 5213 | 5053 | } |
| 5214 | 5054 | |
| 5215 | 5055 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5219,7 +5059,7 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 3 unmodified lines | ||
| 5219 | 5059 | |
| 5220 | 5060 | p = xdr_inline_decode(xdr, 4); |
| 5221 | 5061 | if (unlikely(!p)) |
| 5222 | − goto out_overflow; | |
| 5062 | + return -EIO; | |
| 5223 | 5063 | delegation_type = be32_to_cpup(p); |
| 5224 | 5064 | res->delegation_type = 0; |
| 5225 | 5065 | switch (delegation_type) { |
| @@ -5232,9 +5072,6 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 6 unmodified lines | ||
| 5232 | 5072 | return decode_no_delegation(xdr, res); |
| 5233 | 5073 | } |
| 5234 | 5074 | return -EIO; |
| 5235 | −out_overflow: | |
| 5236 | − print_overflow_msg(__func__, xdr); | |
| 5237 | − return -EIO; | |
| 5238 | 5075 | } |
| 5239 | 5076 | |
| 5240 | 5077 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5256,7 +5093,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 15 unmodified lines | ||
| 5256 | 5093 | |
| 5257 | 5094 | p = xdr_inline_decode(xdr, 8); |
| 5258 | 5095 | if (unlikely(!p)) |
| 5259 | − goto out_overflow; | |
| 5096 | + return -EIO; | |
| 5260 | 5097 | res->rflags = be32_to_cpup(p++); |
| 5261 | 5098 | bmlen = be32_to_cpup(p); |
| 5262 | 5099 | if (bmlen > 10) |
| @@ -5264,7 +5101,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 1 unmodified line | ||
| 5264 | 5101 | |
| 5265 | 5102 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5266 | 5103 | if (unlikely(!p)) |
| 5267 | − goto out_overflow; | |
| 5104 | + return -EIO; | |
| 5268 | 5105 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5269 | 5106 | for (i = 0; i < savewords; ++i) |
| 5270 | 5107 | res->attrset[i] = be32_to_cpup(p++); |
| @@ -5275,9 +5112,6 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 4 unmodified lines | ||
| 5275 | 5112 | xdr_error: |
| 5276 | 5113 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
| 5277 | 5114 | return -EIO; |
| 5278 | −out_overflow: | |
| 5279 | − print_overflow_msg(__func__, xdr); | |
| 5280 | − return -EIO; | |
| 5281 | 5115 | } |
| 5282 | 5116 | |
| 5283 | 5117 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| @@ -5326,7 +5160,7 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, · 42 unmodified lines | ||
| 5326 | 5160 | return status; |
| 5327 | 5161 | p = xdr_inline_decode(xdr, 8); |
| 5328 | 5162 | if (unlikely(!p)) |
| 5329 | − goto out_overflow; | |
| 5163 | + return -EIO; | |
| 5330 | 5164 | eof = be32_to_cpup(p++); |
| 5331 | 5165 | count = be32_to_cpup(p); |
| 5332 | 5166 | recvd = xdr_read_pages(xdr, count); |
| @@ -5339,9 +5173,6 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, · 6 unmodified lines | ||
| 5339 | 5173 | res->eof = eof; |
| 5340 | 5174 | res->count = count; |
| 5341 | 5175 | return 0; |
| 5342 | −out_overflow: | |
| 5343 | − print_overflow_msg(__func__, xdr); | |
| 5344 | − return -EIO; | |
| 5345 | 5176 | } |
| 5346 | 5177 | |
| 5347 | 5178 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| @@ -5374,7 +5205,7 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) · 26 unmodified lines | ||
| 5374 | 5205 | /* Convert length of symlink */ |
| 5375 | 5206 | p = xdr_inline_decode(xdr, 4); |
| 5376 | 5207 | if (unlikely(!p)) |
| 5377 | − goto out_overflow; | |
| 5208 | + return -EIO; | |
| 5378 | 5209 | len = be32_to_cpup(p); |
| 5379 | 5210 | if (len >= rcvbuf->page_len || len <= 0) { |
| 5380 | 5211 | dprintk("nfs: server returned giant symlink!\n"); |
| @@ -5395,9 +5226,6 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) · 14 unmodified lines | ||
| 5395 | 5226 | */ |
| 5396 | 5227 | xdr_terminate_string(rcvbuf, len); |
| 5397 | 5228 | return 0; |
| 5398 | −out_overflow: | |
| 5399 | − print_overflow_msg(__func__, xdr); | |
| 5400 | − return -EIO; | |
| 5401 | 5229 | } |
| 5402 | 5230 | |
| 5403 | 5231 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| @@ -5500,7 +5328,6 @@ static int decode_setattr(struct xdr_stream *xdr) · 96 unmodified lines | ||
| 5500 | 5328 | return status; |
| 5501 | 5329 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
| 5502 | 5330 | return 0; |
| 5503 | − print_overflow_msg(__func__, xdr); | |
| 5504 | 5331 | return -EIO; |
| 5505 | 5332 | } |
| 5506 | 5333 | |
| @@ -5512,7 +5339,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 5 unmodified lines | ||
| 5512 | 5339 | |
| 5513 | 5340 | p = xdr_inline_decode(xdr, 8); |
| 5514 | 5341 | if (unlikely(!p)) |
| 5515 | − goto out_overflow; | |
| 5342 | + return -EIO; | |
| 5516 | 5343 | opnum = be32_to_cpup(p++); |
| 5517 | 5344 | if (opnum != OP_SETCLIENTID) { |
| 5518 | 5345 | dprintk("nfs: decode_setclientid: Server returned operation" |
| @@ -5523,7 +5350,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 4 unmodified lines | ||
| 5523 | 5350 | if (nfserr == NFS_OK) { |
| 5524 | 5351 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5525 | 5352 | if (unlikely(!p)) |
| 5526 | − goto out_overflow; | |
| 5353 | + return -EIO; | |
| 5527 | 5354 | p = xdr_decode_hyper(p, &res->clientid); |
| 5528 | 5355 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
| 5529 | 5356 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| @@ -5532,28 +5359,25 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 2 unmodified lines | ||
| 5532 | 5359 | /* skip netid string */ |
| 5533 | 5360 | p = xdr_inline_decode(xdr, 4); |
| 5534 | 5361 | if (unlikely(!p)) |
| 5535 | − goto out_overflow; | |
| 5362 | + return -EIO; | |
| 5536 | 5363 | len = be32_to_cpup(p); |
| 5537 | 5364 | p = xdr_inline_decode(xdr, len); |
| 5538 | 5365 | if (unlikely(!p)) |
| 5539 | − goto out_overflow; | |
| 5366 | + return -EIO; | |
| 5540 | 5367 | |
| 5541 | 5368 | /* skip uaddr string */ |
| 5542 | 5369 | p = xdr_inline_decode(xdr, 4); |
| 5543 | 5370 | if (unlikely(!p)) |
| 5544 | − goto out_overflow; | |
| 5371 | + return -EIO; | |
| 5545 | 5372 | len = be32_to_cpup(p); |
| 5546 | 5373 | p = xdr_inline_decode(xdr, len); |
| 5547 | 5374 | if (unlikely(!p)) |
| 5548 | − goto out_overflow; | |
| 5375 | + return -EIO; | |
| 5549 | 5376 | return -NFSERR_CLID_INUSE; |
| 5550 | 5377 | } else |
| 5551 | 5378 | return nfs4_stat_to_errno(nfserr); |
| 5552 | 5379 | |
| 5553 | 5380 | return 0; |
| 5554 | −out_overflow: | |
| 5555 | − print_overflow_msg(__func__, xdr); | |
| 5556 | − return -EIO; | |
| 5557 | 5381 | } |
| 5558 | 5382 | |
| 5559 | 5383 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| @@ -5572,13 +5396,10 @@ static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) · 12 unmodified lines | ||
| 5572 | 5396 | |
| 5573 | 5397 | p = xdr_inline_decode(xdr, 8); |
| 5574 | 5398 | if (unlikely(!p)) |
| 5575 | − goto out_overflow; | |
| 5399 | + return -EIO; | |
| 5576 | 5400 | res->count = be32_to_cpup(p++); |
| 5577 | 5401 | res->verf->committed = be32_to_cpup(p++); |
| 5578 | 5402 | return decode_write_verifier(xdr, &res->verf->verifier); |
| 5579 | −out_overflow: | |
| 5580 | − print_overflow_msg(__func__, xdr); | |
| 5581 | − return -EIO; | |
| 5582 | 5403 | } |
| 5583 | 5404 | |
| 5584 | 5405 | static int decode_delegreturn(struct xdr_stream *xdr) |
| @@ -5594,30 +5415,24 @@ static int decode_secinfo_gss(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 5594 | 5415 | |
| 5595 | 5416 | p = xdr_inline_decode(xdr, 4); |
| 5596 | 5417 | if (unlikely(!p)) |
| 5597 | − goto out_overflow; | |
| 5418 | + return -EIO; | |
| 5598 | 5419 | oid_len = be32_to_cpup(p); |
| 5599 | 5420 | if (oid_len > GSS_OID_MAX_LEN) |
| 5600 | − goto out_err; | |
| 5421 | + return -EINVAL; | |
| 5601 | 5422 | |
| 5602 | 5423 | p = xdr_inline_decode(xdr, oid_len); |
| 5603 | 5424 | if (unlikely(!p)) |
| 5604 | − goto out_overflow; | |
| 5425 | + return -EIO; | |
| 5605 | 5426 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5606 | 5427 | flavor->flavor_info.oid.len = oid_len; |
| 5607 | 5428 | |
| 5608 | 5429 | p = xdr_inline_decode(xdr, 8); |
| 5609 | 5430 | if (unlikely(!p)) |
| 5610 | − goto out_overflow; | |
| 5431 | + return -EIO; | |
| 5611 | 5432 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5612 | 5433 | flavor->flavor_info.service = be32_to_cpup(p); |
| 5613 | 5434 | |
| 5614 | 5435 | return 0; |
| 5615 | − | |
| 5616 | −out_overflow: | |
| 5617 | − print_overflow_msg(__func__, xdr); | |
| 5618 | − return -EIO; | |
| 5619 | −out_err: | |
| 5620 | − return -EINVAL; | |
| 5621 | 5436 | } |
| 5622 | 5437 | |
| 5623 | 5438 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| @@ -5629,7 +5444,7 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 5 unmodified lines | ||
| 5629 | 5444 | |
| 5630 | 5445 | p = xdr_inline_decode(xdr, 4); |
| 5631 | 5446 | if (unlikely(!p)) |
| 5632 | − goto out_overflow; | |
| 5447 | + return -EIO; | |
| 5633 | 5448 | |
| 5634 | 5449 | res->flavors->num_flavors = 0; |
| 5635 | 5450 | num_flavors = be32_to_cpup(p); |
| @@ -5641,7 +5456,7 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 5 unmodified lines | ||
| 5641 | 5456 | |
| 5642 | 5457 | p = xdr_inline_decode(xdr, 4); |
| 5643 | 5458 | if (unlikely(!p)) |
| 5644 | − goto out_overflow; | |
| 5459 | + return -EIO; | |
| 5645 | 5460 | sec_flavor->flavor = be32_to_cpup(p); |
| 5646 | 5461 | |
| 5647 | 5462 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
| @@ -5655,9 +5470,6 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 7 unmodified lines | ||
| 5655 | 5470 | status = 0; |
| 5656 | 5471 | out: |
| 5657 | 5472 | return status; |
| 5658 | −out_overflow: | |
| 5659 | − print_overflow_msg(__func__, xdr); | |
| 5660 | − return -EIO; | |
| 5661 | 5473 | } |
| 5662 | 5474 | |
| 5663 | 5475 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| @@ -5711,11 +5523,11 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 47 unmodified lines | ||
| 5711 | 5523 | |
| 5712 | 5524 | p = xdr_inline_decode(xdr, 8); |
| 5713 | 5525 | if (unlikely(!p)) |
| 5714 | − goto out_overflow; | |
| 5526 | + return -EIO; | |
| 5715 | 5527 | xdr_decode_hyper(p, &res->clientid); |
| 5716 | 5528 | p = xdr_inline_decode(xdr, 12); |
| 5717 | 5529 | if (unlikely(!p)) |
| 5718 | − goto out_overflow; | |
| 5530 | + return -EIO; | |
| 5719 | 5531 | res->seqid = be32_to_cpup(p++); |
| 5720 | 5532 | res->flags = be32_to_cpup(p++); |
| 5721 | 5533 | |
| @@ -5739,7 +5551,7 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 17 unmodified lines | ||
| 5739 | 5551 | /* server_owner4.so_minor_id */ |
| 5740 | 5552 | p = xdr_inline_decode(xdr, 8); |
| 5741 | 5553 | if (unlikely(!p)) |
| 5742 | − goto out_overflow; | |
| 5554 | + return -EIO; | |
| 5743 | 5555 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
| 5744 | 5556 | |
| 5745 | 5557 | /* server_owner4.so_major_id */ |
| @@ -5759,7 +5571,7 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 13 unmodified lines | ||
| 5759 | 5571 | /* Implementation Id */ |
| 5760 | 5572 | p = xdr_inline_decode(xdr, 4); |
| 5761 | 5573 | if (unlikely(!p)) |
| 5762 | − goto out_overflow; | |
| 5574 | + return -EIO; | |
| 5763 | 5575 | impl_id_count = be32_to_cpup(p++); |
| 5764 | 5576 | |
| 5765 | 5577 | if (impl_id_count) { |
| @@ -5778,16 +5590,13 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 12 unmodified lines | ||
| 5778 | 5590 | /* nii_date */ |
| 5779 | 5591 | p = xdr_inline_decode(xdr, 12); |
| 5780 | 5592 | if (unlikely(!p)) |
| 5781 | − goto out_overflow; | |
| 5593 | + return -EIO; | |
| 5782 | 5594 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5783 | 5595 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5784 | 5596 | |
| 5785 | 5597 | /* if there's more than one entry, ignore the rest */ |
| 5786 | 5598 | } |
| 5787 | 5599 | return 0; |
| 5788 | −out_overflow: | |
| 5789 | − print_overflow_msg(__func__, xdr); | |
| 5790 | − return -EIO; | |
| 5791 | 5600 | } |
| 5792 | 5601 | |
| 5793 | 5602 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| @@ -5798,7 +5607,7 @@ static int decode_chan_attrs(struct xdr_stream *xdr, · 4 unmodified lines | ||
| 5798 | 5607 | |
| 5799 | 5608 | p = xdr_inline_decode(xdr, 28); |
| 5800 | 5609 | if (unlikely(!p)) |
| 5801 | − goto out_overflow; | |
| 5610 | + return -EIO; | |
| 5802 | 5611 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5803 | 5612 | if (val) |
| 5804 | 5613 | return -EINVAL; /* no support for header padding yet */ |
| @@ -5816,12 +5625,9 @@ static int decode_chan_attrs(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 5816 | 5625 | if (nr_attrs == 1) { |
| 5817 | 5626 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5818 | 5627 | if (unlikely(!p)) |
| 5819 | − goto out_overflow; | |
| 5628 | + return -EIO; | |
| 5820 | 5629 | } |
| 5821 | 5630 | return 0; |
| 5822 | −out_overflow: | |
| 5823 | − print_overflow_msg(__func__, xdr); | |
| 5824 | − return -EIO; | |
| 5825 | 5631 | } |
| 5826 | 5632 | |
| 5827 | 5633 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| @@ -5844,7 +5650,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr, · 16 unmodified lines | ||
| 5844 | 5650 | /* dir flags, rdma mode bool */ |
| 5845 | 5651 | p = xdr_inline_decode(xdr, 8); |
| 5846 | 5652 | if (unlikely(!p)) |
| 5847 | − goto out_overflow; | |
| 5653 | + return -EIO; | |
| 5848 | 5654 | |
| 5849 | 5655 | res->dir = be32_to_cpup(p++); |
| 5850 | 5656 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| @@ -5855,9 +5661,6 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr, · 4 unmodified lines | ||
| 5855 | 5661 | res->use_conn_in_rdma_mode = true; |
| 5856 | 5662 | |
| 5857 | 5663 | return 0; |
| 5858 | −out_overflow: | |
| 5859 | − print_overflow_msg(__func__, xdr); | |
| 5860 | − return -EIO; | |
| 5861 | 5664 | } |
| 5862 | 5665 | |
| 5863 | 5666 | static int decode_create_session(struct xdr_stream *xdr, |
| @@ -5875,7 +5678,7 @@ static int decode_create_session(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 5875 | 5678 | /* seqid, flags */ |
| 5876 | 5679 | p = xdr_inline_decode(xdr, 8); |
| 5877 | 5680 | if (unlikely(!p)) |
| 5878 | − goto out_overflow; | |
| 5681 | + return -EIO; | |
| 5879 | 5682 | res->seqid = be32_to_cpup(p++); |
| 5880 | 5683 | res->flags = be32_to_cpup(p); |
| 5881 | 5684 | |
| @@ -5884,9 +5687,6 @@ static int decode_create_session(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 5884 | 5687 | if (!status) |
| 5885 | 5688 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
| 5886 | 5689 | return status; |
| 5887 | −out_overflow: | |
| 5888 | − print_overflow_msg(__func__, xdr); | |
| 5889 | − return -EIO; | |
| 5890 | 5690 | } |
| 5891 | 5691 | |
| 5892 | 5692 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| @@ -5967,7 +5767,6 @@ out_err: · 74 unmodified lines | ||
| 5967 | 5767 | res->sr_status = status; |
| 5968 | 5768 | return status; |
| 5969 | 5769 | out_overflow: |
| 5970 | − print_overflow_msg(__func__, xdr); | |
| 5971 | 5770 | status = -EIO; |
| 5972 | 5771 | goto out_err; |
| 5973 | 5772 | #else /* CONFIG_NFS_V4_1 */ |
| @@ -5995,7 +5794,7 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 21 unmodified lines | ||
| 5995 | 5794 | if (status == -ETOOSMALL) { |
| 5996 | 5795 | p = xdr_inline_decode(xdr, 4); |
| 5997 | 5796 | if (unlikely(!p)) |
| 5998 | − goto out_overflow; | |
| 5797 | + return -EIO; | |
| 5999 | 5798 | pdev->mincount = be32_to_cpup(p); |
| 6000 | 5799 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 6001 | 5800 | __func__, pdev->mincount); |
| @@ -6005,7 +5804,7 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 3 unmodified lines | ||
| 6005 | 5804 | |
| 6006 | 5805 | p = xdr_inline_decode(xdr, 8); |
| 6007 | 5806 | if (unlikely(!p)) |
| 6008 | − goto out_overflow; | |
| 5807 | + return -EIO; | |
| 6009 | 5808 | type = be32_to_cpup(p++); |
| 6010 | 5809 | if (type != pdev->layout_type) { |
| 6011 | 5810 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| @@ -6019,19 +5818,19 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 6019 | 5818 | */ |
| 6020 | 5819 | pdev->mincount = be32_to_cpup(p); |
| 6021 | 5820 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 6022 | − goto out_overflow; | |
| 5821 | + return -EIO; | |
| 6023 | 5822 | |
| 6024 | 5823 | /* Parse notification bitmap, verifying that it is zero. */ |
| 6025 | 5824 | p = xdr_inline_decode(xdr, 4); |
| 6026 | 5825 | if (unlikely(!p)) |
| 6027 | − goto out_overflow; | |
| 5826 | + return -EIO; | |
| 6028 | 5827 | len = be32_to_cpup(p); |
| 6029 | 5828 | if (len) { |
| 6030 | 5829 | uint32_t i; |
| 6031 | 5830 | |
| 6032 | 5831 | p = xdr_inline_decode(xdr, 4 * len); |
| 6033 | 5832 | if (unlikely(!p)) |
| 6034 | − goto out_overflow; | |
| 5833 | + return -EIO; | |
| 6035 | 5834 | |
| 6036 | 5835 | res->notification = be32_to_cpup(p++); |
| 6037 | 5836 | for (i = 1; i < len; i++) { |
| @@ -6043,9 +5842,6 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 5 unmodified lines | ||
| 6043 | 5842 | } |
| 6044 | 5843 | } |
| 6045 | 5844 | return 0; |
| 6046 | −out_overflow: | |
| 6047 | − print_overflow_msg(__func__, xdr); | |
| 6048 | − return -EIO; | |
| 6049 | 5845 | } |
| 6050 | 5846 | |
| 6051 | 5847 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| @@ -6115,7 +5911,6 @@ out: · 63 unmodified lines | ||
| 6115 | 5911 | res->status = status; |
| 6116 | 5912 | return status; |
| 6117 | 5913 | out_overflow: |
| 6118 | − print_overflow_msg(__func__, xdr); | |
| 6119 | 5914 | status = -EIO; |
| 6120 | 5915 | goto out; |
| 6121 | 5916 | } |
| @@ -6131,16 +5926,13 @@ static int decode_layoutreturn(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 6131 | 5926 | return status; |
| 6132 | 5927 | p = xdr_inline_decode(xdr, 4); |
| 6133 | 5928 | if (unlikely(!p)) |
| 6134 | − goto out_overflow; | |
| 5929 | + return -EIO; | |
| 6135 | 5930 | res->lrs_present = be32_to_cpup(p); |
| 6136 | 5931 | if (res->lrs_present) |
| 6137 | 5932 | status = decode_layout_stateid(xdr, &res->stateid); |
| 6138 | 5933 | else |
| 6139 | 5934 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); |
| 6140 | 5935 | return status; |
| 6141 | −out_overflow: | |
| 6142 | − print_overflow_msg(__func__, xdr); | |
| 6143 | − return -EIO; | |
| 6144 | 5936 | } |
| 6145 | 5937 | |
| 6146 | 5938 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| @@ -6158,19 +5950,16 @@ static int decode_layoutcommit(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 6158 | 5950 | |
| 6159 | 5951 | p = xdr_inline_decode(xdr, 4); |
| 6160 | 5952 | if (unlikely(!p)) |
| 6161 | − goto out_overflow; | |
| 5953 | + return -EIO; | |
| 6162 | 5954 | sizechanged = be32_to_cpup(p); |
| 6163 | 5955 | |
| 6164 | 5956 | if (sizechanged) { |
| 6165 | 5957 | /* throw away new size */ |
| 6166 | 5958 | p = xdr_inline_decode(xdr, 8); |
| 6167 | 5959 | if (unlikely(!p)) |
| 6168 | − goto out_overflow; | |
| 5960 | + return -EIO; | |
| 6169 | 5961 | } |
| 6170 | 5962 | return 0; |
| 6171 | −out_overflow: | |
| 6172 | − print_overflow_msg(__func__, xdr); | |
| 6173 | − return -EIO; | |
| 6174 | 5963 | } |
| 6175 | 5964 | |
| 6176 | 5965 | static int decode_test_stateid(struct xdr_stream *xdr, |
| @@ -6186,21 +5975,17 @@ static int decode_test_stateid(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 6186 | 5975 | |
| 6187 | 5976 | p = xdr_inline_decode(xdr, 4); |
| 6188 | 5977 | if (unlikely(!p)) |
| 6189 | − goto out_overflow; | |
| 5978 | + return -EIO; | |
| 6190 | 5979 | num_res = be32_to_cpup(p++); |
| 6191 | 5980 | if (num_res != 1) |
| 6192 | − goto out; | |
| 5981 | + return -EIO; | |
| 6193 | 5982 | |
| 6194 | 5983 | p = xdr_inline_decode(xdr, 4); |
| 6195 | 5984 | if (unlikely(!p)) |
| 6196 | − goto out_overflow; | |
| 5985 | + return -EIO; | |
| 6197 | 5986 | res->status = be32_to_cpup(p++); |
| 6198 | 5987 | |
| 6199 | 5988 | return status; |
| 6200 | −out_overflow: | |
| 6201 | − print_overflow_msg(__func__, xdr); | |
| 6202 | −out: | |
| 6203 | − return -EIO; | |
| 6204 | 5989 | } |
| 6205 | 5990 | |
| 6206 | 5991 | static int decode_free_stateid(struct xdr_stream *xdr, |
| @@ -7570,11 +7355,11 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 1363 unmodified lines | ||
| 7570 | 7355 | uint64_t new_cookie; |
| 7571 | 7356 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7572 | 7357 | if (unlikely(!p)) |
| 7573 | − goto out_overflow; | |
| 7358 | + return -EAGAIN; | |
| 7574 | 7359 | if (*p == xdr_zero) { |
| 7575 | 7360 | p = xdr_inline_decode(xdr, 4); |
| 7576 | 7361 | if (unlikely(!p)) |
| 7577 | − goto out_overflow; | |
| 7362 | + return -EAGAIN; | |
| 7578 | 7363 | if (*p == xdr_zero) |
| 7579 | 7364 | return -EAGAIN; |
| 7580 | 7365 | entry->eof = 1; |
| @@ -7583,13 +7368,13 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 2 unmodified lines | ||
| 7583 | 7368 | |
| 7584 | 7369 | p = xdr_inline_decode(xdr, 12); |
| 7585 | 7370 | if (unlikely(!p)) |
| 7586 | − goto out_overflow; | |
| 7371 | + return -EAGAIN; | |
| 7587 | 7372 | p = xdr_decode_hyper(p, &new_cookie); |
| 7588 | 7373 | entry->len = be32_to_cpup(p); |
| 7589 | 7374 | |
| 7590 | 7375 | p = xdr_inline_decode(xdr, entry->len); |
| 7591 | 7376 | if (unlikely(!p)) |
| 7592 | − goto out_overflow; | |
| 7377 | + return -EAGAIN; | |
| 7593 | 7378 | entry->name = (const char *) p; |
| 7594 | 7379 | |
| 7595 | 7380 | /* |
| @@ -7601,14 +7386,14 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 5 unmodified lines | ||
| 7601 | 7386 | entry->fattr->valid = 0; |
| 7602 | 7387 | |
| 7603 | 7388 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
| 7604 | − goto out_overflow; | |
| 7389 | + return -EAGAIN; | |
| 7605 | 7390 | |
| 7606 | 7391 | if (decode_attr_length(xdr, &len, &savep) < 0) |
| 7607 | − goto out_overflow; | |
| 7392 | + return -EAGAIN; | |
| 7608 | 7393 | |
| 7609 | 7394 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
| 7610 | 7395 | NULL, entry->label, entry->server) < 0) |
| 7611 | − goto out_overflow; | |
| 7396 | + return -EAGAIN; | |
| 7612 | 7397 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7613 | 7398 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7614 | 7399 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
| @@ -7622,10 +7407,6 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 7 unmodified lines | ||
| 7622 | 7407 | entry->cookie = new_cookie; |
| 7623 | 7408 | |
| 7624 | 7409 | return 0; |
| 7625 | − | |
| 7626 | −out_overflow: | |
| 7627 | − print_overflow_msg(__func__, xdr); | |
| 7628 | − return -EAGAIN; | |
| 7629 | 7410 | } |
| 7630 | 7411 | |
| 7631 | 7412 | /* |
| @@ -7791,6 +7572,7 @@ const struct rpc_procinfo nfs4_procedures[] = { · 159 unmodified lines | ||
| 7791 | 7572 | PROC42(COPY, enc_copy, dec_copy), |
| 7792 | 7573 | PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), |
| 7793 | 7574 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
| 7575 | + PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), | |
| 7794 | 7576 | }; |
| 7795 | 7577 | |
| 7796 | 7578 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
| @@ -11,3 +11,4 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_enter); |
| 13 | 13 | EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_exit); |
| 14 | +EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_xdr_status); | |
| @@ -969,6 +969,91 @@ TRACE_EVENT(nfs_commit_done, · 968 unmodified lines | ||
| 969 | 969 | ) |
| 970 | 970 | ); |
| 971 | 971 | |
| 972 | +TRACE_DEFINE_ENUM(NFS_OK); | |
| 973 | +TRACE_DEFINE_ENUM(NFSERR_PERM); | |
| 974 | +TRACE_DEFINE_ENUM(NFSERR_NOENT); | |
| 975 | +TRACE_DEFINE_ENUM(NFSERR_IO); | |
| 976 | +TRACE_DEFINE_ENUM(NFSERR_NXIO); | |
| 977 | +TRACE_DEFINE_ENUM(NFSERR_ACCES); | |
| 978 | +TRACE_DEFINE_ENUM(NFSERR_EXIST); | |
| 979 | +TRACE_DEFINE_ENUM(NFSERR_XDEV); | |
| 980 | +TRACE_DEFINE_ENUM(NFSERR_NODEV); | |
| 981 | +TRACE_DEFINE_ENUM(NFSERR_NOTDIR); | |
| 982 | +TRACE_DEFINE_ENUM(NFSERR_ISDIR); | |
| 983 | +TRACE_DEFINE_ENUM(NFSERR_INVAL); | |
| 984 | +TRACE_DEFINE_ENUM(NFSERR_FBIG); | |
| 985 | +TRACE_DEFINE_ENUM(NFSERR_NOSPC); | |
| 986 | +TRACE_DEFINE_ENUM(NFSERR_ROFS); | |
| 987 | +TRACE_DEFINE_ENUM(NFSERR_MLINK); | |
| 988 | +TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG); | |
| 989 | +TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY); | |
| 990 | +TRACE_DEFINE_ENUM(NFSERR_DQUOT); | |
| 991 | +TRACE_DEFINE_ENUM(NFSERR_STALE); | |
| 992 | +TRACE_DEFINE_ENUM(NFSERR_REMOTE); | |
| 993 | +TRACE_DEFINE_ENUM(NFSERR_WFLUSH); | |
| 994 | +TRACE_DEFINE_ENUM(NFSERR_BADHANDLE); | |
| 995 | +TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC); | |
| 996 | +TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE); | |
| 997 | +TRACE_DEFINE_ENUM(NFSERR_NOTSUPP); | |
| 998 | +TRACE_DEFINE_ENUM(NFSERR_TOOSMALL); | |
| 999 | +TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT); | |
| 1000 | +TRACE_DEFINE_ENUM(NFSERR_BADTYPE); | |
| 1001 | +TRACE_DEFINE_ENUM(NFSERR_JUKEBOX); | |
| 1002 | + | |
| 1003 | +#define nfs_show_status(x) \ | |
| 1004 | + __print_symbolic(x, \ | |
| 1005 | + { NFS_OK, "OK" }, \ | |
| 1006 | + { NFSERR_PERM, "PERM" }, \ | |
| 1007 | + { NFSERR_NOENT, "NOENT" }, \ | |
| 1008 | + { NFSERR_IO, "IO" }, \ | |
| 1009 | + { NFSERR_NXIO, "NXIO" }, \ | |
| 1010 | + { NFSERR_ACCES, "ACCES" }, \ | |
| 1011 | + { NFSERR_EXIST, "EXIST" }, \ | |
| 1012 | + { NFSERR_XDEV, "XDEV" }, \ | |
| 1013 | + { NFSERR_NODEV, "NODEV" }, \ | |
| 1014 | + { NFSERR_NOTDIR, "NOTDIR" }, \ | |
| 1015 | + { NFSERR_ISDIR, "ISDIR" }, \ | |
| 1016 | + { NFSERR_INVAL, "INVAL" }, \ | |
| 1017 | + { NFSERR_FBIG, "FBIG" }, \ | |
| 1018 | + { NFSERR_NOSPC, "NOSPC" }, \ | |
| 1019 | + { NFSERR_ROFS, "ROFS" }, \ | |
| 1020 | + { NFSERR_MLINK, "MLINK" }, \ | |
| 1021 | + { NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \ | |
| 1022 | + { NFSERR_NOTEMPTY, "NOTEMPTY" }, \ | |
| 1023 | + { NFSERR_DQUOT, "DQUOT" }, \ | |
| 1024 | + { NFSERR_STALE, "STALE" }, \ | |
| 1025 | + { NFSERR_REMOTE, "REMOTE" }, \ | |
| 1026 | + { NFSERR_WFLUSH, "WFLUSH" }, \ | |
| 1027 | + { NFSERR_BADHANDLE, "BADHANDLE" }, \ | |
| 1028 | + { NFSERR_NOT_SYNC, "NOTSYNC" }, \ | |
| 1029 | + { NFSERR_BAD_COOKIE, "BADCOOKIE" }, \ | |
| 1030 | + { NFSERR_NOTSUPP, "NOTSUPP" }, \ | |
| 1031 | + { NFSERR_TOOSMALL, "TOOSMALL" }, \ | |
| 1032 | + { NFSERR_SERVERFAULT, "REMOTEIO" }, \ | |
| 1033 | + { NFSERR_BADTYPE, "BADTYPE" }, \ | |
| 1034 | + { NFSERR_JUKEBOX, "JUKEBOX" }) | |
| 1035 | + | |
| 1036 | +TRACE_EVENT(nfs_xdr_status, | |
| 1037 | + TP_PROTO( | |
| 1038 | + int error | |
| 1039 | + ), | |
| 1040 | + | |
| 1041 | + TP_ARGS(error), | |
| 1042 | + | |
| 1043 | + TP_STRUCT__entry( | |
| 1044 | + __field(int, error) | |
| 1045 | + ), | |
| 1046 | + | |
| 1047 | + TP_fast_assign( | |
| 1048 | + __entry->error = error; | |
| 1049 | + ), | |
| 1050 | + | |
| 1051 | + TP_printk( | |
| 1052 | + "error=%d (%s)", | |
| 1053 | + __entry->error, nfs_show_status(__entry->error) | |
| 1054 | + ) | |
| 1055 | +); | |
| 1056 | + | |
| 972 | 1057 | #endif /* _TRACE_NFS_H */ |
| 973 | 1058 | |
| 974 | 1059 | #undef TRACE_INCLUDE_PATH |
| @@ -350,7 +350,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct page *page, · 349 unmodified lines | ||
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * nfs_unlock_request - Unlock request and wake up sleepers. |
| 353 | − * @req: | |
| 353 | + * @req: pointer to request | |
| 354 | 354 | */ |
| 355 | 355 | void nfs_unlock_request(struct nfs_page *req) |
| 356 | 356 | { |
| @@ -368,7 +368,7 @@ void nfs_unlock_request(struct nfs_page *req) · 11 unmodified lines | ||
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * nfs_unlock_and_release_request - Unlock request and release the nfs_page |
| 371 | − * @req: | |
| 371 | + * @req: pointer to request | |
| 372 | 372 | */ |
| 373 | 373 | void nfs_unlock_and_release_request(struct nfs_page *req) |
| 374 | 374 | { |
| @@ -531,7 +531,6 @@ EXPORT_SYMBOL_GPL(nfs_pgio_header_free); · 156 unmodified lines | ||
| 531 | 531 | * nfs_pgio_rpcsetup - Set up arguments for a pageio call |
| 532 | 532 | * @hdr: The pageio hdr |
| 533 | 533 | * @count: Number of bytes to read |
| 534 | − * @offset: Initial offset | |
| 535 | 534 | * @how: How to commit data (writes only) |
| 536 | 535 | * @cinfo: Commit information for the call (writes only) |
| 537 | 536 | */ |
| @@ -634,7 +633,6 @@ EXPORT_SYMBOL_GPL(nfs_initiate_pgio); · 96 unmodified lines | ||
| 634 | 633 | |
| 635 | 634 | /** |
| 636 | 635 | * nfs_pgio_error - Clean up from a pageio error |
| 637 | − * @desc: IO descriptor | |
| 638 | 636 | * @hdr: pageio header |
| 639 | 637 | */ |
| 640 | 638 | static void nfs_pgio_error(struct nfs_pgio_header *hdr) |
| @@ -768,8 +766,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, · 127 unmodified lines | ||
| 768 | 766 | pageused = 0; |
| 769 | 767 | while (!list_empty(head)) { |
| 770 | 768 | req = nfs_list_entry(head->next); |
| 771 | − nfs_list_remove_request(req); | |
| 772 | − nfs_list_add_request(req, &hdr->pages); | |
| 769 | + nfs_list_move_request(req, &hdr->pages); | |
| 773 | 770 | |
| 774 | 771 | if (!last_page || last_page != req->wb_page) { |
| 775 | 772 | pageused++; |
| @@ -893,6 +890,7 @@ static bool nfs_match_lock_context(const struct nfs_lock_context *l1, · 117 unmodified lines | ||
| 893 | 890 | * nfs_can_coalesce_requests - test two requests for compatibility |
| 894 | 891 | * @prev: pointer to nfs_page |
| 895 | 892 | * @req: pointer to nfs_page |
| 893 | + * @pgio: pointer to nfs_pagio_descriptor | |
| 896 | 894 | * |
| 897 | 895 | * The nfs_page structures 'prev' and 'req' are compared to ensure that the |
| 898 | 896 | * page data area they describe is contiguous, and that their RPC |
| @@ -961,8 +959,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc, · 62 unmodified lines | ||
| 961 | 959 | } |
| 962 | 960 | if (!nfs_can_coalesce_requests(prev, req, desc)) |
| 963 | 961 | return 0; |
| 964 | − nfs_list_remove_request(req); | |
| 965 | − nfs_list_add_request(req, &mirror->pg_list); | |
| 962 | + nfs_list_move_request(req, &mirror->pg_list); | |
| 966 | 963 | mirror->pg_count += req->wb_bytes; |
| 967 | 964 | return 1; |
| 968 | 965 | } |
| @@ -988,6 +985,16 @@ static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc) · 19 unmodified lines | ||
| 988 | 985 | } |
| 989 | 986 | } |
| 990 | 987 | |
| 988 | +static void | |
| 989 | +nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc, | |
| 990 | + struct nfs_page *req) | |
| 991 | +{ | |
| 992 | + LIST_HEAD(head); | |
| 993 | + | |
| 994 | + nfs_list_move_request(req, &head); | |
| 995 | + desc->pg_completion_ops->error_cleanup(&head, desc->pg_error); | |
| 996 | +} | |
| 997 | + | |
| 991 | 998 | /** |
| 992 | 999 | * nfs_pageio_add_request - Attempt to coalesce a request into a page list. |
| 993 | 1000 | * @desc: destination io descriptor |
| @@ -1025,10 +1032,8 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, · 31 unmodified lines | ||
| 1025 | 1032 | nfs_page_group_unlock(req); |
| 1026 | 1033 | desc->pg_moreio = 1; |
| 1027 | 1034 | nfs_pageio_doio(desc); |
| 1028 | − if (desc->pg_error < 0) | |
| 1029 | − return 0; | |
| 1030 | − if (mirror->pg_recoalesce) | |
| 1031 | − return 0; | |
| 1035 | + if (desc->pg_error < 0 || mirror->pg_recoalesce) | |
| 1036 | + goto out_cleanup_subreq; | |
| 1032 | 1037 | /* retry add_request for this subreq */ |
| 1033 | 1038 | nfs_page_group_lock(req); |
| 1034 | 1039 | continue; |
| @@ -1061,6 +1066,10 @@ err_ptr: · 26 unmodified lines | ||
| 1061 | 1066 | desc->pg_error = PTR_ERR(subreq); |
| 1062 | 1067 | nfs_page_group_unlock(req); |
| 1063 | 1068 | return 0; |
| 1069 | +out_cleanup_subreq: | |
| 1070 | + if (req != subreq) | |
| 1071 | + nfs_pageio_cleanup_request(desc, subreq); | |
| 1072 | + return 0; | |
| 1064 | 1073 | } |
| 1065 | 1074 | |
| 1066 | 1075 | static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc) |
| @@ -1079,7 +1088,6 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc) · 12 unmodified lines | ||
| 1079 | 1088 | struct nfs_page *req; |
| 1080 | 1089 | |
| 1081 | 1090 | req = list_first_entry(&head, struct nfs_page, wb_list); |
| 1082 | − nfs_list_remove_request(req); | |
| 1083 | 1091 | if (__nfs_pageio_add_request(desc, req)) |
| 1084 | 1092 | continue; |
| 1085 | 1093 | if (desc->pg_error < 0) { |
| @@ -1120,7 +1128,8 @@ static void nfs_pageio_error_cleanup(struct nfs_pageio_descriptor *desc) · 34 unmodified lines | ||
| 1120 | 1128 | |
| 1121 | 1129 | for (midx = 0; midx < desc->pg_mirror_count; midx++) { |
| 1122 | 1130 | mirror = &desc->pg_mirrors[midx]; |
| 1123 | − desc->pg_completion_ops->error_cleanup(&mirror->pg_list); | |
| 1131 | + desc->pg_completion_ops->error_cleanup(&mirror->pg_list, | |
| 1132 | + desc->pg_error); | |
| 1124 | 1133 | } |
| 1125 | 1134 | } |
| 1126 | 1135 | |
| @@ -1168,11 +1177,14 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, · 41 unmodified lines | ||
| 1168 | 1177 | if (nfs_pgio_has_mirroring(desc)) |
| 1169 | 1178 | desc->pg_mirror_idx = midx; |
| 1170 | 1179 | if (!nfs_pageio_add_request_mirror(desc, dupreq)) |
| 1171 | − goto out_failed; | |
| 1180 | + goto out_cleanup_subreq; | |
| 1172 | 1181 | } |
| 1173 | 1182 | |
| 1174 | 1183 | return 1; |
| 1175 | 1184 | |
| 1185 | +out_cleanup_subreq: | |
| 1186 | + if (req != dupreq) | |
| 1187 | + nfs_pageio_cleanup_request(desc, dupreq); | |
| 1176 | 1188 | out_failed: |
| 1177 | 1189 | nfs_pageio_error_cleanup(desc); |
| 1178 | 1190 | return 0; |
| @@ -1194,7 +1206,7 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc, · 15 unmodified lines | ||
| 1194 | 1206 | desc->pg_mirror_idx = mirror_idx; |
| 1195 | 1207 | for (;;) { |
| 1196 | 1208 | nfs_pageio_doio(desc); |
| 1197 | − if (!mirror->pg_recoalesce) | |
| 1209 | + if (desc->pg_error < 0 || !mirror->pg_recoalesce) | |
| 1198 | 1210 | break; |
| 1199 | 1211 | if (!nfs_do_recoalesce(desc)) |
| 1200 | 1212 | break; |
| @@ -1222,9 +1234,8 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, · 21 unmodified lines | ||
| 1222 | 1234 | while (!list_empty(&hdr->pages)) { |
| 1223 | 1235 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); |
| 1224 | 1236 | |
| 1225 | − nfs_list_remove_request(req); | |
| 1226 | 1237 | if (!nfs_pageio_add_request(desc, req)) |
| 1227 | − nfs_list_add_request(req, &failed); | |
| 1238 | + nfs_list_move_request(req, &failed); | |
| 1228 | 1239 | } |
| 1229 | 1240 | nfs_pageio_complete(desc); |
| 1230 | 1241 | if (!list_empty(&failed)) { |
| @@ -758,22 +758,35 @@ static int · 757 unmodified lines | ||
| 758 | 758 | pnfs_layout_bulk_destroy_byserver_locked(struct nfs_client *clp, |
| 759 | 759 | struct nfs_server *server, |
| 760 | 760 | struct list_head *layout_list) |
| 761 | + __must_hold(&clp->cl_lock) | |
| 762 | + __must_hold(RCU) | |
| 761 | 763 | { |
| 762 | 764 | struct pnfs_layout_hdr *lo, *next; |
| 763 | 765 | struct inode *inode; |
| 764 | 766 | |
| 765 | 767 | list_for_each_entry_safe(lo, next, &server->layouts, plh_layouts) { |
| 766 | − if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) | |
| 768 | + if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) || | |
| 769 | + test_bit(NFS_LAYOUT_INODE_FREEING, &lo->plh_flags) || | |
| 770 | + !list_empty(&lo->plh_bulk_destroy)) | |
| 767 | 771 | continue; |
| 772 | + /* If the sb is being destroyed, just bail */ | |
| 773 | + if (!nfs_sb_active(server->super)) | |
| 774 | + break; | |
| 768 | 775 | inode = igrab(lo->plh_inode); |
| 769 | − if (inode == NULL) | |
| 770 | − continue; | |
| 771 | − list_del_init(&lo->plh_layouts); | |
| 772 | − if (pnfs_layout_add_bulk_destroy_list(inode, layout_list)) | |
| 773 | − continue; | |
| 774 | − rcu_read_unlock(); | |
| 775 | − spin_unlock(&clp->cl_lock); | |
| 776 | − iput(inode); | |
| 776 | + if (inode != NULL) { | |
| 777 | + list_del_init(&lo->plh_layouts); | |
| 778 | + if (pnfs_layout_add_bulk_destroy_list(inode, | |
| 779 | + layout_list)) | |
| 780 | + continue; | |
| 781 | + rcu_read_unlock(); | |
| 782 | + spin_unlock(&clp->cl_lock); | |
| 783 | + iput(inode); | |
| 784 | + } else { | |
| 785 | + rcu_read_unlock(); | |
| 786 | + spin_unlock(&clp->cl_lock); | |
| 787 | + set_bit(NFS_LAYOUT_INODE_FREEING, &lo->plh_flags); | |
| 788 | + } | |
| 789 | + nfs_sb_deactive(server->super); | |
| 777 | 790 | spin_lock(&clp->cl_lock); |
| 778 | 791 | rcu_read_lock(); |
| 779 | 792 | return -EAGAIN; |
| @@ -811,7 +824,7 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, · 31 unmodified lines | ||
| 811 | 824 | /* Free all lsegs that are attached to commit buckets */ |
| 812 | 825 | nfs_commit_inode(inode, 0); |
| 813 | 826 | pnfs_put_layout_hdr(lo); |
| 814 | − iput(inode); | |
| 827 | + nfs_iput_and_deactive(inode); | |
| 815 | 828 | } |
| 816 | 829 | return ret; |
| 817 | 830 | } |
| @@ -104,6 +104,7 @@ enum { · 103 unmodified lines | ||
| 104 | 104 | NFS_LAYOUT_RETURN_REQUESTED, /* Return this layout ASAP */ |
| 105 | 105 | NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ |
| 106 | 106 | NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */ |
| 107 | + NFS_LAYOUT_INODE_FREEING, /* The inode is being freed */ | |
| 107 | 108 | }; |
| 108 | 109 | |
| 109 | 110 | enum layoutdriver_policy_flags { |
| @@ -349,6 +350,7 @@ void nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *, const struct nf · 239 unmodified lines | ||
| 349 | 350 | void nfs4_init_deviceid_node(struct nfs4_deviceid_node *, struct nfs_server *, |
| 350 | 351 | const struct nfs4_deviceid *); |
| 351 | 352 | bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *); |
| 353 | +void nfs4_mark_deviceid_available(struct nfs4_deviceid_node *node); | |
| 352 | 354 | void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node); |
| 353 | 355 | bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); |
| 354 | 356 | void nfs4_deviceid_purge_client(const struct nfs_client *); |
| @@ -283,11 +283,23 @@ nfs4_put_deviceid_node(struct nfs4_deviceid_node *d) · 282 unmodified lines | ||
| 283 | 283 | } |
| 284 | 284 | EXPORT_SYMBOL_GPL(nfs4_put_deviceid_node); |
| 285 | 285 | |
| 286 | +void | |
| 287 | +nfs4_mark_deviceid_available(struct nfs4_deviceid_node *node) | |
| 288 | +{ | |
| 289 | + if (test_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags)) { | |
| 290 | + clear_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags); | |
| 291 | + smp_mb__after_atomic(); | |
| 292 | + } | |
| 293 | +} | |
| 294 | +EXPORT_SYMBOL_GPL(nfs4_mark_deviceid_available); | |
| 295 | + | |
| 286 | 296 | void |
| 287 | 297 | nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node) |
| 288 | 298 | { |
| 289 | 299 | node->timestamp_unavailable = jiffies; |
| 300 | + smp_mb__before_atomic(); | |
| 290 | 301 | set_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags); |
| 302 | + smp_mb__after_atomic(); | |
| 291 | 303 | } |
| 292 | 304 | EXPORT_SYMBOL_GPL(nfs4_mark_deviceid_unavailable); |
| 293 | 305 | |
| @@ -302,6 +314,7 @@ nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node) · 8 unmodified lines | ||
| 302 | 314 | if (time_in_range(node->timestamp_unavailable, start, end)) |
| 303 | 315 | return true; |
| 304 | 316 | clear_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags); |
| 317 | + smp_mb__after_atomic(); | |
| 305 | 318 | } |
| 306 | 319 | return false; |
| 307 | 320 | } |
| @@ -205,7 +205,7 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr, · 204 unmodified lines | ||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | static void |
| 208 | −nfs_async_read_error(struct list_head *head) | |
| 208 | +nfs_async_read_error(struct list_head *head, int error) | |
| 209 | 209 | { |
| 210 | 210 | struct nfs_page *req; |
| 211 | 211 | |
| @@ -1919,7 +1919,7 @@ static int nfs_parse_devname(const char *dev_name, · 1918 unmodified lines | ||
| 1919 | 1919 | /* kill possible hostname list: not supported */ |
| 1920 | 1920 | comma = strchr(dev_name, ','); |
| 1921 | 1921 | if (comma != NULL && comma < end) |
| 1922 | − *comma = 0; | |
| 1922 | + len = comma - dev_name; | |
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | 1925 | if (len > maxnamlen) |
| @@ -39,6 +39,7 @@ nfs_free_unlinkdata(struct nfs_unlinkdata *data) · 38 unmodified lines | ||
| 39 | 39 | /** |
| 40 | 40 | * nfs_async_unlink_done - Sillydelete post-processing |
| 41 | 41 | * @task: rpc_task of the sillydelete |
| 42 | + * @calldata: pointer to nfs_unlinkdata | |
| 42 | 43 | * |
| 43 | 44 | * Do the directory attribute update. |
| 44 | 45 | */ |
| @@ -54,7 +55,7 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) · 9 unmodified lines | ||
| 54 | 55 | |
| 55 | 56 | /** |
| 56 | 57 | * nfs_async_unlink_release - Release the sillydelete data. |
| 57 | − * @task: rpc_task of the sillydelete | |
| 58 | + * @calldata: struct nfs_unlinkdata to release | |
| 58 | 59 | * |
| 59 | 60 | * We need to call nfs_put_unlinkdata as a 'tk_release' task since the |
| 60 | 61 | * rpc_task would be freed too. |
| @@ -159,8 +160,8 @@ static int nfs_call_unlink(struct dentry *dentry, struct inode *inode, struct nf · 98 unmodified lines | ||
| 159 | 160 | |
| 160 | 161 | /** |
| 161 | 162 | * nfs_async_unlink - asynchronous unlinking of a file |
| 162 | − * @dir: parent directory of dentry | |
| 163 | − * @dentry: dentry to unlink | |
| 163 | + * @dentry: parent directory of dentry | |
| 164 | + * @name: name of dentry to unlink | |
| 164 | 165 | */ |
| 165 | 166 | static int |
| 166 | 167 | nfs_async_unlink(struct dentry *dentry, const struct qstr *name) |
| @@ -324,6 +325,7 @@ static const struct rpc_call_ops nfs_rename_ops = { · 157 unmodified lines | ||
| 324 | 325 | * @new_dir: target directory for the rename |
| 325 | 326 | * @old_dentry: original dentry to be renamed |
| 326 | 327 | * @new_dentry: dentry to which the old_dentry should be renamed |
| 328 | + * @complete: Function to run on successful completion | |
| 327 | 329 | * |
| 328 | 330 | * It's expected that valid references to the dentries and inodes are held |
| 329 | 331 | */ |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <linux/iversion.h> |
| 27 | 27 | |
| 28 | 28 | #include <linux/uaccess.h> |
| 29 | +#include <linux/sched/mm.h> | |
| 29 | 30 | |
| 30 | 31 | #include "delegation.h" |
| 31 | 32 | #include "internal.h" |
| @@ -712,11 +713,13 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) · 680 unmodified lines | ||
| 712 | 713 | { |
| 713 | 714 | struct inode *inode = mapping->host; |
| 714 | 715 | struct nfs_pageio_descriptor pgio; |
| 715 | − struct nfs_io_completion *ioc = nfs_io_completion_alloc(GFP_NOFS); | |
| 716 | + struct nfs_io_completion *ioc; | |
| 717 | + unsigned int pflags = memalloc_nofs_save(); | |
| 716 | 718 | int err; |
| 717 | 719 | |
| 718 | 720 | nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); |
| 719 | 721 | |
| 722 | + ioc = nfs_io_completion_alloc(GFP_NOFS); | |
| 720 | 723 | if (ioc) |
| 721 | 724 | nfs_io_completion_init(ioc, nfs_io_completion_commit, inode); |
| 722 | 725 | |
| @@ -727,6 +730,8 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) · 4 unmodified lines | ||
| 727 | 730 | nfs_pageio_complete(&pgio); |
| 728 | 731 | nfs_io_completion_put(ioc); |
| 729 | 732 | |
| 733 | + memalloc_nofs_restore(pflags); | |
| 734 | + | |
| 730 | 735 | if (err < 0) |
| 731 | 736 | goto out_err; |
| 732 | 737 | err = pgio.pg_error; |
| @@ -865,7 +870,6 @@ EXPORT_SYMBOL_GPL(nfs_request_add_commit_list_locked); · 132 unmodified lines | ||
| 865 | 870 | /** |
| 866 | 871 | * nfs_request_add_commit_list - add request to a commit list |
| 867 | 872 | * @req: pointer to a struct nfs_page |
| 868 | − * @dst: commit list head | |
| 869 | 873 | * @cinfo: holds list lock and accounting info |
| 870 | 874 | * |
| 871 | 875 | * This sets the PG_CLEAN bit, updates the cinfo count of |
| @@ -1412,20 +1416,27 @@ static void nfs_redirty_request(struct nfs_page *req) · 540 unmodified lines | ||
| 1412 | 1416 | nfs_release_request(req); |
| 1413 | 1417 | } |
| 1414 | 1418 | |
| 1415 | −static void nfs_async_write_error(struct list_head *head) | |
| 1419 | +static void nfs_async_write_error(struct list_head *head, int error) | |
| 1416 | 1420 | { |
| 1417 | 1421 | struct nfs_page *req; |
| 1418 | 1422 | |
| 1419 | 1423 | while (!list_empty(head)) { |
| 1420 | 1424 | req = nfs_list_entry(head->next); |
| 1421 | 1425 | nfs_list_remove_request(req); |
| 1426 | + if (nfs_error_is_fatal(error)) { | |
| 1427 | + nfs_context_set_write_error(req->wb_context, error); | |
| 1428 | + if (nfs_error_is_fatal_on_server(error)) { | |
| 1429 | + nfs_write_error_remove_page(req); | |
| 1430 | + continue; | |
| 1431 | + } | |
| 1432 | + } | |
| 1422 | 1433 | nfs_redirty_request(req); |
| 1423 | 1434 | } |
| 1424 | 1435 | } |
| 1425 | 1436 | |
| 1426 | 1437 | static void nfs_async_write_reschedule_io(struct nfs_pgio_header *hdr) |
| 1427 | 1438 | { |
| 1428 | − nfs_async_write_error(&hdr->pages); | |
| 1439 | + nfs_async_write_error(&hdr->pages, 0); | |
| 1429 | 1440 | filemap_fdatawrite_range(hdr->inode->i_mapping, hdr->args.offset, |
| 1430 | 1441 | hdr->args.offset + hdr->args.count - 1); |
| 1431 | 1442 | } |
| @@ -60,16 +60,6 @@ struct nfs4_cb_compound_hdr { · 59 unmodified lines | ||
| 60 | 60 | int status; |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | −/* | |
| 64 | − * Handle decode buffer overflows out-of-line. | |
| 65 | − */ | |
| 66 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 67 | −{ | |
| 68 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 69 | − "Remaining buffer length is %tu words.\n", | |
| 70 | − func, xdr->end - xdr->p); | |
| 71 | −} | |
| 72 | − | |
| 73 | 63 | static __be32 *xdr_encode_empty_array(__be32 *p) |
| 74 | 64 | { |
| 75 | 65 | *p++ = xdr_zero; |
| @@ -240,7 +230,6 @@ static int decode_cb_op_status(struct xdr_stream *xdr, · 164 unmodified lines | ||
| 240 | 230 | *status = nfs_cb_stat_to_errno(be32_to_cpup(p)); |
| 241 | 231 | return 0; |
| 242 | 232 | out_overflow: |
| 243 | − print_overflow_msg(__func__, xdr); | |
| 244 | 233 | return -EIO; |
| 245 | 234 | out_unexpected: |
| 246 | 235 | dprintk("NFSD: Callback server returned operation %d but " |
| @@ -309,7 +298,6 @@ static int decode_cb_compound4res(struct xdr_stream *xdr, · 62 unmodified lines | ||
| 309 | 298 | hdr->nops = be32_to_cpup(p); |
| 310 | 299 | return 0; |
| 311 | 300 | out_overflow: |
| 312 | − print_overflow_msg(__func__, xdr); | |
| 313 | 301 | return -EIO; |
| 314 | 302 | } |
| 315 | 303 | |
| @@ -437,7 +425,6 @@ out: · 121 unmodified lines | ||
| 437 | 425 | cb->cb_seq_status = status; |
| 438 | 426 | return status; |
| 439 | 427 | out_overflow: |
| 440 | − print_overflow_msg(__func__, xdr); | |
| 441 | 428 | status = -EIO; |
| 442 | 429 | goto out; |
| 443 | 430 | } |
| @@ -538,6 +538,7 @@ enum { · 537 unmodified lines | ||
| 538 | 538 | NFSPROC4_CLNT_OFFLOAD_CANCEL, |
| 539 | 539 | |
| 540 | 540 | NFSPROC4_CLNT_LOOKUPP, |
| 541 | + NFSPROC4_CLNT_LAYOUTERROR, | |
| 541 | 542 | }; |
| 542 | 543 | |
| 543 | 544 | /* nfs41 types */ |
| @@ -261,5 +261,6 @@ struct nfs_server { · 260 unmodified lines | ||
| 261 | 261 | #define NFS_CAP_CLONE (1U << 23) |
| 262 | 262 | #define NFS_CAP_COPY (1U << 24) |
| 263 | 263 | #define NFS_CAP_OFFLOAD_CANCEL (1U << 25) |
| 264 | +#define NFS_CAP_LAYOUTERROR (1U << 26) | |
| 264 | 265 | |
| 265 | 266 | #endif |
| @@ -164,6 +164,16 @@ nfs_list_add_request(struct nfs_page *req, struct list_head *head) · 163 unmodified lines | ||
| 164 | 164 | list_add_tail(&req->wb_list, head); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | +/** | |
| 168 | + * nfs_list_move_request - Move a request to a new list | |
| 169 | + * @req: request | |
| 170 | + * @head: head of list into which to insert the request. | |
| 171 | + */ | |
| 172 | +static inline void | |
| 173 | +nfs_list_move_request(struct nfs_page *req, struct list_head *head) | |
| 174 | +{ | |
| 175 | + list_move_tail(&req->wb_list, head); | |
| 176 | +} | |
| 167 | 177 | |
| 168 | 178 | /** |
| 169 | 179 | * nfs_list_remove_request - Remove a request from its wb_list |
| @@ -383,6 +383,41 @@ struct nfs42_layoutstat_data { · 382 unmodified lines | ||
| 383 | 383 | struct nfs42_layoutstat_res res; |
| 384 | 384 | }; |
| 385 | 385 | |
| 386 | +struct nfs42_device_error { | |
| 387 | + struct nfs4_deviceid dev_id; | |
| 388 | + int status; | |
| 389 | + enum nfs_opnum4 opnum; | |
| 390 | +}; | |
| 391 | + | |
| 392 | +struct nfs42_layout_error { | |
| 393 | + __u64 offset; | |
| 394 | + __u64 length; | |
| 395 | + nfs4_stateid stateid; | |
| 396 | + struct nfs42_device_error errors[1]; | |
| 397 | +}; | |
| 398 | + | |
| 399 | +#define NFS42_LAYOUTERROR_MAX 5 | |
| 400 | + | |
| 401 | +struct nfs42_layouterror_args { | |
| 402 | + struct nfs4_sequence_args seq_args; | |
| 403 | + struct inode *inode; | |
| 404 | + unsigned int num_errors; | |
| 405 | + struct nfs42_layout_error errors[NFS42_LAYOUTERROR_MAX]; | |
| 406 | +}; | |
| 407 | + | |
| 408 | +struct nfs42_layouterror_res { | |
| 409 | + struct nfs4_sequence_res seq_res; | |
| 410 | + unsigned int num_errors; | |
| 411 | + int rpc_status; | |
| 412 | +}; | |
| 413 | + | |
| 414 | +struct nfs42_layouterror_data { | |
| 415 | + struct nfs42_layouterror_args args; | |
| 416 | + struct nfs42_layouterror_res res; | |
| 417 | + struct inode *inode; | |
| 418 | + struct pnfs_layout_segment *lseg; | |
| 419 | +}; | |
| 420 | + | |
| 386 | 421 | struct nfs42_clone_args { |
| 387 | 422 | struct nfs4_sequence_args seq_args; |
| 388 | 423 | struct nfs_fh *src_fh; |
| @@ -1549,7 +1584,7 @@ struct nfs_commit_data { · 1160 unmodified lines | ||
| 1549 | 1584 | }; |
| 1550 | 1585 | |
| 1551 | 1586 | struct nfs_pgio_completion_ops { |
| 1552 | − void (*error_cleanup)(struct list_head *head); | |
| 1587 | + void (*error_cleanup)(struct list_head *head, int); | |
| 1553 | 1588 | void (*init_hdr)(struct nfs_pgio_header *hdr); |
| 1554 | 1589 | void (*completion)(struct nfs_pgio_header *hdr); |
| 1555 | 1590 | void (*reschedule_io)(struct nfs_pgio_header *hdr); |
| @@ -74,14 +74,12 @@ struct rpc_cred_cache; · 73 unmodified lines | ||
| 74 | 74 | struct rpc_authops; |
| 75 | 75 | struct rpc_auth { |
| 76 | 76 | unsigned int au_cslack; /* call cred size estimate */ |
| 77 | − /* guess at number of u32's auth adds before | |
| 78 | − * reply data; normally the verifier size: */ | |
| 79 | − unsigned int au_rslack; | |
| 80 | − /* for gss, used to calculate au_rslack: */ | |
| 81 | − unsigned int au_verfsize; | |
| 82 | − | |
| 83 | − unsigned int au_flags; /* various flags */ | |
| 84 | − const struct rpc_authops *au_ops; /* operations */ | |
| 77 | + unsigned int au_rslack; /* reply cred size estimate */ | |
| 78 | + unsigned int au_verfsize; /* size of reply verifier */ | |
| 79 | + unsigned int au_ralign; /* words before UL header */ | |
| 80 | + | |
| 81 | + unsigned int au_flags; | |
| 82 | + const struct rpc_authops *au_ops; | |
| 85 | 83 | rpc_authflavor_t au_flavor; /* pseudoflavor (note may |
| 86 | 84 | * differ from the flavor in |
| 87 | 85 | * au_ops->au_flavor in gss |
| @@ -131,13 +129,15 @@ struct rpc_credops { · 43 unmodified lines | ||
| 131 | 129 | void (*crdestroy)(struct rpc_cred *); |
| 132 | 130 | |
| 133 | 131 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
| 134 | − __be32 * (*crmarshal)(struct rpc_task *, __be32 *); | |
| 132 | + int (*crmarshal)(struct rpc_task *task, | |
| 133 | + struct xdr_stream *xdr); | |
| 135 | 134 | int (*crrefresh)(struct rpc_task *); |
| 136 | − __be32 * (*crvalidate)(struct rpc_task *, __be32 *); | |
| 137 | − int (*crwrap_req)(struct rpc_task *, kxdreproc_t, | |
| 138 | − void *, __be32 *, void *); | |
| 139 | − int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t, | |
| 140 | − void *, __be32 *, void *); | |
| 135 | + int (*crvalidate)(struct rpc_task *task, | |
| 136 | + struct xdr_stream *xdr); | |
| 137 | + int (*crwrap_req)(struct rpc_task *task, | |
| 138 | + struct xdr_stream *xdr); | |
| 139 | + int (*crunwrap_resp)(struct rpc_task *task, | |
| 140 | + struct xdr_stream *xdr); | |
| 141 | 141 | int (*crkey_timeout)(struct rpc_cred *); |
| 142 | 142 | char * (*crstringify_acceptor)(struct rpc_cred *); |
| 143 | 143 | bool (*crneed_reencode)(struct rpc_task *); |
| @@ -165,10 +165,18 @@ struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred * · 21 unmodified lines | ||
| 165 | 165 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
| 166 | 166 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
| 167 | 167 | void put_rpccred(struct rpc_cred *); |
| 168 | −__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); | |
| 169 | −__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *); | |
| 170 | −int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj); | |
| 171 | −int rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, __be32 *data, void *obj); | |
| 168 | +int rpcauth_marshcred(struct rpc_task *task, | |
| 169 | + struct xdr_stream *xdr); | |
| 170 | +int rpcauth_checkverf(struct rpc_task *task, | |
| 171 | + struct xdr_stream *xdr); | |
| 172 | +int rpcauth_wrap_req_encode(struct rpc_task *task, | |
| 173 | + struct xdr_stream *xdr); | |
| 174 | +int rpcauth_wrap_req(struct rpc_task *task, | |
| 175 | + struct xdr_stream *xdr); | |
| 176 | +int rpcauth_unwrap_resp_decode(struct rpc_task *task, | |
| 177 | + struct xdr_stream *xdr); | |
| 178 | +int rpcauth_unwrap_resp(struct rpc_task *task, | |
| 179 | + struct xdr_stream *xdr); | |
| 172 | 180 | bool rpcauth_xmit_need_reencode(struct rpc_task *task); |
| 173 | 181 | int rpcauth_refreshcred(struct rpc_task *); |
| 174 | 182 | void rpcauth_invalcred(struct rpc_task *); |
| @@ -169,6 +169,9 @@ int rpcb_v4_register(struct net *net, const u32 program, · 168 unmodified lines | ||
| 169 | 169 | const char *netid); |
| 170 | 170 | void rpcb_getport_async(struct rpc_task *); |
| 171 | 171 | |
| 172 | +void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, | |
| 173 | + unsigned int base, unsigned int len, | |
| 174 | + unsigned int hdrsize); | |
| 172 | 175 | void rpc_call_start(struct rpc_task *); |
| 173 | 176 | int rpc_call_async(struct rpc_clnt *clnt, |
| 174 | 177 | const struct rpc_message *msg, int flags, |
| @@ -1,4 +1,44 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 1 | 2 | /* |
| 2 | − * Dumb way to share this static piece of information with nfsd | |
| 3 | + * Define the string that exports the set of kernel-supported | |
| 4 | + * Kerberos enctypes. This list is sent via upcall to gssd, and | |
| 5 | + * is also exposed via the nfsd /proc API. The consumers generally | |
| 6 | + * treat this as an ordered list, where the first item in the list | |
| 7 | + * is the most preferred. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +#ifndef _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H | |
| 11 | +#define _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H | |
| 12 | + | |
| 13 | +#ifdef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 14 | + | |
| 15 | +/* | |
| 16 | + * NB: This list includes encryption types that were deprecated | |
| 17 | + * by RFC 8429 (DES3_CBC_SHA1 and ARCFOUR_HMAC). | |
| 18 | + * | |
| 19 | + * ENCTYPE_AES256_CTS_HMAC_SHA1_96 | |
| 20 | + * ENCTYPE_AES128_CTS_HMAC_SHA1_96 | |
| 21 | + * ENCTYPE_DES3_CBC_SHA1 | |
| 22 | + * ENCTYPE_ARCFOUR_HMAC | |
| 23 | + */ | |
| 24 | +#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23" | |
| 25 | + | |
| 26 | +#else /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 27 | + | |
| 28 | +/* | |
| 29 | + * NB: This list includes encryption types that were deprecated | |
| 30 | + * by RFC 8429 and RFC 6649. | |
| 31 | + * | |
| 32 | + * ENCTYPE_AES256_CTS_HMAC_SHA1_96 | |
| 33 | + * ENCTYPE_AES128_CTS_HMAC_SHA1_96 | |
| 34 | + * ENCTYPE_DES3_CBC_SHA1 | |
| 35 | + * ENCTYPE_ARCFOUR_HMAC | |
| 36 | + * ENCTYPE_DES_CBC_MD5 | |
| 37 | + * ENCTYPE_DES_CBC_CRC | |
| 38 | + * ENCTYPE_DES_CBC_MD4 | |
| 3 | 39 | */ |
| 4 | 40 | #define KRB5_SUPPORTED_ENCTYPES "18,17,16,23,3,1,2" |
| 41 | + | |
| 42 | +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 43 | + | |
| 44 | +#endif /* _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H */ | |
| @@ -97,6 +97,7 @@ typedef void (*rpc_action)(struct rpc_task *); · 96 unmodified lines | ||
| 97 | 97 | |
| 98 | 98 | struct rpc_call_ops { |
| 99 | 99 | void (*rpc_call_prepare)(struct rpc_task *, void *); |
| 100 | + void (*rpc_call_prepare_transmit)(struct rpc_task *, void *); | |
| 100 | 101 | void (*rpc_call_done)(struct rpc_task *, void *); |
| 101 | 102 | void (*rpc_count_stats)(struct rpc_task *, void *); |
| 102 | 103 | void (*rpc_release)(void *); |
| @@ -303,4 +304,12 @@ rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) · 200 unmodified lines | ||
| 303 | 304 | } |
| 304 | 305 | #endif /* CONFIG_SUNRPC_SWAP */ |
| 305 | 306 | |
| 307 | +static inline bool | |
| 308 | +rpc_task_need_resched(const struct rpc_task *task) | |
| 309 | +{ | |
| 310 | + if (RPC_IS_QUEUED(task) || task->tk_callback) | |
| 311 | + return true; | |
| 312 | + return false; | |
| 313 | +} | |
| 314 | + | |
| 306 | 315 | #endif /* _LINUX_SUNRPC_SCHED_H_ */ |
| @@ -87,6 +87,16 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 86 unmodified lines | ||
| 87 | 87 | #define xdr_one cpu_to_be32(1) |
| 88 | 88 | #define xdr_two cpu_to_be32(2) |
| 89 | 89 | |
| 90 | +#define rpc_auth_null cpu_to_be32(RPC_AUTH_NULL) | |
| 91 | +#define rpc_auth_unix cpu_to_be32(RPC_AUTH_UNIX) | |
| 92 | +#define rpc_auth_short cpu_to_be32(RPC_AUTH_SHORT) | |
| 93 | +#define rpc_auth_gss cpu_to_be32(RPC_AUTH_GSS) | |
| 94 | + | |
| 95 | +#define rpc_call cpu_to_be32(RPC_CALL) | |
| 96 | +#define rpc_reply cpu_to_be32(RPC_REPLY) | |
| 97 | + | |
| 98 | +#define rpc_msg_accepted cpu_to_be32(RPC_MSG_ACCEPTED) | |
| 99 | + | |
| 90 | 100 | #define rpc_success cpu_to_be32(RPC_SUCCESS) |
| 91 | 101 | #define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) |
| 92 | 102 | #define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) |
| @@ -95,6 +105,9 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 2 unmodified lines | ||
| 95 | 105 | #define rpc_system_err cpu_to_be32(RPC_SYSTEM_ERR) |
| 96 | 106 | #define rpc_drop_reply cpu_to_be32(RPC_DROP_REPLY) |
| 97 | 107 | |
| 108 | +#define rpc_mismatch cpu_to_be32(RPC_MISMATCH) | |
| 109 | +#define rpc_auth_error cpu_to_be32(RPC_AUTH_ERROR) | |
| 110 | + | |
| 98 | 111 | #define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) |
| 99 | 112 | #define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) |
| 100 | 113 | #define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED) |
| @@ -103,7 +116,6 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 2 unmodified lines | ||
| 103 | 116 | #define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) |
| 104 | 117 | #define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM) |
| 105 | 118 | #define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM) |
| 106 | −#define rpc_autherr_oldseqnum cpu_to_be32(101) | |
| 107 | 119 | |
| 108 | 120 | /* |
| 109 | 121 | * Miscellaneous XDR helper functions |
| @@ -167,7 +179,6 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p) · 57 unmodified lines | ||
| 167 | 179 | extern void xdr_shift_buf(struct xdr_buf *, size_t); |
| 168 | 180 | extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *); |
| 169 | 181 | extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int); |
| 170 | −extern void xdr_buf_trim(struct xdr_buf *, unsigned int); | |
| 171 | 182 | extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, unsigned int); |
| 172 | 183 | extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); |
| 173 | 184 | extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); |
| @@ -217,6 +228,8 @@ struct xdr_stream { · 43 unmodified lines | ||
| 217 | 228 | struct kvec scratch; /* Scratch buffer */ |
| 218 | 229 | struct page **page_ptr; /* pointer to the current page */ |
| 219 | 230 | unsigned int nwords; /* Remaining decode buffer length */ |
| 231 | + | |
| 232 | + struct rpc_rqst *rqst; /* For debugging */ | |
| 220 | 233 | }; |
| 221 | 234 | |
| 222 | 235 | /* |
| @@ -227,7 +240,8 @@ typedef void (*kxdreproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr, · 4 unmodified lines | ||
| 227 | 240 | typedef int (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 228 | 241 | void *obj); |
| 229 | 242 | |
| 230 | −extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); | |
| 243 | +extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 244 | + __be32 *p, struct rpc_rqst *rqst); | |
| 231 | 245 | extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); |
| 232 | 246 | extern void xdr_commit_encode(struct xdr_stream *xdr); |
| 233 | 247 | extern void xdr_truncate_encode(struct xdr_stream *xdr, size_t len); |
| @@ -235,7 +249,8 @@ extern int xdr_restrict_buflen(struct xdr_stream *xdr, int newbuflen); · 1 unmodified line | ||
| 235 | 249 | extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, |
| 236 | 250 | unsigned int base, unsigned int len); |
| 237 | 251 | extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr); |
| 238 | −extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); | |
| 252 | +extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 253 | + __be32 *p, struct rpc_rqst *rqst); | |
| 239 | 254 | extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, |
| 240 | 255 | struct page **pages, unsigned int len); |
| 241 | 256 | extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen); |
| @@ -196,8 +196,6 @@ struct rpc_xprt { · 195 unmodified lines | ||
| 196 | 196 | |
| 197 | 197 | size_t max_payload; /* largest RPC payload size, |
| 198 | 198 | in bytes */ |
| 199 | − unsigned int tsh_size; /* size of transport specific | |
| 200 | − header */ | |
| 201 | 199 | |
| 202 | 200 | struct rpc_wait_queue binding; /* requests waiting on rpcbind */ |
| 203 | 201 | struct rpc_wait_queue sending; /* requests waiting to send */ |
| @@ -362,11 +360,6 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, · 158 unmodified lines | ||
| 362 | 360 | unsigned int max_req); |
| 363 | 361 | void xprt_free(struct rpc_xprt *); |
| 364 | 362 | |
| 365 | −static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) | |
| 366 | −{ | |
| 367 | − return p + xprt->tsh_size; | |
| 368 | −} | |
| 369 | − | |
| 370 | 363 | static inline int |
| 371 | 364 | xprt_enable_swap(struct rpc_xprt *xprt) |
| 372 | 365 | { |
| @@ -26,6 +26,7 @@ struct sock_xprt { · 25 unmodified lines | ||
| 26 | 26 | */ |
| 27 | 27 | struct socket * sock; |
| 28 | 28 | struct sock * inet; |
| 29 | + struct file * file; | |
| 29 | 30 | |
| 30 | 31 | /* |
| 31 | 32 | * State of TCP reply receive |
| @@ -0,0 +1,361 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | +/* | |
| 3 | + * Copyright (c) 2018 Oracle. All rights reserved. | |
| 4 | + * | |
| 5 | + * Trace point definitions for the "rpcgss" subsystem. | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#undef TRACE_SYSTEM | |
| 9 | +#define TRACE_SYSTEM rpcgss | |
| 10 | + | |
| 11 | +#if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ) | |
| 12 | +#define _TRACE_RPCGSS_H | |
| 13 | + | |
| 14 | +#include <linux/tracepoint.h> | |
| 15 | + | |
| 16 | +/** | |
| 17 | + ** GSS-API related trace events | |
| 18 | + **/ | |
| 19 | + | |
| 20 | +TRACE_DEFINE_ENUM(GSS_S_BAD_MECH); | |
| 21 | +TRACE_DEFINE_ENUM(GSS_S_BAD_NAME); | |
| 22 | +TRACE_DEFINE_ENUM(GSS_S_BAD_NAMETYPE); | |
| 23 | +TRACE_DEFINE_ENUM(GSS_S_BAD_BINDINGS); | |
| 24 | +TRACE_DEFINE_ENUM(GSS_S_BAD_STATUS); | |
| 25 | +TRACE_DEFINE_ENUM(GSS_S_BAD_SIG); | |
| 26 | +TRACE_DEFINE_ENUM(GSS_S_NO_CRED); | |
| 27 | +TRACE_DEFINE_ENUM(GSS_S_NO_CONTEXT); | |
| 28 | +TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_TOKEN); | |
| 29 | +TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_CREDENTIAL); | |
| 30 | +TRACE_DEFINE_ENUM(GSS_S_CREDENTIALS_EXPIRED); | |
| 31 | +TRACE_DEFINE_ENUM(GSS_S_CONTEXT_EXPIRED); | |
| 32 | +TRACE_DEFINE_ENUM(GSS_S_FAILURE); | |
| 33 | +TRACE_DEFINE_ENUM(GSS_S_BAD_QOP); | |
| 34 | +TRACE_DEFINE_ENUM(GSS_S_UNAUTHORIZED); | |
| 35 | +TRACE_DEFINE_ENUM(GSS_S_UNAVAILABLE); | |
| 36 | +TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_ELEMENT); | |
| 37 | +TRACE_DEFINE_ENUM(GSS_S_NAME_NOT_MN); | |
| 38 | +TRACE_DEFINE_ENUM(GSS_S_CONTINUE_NEEDED); | |
| 39 | +TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_TOKEN); | |
| 40 | +TRACE_DEFINE_ENUM(GSS_S_OLD_TOKEN); | |
| 41 | +TRACE_DEFINE_ENUM(GSS_S_UNSEQ_TOKEN); | |
| 42 | +TRACE_DEFINE_ENUM(GSS_S_GAP_TOKEN); | |
| 43 | + | |
| 44 | +#define show_gss_status(x) \ | |
| 45 | + __print_flags(x, "|", \ | |
| 46 | + { GSS_S_BAD_MECH, "GSS_S_BAD_MECH" }, \ | |
| 47 | + { GSS_S_BAD_NAME, "GSS_S_BAD_NAME" }, \ | |
| 48 | + { GSS_S_BAD_NAMETYPE, "GSS_S_BAD_NAMETYPE" }, \ | |
| 49 | + { GSS_S_BAD_BINDINGS, "GSS_S_BAD_BINDINGS" }, \ | |
| 50 | + { GSS_S_BAD_STATUS, "GSS_S_BAD_STATUS" }, \ | |
| 51 | + { GSS_S_BAD_SIG, "GSS_S_BAD_SIG" }, \ | |
| 52 | + { GSS_S_NO_CRED, "GSS_S_NO_CRED" }, \ | |
| 53 | + { GSS_S_NO_CONTEXT, "GSS_S_NO_CONTEXT" }, \ | |
| 54 | + { GSS_S_DEFECTIVE_TOKEN, "GSS_S_DEFECTIVE_TOKEN" }, \ | |
| 55 | + { GSS_S_DEFECTIVE_CREDENTIAL, "GSS_S_DEFECTIVE_CREDENTIAL" }, \ | |
| 56 | + { GSS_S_CREDENTIALS_EXPIRED, "GSS_S_CREDENTIALS_EXPIRED" }, \ | |
| 57 | + { GSS_S_CONTEXT_EXPIRED, "GSS_S_CONTEXT_EXPIRED" }, \ | |
| 58 | + { GSS_S_FAILURE, "GSS_S_FAILURE" }, \ | |
| 59 | + { GSS_S_BAD_QOP, "GSS_S_BAD_QOP" }, \ | |
| 60 | + { GSS_S_UNAUTHORIZED, "GSS_S_UNAUTHORIZED" }, \ | |
| 61 | + { GSS_S_UNAVAILABLE, "GSS_S_UNAVAILABLE" }, \ | |
| 62 | + { GSS_S_DUPLICATE_ELEMENT, "GSS_S_DUPLICATE_ELEMENT" }, \ | |
| 63 | + { GSS_S_NAME_NOT_MN, "GSS_S_NAME_NOT_MN" }, \ | |
| 64 | + { GSS_S_CONTINUE_NEEDED, "GSS_S_CONTINUE_NEEDED" }, \ | |
| 65 | + { GSS_S_DUPLICATE_TOKEN, "GSS_S_DUPLICATE_TOKEN" }, \ | |
| 66 | + { GSS_S_OLD_TOKEN, "GSS_S_OLD_TOKEN" }, \ | |
| 67 | + { GSS_S_UNSEQ_TOKEN, "GSS_S_UNSEQ_TOKEN" }, \ | |
| 68 | + { GSS_S_GAP_TOKEN, "GSS_S_GAP_TOKEN" }) | |
| 69 | + | |
| 70 | + | |
| 71 | +DECLARE_EVENT_CLASS(rpcgss_gssapi_event, | |
| 72 | + TP_PROTO( | |
| 73 | + const struct rpc_task *task, | |
| 74 | + u32 maj_stat | |
| 75 | + ), | |
| 76 | + | |
| 77 | + TP_ARGS(task, maj_stat), | |
| 78 | + | |
| 79 | + TP_STRUCT__entry( | |
| 80 | + __field(unsigned int, task_id) | |
| 81 | + __field(unsigned int, client_id) | |
| 82 | + __field(u32, maj_stat) | |
| 83 | + | |
| 84 | + ), | |
| 85 | + | |
| 86 | + TP_fast_assign( | |
| 87 | + __entry->task_id = task->tk_pid; | |
| 88 | + __entry->client_id = task->tk_client->cl_clid; | |
| 89 | + __entry->maj_stat = maj_stat; | |
| 90 | + ), | |
| 91 | + | |
| 92 | + TP_printk("task:%u@%u maj_stat=%s", | |
| 93 | + __entry->task_id, __entry->client_id, | |
| 94 | + __entry->maj_stat == 0 ? | |
| 95 | + "GSS_S_COMPLETE" : show_gss_status(__entry->maj_stat)) | |
| 96 | +); | |
| 97 | + | |
| 98 | +#define DEFINE_GSSAPI_EVENT(name) \ | |
| 99 | + DEFINE_EVENT(rpcgss_gssapi_event, rpcgss_##name, \ | |
| 100 | + TP_PROTO( \ | |
| 101 | + const struct rpc_task *task, \ | |
| 102 | + u32 maj_stat \ | |
| 103 | + ), \ | |
| 104 | + TP_ARGS(task, maj_stat)) | |
| 105 | + | |
| 106 | +TRACE_EVENT(rpcgss_import_ctx, | |
| 107 | + TP_PROTO( | |
| 108 | + int status | |
| 109 | + ), | |
| 110 | + | |
| 111 | + TP_ARGS(status), | |
| 112 | + | |
| 113 | + TP_STRUCT__entry( | |
| 114 | + __field(int, status) | |
| 115 | + ), | |
| 116 | + | |
| 117 | + TP_fast_assign( | |
| 118 | + __entry->status = status; | |
| 119 | + ), | |
| 120 | + | |
| 121 | + TP_printk("status=%d", __entry->status) | |
| 122 | +); | |
| 123 | + | |
| 124 | +DEFINE_GSSAPI_EVENT(get_mic); | |
| 125 | +DEFINE_GSSAPI_EVENT(verify_mic); | |
| 126 | +DEFINE_GSSAPI_EVENT(wrap); | |
| 127 | +DEFINE_GSSAPI_EVENT(unwrap); | |
| 128 | + | |
| 129 | + | |
| 130 | +/** | |
| 131 | + ** GSS auth unwrap failures | |
| 132 | + **/ | |
| 133 | + | |
| 134 | +TRACE_EVENT(rpcgss_unwrap_failed, | |
| 135 | + TP_PROTO( | |
| 136 | + const struct rpc_task *task | |
| 137 | + ), | |
| 138 | + | |
| 139 | + TP_ARGS(task), | |
| 140 | + | |
| 141 | + TP_STRUCT__entry( | |
| 142 | + __field(unsigned int, task_id) | |
| 143 | + __field(unsigned int, client_id) | |
| 144 | + ), | |
| 145 | + | |
| 146 | + TP_fast_assign( | |
| 147 | + __entry->task_id = task->tk_pid; | |
| 148 | + __entry->client_id = task->tk_client->cl_clid; | |
| 149 | + ), | |
| 150 | + | |
| 151 | + TP_printk("task:%u@%u", __entry->task_id, __entry->client_id) | |
| 152 | +); | |
| 153 | + | |
| 154 | +TRACE_EVENT(rpcgss_bad_seqno, | |
| 155 | + TP_PROTO( | |
| 156 | + const struct rpc_task *task, | |
| 157 | + u32 expected, | |
| 158 | + u32 received | |
| 159 | + ), | |
| 160 | + | |
| 161 | + TP_ARGS(task, expected, received), | |
| 162 | + | |
| 163 | + TP_STRUCT__entry( | |
| 164 | + __field(unsigned int, task_id) | |
| 165 | + __field(unsigned int, client_id) | |
| 166 | + __field(u32, expected) | |
| 167 | + __field(u32, received) | |
| 168 | + ), | |
| 169 | + | |
| 170 | + TP_fast_assign( | |
| 171 | + __entry->task_id = task->tk_pid; | |
| 172 | + __entry->client_id = task->tk_client->cl_clid; | |
| 173 | + __entry->expected = expected; | |
| 174 | + __entry->received = received; | |
| 175 | + ), | |
| 176 | + | |
| 177 | + TP_printk("task:%u@%u expected seqno %u, received seqno %u", | |
| 178 | + __entry->task_id, __entry->client_id, | |
| 179 | + __entry->expected, __entry->received) | |
| 180 | +); | |
| 181 | + | |
| 182 | +TRACE_EVENT(rpcgss_seqno, | |
| 183 | + TP_PROTO( | |
| 184 | + const struct rpc_task *task | |
| 185 | + ), | |
| 186 | + | |
| 187 | + TP_ARGS(task), | |
| 188 | + | |
| 189 | + TP_STRUCT__entry( | |
| 190 | + __field(unsigned int, task_id) | |
| 191 | + __field(unsigned int, client_id) | |
| 192 | + __field(u32, xid) | |
| 193 | + __field(u32, seqno) | |
| 194 | + ), | |
| 195 | + | |
| 196 | + TP_fast_assign( | |
| 197 | + const struct rpc_rqst *rqst = task->tk_rqstp; | |
| 198 | + | |
| 199 | + __entry->task_id = task->tk_pid; | |
| 200 | + __entry->client_id = task->tk_client->cl_clid; | |
| 201 | + __entry->xid = be32_to_cpu(rqst->rq_xid); | |
| 202 | + __entry->seqno = rqst->rq_seqno; | |
| 203 | + ), | |
| 204 | + | |
| 205 | + TP_printk("task:%u@%u xid=0x%08x seqno=%u", | |
| 206 | + __entry->task_id, __entry->client_id, | |
| 207 | + __entry->xid, __entry->seqno) | |
| 208 | +); | |
| 209 | + | |
| 210 | +TRACE_EVENT(rpcgss_need_reencode, | |
| 211 | + TP_PROTO( | |
| 212 | + const struct rpc_task *task, | |
| 213 | + u32 seq_xmit, | |
| 214 | + bool ret | |
| 215 | + ), | |
| 216 | + | |
| 217 | + TP_ARGS(task, seq_xmit, ret), | |
| 218 | + | |
| 219 | + TP_STRUCT__entry( | |
| 220 | + __field(unsigned int, task_id) | |
| 221 | + __field(unsigned int, client_id) | |
| 222 | + __field(u32, xid) | |
| 223 | + __field(u32, seq_xmit) | |
| 224 | + __field(u32, seqno) | |
| 225 | + __field(bool, ret) | |
| 226 | + ), | |
| 227 | + | |
| 228 | + TP_fast_assign( | |
| 229 | + __entry->task_id = task->tk_pid; | |
| 230 | + __entry->client_id = task->tk_client->cl_clid; | |
| 231 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 232 | + __entry->seq_xmit = seq_xmit; | |
| 233 | + __entry->seqno = task->tk_rqstp->rq_seqno; | |
| 234 | + __entry->ret = ret; | |
| 235 | + ), | |
| 236 | + | |
| 237 | + TP_printk("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded", | |
| 238 | + __entry->task_id, __entry->client_id, | |
| 239 | + __entry->xid, __entry->seqno, __entry->seq_xmit, | |
| 240 | + __entry->ret ? "" : "un") | |
| 241 | +); | |
| 242 | + | |
| 243 | +/** | |
| 244 | + ** gssd upcall related trace events | |
| 245 | + **/ | |
| 246 | + | |
| 247 | +TRACE_EVENT(rpcgss_upcall_msg, | |
| 248 | + TP_PROTO( | |
| 249 | + const char *buf | |
| 250 | + ), | |
| 251 | + | |
| 252 | + TP_ARGS(buf), | |
| 253 | + | |
| 254 | + TP_STRUCT__entry( | |
| 255 | + __string(msg, buf) | |
| 256 | + ), | |
| 257 | + | |
| 258 | + TP_fast_assign( | |
| 259 | + __assign_str(msg, buf) | |
| 260 | + ), | |
| 261 | + | |
| 262 | + TP_printk("msg='%s'", __get_str(msg)) | |
| 263 | +); | |
| 264 | + | |
| 265 | +TRACE_EVENT(rpcgss_upcall_result, | |
| 266 | + TP_PROTO( | |
| 267 | + u32 uid, | |
| 268 | + int result | |
| 269 | + ), | |
| 270 | + | |
| 271 | + TP_ARGS(uid, result), | |
| 272 | + | |
| 273 | + TP_STRUCT__entry( | |
| 274 | + __field(u32, uid) | |
| 275 | + __field(int, result) | |
| 276 | + | |
| 277 | + ), | |
| 278 | + | |
| 279 | + TP_fast_assign( | |
| 280 | + __entry->uid = uid; | |
| 281 | + __entry->result = result; | |
| 282 | + ), | |
| 283 | + | |
| 284 | + TP_printk("for uid %u, result=%d", __entry->uid, __entry->result) | |
| 285 | +); | |
| 286 | + | |
| 287 | +TRACE_EVENT(rpcgss_context, | |
| 288 | + TP_PROTO( | |
| 289 | + unsigned long expiry, | |
| 290 | + unsigned long now, | |
| 291 | + unsigned int timeout, | |
| 292 | + unsigned int len, | |
| 293 | + const u8 *data | |
| 294 | + ), | |
| 295 | + | |
| 296 | + TP_ARGS(expiry, now, timeout, len, data), | |
| 297 | + | |
| 298 | + TP_STRUCT__entry( | |
| 299 | + __field(unsigned long, expiry) | |
| 300 | + __field(unsigned long, now) | |
| 301 | + __field(unsigned int, timeout) | |
| 302 | + __field(int, len) | |
| 303 | + __string(acceptor, data) | |
| 304 | + ), | |
| 305 | + | |
| 306 | + TP_fast_assign( | |
| 307 | + __entry->expiry = expiry; | |
| 308 | + __entry->now = now; | |
| 309 | + __entry->timeout = timeout; | |
| 310 | + __entry->len = len; | |
| 311 | + strncpy(__get_str(acceptor), data, len); | |
| 312 | + ), | |
| 313 | + | |
| 314 | + TP_printk("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s", | |
| 315 | + __entry->expiry, __entry->now, __entry->timeout, | |
| 316 | + __entry->len, __get_str(acceptor)) | |
| 317 | +); | |
| 318 | + | |
| 319 | + | |
| 320 | +/** | |
| 321 | + ** Miscellaneous events | |
| 322 | + */ | |
| 323 | + | |
| 324 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5); | |
| 325 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I); | |
| 326 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P); | |
| 327 | + | |
| 328 | +#define show_pseudoflavor(x) \ | |
| 329 | + __print_symbolic(x, \ | |
| 330 | + { RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" }, \ | |
| 331 | + { RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" }, \ | |
| 332 | + { RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" }) | |
| 333 | + | |
| 334 | + | |
| 335 | +TRACE_EVENT(rpcgss_createauth, | |
| 336 | + TP_PROTO( | |
| 337 | + unsigned int flavor, | |
| 338 | + int error | |
| 339 | + ), | |
| 340 | + | |
| 341 | + TP_ARGS(flavor, error), | |
| 342 | + | |
| 343 | + TP_STRUCT__entry( | |
| 344 | + __field(unsigned int, flavor) | |
| 345 | + __field(int, error) | |
| 346 | + | |
| 347 | + ), | |
| 348 | + | |
| 349 | + TP_fast_assign( | |
| 350 | + __entry->flavor = flavor; | |
| 351 | + __entry->error = error; | |
| 352 | + ), | |
| 353 | + | |
| 354 | + TP_printk("flavor=%s error=%d", | |
| 355 | + show_pseudoflavor(__entry->flavor), __entry->error) | |
| 356 | +); | |
| 357 | + | |
| 358 | + | |
| 359 | +#endif /* _TRACE_RPCGSS_H */ | |
| 360 | + | |
| 361 | +#include <trace/define_trace.h> | |
| @@ -521,12 +521,18 @@ TRACE_EVENT(xprtrdma_post_send, · 520 unmodified lines | ||
| 521 | 521 | |
| 522 | 522 | TP_STRUCT__entry( |
| 523 | 523 | __field(const void *, req) |
| 524 | + __field(unsigned int, task_id) | |
| 525 | + __field(unsigned int, client_id) | |
| 524 | 526 | __field(int, num_sge) |
| 525 | 527 | __field(int, signaled) |
| 526 | 528 | __field(int, status) |
| 527 | 529 | ), |
| 528 | 530 | |
| 529 | 531 | TP_fast_assign( |
| 532 | + const struct rpc_rqst *rqst = &req->rl_slot; | |
| 533 | + | |
| 534 | + __entry->task_id = rqst->rq_task->tk_pid; | |
| 535 | + __entry->client_id = rqst->rq_task->tk_client->cl_clid; | |
| 530 | 536 | __entry->req = req; |
| 531 | 537 | __entry->num_sge = req->rl_sendctx->sc_wr.num_sge; |
| 532 | 538 | __entry->signaled = req->rl_sendctx->sc_wr.send_flags & |
| @@ -534,9 +540,11 @@ TRACE_EVENT(xprtrdma_post_send, · 1 unmodified line | ||
| 534 | 540 | __entry->status = status; |
| 535 | 541 | ), |
| 536 | 542 | |
| 537 | − TP_printk("req=%p, %d SGEs%s, status=%d", | |
| 543 | + TP_printk("task:%u@%u req=%p (%d SGE%s) %sstatus=%d", | |
| 544 | + __entry->task_id, __entry->client_id, | |
| 538 | 545 | __entry->req, __entry->num_sge, |
| 539 | − (__entry->signaled ? ", signaled" : ""), | |
| 546 | + (__entry->num_sge == 1 ? "" : "s"), | |
| 547 | + (__entry->signaled ? "signaled " : ""), | |
| 540 | 548 | __entry->status |
| 541 | 549 | ) |
| 542 | 550 | ); |
| @@ -77,6 +77,50 @@ TRACE_EVENT(rpc_request, · 76 unmodified lines | ||
| 77 | 77 | ) |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | +TRACE_DEFINE_ENUM(RPC_TASK_ASYNC); | |
| 81 | +TRACE_DEFINE_ENUM(RPC_TASK_SWAPPER); | |
| 82 | +TRACE_DEFINE_ENUM(RPC_CALL_MAJORSEEN); | |
| 83 | +TRACE_DEFINE_ENUM(RPC_TASK_ROOTCREDS); | |
| 84 | +TRACE_DEFINE_ENUM(RPC_TASK_DYNAMIC); | |
| 85 | +TRACE_DEFINE_ENUM(RPC_TASK_KILLED); | |
| 86 | +TRACE_DEFINE_ENUM(RPC_TASK_SOFT); | |
| 87 | +TRACE_DEFINE_ENUM(RPC_TASK_SOFTCONN); | |
| 88 | +TRACE_DEFINE_ENUM(RPC_TASK_SENT); | |
| 89 | +TRACE_DEFINE_ENUM(RPC_TASK_TIMEOUT); | |
| 90 | +TRACE_DEFINE_ENUM(RPC_TASK_NOCONNECT); | |
| 91 | +TRACE_DEFINE_ENUM(RPC_TASK_NO_RETRANS_TIMEOUT); | |
| 92 | + | |
| 93 | +#define rpc_show_task_flags(flags) \ | |
| 94 | + __print_flags(flags, "|", \ | |
| 95 | + { RPC_TASK_ASYNC, "ASYNC" }, \ | |
| 96 | + { RPC_TASK_SWAPPER, "SWAPPER" }, \ | |
| 97 | + { RPC_CALL_MAJORSEEN, "MAJORSEEN" }, \ | |
| 98 | + { RPC_TASK_ROOTCREDS, "ROOTCREDS" }, \ | |
| 99 | + { RPC_TASK_DYNAMIC, "DYNAMIC" }, \ | |
| 100 | + { RPC_TASK_KILLED, "KILLED" }, \ | |
| 101 | + { RPC_TASK_SOFT, "SOFT" }, \ | |
| 102 | + { RPC_TASK_SOFTCONN, "SOFTCONN" }, \ | |
| 103 | + { RPC_TASK_SENT, "SENT" }, \ | |
| 104 | + { RPC_TASK_TIMEOUT, "TIMEOUT" }, \ | |
| 105 | + { RPC_TASK_NOCONNECT, "NOCONNECT" }, \ | |
| 106 | + { RPC_TASK_NO_RETRANS_TIMEOUT, "NORTO" }) | |
| 107 | + | |
| 108 | +TRACE_DEFINE_ENUM(RPC_TASK_RUNNING); | |
| 109 | +TRACE_DEFINE_ENUM(RPC_TASK_QUEUED); | |
| 110 | +TRACE_DEFINE_ENUM(RPC_TASK_ACTIVE); | |
| 111 | +TRACE_DEFINE_ENUM(RPC_TASK_NEED_XMIT); | |
| 112 | +TRACE_DEFINE_ENUM(RPC_TASK_NEED_RECV); | |
| 113 | +TRACE_DEFINE_ENUM(RPC_TASK_MSG_PIN_WAIT); | |
| 114 | + | |
| 115 | +#define rpc_show_runstate(flags) \ | |
| 116 | + __print_flags(flags, "|", \ | |
| 117 | + { (1UL << RPC_TASK_RUNNING), "RUNNING" }, \ | |
| 118 | + { (1UL << RPC_TASK_QUEUED), "QUEUED" }, \ | |
| 119 | + { (1UL << RPC_TASK_ACTIVE), "ACTIVE" }, \ | |
| 120 | + { (1UL << RPC_TASK_NEED_XMIT), "NEED_XMIT" }, \ | |
| 121 | + { (1UL << RPC_TASK_NEED_RECV), "NEED_RECV" }, \ | |
| 122 | + { (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" }) | |
| 123 | + | |
| 80 | 124 | DECLARE_EVENT_CLASS(rpc_task_running, |
| 81 | 125 | |
| 82 | 126 | TP_PROTO(const struct rpc_task *task, const void *action), |
| @@ -102,10 +146,10 @@ DECLARE_EVENT_CLASS(rpc_task_running, · 19 unmodified lines | ||
| 102 | 146 | __entry->flags = task->tk_flags; |
| 103 | 147 | ), |
| 104 | 148 | |
| 105 | − TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d action=%pf", | |
| 149 | + TP_printk("task:%u@%d flags=%s runstate=%s status=%d action=%pf", | |
| 106 | 150 | __entry->task_id, __entry->client_id, |
| 107 | − __entry->flags, | |
| 108 | − __entry->runstate, | |
| 151 | + rpc_show_task_flags(__entry->flags), | |
| 152 | + rpc_show_runstate(__entry->runstate), | |
| 109 | 153 | __entry->status, |
| 110 | 154 | __entry->action |
| 111 | 155 | ) |
| @@ -149,10 +193,10 @@ DECLARE_EVENT_CLASS(rpc_task_queued, · 37 unmodified lines | ||
| 149 | 193 | __assign_str(q_name, rpc_qname(q)); |
| 150 | 194 | ), |
| 151 | 195 | |
| 152 | − TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s", | |
| 196 | + TP_printk("task:%u@%d flags=%s runstate=%s status=%d timeout=%lu queue=%s", | |
| 153 | 197 | __entry->task_id, __entry->client_id, |
| 154 | − __entry->flags, | |
| 155 | − __entry->runstate, | |
| 198 | + rpc_show_task_flags(__entry->flags), | |
| 199 | + rpc_show_runstate(__entry->runstate), | |
| 156 | 200 | __entry->status, |
| 157 | 201 | __entry->timeout, |
| 158 | 202 | __get_str(q_name) |
| @@ -169,6 +213,87 @@ DECLARE_EVENT_CLASS(rpc_task_queued, · 10 unmodified lines | ||
| 169 | 213 | DEFINE_RPC_QUEUED_EVENT(sleep); |
| 170 | 214 | DEFINE_RPC_QUEUED_EVENT(wakeup); |
| 171 | 215 | |
| 216 | +DECLARE_EVENT_CLASS(rpc_failure, | |
| 217 | + | |
| 218 | + TP_PROTO(const struct rpc_task *task), | |
| 219 | + | |
| 220 | + TP_ARGS(task), | |
| 221 | + | |
| 222 | + TP_STRUCT__entry( | |
| 223 | + __field(unsigned int, task_id) | |
| 224 | + __field(unsigned int, client_id) | |
| 225 | + ), | |
| 226 | + | |
| 227 | + TP_fast_assign( | |
| 228 | + __entry->task_id = task->tk_pid; | |
| 229 | + __entry->client_id = task->tk_client->cl_clid; | |
| 230 | + ), | |
| 231 | + | |
| 232 | + TP_printk("task:%u@%u", | |
| 233 | + __entry->task_id, __entry->client_id) | |
| 234 | +); | |
| 235 | + | |
| 236 | +#define DEFINE_RPC_FAILURE(name) \ | |
| 237 | + DEFINE_EVENT(rpc_failure, rpc_bad_##name, \ | |
| 238 | + TP_PROTO( \ | |
| 239 | + const struct rpc_task *task \ | |
| 240 | + ), \ | |
| 241 | + TP_ARGS(task)) | |
| 242 | + | |
| 243 | +DEFINE_RPC_FAILURE(callhdr); | |
| 244 | +DEFINE_RPC_FAILURE(verifier); | |
| 245 | + | |
| 246 | +DECLARE_EVENT_CLASS(rpc_reply_event, | |
| 247 | + | |
| 248 | + TP_PROTO( | |
| 249 | + const struct rpc_task *task | |
| 250 | + ), | |
| 251 | + | |
| 252 | + TP_ARGS(task), | |
| 253 | + | |
| 254 | + TP_STRUCT__entry( | |
| 255 | + __field(unsigned int, task_id) | |
| 256 | + __field(unsigned int, client_id) | |
| 257 | + __field(u32, xid) | |
| 258 | + __string(progname, task->tk_client->cl_program->name) | |
| 259 | + __field(u32, version) | |
| 260 | + __string(procname, rpc_proc_name(task)) | |
| 261 | + __string(servername, task->tk_xprt->servername) | |
| 262 | + ), | |
| 263 | + | |
| 264 | + TP_fast_assign( | |
| 265 | + __entry->task_id = task->tk_pid; | |
| 266 | + __entry->client_id = task->tk_client->cl_clid; | |
| 267 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 268 | + __assign_str(progname, task->tk_client->cl_program->name) | |
| 269 | + __entry->version = task->tk_client->cl_vers; | |
| 270 | + __assign_str(procname, rpc_proc_name(task)) | |
| 271 | + __assign_str(servername, task->tk_xprt->servername) | |
| 272 | + ), | |
| 273 | + | |
| 274 | + TP_printk("task:%u@%d server=%s xid=0x%08x %sv%d %s", | |
| 275 | + __entry->task_id, __entry->client_id, __get_str(servername), | |
| 276 | + __entry->xid, __get_str(progname), __entry->version, | |
| 277 | + __get_str(procname)) | |
| 278 | +) | |
| 279 | + | |
| 280 | +#define DEFINE_RPC_REPLY_EVENT(name) \ | |
| 281 | + DEFINE_EVENT(rpc_reply_event, rpc__##name, \ | |
| 282 | + TP_PROTO( \ | |
| 283 | + const struct rpc_task *task \ | |
| 284 | + ), \ | |
| 285 | + TP_ARGS(task)) | |
| 286 | + | |
| 287 | +DEFINE_RPC_REPLY_EVENT(prog_unavail); | |
| 288 | +DEFINE_RPC_REPLY_EVENT(prog_mismatch); | |
| 289 | +DEFINE_RPC_REPLY_EVENT(proc_unavail); | |
| 290 | +DEFINE_RPC_REPLY_EVENT(garbage_args); | |
| 291 | +DEFINE_RPC_REPLY_EVENT(unparsable); | |
| 292 | +DEFINE_RPC_REPLY_EVENT(mismatch); | |
| 293 | +DEFINE_RPC_REPLY_EVENT(stale_creds); | |
| 294 | +DEFINE_RPC_REPLY_EVENT(bad_creds); | |
| 295 | +DEFINE_RPC_REPLY_EVENT(auth_tooweak); | |
| 296 | + | |
| 172 | 297 | TRACE_EVENT(rpc_stats_latency, |
| 173 | 298 | |
| 174 | 299 | TP_PROTO( |
| @@ -210,6 +335,169 @@ TRACE_EVENT(rpc_stats_latency, · 35 unmodified lines | ||
| 210 | 335 | __entry->backlog, __entry->rtt, __entry->execute) |
| 211 | 336 | ); |
| 212 | 337 | |
| 338 | +TRACE_EVENT(rpc_xdr_overflow, | |
| 339 | + TP_PROTO( | |
| 340 | + const struct xdr_stream *xdr, | |
| 341 | + size_t requested | |
| 342 | + ), | |
| 343 | + | |
| 344 | + TP_ARGS(xdr, requested), | |
| 345 | + | |
| 346 | + TP_STRUCT__entry( | |
| 347 | + __field(unsigned int, task_id) | |
| 348 | + __field(unsigned int, client_id) | |
| 349 | + __field(int, version) | |
| 350 | + __field(size_t, requested) | |
| 351 | + __field(const void *, end) | |
| 352 | + __field(const void *, p) | |
| 353 | + __field(const void *, head_base) | |
| 354 | + __field(size_t, head_len) | |
| 355 | + __field(const void *, tail_base) | |
| 356 | + __field(size_t, tail_len) | |
| 357 | + __field(unsigned int, page_len) | |
| 358 | + __field(unsigned int, len) | |
| 359 | + __string(progname, | |
| 360 | + xdr->rqst->rq_task->tk_client->cl_program->name) | |
| 361 | + __string(procedure, | |
| 362 | + xdr->rqst->rq_task->tk_msg.rpc_proc->p_name) | |
| 363 | + ), | |
| 364 | + | |
| 365 | + TP_fast_assign( | |
| 366 | + if (xdr->rqst) { | |
| 367 | + const struct rpc_task *task = xdr->rqst->rq_task; | |
| 368 | + | |
| 369 | + __entry->task_id = task->tk_pid; | |
| 370 | + __entry->client_id = task->tk_client->cl_clid; | |
| 371 | + __assign_str(progname, | |
| 372 | + task->tk_client->cl_program->name) | |
| 373 | + __entry->version = task->tk_client->cl_vers; | |
| 374 | + __assign_str(procedure, task->tk_msg.rpc_proc->p_name) | |
| 375 | + } else { | |
| 376 | + __entry->task_id = 0; | |
| 377 | + __entry->client_id = 0; | |
| 378 | + __assign_str(progname, "unknown") | |
| 379 | + __entry->version = 0; | |
| 380 | + __assign_str(procedure, "unknown") | |
| 381 | + } | |
| 382 | + __entry->requested = requested; | |
| 383 | + __entry->end = xdr->end; | |
| 384 | + __entry->p = xdr->p; | |
| 385 | + __entry->head_base = xdr->buf->head[0].iov_base, | |
| 386 | + __entry->head_len = xdr->buf->head[0].iov_len, | |
| 387 | + __entry->page_len = xdr->buf->page_len, | |
| 388 | + __entry->tail_base = xdr->buf->tail[0].iov_base, | |
| 389 | + __entry->tail_len = xdr->buf->tail[0].iov_len, | |
| 390 | + __entry->len = xdr->buf->len; | |
| 391 | + ), | |
| 392 | + | |
| 393 | + TP_printk( | |
| 394 | + "task:%u@%u %sv%d %s requested=%zu p=%p end=%p xdr=[%p,%zu]/%u/[%p,%zu]/%u\n", | |
| 395 | + __entry->task_id, __entry->client_id, | |
| 396 | + __get_str(progname), __entry->version, __get_str(procedure), | |
| 397 | + __entry->requested, __entry->p, __entry->end, | |
| 398 | + __entry->head_base, __entry->head_len, | |
| 399 | + __entry->page_len, | |
| 400 | + __entry->tail_base, __entry->tail_len, | |
| 401 | + __entry->len | |
| 402 | + ) | |
| 403 | +); | |
| 404 | + | |
| 405 | +TRACE_EVENT(rpc_xdr_alignment, | |
| 406 | + TP_PROTO( | |
| 407 | + const struct xdr_stream *xdr, | |
| 408 | + size_t offset, | |
| 409 | + unsigned int copied | |
| 410 | + ), | |
| 411 | + | |
| 412 | + TP_ARGS(xdr, offset, copied), | |
| 413 | + | |
| 414 | + TP_STRUCT__entry( | |
| 415 | + __field(unsigned int, task_id) | |
| 416 | + __field(unsigned int, client_id) | |
| 417 | + __field(int, version) | |
| 418 | + __field(size_t, offset) | |
| 419 | + __field(unsigned int, copied) | |
| 420 | + __field(const void *, head_base) | |
| 421 | + __field(size_t, head_len) | |
| 422 | + __field(const void *, tail_base) | |
| 423 | + __field(size_t, tail_len) | |
| 424 | + __field(unsigned int, page_len) | |
| 425 | + __field(unsigned int, len) | |
| 426 | + __string(progname, | |
| 427 | + xdr->rqst->rq_task->tk_client->cl_program->name) | |
| 428 | + __string(procedure, | |
| 429 | + xdr->rqst->rq_task->tk_msg.rpc_proc->p_name) | |
| 430 | + ), | |
| 431 | + | |
| 432 | + TP_fast_assign( | |
| 433 | + const struct rpc_task *task = xdr->rqst->rq_task; | |
| 434 | + | |
| 435 | + __entry->task_id = task->tk_pid; | |
| 436 | + __entry->client_id = task->tk_client->cl_clid; | |
| 437 | + __assign_str(progname, | |
| 438 | + task->tk_client->cl_program->name) | |
| 439 | + __entry->version = task->tk_client->cl_vers; | |
| 440 | + __assign_str(procedure, task->tk_msg.rpc_proc->p_name) | |
| 441 | + | |
| 442 | + __entry->offset = offset; | |
| 443 | + __entry->copied = copied; | |
| 444 | + __entry->head_base = xdr->buf->head[0].iov_base, | |
| 445 | + __entry->head_len = xdr->buf->head[0].iov_len, | |
| 446 | + __entry->page_len = xdr->buf->page_len, | |
| 447 | + __entry->tail_base = xdr->buf->tail[0].iov_base, | |
| 448 | + __entry->tail_len = xdr->buf->tail[0].iov_len, | |
| 449 | + __entry->len = xdr->buf->len; | |
| 450 | + ), | |
| 451 | + | |
| 452 | + TP_printk( | |
| 453 | + "task:%u@%u %sv%d %s offset=%zu copied=%u xdr=[%p,%zu]/%u/[%p,%zu]/%u\n", | |
| 454 | + __entry->task_id, __entry->client_id, | |
| 455 | + __get_str(progname), __entry->version, __get_str(procedure), | |
| 456 | + __entry->offset, __entry->copied, | |
| 457 | + __entry->head_base, __entry->head_len, | |
| 458 | + __entry->page_len, | |
| 459 | + __entry->tail_base, __entry->tail_len, | |
| 460 | + __entry->len | |
| 461 | + ) | |
| 462 | +); | |
| 463 | + | |
| 464 | +TRACE_EVENT(rpc_reply_pages, | |
| 465 | + TP_PROTO( | |
| 466 | + const struct rpc_rqst *req | |
| 467 | + ), | |
| 468 | + | |
| 469 | + TP_ARGS(req), | |
| 470 | + | |
| 471 | + TP_STRUCT__entry( | |
| 472 | + __field(unsigned int, task_id) | |
| 473 | + __field(unsigned int, client_id) | |
| 474 | + __field(const void *, head_base) | |
| 475 | + __field(size_t, head_len) | |
| 476 | + __field(const void *, tail_base) | |
| 477 | + __field(size_t, tail_len) | |
| 478 | + __field(unsigned int, page_len) | |
| 479 | + ), | |
| 480 | + | |
| 481 | + TP_fast_assign( | |
| 482 | + __entry->task_id = req->rq_task->tk_pid; | |
| 483 | + __entry->client_id = req->rq_task->tk_client->cl_clid; | |
| 484 | + | |
| 485 | + __entry->head_base = req->rq_rcv_buf.head[0].iov_base; | |
| 486 | + __entry->head_len = req->rq_rcv_buf.head[0].iov_len; | |
| 487 | + __entry->page_len = req->rq_rcv_buf.page_len; | |
| 488 | + __entry->tail_base = req->rq_rcv_buf.tail[0].iov_base; | |
| 489 | + __entry->tail_len = req->rq_rcv_buf.tail[0].iov_len; | |
| 490 | + ), | |
| 491 | + | |
| 492 | + TP_printk( | |
| 493 | + "task:%u@%u xdr=[%p,%zu]/%u/[%p,%zu]\n", | |
| 494 | + __entry->task_id, __entry->client_id, | |
| 495 | + __entry->head_base, __entry->head_len, | |
| 496 | + __entry->page_len, | |
| 497 | + __entry->tail_base, __entry->tail_len | |
| 498 | + ) | |
| 499 | +); | |
| 500 | + | |
| 213 | 501 | /* |
| 214 | 502 | * First define the enums in the below macros to be exported to userspace |
| 215 | 503 | * via TRACE_DEFINE_ENUM(). |
| @@ -404,9 +692,68 @@ DECLARE_EVENT_CLASS(rpc_xprt_event, · 188 unmodified lines | ||
| 404 | 692 | |
| 405 | 693 | DEFINE_RPC_XPRT_EVENT(timer); |
| 406 | 694 | DEFINE_RPC_XPRT_EVENT(lookup_rqst); |
| 407 | −DEFINE_RPC_XPRT_EVENT(transmit); | |
| 408 | 695 | DEFINE_RPC_XPRT_EVENT(complete_rqst); |
| 409 | 696 | |
| 697 | +TRACE_EVENT(xprt_transmit, | |
| 698 | + TP_PROTO( | |
| 699 | + const struct rpc_rqst *rqst, | |
| 700 | + int status | |
| 701 | + ), | |
| 702 | + | |
| 703 | + TP_ARGS(rqst, status), | |
| 704 | + | |
| 705 | + TP_STRUCT__entry( | |
| 706 | + __field(unsigned int, task_id) | |
| 707 | + __field(unsigned int, client_id) | |
| 708 | + __field(u32, xid) | |
| 709 | + __field(u32, seqno) | |
| 710 | + __field(int, status) | |
| 711 | + ), | |
| 712 | + | |
| 713 | + TP_fast_assign( | |
| 714 | + __entry->task_id = rqst->rq_task->tk_pid; | |
| 715 | + __entry->client_id = rqst->rq_task->tk_client->cl_clid; | |
| 716 | + __entry->xid = be32_to_cpu(rqst->rq_xid); | |
| 717 | + __entry->seqno = rqst->rq_seqno; | |
| 718 | + __entry->status = status; | |
| 719 | + ), | |
| 720 | + | |
| 721 | + TP_printk( | |
| 722 | + "task:%u@%u xid=0x%08x seqno=%u status=%d", | |
| 723 | + __entry->task_id, __entry->client_id, __entry->xid, | |
| 724 | + __entry->seqno, __entry->status) | |
| 725 | +); | |
| 726 | + | |
| 727 | +TRACE_EVENT(xprt_enq_xmit, | |
| 728 | + TP_PROTO( | |
| 729 | + const struct rpc_task *task, | |
| 730 | + int stage | |
| 731 | + ), | |
| 732 | + | |
| 733 | + TP_ARGS(task, stage), | |
| 734 | + | |
| 735 | + TP_STRUCT__entry( | |
| 736 | + __field(unsigned int, task_id) | |
| 737 | + __field(unsigned int, client_id) | |
| 738 | + __field(u32, xid) | |
| 739 | + __field(u32, seqno) | |
| 740 | + __field(int, stage) | |
| 741 | + ), | |
| 742 | + | |
| 743 | + TP_fast_assign( | |
| 744 | + __entry->task_id = task->tk_pid; | |
| 745 | + __entry->client_id = task->tk_client->cl_clid; | |
| 746 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 747 | + __entry->seqno = task->tk_rqstp->rq_seqno; | |
| 748 | + __entry->stage = stage; | |
| 749 | + ), | |
| 750 | + | |
| 751 | + TP_printk( | |
| 752 | + "task:%u@%u xid=0x%08x seqno=%u stage=%d", | |
| 753 | + __entry->task_id, __entry->client_id, __entry->xid, | |
| 754 | + __entry->seqno, __entry->stage) | |
| 755 | +); | |
| 756 | + | |
| 410 | 757 | TRACE_EVENT(xprt_ping, |
| 411 | 758 | TP_PROTO(const struct rpc_xprt *xprt, int status), |
| 412 | 759 | |
| @@ -34,6 +34,22 @@ config RPCSEC_GSS_KRB5 · 33 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | If unsure, say Y. |
| 36 | 36 | |
| 37 | +config CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 38 | + bool "Secure RPC: Disable insecure Kerberos encryption types" | |
| 39 | + depends on RPCSEC_GSS_KRB5 | |
| 40 | + default n | |
| 41 | + help | |
| 42 | + Choose Y here to disable the use of deprecated encryption types | |
| 43 | + with the Kerberos version 5 GSS-API mechanism (RFC 1964). The | |
| 44 | + deprecated encryption types include DES-CBC-MD5, DES-CBC-CRC, | |
| 45 | + and DES-CBC-MD4. These types were deprecated by RFC 6649 because | |
| 46 | + they were found to be insecure. | |
| 47 | + | |
| 48 | + N is the default because many sites have deployed KDCs and | |
| 49 | + keytabs that contain only these deprecated encryption types. | |
| 50 | + Choosing Y prevents the use of known-insecure encryption types | |
| 51 | + but might result in compatibility problems. | |
| 52 | + | |
| 37 | 53 | config SUNRPC_DEBUG |
| 38 | 54 | bool "RPC: Enable dprintk debugging" |
| 39 | 55 | depends on SUNRPC && SYSCTL |
| @@ -17,9 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/sunrpc/gss_api.h> |
| 18 | 18 | #include <linux/spinlock.h> |
| 19 | 19 | |
| 20 | −#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) | |
| 21 | −# define RPCDBG_FACILITY RPCDBG_AUTH | |
| 22 | −#endif | |
| 20 | +#include <trace/events/sunrpc.h> | |
| 23 | 21 | |
| 24 | 22 | #define RPC_CREDCACHE_DEFAULT_HASHBITS (4) |
| 25 | 23 | struct rpc_cred_cache { |
| @@ -267,8 +265,6 @@ rpcauth_list_flavors(rpc_authflavor_t *array, int size) · 241 unmodified lines | ||
| 267 | 265 | } |
| 268 | 266 | } |
| 269 | 267 | rcu_read_unlock(); |
| 270 | − | |
| 271 | − dprintk("RPC: %s returns %d\n", __func__, result); | |
| 272 | 268 | return result; |
| 273 | 269 | } |
| 274 | 270 | EXPORT_SYMBOL_GPL(rpcauth_list_flavors); |
| @@ -636,9 +632,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags) · 361 unmodified lines | ||
| 636 | 632 | struct rpc_cred *ret; |
| 637 | 633 | const struct cred *cred = current_cred(); |
| 638 | 634 | |
| 639 | − dprintk("RPC: looking up %s cred\n", | |
| 640 | − auth->au_ops->au_name); | |
| 641 | − | |
| 642 | 635 | memset(&acred, 0, sizeof(acred)); |
| 643 | 636 | acred.cred = cred; |
| 644 | 637 | ret = auth->au_ops->lookup_cred(auth, &acred, flags); |
| @@ -670,8 +663,6 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) · 25 unmodified lines | ||
| 670 | 663 | }; |
| 671 | 664 | struct rpc_cred *ret; |
| 672 | 665 | |
| 673 | − dprintk("RPC: %5u looking up %s cred\n", | |
| 674 | − task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); | |
| 675 | 666 | ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags); |
| 676 | 667 | put_cred(acred.cred); |
| 677 | 668 | return ret; |
| @@ -688,8 +679,6 @@ rpcauth_bind_machine_cred(struct rpc_task *task, int lookupflags) · 10 unmodified lines | ||
| 688 | 679 | |
| 689 | 680 | if (!acred.principal) |
| 690 | 681 | return NULL; |
| 691 | − dprintk("RPC: %5u looking up %s machine cred\n", | |
| 692 | − task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); | |
| 693 | 682 | return auth->au_ops->lookup_cred(auth, &acred, lookupflags); |
| 694 | 683 | } |
| 695 | 684 | |
| @@ -698,8 +687,6 @@ rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) · 2 unmodified lines | ||
| 698 | 687 | { |
| 699 | 688 | struct rpc_auth *auth = task->tk_client->cl_auth; |
| 700 | 689 | |
| 701 | − dprintk("RPC: %5u looking up %s cred\n", | |
| 702 | − task->tk_pid, auth->au_ops->au_name); | |
| 703 | 690 | return rpcauth_lookupcred(auth, lookupflags); |
| 704 | 691 | } |
| 705 | 692 | |
| @@ -771,75 +758,102 @@ destroy: · 65 unmodified lines | ||
| 771 | 758 | } |
| 772 | 759 | EXPORT_SYMBOL_GPL(put_rpccred); |
| 773 | 760 | |
| 774 | −__be32 * | |
| 775 | −rpcauth_marshcred(struct rpc_task *task, __be32 *p) | |
| 761 | +/** | |
| 762 | + * rpcauth_marshcred - Append RPC credential to end of @xdr | |
| 763 | + * @task: controlling RPC task | |
| 764 | + * @xdr: xdr_stream containing initial portion of RPC Call header | |
| 765 | + * | |
| 766 | + * On success, an appropriate verifier is added to @xdr, @xdr is | |
| 767 | + * updated to point past the verifier, and zero is returned. | |
| 768 | + * Otherwise, @xdr is in an undefined state and a negative errno | |
| 769 | + * is returned. | |
| 770 | + */ | |
| 771 | +int rpcauth_marshcred(struct rpc_task *task, struct xdr_stream *xdr) | |
| 776 | 772 | { |
| 777 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 773 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 778 | 774 | |
| 779 | − dprintk("RPC: %5u marshaling %s cred %p\n", | |
| 780 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 781 | − | |
| 782 | − return cred->cr_ops->crmarshal(task, p); | |
| 775 | + return ops->crmarshal(task, xdr); | |
| 783 | 776 | } |
| 784 | 777 | |
| 785 | −__be32 * | |
| 786 | −rpcauth_checkverf(struct rpc_task *task, __be32 *p) | |
| 778 | +/** | |
| 779 | + * rpcauth_wrap_req_encode - XDR encode the RPC procedure | |
| 780 | + * @task: controlling RPC task | |
| 781 | + * @xdr: stream where on-the-wire bytes are to be marshalled | |
| 782 | + * | |
| 783 | + * On success, @xdr contains the encoded and wrapped message. | |
| 784 | + * Otherwise, @xdr is in an undefined state. | |
| 785 | + */ | |
| 786 | +int rpcauth_wrap_req_encode(struct rpc_task *task, struct xdr_stream *xdr) | |
| 787 | 787 | { |
| 788 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 788 | + kxdreproc_t encode = task->tk_msg.rpc_proc->p_encode; | |
| 789 | 789 | |
| 790 | − dprintk("RPC: %5u validating %s cred %p\n", | |
| 791 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 792 | − | |
| 793 | − return cred->cr_ops->crvalidate(task, p); | |
| 790 | + encode(task->tk_rqstp, xdr, task->tk_msg.rpc_argp); | |
| 791 | + return 0; | |
| 794 | 792 | } |
| 793 | +EXPORT_SYMBOL_GPL(rpcauth_wrap_req_encode); | |
| 795 | 794 | |
| 796 | −static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 797 | − __be32 *data, void *obj) | |
| 795 | +/** | |
| 796 | + * rpcauth_wrap_req - XDR encode and wrap the RPC procedure | |
| 797 | + * @task: controlling RPC task | |
| 798 | + * @xdr: stream where on-the-wire bytes are to be marshalled | |
| 799 | + * | |
| 800 | + * On success, @xdr contains the encoded and wrapped message, | |
| 801 | + * and zero is returned. Otherwise, @xdr is in an undefined | |
| 802 | + * state and a negative errno is returned. | |
| 803 | + */ | |
| 804 | +int rpcauth_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | |
| 798 | 805 | { |
| 799 | − struct xdr_stream xdr; | |
| 806 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 800 | 807 | |
| 801 | − xdr_init_encode(&xdr, &rqstp->rq_snd_buf, data); | |
| 802 | − encode(rqstp, &xdr, obj); | |
| 808 | + return ops->crwrap_req(task, xdr); | |
| 803 | 809 | } |
| 804 | 810 | |
| 811 | +/** | |
| 812 | + * rpcauth_checkverf - Validate verifier in RPC Reply header | |
| 813 | + * @task: controlling RPC task | |
| 814 | + * @xdr: xdr_stream containing RPC Reply header | |
| 815 | + * | |
| 816 | + * On success, @xdr is updated to point past the verifier and | |
| 817 | + * zero is returned. Otherwise, @xdr is in an undefined state | |
| 818 | + * and a negative errno is returned. | |
| 819 | + */ | |
| 805 | 820 | int |
| 806 | −rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, | |
| 807 | − __be32 *data, void *obj) | |
| 821 | +rpcauth_checkverf(struct rpc_task *task, struct xdr_stream *xdr) | |
| 808 | 822 | { |
| 809 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 823 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 810 | 824 | |
| 811 | − dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", | |
| 812 | − task->tk_pid, cred->cr_ops->cr_name, cred); | |
| 813 | − if (cred->cr_ops->crwrap_req) | |
| 814 | − return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); | |
| 815 | − /* By default, we encode the arguments normally. */ | |
| 816 | − rpcauth_wrap_req_encode(encode, rqstp, data, obj); | |
| 817 | − return 0; | |
| 825 | + return ops->crvalidate(task, xdr); | |
| 818 | 826 | } |
| 819 | 827 | |
| 820 | −static int | |
| 821 | −rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, | |
| 822 | − __be32 *data, void *obj) | |
| 828 | +/** | |
| 829 | + * rpcauth_unwrap_resp_decode - Invoke XDR decode function | |
| 830 | + * @task: controlling RPC task | |
| 831 | + * @xdr: stream where the Reply message resides | |
| 832 | + * | |
| 833 | + * Returns zero on success; otherwise a negative errno is returned. | |
| 834 | + */ | |
| 835 | +int | |
| 836 | +rpcauth_unwrap_resp_decode(struct rpc_task *task, struct xdr_stream *xdr) | |
| 823 | 837 | { |
| 824 | − struct xdr_stream xdr; | |
| 838 | + kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode; | |
| 825 | 839 | |
| 826 | − xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data); | |
| 827 | − return decode(rqstp, &xdr, obj); | |
| 840 | + return decode(task->tk_rqstp, xdr, task->tk_msg.rpc_resp); | |
| 828 | 841 | } |
| 842 | +EXPORT_SYMBOL_GPL(rpcauth_unwrap_resp_decode); | |
| 829 | 843 | |
| 844 | +/** | |
| 845 | + * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred | |
| 846 | + * @task: controlling RPC task | |
| 847 | + * @xdr: stream where the Reply message resides | |
| 848 | + * | |
| 849 | + * Returns zero on success; otherwise a negative errno is returned. | |
| 850 | + */ | |
| 830 | 851 | int |
| 831 | −rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, | |
| 832 | − __be32 *data, void *obj) | |
| 852 | +rpcauth_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr) | |
| 833 | 853 | { |
| 834 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 854 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 835 | 855 | |
| 836 | − dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", | |
| 837 | − task->tk_pid, cred->cr_ops->cr_name, cred); | |
| 838 | − if (cred->cr_ops->crunwrap_resp) | |
| 839 | − return cred->cr_ops->crunwrap_resp(task, decode, rqstp, | |
| 840 | − data, obj); | |
| 841 | − /* By default, we decode the arguments normally. */ | |
| 842 | − return rpcauth_unwrap_req_decode(decode, rqstp, data, obj); | |
| 856 | + return ops->crunwrap_resp(task, xdr); | |
| 843 | 857 | } |
| 844 | 858 | |
| 845 | 859 | bool |
| @@ -865,8 +879,6 @@ rpcauth_refreshcred(struct rpc_task *task) · 19 unmodified lines | ||
| 865 | 879 | goto out; |
| 866 | 880 | cred = task->tk_rqstp->rq_cred; |
| 867 | 881 | } |
| 868 | − dprintk("RPC: %5u refreshing %s cred %p\n", | |
| 869 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 870 | 882 | |
| 871 | 883 | err = cred->cr_ops->crrefresh(task); |
| 872 | 884 | out: |
| @@ -880,8 +892,6 @@ rpcauth_invalcred(struct rpc_task *task) · 7 unmodified lines | ||
| 880 | 892 | { |
| 881 | 893 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 882 | 894 | |
| 883 | − dprintk("RPC: %5u invalidating %s cred %p\n", | |
| 884 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 885 | 895 | if (cred) |
| 886 | 896 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 887 | 897 | } |
| @@ -7,7 +7,7 @@ obj-$(CONFIG_SUNRPC_GSS) += auth_rpcgss.o · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | auth_rpcgss-y := auth_gss.o gss_generic_token.o \ |
| 9 | 9 | gss_mech_switch.o svcauth_gss.o \ |
| 10 | − gss_rpc_upcall.o gss_rpc_xdr.o | |
| 10 | + gss_rpc_upcall.o gss_rpc_xdr.o trace.o | |
| 11 | 11 | |
| 12 | 12 | obj-$(CONFIG_RPCSEC_GSS_KRB5) += rpcsec_gss_krb5.o |
| 13 | 13 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/auth_gss/auth_gss.c |
| 3 | 4 | * |
| @@ -8,34 +9,8 @@ · 4 unmodified lines | ||
| 8 | 9 | * |
| 9 | 10 | * Dug Song <dugsong@monkey.org> |
| 10 | 11 | * Andy Adamson <andros@umich.edu> |
| 11 | − * | |
| 12 | − * Redistribution and use in source and binary forms, with or without | |
| 13 | − * modification, are permitted provided that the following conditions | |
| 14 | − * are met: | |
| 15 | − * | |
| 16 | − * 1. Redistributions of source code must retain the above copyright | |
| 17 | − * notice, this list of conditions and the following disclaimer. | |
| 18 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 19 | − * notice, this list of conditions and the following disclaimer in the | |
| 20 | − * documentation and/or other materials provided with the distribution. | |
| 21 | − * 3. Neither the name of the University nor the names of its | |
| 22 | − * contributors may be used to endorse or promote products derived | |
| 23 | − * from this software without specific prior written permission. | |
| 24 | − * | |
| 25 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 26 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 27 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 28 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 29 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 30 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 31 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 32 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 33 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 34 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 35 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 36 | 12 | */ |
| 37 | 13 | |
| 38 | − | |
| 39 | 14 | #include <linux/module.h> |
| 40 | 15 | #include <linux/init.h> |
| 41 | 16 | #include <linux/types.h> |
| @@ -55,6 +30,8 @@ · 13 unmodified lines | ||
| 55 | 30 | |
| 56 | 31 | #include "../netns.h" |
| 57 | 32 | |
| 33 | +#include <trace/events/rpcgss.h> | |
| 34 | + | |
| 58 | 35 | static const struct rpc_authops authgss_ops; |
| 59 | 36 | |
| 60 | 37 | static const struct rpc_credops gss_credops; |
| @@ -260,6 +237,7 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct · 199 unmodified lines | ||
| 260 | 237 | } |
| 261 | 238 | ret = gss_import_sec_context(p, seclen, gm, &ctx->gc_gss_ctx, NULL, GFP_NOFS); |
| 262 | 239 | if (ret < 0) { |
| 240 | + trace_rpcgss_import_ctx(ret); | |
| 263 | 241 | p = ERR_PTR(ret); |
| 264 | 242 | goto err; |
| 265 | 243 | } |
| @@ -275,12 +253,9 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct · 9 unmodified lines | ||
| 275 | 253 | if (IS_ERR(p)) |
| 276 | 254 | goto err; |
| 277 | 255 | done: |
| 278 | − dprintk("RPC: %s Success. gc_expiry %lu now %lu timeout %u acceptor %.*s\n", | |
| 279 | − __func__, ctx->gc_expiry, now, timeout, ctx->gc_acceptor.len, | |
| 280 | − ctx->gc_acceptor.data); | |
| 281 | − return p; | |
| 256 | + trace_rpcgss_context(ctx->gc_expiry, now, timeout, | |
| 257 | + ctx->gc_acceptor.len, ctx->gc_acceptor.data); | |
| 282 | 258 | err: |
| 283 | − dprintk("RPC: %s returns error %ld\n", __func__, -PTR_ERR(p)); | |
| 284 | 259 | return p; |
| 285 | 260 | } |
| 286 | 261 | |
| @@ -354,10 +329,8 @@ __gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid, const struct gss_auth *auth · 67 unmodified lines | ||
| 354 | 329 | if (auth && pos->auth->service != auth->service) |
| 355 | 330 | continue; |
| 356 | 331 | refcount_inc(&pos->count); |
| 357 | − dprintk("RPC: %s found msg %p\n", __func__, pos); | |
| 358 | 332 | return pos; |
| 359 | 333 | } |
| 360 | − dprintk("RPC: %s found nothing\n", __func__); | |
| 361 | 334 | return NULL; |
| 362 | 335 | } |
| 363 | 336 | |
| @@ -456,7 +429,7 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 92 unmodified lines | ||
| 456 | 429 | size_t buflen = sizeof(gss_msg->databuf); |
| 457 | 430 | int len; |
| 458 | 431 | |
| 459 | − len = scnprintf(p, buflen, "mech=%s uid=%d ", mech->gm_name, | |
| 432 | + len = scnprintf(p, buflen, "mech=%s uid=%d", mech->gm_name, | |
| 460 | 433 | from_kuid(&init_user_ns, gss_msg->uid)); |
| 461 | 434 | buflen -= len; |
| 462 | 435 | p += len; |
| @@ -467,7 +440,7 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 4 unmodified lines | ||
| 467 | 440 | * identity that we are authenticating to. |
| 468 | 441 | */ |
| 469 | 442 | if (target_name) { |
| 470 | − len = scnprintf(p, buflen, "target=%s ", target_name); | |
| 443 | + len = scnprintf(p, buflen, " target=%s", target_name); | |
| 471 | 444 | buflen -= len; |
| 472 | 445 | p += len; |
| 473 | 446 | gss_msg->msg.len += len; |
| @@ -487,11 +460,11 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 13 unmodified lines | ||
| 487 | 460 | char *c = strchr(service_name, '@'); |
| 488 | 461 | |
| 489 | 462 | if (!c) |
| 490 | − len = scnprintf(p, buflen, "service=%s ", | |
| 463 | + len = scnprintf(p, buflen, " service=%s", | |
| 491 | 464 | service_name); |
| 492 | 465 | else |
| 493 | 466 | len = scnprintf(p, buflen, |
| 494 | − "service=%.*s srchost=%s ", | |
| 467 | + " service=%.*s srchost=%s", | |
| 495 | 468 | (int)(c - service_name), |
| 496 | 469 | service_name, c + 1); |
| 497 | 470 | buflen -= len; |
| @@ -500,17 +473,17 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 2 unmodified lines | ||
| 500 | 473 | } |
| 501 | 474 | |
| 502 | 475 | if (mech->gm_upcall_enctypes) { |
| 503 | − len = scnprintf(p, buflen, "enctypes=%s ", | |
| 476 | + len = scnprintf(p, buflen, " enctypes=%s", | |
| 504 | 477 | mech->gm_upcall_enctypes); |
| 505 | 478 | buflen -= len; |
| 506 | 479 | p += len; |
| 507 | 480 | gss_msg->msg.len += len; |
| 508 | 481 | } |
| 482 | + trace_rpcgss_upcall_msg(gss_msg->databuf); | |
| 509 | 483 | len = scnprintf(p, buflen, "\n"); |
| 510 | 484 | if (len == 0) |
| 511 | 485 | goto out_overflow; |
| 512 | 486 | gss_msg->msg.len += len; |
| 513 | − | |
| 514 | 487 | gss_msg->msg.data = gss_msg->databuf; |
| 515 | 488 | return 0; |
| 516 | 489 | out_overflow: |
| @@ -603,8 +576,6 @@ gss_refresh_upcall(struct rpc_task *task) · 86 unmodified lines | ||
| 603 | 576 | struct rpc_pipe *pipe; |
| 604 | 577 | int err = 0; |
| 605 | 578 | |
| 606 | − dprintk("RPC: %5u %s for uid %u\n", | |
| 607 | − task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 608 | 579 | gss_msg = gss_setup_upcall(gss_auth, cred); |
| 609 | 580 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
| 610 | 581 | /* XXX: warning on the first, under the assumption we |
| @@ -612,7 +583,8 @@ gss_refresh_upcall(struct rpc_task *task) · 1 unmodified line | ||
| 612 | 583 | warn_gssd(); |
| 613 | 584 | task->tk_timeout = 15*HZ; |
| 614 | 585 | rpc_sleep_on(&pipe_version_rpc_waitqueue, task, NULL); |
| 615 | − return -EAGAIN; | |
| 586 | + err = -EAGAIN; | |
| 587 | + goto out; | |
| 616 | 588 | } |
| 617 | 589 | if (IS_ERR(gss_msg)) { |
| 618 | 590 | err = PTR_ERR(gss_msg); |
| @@ -635,9 +607,8 @@ gss_refresh_upcall(struct rpc_task *task) · 16 unmodified lines | ||
| 635 | 607 | spin_unlock(&pipe->lock); |
| 636 | 608 | gss_release_msg(gss_msg); |
| 637 | 609 | out: |
| 638 | − dprintk("RPC: %5u %s for uid %u result %d\n", | |
| 639 | − task->tk_pid, __func__, | |
| 640 | − from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); | |
| 610 | + trace_rpcgss_upcall_result(from_kuid(&init_user_ns, | |
| 611 | + cred->cr_cred->fsuid), err); | |
| 641 | 612 | return err; |
| 642 | 613 | } |
| 643 | 614 | |
| @@ -652,14 +623,13 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) · 8 unmodified lines | ||
| 652 | 623 | DEFINE_WAIT(wait); |
| 653 | 624 | int err; |
| 654 | 625 | |
| 655 | − dprintk("RPC: %s for uid %u\n", | |
| 656 | − __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 657 | 626 | retry: |
| 658 | 627 | err = 0; |
| 659 | 628 | /* if gssd is down, just skip upcalling altogether */ |
| 660 | 629 | if (!gssd_running(net)) { |
| 661 | 630 | warn_gssd(); |
| 662 | − return -EACCES; | |
| 631 | + err = -EACCES; | |
| 632 | + goto out; | |
| 663 | 633 | } |
| 664 | 634 | gss_msg = gss_setup_upcall(gss_auth, cred); |
| 665 | 635 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
| @@ -700,8 +670,8 @@ out_intr: · 34 unmodified lines | ||
| 700 | 670 | finish_wait(&gss_msg->waitqueue, &wait); |
| 701 | 671 | gss_release_msg(gss_msg); |
| 702 | 672 | out: |
| 703 | − dprintk("RPC: %s for uid %u result %d\n", | |
| 704 | − __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); | |
| 673 | + trace_rpcgss_upcall_result(from_kuid(&init_user_ns, | |
| 674 | + cred->cr_cred->fsuid), err); | |
| 705 | 675 | return err; |
| 706 | 676 | } |
| 707 | 677 | |
| @@ -794,7 +764,6 @@ err_put_ctx: · 86 unmodified lines | ||
| 794 | 764 | err: |
| 795 | 765 | kfree(buf); |
| 796 | 766 | out: |
| 797 | − dprintk("RPC: %s returning %zd\n", __func__, err); | |
| 798 | 767 | return err; |
| 799 | 768 | } |
| 800 | 769 | |
| @@ -863,8 +832,6 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) · 62 unmodified lines | ||
| 863 | 832 | struct gss_upcall_msg *gss_msg = container_of(msg, struct gss_upcall_msg, msg); |
| 864 | 833 | |
| 865 | 834 | if (msg->errno < 0) { |
| 866 | − dprintk("RPC: %s releasing msg %p\n", | |
| 867 | − __func__, gss_msg); | |
| 868 | 835 | refcount_inc(&gss_msg->count); |
| 869 | 836 | gss_unhash_msg(gss_msg); |
| 870 | 837 | if (msg->errno == -ETIMEDOUT) |
| @@ -1024,8 +991,6 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 153 unmodified lines | ||
| 1024 | 991 | struct rpc_auth * auth; |
| 1025 | 992 | int err = -ENOMEM; /* XXX? */ |
| 1026 | 993 | |
| 1027 | − dprintk("RPC: creating GSS authenticator for client %p\n", clnt); | |
| 1028 | − | |
| 1029 | 994 | if (!try_module_get(THIS_MODULE)) |
| 1030 | 995 | return ERR_PTR(err); |
| 1031 | 996 | if (!(gss_auth = kmalloc(sizeof(*gss_auth), GFP_KERNEL))) |
| @@ -1041,10 +1006,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 9 unmodified lines | ||
| 1041 | 1006 | gss_auth->net = get_net(rpc_net_ns(clnt)); |
| 1042 | 1007 | err = -EINVAL; |
| 1043 | 1008 | gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); |
| 1044 | − if (!gss_auth->mech) { | |
| 1045 | − dprintk("RPC: Pseudoflavor %d not found!\n", flavor); | |
| 1009 | + if (!gss_auth->mech) | |
| 1046 | 1010 | goto err_put_net; |
| 1047 | − } | |
| 1048 | 1011 | gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor); |
| 1049 | 1012 | if (gss_auth->service == 0) |
| 1050 | 1013 | goto err_put_mech; |
| @@ -1053,6 +1016,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 2 unmodified lines | ||
| 1053 | 1016 | auth = &gss_auth->rpc_auth; |
| 1054 | 1017 | auth->au_cslack = GSS_CRED_SLACK >> 2; |
| 1055 | 1018 | auth->au_rslack = GSS_VERF_SLACK >> 2; |
| 1019 | + auth->au_verfsize = GSS_VERF_SLACK >> 2; | |
| 1020 | + auth->au_ralign = GSS_VERF_SLACK >> 2; | |
| 1056 | 1021 | auth->au_flags = 0; |
| 1057 | 1022 | auth->au_ops = &authgss_ops; |
| 1058 | 1023 | auth->au_flavor = flavor; |
| @@ -1099,6 +1064,7 @@ err_free: · 40 unmodified lines | ||
| 1099 | 1064 | kfree(gss_auth); |
| 1100 | 1065 | out_dec: |
| 1101 | 1066 | module_put(THIS_MODULE); |
| 1067 | + trace_rpcgss_createauth(flavor, err); | |
| 1102 | 1068 | return ERR_PTR(err); |
| 1103 | 1069 | } |
| 1104 | 1070 | |
| @@ -1135,9 +1101,6 @@ gss_destroy(struct rpc_auth *auth) · 30 unmodified lines | ||
| 1135 | 1101 | struct gss_auth *gss_auth = container_of(auth, |
| 1136 | 1102 | struct gss_auth, rpc_auth); |
| 1137 | 1103 | |
| 1138 | − dprintk("RPC: destroying GSS authenticator %p flavor %d\n", | |
| 1139 | − auth, auth->au_flavor); | |
| 1140 | − | |
| 1141 | 1104 | if (hash_hashed(&gss_auth->hash)) { |
| 1142 | 1105 | spin_lock(&gss_auth_hash_lock); |
| 1143 | 1106 | hash_del(&gss_auth->hash); |
| @@ -1245,7 +1208,7 @@ gss_dup_cred(struct gss_auth *gss_auth, struct gss_cred *gss_cred) · 101 unmodified lines | ||
| 1245 | 1208 | struct gss_cred *new; |
| 1246 | 1209 | |
| 1247 | 1210 | /* Make a copy of the cred so that we can reference count it */ |
| 1248 | − new = kzalloc(sizeof(*gss_cred), GFP_NOIO); | |
| 1211 | + new = kzalloc(sizeof(*gss_cred), GFP_NOFS); | |
| 1249 | 1212 | if (new) { |
| 1250 | 1213 | struct auth_cred acred = { |
| 1251 | 1214 | .cred = gss_cred->gc_base.cr_cred, |
| @@ -1300,8 +1263,6 @@ gss_send_destroy_context(struct rpc_cred *cred) · 48 unmodified lines | ||
| 1300 | 1263 | static void |
| 1301 | 1264 | gss_do_free_ctx(struct gss_cl_ctx *ctx) |
| 1302 | 1265 | { |
| 1303 | − dprintk("RPC: %s\n", __func__); | |
| 1304 | − | |
| 1305 | 1266 | gss_delete_sec_context(&ctx->gc_gss_ctx); |
| 1306 | 1267 | kfree(ctx->gc_wire_ctx.data); |
| 1307 | 1268 | kfree(ctx->gc_acceptor.data); |
| @@ -1324,7 +1285,6 @@ gss_free_ctx(struct gss_cl_ctx *ctx) · 16 unmodified lines | ||
| 1324 | 1285 | static void |
| 1325 | 1286 | gss_free_cred(struct gss_cred *gss_cred) |
| 1326 | 1287 | { |
| 1327 | − dprintk("RPC: %s cred=%p\n", __func__, gss_cred); | |
| 1328 | 1288 | kfree(gss_cred); |
| 1329 | 1289 | } |
| 1330 | 1290 | |
| @@ -1381,10 +1341,6 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t · 50 unmodified lines | ||
| 1381 | 1341 | struct gss_cred *cred = NULL; |
| 1382 | 1342 | int err = -ENOMEM; |
| 1383 | 1343 | |
| 1384 | − dprintk("RPC: %s for uid %d, flavor %d\n", | |
| 1385 | − __func__, from_kuid(&init_user_ns, acred->cred->fsuid), | |
| 1386 | − auth->au_flavor); | |
| 1387 | − | |
| 1388 | 1344 | if (!(cred = kzalloc(sizeof(*cred), gfp))) |
| 1389 | 1345 | goto out_err; |
| 1390 | 1346 | |
| @@ -1400,7 +1356,6 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t · 9 unmodified lines | ||
| 1400 | 1356 | return &cred->gc_base; |
| 1401 | 1357 | |
| 1402 | 1358 | out_err: |
| 1403 | − dprintk("RPC: %s failed with error %d\n", __func__, err); | |
| 1404 | 1359 | return ERR_PTR(err); |
| 1405 | 1360 | } |
| 1406 | 1361 | |
| @@ -1526,69 +1481,84 @@ out: · 119 unmodified lines | ||
| 1526 | 1481 | } |
| 1527 | 1482 | |
| 1528 | 1483 | /* |
| 1529 | −* Marshal credentials. | |
| 1530 | −* Maybe we should keep a cached credential for performance reasons. | |
| 1531 | −*/ | |
| 1532 | −static __be32 * | |
| 1533 | −gss_marshal(struct rpc_task *task, __be32 *p) | |
| 1484 | + * Marshal credentials. | |
| 1485 | + * | |
| 1486 | + * The expensive part is computing the verifier. We can't cache a | |
| 1487 | + * pre-computed version of the verifier because the seqno, which | |
| 1488 | + * is different every time, is included in the MIC. | |
| 1489 | + */ | |
| 1490 | +static int gss_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1534 | 1491 | { |
| 1535 | 1492 | struct rpc_rqst *req = task->tk_rqstp; |
| 1536 | 1493 | struct rpc_cred *cred = req->rq_cred; |
| 1537 | 1494 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 1538 | 1495 | gc_base); |
| 1539 | 1496 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1540 | − __be32 *cred_len; | |
| 1497 | + __be32 *p, *cred_len; | |
| 1541 | 1498 | u32 maj_stat = 0; |
| 1542 | 1499 | struct xdr_netobj mic; |
| 1543 | 1500 | struct kvec iov; |
| 1544 | 1501 | struct xdr_buf verf_buf; |
| 1502 | + int status; | |
| 1545 | 1503 | |
| 1546 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1504 | + /* Credential */ | |
| 1547 | 1505 | |
| 1548 | − *p++ = htonl(RPC_AUTH_GSS); | |
| 1506 | + p = xdr_reserve_space(xdr, 7 * sizeof(*p) + | |
| 1507 | + ctx->gc_wire_ctx.len); | |
| 1508 | + if (!p) | |
| 1509 | + goto marshal_failed; | |
| 1510 | + *p++ = rpc_auth_gss; | |
| 1549 | 1511 | cred_len = p++; |
| 1550 | 1512 | |
| 1551 | 1513 | spin_lock(&ctx->gc_seq_lock); |
| 1552 | 1514 | req->rq_seqno = (ctx->gc_seq < MAXSEQ) ? ctx->gc_seq++ : MAXSEQ; |
| 1553 | 1515 | spin_unlock(&ctx->gc_seq_lock); |
| 1554 | 1516 | if (req->rq_seqno == MAXSEQ) |
| 1555 | − goto out_expired; | |
| 1517 | + goto expired; | |
| 1518 | + trace_rpcgss_seqno(task); | |
| 1556 | 1519 | |
| 1557 | − *p++ = htonl((u32) RPC_GSS_VERSION); | |
| 1558 | − *p++ = htonl((u32) ctx->gc_proc); | |
| 1559 | − *p++ = htonl((u32) req->rq_seqno); | |
| 1560 | − *p++ = htonl((u32) gss_cred->gc_service); | |
| 1520 | + *p++ = cpu_to_be32(RPC_GSS_VERSION); | |
| 1521 | + *p++ = cpu_to_be32(ctx->gc_proc); | |
| 1522 | + *p++ = cpu_to_be32(req->rq_seqno); | |
| 1523 | + *p++ = cpu_to_be32(gss_cred->gc_service); | |
| 1561 | 1524 | p = xdr_encode_netobj(p, &ctx->gc_wire_ctx); |
| 1562 | − *cred_len = htonl((p - (cred_len + 1)) << 2); | |
| 1525 | + *cred_len = cpu_to_be32((p - (cred_len + 1)) << 2); | |
| 1526 | + | |
| 1527 | + /* Verifier */ | |
| 1563 | 1528 | |
| 1564 | 1529 | /* We compute the checksum for the verifier over the xdr-encoded bytes |
| 1565 | 1530 | * starting with the xid and ending at the end of the credential: */ |
| 1566 | − iov.iov_base = xprt_skip_transport_header(req->rq_xprt, | |
| 1567 | − req->rq_snd_buf.head[0].iov_base); | |
| 1531 | + iov.iov_base = req->rq_snd_buf.head[0].iov_base; | |
| 1568 | 1532 | iov.iov_len = (u8 *)p - (u8 *)iov.iov_base; |
| 1569 | 1533 | xdr_buf_from_iov(&iov, &verf_buf); |
| 1570 | 1534 | |
| 1571 | − /* set verifier flavor*/ | |
| 1572 | − *p++ = htonl(RPC_AUTH_GSS); | |
| 1573 | − | |
| 1535 | + p = xdr_reserve_space(xdr, sizeof(*p)); | |
| 1536 | + if (!p) | |
| 1537 | + goto marshal_failed; | |
| 1538 | + *p++ = rpc_auth_gss; | |
| 1574 | 1539 | mic.data = (u8 *)(p + 1); |
| 1575 | 1540 | maj_stat = gss_get_mic(ctx->gc_gss_ctx, &verf_buf, &mic); |
| 1576 | − if (maj_stat == GSS_S_CONTEXT_EXPIRED) { | |
| 1577 | − goto out_expired; | |
| 1578 | − } else if (maj_stat != 0) { | |
| 1579 | − pr_warn("gss_marshal: gss_get_mic FAILED (%d)\n", maj_stat); | |
| 1580 | − task->tk_status = -EIO; | |
| 1581 | − goto out_put_ctx; | |
| 1582 | − } | |
| 1583 | − p = xdr_encode_opaque(p, NULL, mic.len); | |
| 1541 | + if (maj_stat == GSS_S_CONTEXT_EXPIRED) | |
| 1542 | + goto expired; | |
| 1543 | + else if (maj_stat != 0) | |
| 1544 | + goto bad_mic; | |
| 1545 | + if (xdr_stream_encode_opaque_inline(xdr, (void **)&p, mic.len) < 0) | |
| 1546 | + goto marshal_failed; | |
| 1547 | + status = 0; | |
| 1548 | +out: | |
| 1584 | 1549 | gss_put_ctx(ctx); |
| 1585 | − return p; | |
| 1586 | −out_expired: | |
| 1550 | + return status; | |
| 1551 | +expired: | |
| 1587 | 1552 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1588 | − task->tk_status = -EKEYEXPIRED; | |
| 1589 | −out_put_ctx: | |
| 1590 | − gss_put_ctx(ctx); | |
| 1591 | − return NULL; | |
| 1553 | + status = -EKEYEXPIRED; | |
| 1554 | + goto out; | |
| 1555 | +marshal_failed: | |
| 1556 | + status = -EMSGSIZE; | |
| 1557 | + goto out; | |
| 1558 | +bad_mic: | |
| 1559 | + trace_rpcgss_get_mic(task, maj_stat); | |
| 1560 | + status = -EIO; | |
| 1561 | + goto out; | |
| 1592 | 1562 | } |
| 1593 | 1563 | |
| 1594 | 1564 | static int gss_renew_cred(struct rpc_task *task) |
| @@ -1662,116 +1632,105 @@ gss_refresh_null(struct rpc_task *task) · 67 unmodified lines | ||
| 1662 | 1632 | return 0; |
| 1663 | 1633 | } |
| 1664 | 1634 | |
| 1665 | −static __be32 * | |
| 1666 | −gss_validate(struct rpc_task *task, __be32 *p) | |
| 1635 | +static int | |
| 1636 | +gss_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1667 | 1637 | { |
| 1668 | 1638 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 1669 | 1639 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1670 | − __be32 *seq = NULL; | |
| 1640 | + __be32 *p, *seq = NULL; | |
| 1671 | 1641 | struct kvec iov; |
| 1672 | 1642 | struct xdr_buf verf_buf; |
| 1673 | 1643 | struct xdr_netobj mic; |
| 1674 | − u32 flav,len; | |
| 1675 | − u32 maj_stat; | |
| 1676 | − __be32 *ret = ERR_PTR(-EIO); | |
| 1644 | + u32 len, maj_stat; | |
| 1645 | + int status; | |
| 1677 | 1646 | |
| 1678 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1647 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1648 | + if (!p) | |
| 1649 | + goto validate_failed; | |
| 1650 | + if (*p++ != rpc_auth_gss) | |
| 1651 | + goto validate_failed; | |
| 1652 | + len = be32_to_cpup(p); | |
| 1653 | + if (len > RPC_MAX_AUTH_SIZE) | |
| 1654 | + goto validate_failed; | |
| 1655 | + p = xdr_inline_decode(xdr, len); | |
| 1656 | + if (!p) | |
| 1657 | + goto validate_failed; | |
| 1679 | 1658 | |
| 1680 | − flav = ntohl(*p++); | |
| 1681 | − if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE) | |
| 1682 | − goto out_bad; | |
| 1683 | − if (flav != RPC_AUTH_GSS) | |
| 1684 | − goto out_bad; | |
| 1685 | 1659 | seq = kmalloc(4, GFP_NOFS); |
| 1686 | 1660 | if (!seq) |
| 1687 | − goto out_bad; | |
| 1688 | − *seq = htonl(task->tk_rqstp->rq_seqno); | |
| 1661 | + goto validate_failed; | |
| 1662 | + *seq = cpu_to_be32(task->tk_rqstp->rq_seqno); | |
| 1689 | 1663 | iov.iov_base = seq; |
| 1690 | 1664 | iov.iov_len = 4; |
| 1691 | 1665 | xdr_buf_from_iov(&iov, &verf_buf); |
| 1692 | 1666 | mic.data = (u8 *)p; |
| 1693 | 1667 | mic.len = len; |
| 1694 | − | |
| 1695 | − ret = ERR_PTR(-EACCES); | |
| 1696 | 1668 | maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &verf_buf, &mic); |
| 1697 | 1669 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1698 | 1670 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1699 | − if (maj_stat) { | |
| 1700 | − dprintk("RPC: %5u %s: gss_verify_mic returned error 0x%08x\n", | |
| 1701 | − task->tk_pid, __func__, maj_stat); | |
| 1702 | − goto out_bad; | |
| 1703 | − } | |
| 1671 | + if (maj_stat) | |
| 1672 | + goto bad_mic; | |
| 1673 | + | |
| 1704 | 1674 | /* We leave it to unwrap to calculate au_rslack. For now we just |
| 1705 | 1675 | * calculate the length of the verifier: */ |
| 1706 | 1676 | cred->cr_auth->au_verfsize = XDR_QUADLEN(len) + 2; |
| 1677 | + status = 0; | |
| 1678 | +out: | |
| 1707 | 1679 | gss_put_ctx(ctx); |
| 1708 | − dprintk("RPC: %5u %s: gss_verify_mic succeeded.\n", | |
| 1709 | − task->tk_pid, __func__); | |
| 1710 | − kfree(seq); | |
| 1711 | − return p + XDR_QUADLEN(len); | |
| 1712 | −out_bad: | |
| 1713 | − gss_put_ctx(ctx); | |
| 1714 | − dprintk("RPC: %5u %s failed ret %ld.\n", task->tk_pid, __func__, | |
| 1715 | − PTR_ERR(ret)); | |
| 1716 | 1680 | kfree(seq); |
| 1717 | − return ret; | |
| 1718 | −} | |
| 1719 | − | |
| 1720 | −static void gss_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1721 | − __be32 *p, void *obj) | |
| 1722 | −{ | |
| 1723 | − struct xdr_stream xdr; | |
| 1681 | + return status; | |
| 1724 | 1682 | |
| 1725 | − xdr_init_encode(&xdr, &rqstp->rq_snd_buf, p); | |
| 1726 | − encode(rqstp, &xdr, obj); | |
| 1683 | +validate_failed: | |
| 1684 | + status = -EIO; | |
| 1685 | + goto out; | |
| 1686 | +bad_mic: | |
| 1687 | + trace_rpcgss_verify_mic(task, maj_stat); | |
| 1688 | + status = -EACCES; | |
| 1689 | + goto out; | |
| 1727 | 1690 | } |
| 1728 | 1691 | |
| 1729 | −static inline int | |
| 1730 | −gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1731 | − kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1732 | − __be32 *p, void *obj) | |
| 1692 | +static int gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1693 | + struct rpc_task *task, struct xdr_stream *xdr) | |
| 1733 | 1694 | { |
| 1734 | − struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; | |
| 1735 | − struct xdr_buf integ_buf; | |
| 1736 | − __be32 *integ_len = NULL; | |
| 1695 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 1696 | + struct xdr_buf integ_buf, *snd_buf = &rqstp->rq_snd_buf; | |
| 1737 | 1697 | struct xdr_netobj mic; |
| 1738 | − u32 offset; | |
| 1739 | − __be32 *q; | |
| 1740 | − struct kvec *iov; | |
| 1741 | − u32 maj_stat = 0; | |
| 1742 | − int status = -EIO; | |
| 1698 | + __be32 *p, *integ_len; | |
| 1699 | + u32 offset, maj_stat; | |
| 1743 | 1700 | |
| 1701 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 1702 | + if (!p) | |
| 1703 | + goto wrap_failed; | |
| 1744 | 1704 | integ_len = p++; |
| 1745 | − offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1746 | − *p++ = htonl(rqstp->rq_seqno); | |
| 1705 | + *p = cpu_to_be32(rqstp->rq_seqno); | |
| 1747 | 1706 | |
| 1748 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1707 | + if (rpcauth_wrap_req_encode(task, xdr)) | |
| 1708 | + goto wrap_failed; | |
| 1749 | 1709 | |
| 1710 | + offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1750 | 1711 | if (xdr_buf_subsegment(snd_buf, &integ_buf, |
| 1751 | 1712 | offset, snd_buf->len - offset)) |
| 1752 | − return status; | |
| 1753 | − *integ_len = htonl(integ_buf.len); | |
| 1713 | + goto wrap_failed; | |
| 1714 | + *integ_len = cpu_to_be32(integ_buf.len); | |
| 1754 | 1715 | |
| 1755 | − /* guess whether we're in the head or the tail: */ | |
| 1756 | − if (snd_buf->page_len || snd_buf->tail[0].iov_len) | |
| 1757 | − iov = snd_buf->tail; | |
| 1758 | − else | |
| 1759 | − iov = snd_buf->head; | |
| 1760 | − p = iov->iov_base + iov->iov_len; | |
| 1716 | + p = xdr_reserve_space(xdr, 0); | |
| 1717 | + if (!p) | |
| 1718 | + goto wrap_failed; | |
| 1761 | 1719 | mic.data = (u8 *)(p + 1); |
| 1762 | − | |
| 1763 | 1720 | maj_stat = gss_get_mic(ctx->gc_gss_ctx, &integ_buf, &mic); |
| 1764 | − status = -EIO; /* XXX? */ | |
| 1765 | 1721 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1766 | 1722 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1767 | 1723 | else if (maj_stat) |
| 1768 | − return status; | |
| 1769 | − q = xdr_encode_opaque(p, NULL, mic.len); | |
| 1770 | − | |
| 1771 | − offset = (u8 *)q - (u8 *)p; | |
| 1772 | − iov->iov_len += offset; | |
| 1773 | − snd_buf->len += offset; | |
| 1724 | + goto bad_mic; | |
| 1725 | + /* Check that the trailing MIC fit in the buffer, after the fact */ | |
| 1726 | + if (xdr_stream_encode_opaque_inline(xdr, (void **)&p, mic.len) < 0) | |
| 1727 | + goto wrap_failed; | |
| 1774 | 1728 | return 0; |
| 1729 | +wrap_failed: | |
| 1730 | + return -EMSGSIZE; | |
| 1731 | +bad_mic: | |
| 1732 | + trace_rpcgss_get_mic(task, maj_stat); | |
| 1733 | + return -EIO; | |
| 1775 | 1734 | } |
| 1776 | 1735 | |
| 1777 | 1736 | static void |
| @@ -1822,61 +1781,62 @@ out: · 44 unmodified lines | ||
| 1822 | 1781 | return -EAGAIN; |
| 1823 | 1782 | } |
| 1824 | 1783 | |
| 1825 | −static inline int | |
| 1826 | −gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1827 | − kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1828 | − __be32 *p, void *obj) | |
| 1784 | +static int gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1785 | + struct rpc_task *task, struct xdr_stream *xdr) | |
| 1829 | 1786 | { |
| 1787 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 1830 | 1788 | struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; |
| 1831 | − u32 offset; | |
| 1832 | − u32 maj_stat; | |
| 1789 | + u32 pad, offset, maj_stat; | |
| 1833 | 1790 | int status; |
| 1834 | − __be32 *opaque_len; | |
| 1791 | + __be32 *p, *opaque_len; | |
| 1835 | 1792 | struct page **inpages; |
| 1836 | 1793 | int first; |
| 1837 | − int pad; | |
| 1838 | 1794 | struct kvec *iov; |
| 1839 | − char *tmp; | |
| 1840 | 1795 | |
| 1796 | + status = -EIO; | |
| 1797 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 1798 | + if (!p) | |
| 1799 | + goto wrap_failed; | |
| 1841 | 1800 | opaque_len = p++; |
| 1842 | − offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1843 | − *p++ = htonl(rqstp->rq_seqno); | |
| 1801 | + *p = cpu_to_be32(rqstp->rq_seqno); | |
| 1844 | 1802 | |
| 1845 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1803 | + if (rpcauth_wrap_req_encode(task, xdr)) | |
| 1804 | + goto wrap_failed; | |
| 1846 | 1805 | |
| 1847 | 1806 | status = alloc_enc_pages(rqstp); |
| 1848 | − if (status) | |
| 1849 | − return status; | |
| 1807 | + if (unlikely(status)) | |
| 1808 | + goto wrap_failed; | |
| 1850 | 1809 | first = snd_buf->page_base >> PAGE_SHIFT; |
| 1851 | 1810 | inpages = snd_buf->pages + first; |
| 1852 | 1811 | snd_buf->pages = rqstp->rq_enc_pages; |
| 1853 | 1812 | snd_buf->page_base -= first << PAGE_SHIFT; |
| 1854 | 1813 | /* |
| 1855 | − * Give the tail its own page, in case we need extra space in the | |
| 1856 | − * head when wrapping: | |
| 1814 | + * Move the tail into its own page, in case gss_wrap needs | |
| 1815 | + * more space in the head when wrapping. | |
| 1857 | 1816 | * |
| 1858 | − * call_allocate() allocates twice the slack space required | |
| 1859 | − * by the authentication flavor to rq_callsize. | |
| 1860 | − * For GSS, slack is GSS_CRED_SLACK. | |
| 1817 | + * Still... Why can't gss_wrap just slide the tail down? | |
| 1861 | 1818 | */ |
| 1862 | 1819 | if (snd_buf->page_len || snd_buf->tail[0].iov_len) { |
| 1820 | + char *tmp; | |
| 1821 | + | |
| 1863 | 1822 | tmp = page_address(rqstp->rq_enc_pages[rqstp->rq_enc_pages_num - 1]); |
| 1864 | 1823 | memcpy(tmp, snd_buf->tail[0].iov_base, snd_buf->tail[0].iov_len); |
| 1865 | 1824 | snd_buf->tail[0].iov_base = tmp; |
| 1866 | 1825 | } |
| 1826 | + offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1867 | 1827 | maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages); |
| 1868 | 1828 | /* slack space should prevent this ever happening: */ |
| 1869 | − BUG_ON(snd_buf->len > snd_buf->buflen); | |
| 1870 | − status = -EIO; | |
| 1829 | + if (unlikely(snd_buf->len > snd_buf->buflen)) | |
| 1830 | + goto wrap_failed; | |
| 1871 | 1831 | /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was |
| 1872 | 1832 | * done anyway, so it's safe to put the request on the wire: */ |
| 1873 | 1833 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1874 | 1834 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1875 | 1835 | else if (maj_stat) |
| 1876 | − return status; | |
| 1836 | + goto bad_wrap; | |
| 1877 | 1837 | |
| 1878 | − *opaque_len = htonl(snd_buf->len - offset); | |
| 1879 | − /* guess whether we're in the head or the tail: */ | |
| 1838 | + *opaque_len = cpu_to_be32(snd_buf->len - offset); | |
| 1839 | + /* guess whether the pad goes into the head or the tail: */ | |
| 1880 | 1840 | if (snd_buf->page_len || snd_buf->tail[0].iov_len) |
| 1881 | 1841 | iov = snd_buf->tail; |
| 1882 | 1842 | else |
| @@ -1888,118 +1848,154 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, · 5 unmodified lines | ||
| 1888 | 1848 | snd_buf->len += pad; |
| 1889 | 1849 | |
| 1890 | 1850 | return 0; |
| 1851 | +wrap_failed: | |
| 1852 | + return status; | |
| 1853 | +bad_wrap: | |
| 1854 | + trace_rpcgss_wrap(task, maj_stat); | |
| 1855 | + return -EIO; | |
| 1891 | 1856 | } |
| 1892 | 1857 | |
| 1893 | −static int | |
| 1894 | −gss_wrap_req(struct rpc_task *task, | |
| 1895 | − kxdreproc_t encode, void *rqstp, __be32 *p, void *obj) | |
| 1858 | +static int gss_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1896 | 1859 | { |
| 1897 | 1860 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 1898 | 1861 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 1899 | 1862 | gc_base); |
| 1900 | 1863 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1901 | − int status = -EIO; | |
| 1864 | + int status; | |
| 1902 | 1865 | |
| 1903 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1866 | + status = -EIO; | |
| 1904 | 1867 | if (ctx->gc_proc != RPC_GSS_PROC_DATA) { |
| 1905 | 1868 | /* The spec seems a little ambiguous here, but I think that not |
| 1906 | 1869 | * wrapping context destruction requests makes the most sense. |
| 1907 | 1870 | */ |
| 1908 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1909 | − status = 0; | |
| 1871 | + status = rpcauth_wrap_req_encode(task, xdr); | |
| 1910 | 1872 | goto out; |
| 1911 | 1873 | } |
| 1912 | 1874 | switch (gss_cred->gc_service) { |
| 1913 | 1875 | case RPC_GSS_SVC_NONE: |
| 1914 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1915 | − status = 0; | |
| 1876 | + status = rpcauth_wrap_req_encode(task, xdr); | |
| 1916 | 1877 | break; |
| 1917 | 1878 | case RPC_GSS_SVC_INTEGRITY: |
| 1918 | − status = gss_wrap_req_integ(cred, ctx, encode, rqstp, p, obj); | |
| 1879 | + status = gss_wrap_req_integ(cred, ctx, task, xdr); | |
| 1919 | 1880 | break; |
| 1920 | 1881 | case RPC_GSS_SVC_PRIVACY: |
| 1921 | − status = gss_wrap_req_priv(cred, ctx, encode, rqstp, p, obj); | |
| 1882 | + status = gss_wrap_req_priv(cred, ctx, task, xdr); | |
| 1922 | 1883 | break; |
| 1884 | + default: | |
| 1885 | + status = -EIO; | |
| 1923 | 1886 | } |
| 1924 | 1887 | out: |
| 1925 | 1888 | gss_put_ctx(ctx); |
| 1926 | − dprintk("RPC: %5u %s returning %d\n", task->tk_pid, __func__, status); | |
| 1927 | 1889 | return status; |
| 1928 | 1890 | } |
| 1929 | 1891 | |
| 1930 | −static inline int | |
| 1931 | −gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1932 | − struct rpc_rqst *rqstp, __be32 **p) | |
| 1892 | +static int | |
| 1893 | +gss_unwrap_resp_auth(struct rpc_cred *cred) | |
| 1933 | 1894 | { |
| 1934 | − struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1935 | − struct xdr_buf integ_buf; | |
| 1895 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1896 | + | |
| 1897 | + auth->au_rslack = auth->au_verfsize; | |
| 1898 | + auth->au_ralign = auth->au_verfsize; | |
| 1899 | + return 0; | |
| 1900 | +} | |
| 1901 | + | |
| 1902 | +static int | |
| 1903 | +gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, | |
| 1904 | + struct gss_cl_ctx *ctx, struct rpc_rqst *rqstp, | |
| 1905 | + struct xdr_stream *xdr) | |
| 1906 | +{ | |
| 1907 | + struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1908 | + u32 data_offset, mic_offset, integ_len, maj_stat; | |
| 1909 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1936 | 1910 | struct xdr_netobj mic; |
| 1937 | − u32 data_offset, mic_offset; | |
| 1938 | − u32 integ_len; | |
| 1939 | − u32 maj_stat; | |
| 1940 | − int status = -EIO; | |
| 1911 | + __be32 *p; | |
| 1941 | 1912 | |
| 1942 | − integ_len = ntohl(*(*p)++); | |
| 1913 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1914 | + if (unlikely(!p)) | |
| 1915 | + goto unwrap_failed; | |
| 1916 | + integ_len = be32_to_cpup(p++); | |
| 1943 | 1917 | if (integ_len & 3) |
| 1944 | − return status; | |
| 1945 | − data_offset = (u8 *)(*p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1918 | + goto unwrap_failed; | |
| 1919 | + data_offset = (u8 *)(p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1946 | 1920 | mic_offset = integ_len + data_offset; |
| 1947 | 1921 | if (mic_offset > rcv_buf->len) |
| 1948 | − return status; | |
| 1949 | − if (ntohl(*(*p)++) != rqstp->rq_seqno) | |
| 1950 | − return status; | |
| 1951 | − | |
| 1952 | − if (xdr_buf_subsegment(rcv_buf, &integ_buf, data_offset, | |
| 1953 | − mic_offset - data_offset)) | |
| 1954 | − return status; | |
| 1922 | + goto unwrap_failed; | |
| 1923 | + if (be32_to_cpup(p) != rqstp->rq_seqno) | |
| 1924 | + goto bad_seqno; | |
| 1955 | 1925 | |
| 1926 | + if (xdr_buf_subsegment(rcv_buf, &integ_buf, data_offset, integ_len)) | |
| 1927 | + goto unwrap_failed; | |
| 1956 | 1928 | if (xdr_buf_read_netobj(rcv_buf, &mic, mic_offset)) |
| 1957 | − return status; | |
| 1958 | − | |
| 1929 | + goto unwrap_failed; | |
| 1959 | 1930 | maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &integ_buf, &mic); |
| 1960 | 1931 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1961 | 1932 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1962 | 1933 | if (maj_stat != GSS_S_COMPLETE) |
| 1963 | − return status; | |
| 1934 | + goto bad_mic; | |
| 1935 | + | |
| 1936 | + auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len); | |
| 1937 | + auth->au_ralign = auth->au_verfsize + 2; | |
| 1964 | 1938 | return 0; |
| 1939 | +unwrap_failed: | |
| 1940 | + trace_rpcgss_unwrap_failed(task); | |
| 1941 | + return -EIO; | |
| 1942 | +bad_seqno: | |
| 1943 | + trace_rpcgss_bad_seqno(task, rqstp->rq_seqno, be32_to_cpup(p)); | |
| 1944 | + return -EIO; | |
| 1945 | +bad_mic: | |
| 1946 | + trace_rpcgss_verify_mic(task, maj_stat); | |
| 1947 | + return -EIO; | |
| 1965 | 1948 | } |
| 1966 | 1949 | |
| 1967 | −static inline int | |
| 1968 | −gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1969 | − struct rpc_rqst *rqstp, __be32 **p) | |
| 1970 | −{ | |
| 1971 | − struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1972 | − u32 offset; | |
| 1973 | − u32 opaque_len; | |
| 1974 | − u32 maj_stat; | |
| 1975 | − int status = -EIO; | |
| 1976 | − | |
| 1977 | − opaque_len = ntohl(*(*p)++); | |
| 1978 | − offset = (u8 *)(*p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1950 | +static int | |
| 1951 | +gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, | |
| 1952 | + struct gss_cl_ctx *ctx, struct rpc_rqst *rqstp, | |
| 1953 | + struct xdr_stream *xdr) | |
| 1954 | +{ | |
| 1955 | + struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1956 | + struct kvec *head = rqstp->rq_rcv_buf.head; | |
| 1957 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1958 | + unsigned int savedlen = rcv_buf->len; | |
| 1959 | + u32 offset, opaque_len, maj_stat; | |
| 1960 | + __be32 *p; | |
| 1961 | + | |
| 1962 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1963 | + if (unlikely(!p)) | |
| 1964 | + goto unwrap_failed; | |
| 1965 | + opaque_len = be32_to_cpup(p++); | |
| 1966 | + offset = (u8 *)(p) - (u8 *)head->iov_base; | |
| 1979 | 1967 | if (offset + opaque_len > rcv_buf->len) |
| 1980 | − return status; | |
| 1981 | − /* remove padding: */ | |
| 1968 | + goto unwrap_failed; | |
| 1982 | 1969 | rcv_buf->len = offset + opaque_len; |
| 1983 | 1970 | |
| 1984 | 1971 | maj_stat = gss_unwrap(ctx->gc_gss_ctx, offset, rcv_buf); |
| 1985 | 1972 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1986 | 1973 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1987 | 1974 | if (maj_stat != GSS_S_COMPLETE) |
| 1988 | − return status; | |
| 1989 | − if (ntohl(*(*p)++) != rqstp->rq_seqno) | |
| 1990 | − return status; | |
| 1975 | + goto bad_unwrap; | |
| 1976 | + /* gss_unwrap decrypted the sequence number */ | |
| 1977 | + if (be32_to_cpup(p++) != rqstp->rq_seqno) | |
| 1978 | + goto bad_seqno; | |
| 1991 | 1979 | |
| 1992 | − return 0; | |
| 1993 | −} | |
| 1994 | − | |
| 1995 | −static int | |
| 1996 | −gss_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, | |
| 1997 | − __be32 *p, void *obj) | |
| 1998 | −{ | |
| 1999 | − struct xdr_stream xdr; | |
| 1980 | + /* gss_unwrap redacts the opaque blob from the head iovec. | |
| 1981 | + * rcv_buf has changed, thus the stream needs to be reset. | |
| 1982 | + */ | |
| 1983 | + xdr_init_decode(xdr, rcv_buf, p, rqstp); | |
| 2000 | 1984 | |
| 2001 | − xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | |
| 2002 | − return decode(rqstp, &xdr, obj); | |
| 1985 | + auth->au_rslack = auth->au_verfsize + 2 + | |
| 1986 | + XDR_QUADLEN(savedlen - rcv_buf->len); | |
| 1987 | + auth->au_ralign = auth->au_verfsize + 2 + | |
| 1988 | + XDR_QUADLEN(savedlen - rcv_buf->len); | |
| 1989 | + return 0; | |
| 1990 | +unwrap_failed: | |
| 1991 | + trace_rpcgss_unwrap_failed(task); | |
| 1992 | + return -EIO; | |
| 1993 | +bad_seqno: | |
| 1994 | + trace_rpcgss_bad_seqno(task, rqstp->rq_seqno, be32_to_cpup(--p)); | |
| 1995 | + return -EIO; | |
| 1996 | +bad_unwrap: | |
| 1997 | + trace_rpcgss_unwrap(task, maj_stat); | |
| 1998 | + return -EIO; | |
| 2003 | 1999 | } |
| 2004 | 2000 | |
| 2005 | 2001 | static bool |
| @@ -2014,14 +2010,14 @@ gss_xmit_need_reencode(struct rpc_task *task) · 8 unmodified lines | ||
| 2014 | 2010 | struct rpc_rqst *req = task->tk_rqstp; |
| 2015 | 2011 | struct rpc_cred *cred = req->rq_cred; |
| 2016 | 2012 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 2017 | − u32 win, seq_xmit; | |
| 2013 | + u32 win, seq_xmit = 0; | |
| 2018 | 2014 | bool ret = true; |
| 2019 | 2015 | |
| 2020 | 2016 | if (!ctx) |
| 2021 | − return true; | |
| 2017 | + goto out; | |
| 2022 | 2018 | |
| 2023 | 2019 | if (gss_seq_is_newer(req->rq_seqno, READ_ONCE(ctx->gc_seq))) |
| 2024 | − goto out; | |
| 2020 | + goto out_ctx; | |
| 2025 | 2021 | |
| 2026 | 2022 | seq_xmit = READ_ONCE(ctx->gc_seq_xmit); |
| 2027 | 2023 | while (gss_seq_is_newer(req->rq_seqno, seq_xmit)) { |
| @@ -2030,56 +2026,51 @@ gss_xmit_need_reencode(struct rpc_task *task) · 2 unmodified lines | ||
| 2030 | 2026 | seq_xmit = cmpxchg(&ctx->gc_seq_xmit, tmp, req->rq_seqno); |
| 2031 | 2027 | if (seq_xmit == tmp) { |
| 2032 | 2028 | ret = false; |
| 2033 | − goto out; | |
| 2029 | + goto out_ctx; | |
| 2034 | 2030 | } |
| 2035 | 2031 | } |
| 2036 | 2032 | |
| 2037 | 2033 | win = ctx->gc_win; |
| 2038 | 2034 | if (win > 0) |
| 2039 | 2035 | ret = !gss_seq_is_newer(req->rq_seqno, seq_xmit - win); |
| 2040 | −out: | |
| 2036 | + | |
| 2037 | +out_ctx: | |
| 2041 | 2038 | gss_put_ctx(ctx); |
| 2039 | +out: | |
| 2040 | + trace_rpcgss_need_reencode(task, seq_xmit, ret); | |
| 2042 | 2041 | return ret; |
| 2043 | 2042 | } |
| 2044 | 2043 | |
| 2045 | 2044 | static int |
| 2046 | −gss_unwrap_resp(struct rpc_task *task, | |
| 2047 | − kxdrdproc_t decode, void *rqstp, __be32 *p, void *obj) | |
| 2045 | +gss_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2048 | 2046 | { |
| 2049 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 2047 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 2048 | + struct rpc_cred *cred = rqstp->rq_cred; | |
| 2050 | 2049 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 2051 | 2050 | gc_base); |
| 2052 | 2051 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 2053 | − __be32 *savedp = p; | |
| 2054 | − struct kvec *head = ((struct rpc_rqst *)rqstp)->rq_rcv_buf.head; | |
| 2055 | − int savedlen = head->iov_len; | |
| 2056 | − int status = -EIO; | |
| 2052 | + int status = -EIO; | |
| 2057 | 2053 | |
| 2058 | 2054 | if (ctx->gc_proc != RPC_GSS_PROC_DATA) |
| 2059 | 2055 | goto out_decode; |
| 2060 | 2056 | switch (gss_cred->gc_service) { |
| 2061 | 2057 | case RPC_GSS_SVC_NONE: |
| 2058 | + status = gss_unwrap_resp_auth(cred); | |
| 2062 | 2059 | break; |
| 2063 | 2060 | case RPC_GSS_SVC_INTEGRITY: |
| 2064 | − status = gss_unwrap_resp_integ(cred, ctx, rqstp, &p); | |
| 2065 | − if (status) | |
| 2066 | − goto out; | |
| 2061 | + status = gss_unwrap_resp_integ(task, cred, ctx, rqstp, xdr); | |
| 2067 | 2062 | break; |
| 2068 | 2063 | case RPC_GSS_SVC_PRIVACY: |
| 2069 | − status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); | |
| 2070 | − if (status) | |
| 2071 | − goto out; | |
| 2064 | + status = gss_unwrap_resp_priv(task, cred, ctx, rqstp, xdr); | |
| 2072 | 2065 | break; |
| 2073 | 2066 | } |
| 2074 | − /* take into account extra slack for integrity and privacy cases: */ | |
| 2075 | − cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) | |
| 2076 | − + (savedlen - head->iov_len); | |
| 2067 | + if (status) | |
| 2068 | + goto out; | |
| 2069 | + | |
| 2077 | 2070 | out_decode: |
| 2078 | − status = gss_unwrap_req_decode(decode, rqstp, p, obj); | |
| 2071 | + status = rpcauth_unwrap_resp_decode(task, xdr); | |
| 2079 | 2072 | out: |
| 2080 | 2073 | gss_put_ctx(ctx); |
| 2081 | − dprintk("RPC: %5u %s returning %d\n", | |
| 2082 | − task->tk_pid, __func__, status); | |
| 2083 | 2074 | return status; |
| 2084 | 2075 | } |
| 2085 | 2076 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_krb5_mech.c |
| 3 | 4 | * |
| @@ -6,32 +7,6 @@ · 2 unmodified lines | ||
| 6 | 7 | * |
| 7 | 8 | * Andy Adamson <andros@umich.edu> |
| 8 | 9 | * J. Bruce Fields <bfields@umich.edu> |
| 9 | − * | |
| 10 | − * Redistribution and use in source and binary forms, with or without | |
| 11 | − * modification, are permitted provided that the following conditions | |
| 12 | − * are met: | |
| 13 | − * | |
| 14 | − * 1. Redistributions of source code must retain the above copyright | |
| 15 | − * notice, this list of conditions and the following disclaimer. | |
| 16 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 17 | − * notice, this list of conditions and the following disclaimer in the | |
| 18 | − * documentation and/or other materials provided with the distribution. | |
| 19 | − * 3. Neither the name of the University nor the names of its | |
| 20 | − * contributors may be used to endorse or promote products derived | |
| 21 | − * from this software without specific prior written permission. | |
| 22 | − * | |
| 23 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 24 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 25 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 26 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 27 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 28 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 29 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 30 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 31 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 32 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 33 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 34 | − * | |
| 35 | 10 | */ |
| 36 | 11 | |
| 37 | 12 | #include <crypto/hash.h> |
| @@ -53,6 +28,7 @@ · 15 unmodified lines | ||
| 53 | 28 | static struct gss_api_mech gss_kerberos_mech; /* forward declaration */ |
| 54 | 29 | |
| 55 | 30 | static const struct gss_krb5_enctype supported_gss_krb5_enctypes[] = { |
| 31 | +#ifndef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 56 | 32 | /* |
| 57 | 33 | * DES (All DES enctypes are mapped to the same gss functionality) |
| 58 | 34 | */ |
| @@ -74,6 +50,7 @@ static const struct gss_krb5_enctype supported_gss_krb5_enctypes[] = { · 15 unmodified lines | ||
| 74 | 50 | .cksumlength = 8, |
| 75 | 51 | .keyed_cksum = 0, |
| 76 | 52 | }, |
| 53 | +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 77 | 54 | /* |
| 78 | 55 | * RC4-HMAC |
| 79 | 56 | */ |
| @@ -570,14 +570,16 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) · 569 unmodified lines | ||
| 570 | 570 | */ |
| 571 | 571 | movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); |
| 572 | 572 | movelen -= offset + GSS_KRB5_TOK_HDR_LEN + headskip; |
| 573 | − BUG_ON(offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen > | |
| 574 | − buf->head[0].iov_len); | |
| 573 | + if (offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen > | |
| 574 | + buf->head[0].iov_len) | |
| 575 | + return GSS_S_FAILURE; | |
| 575 | 576 | memmove(ptr, ptr + GSS_KRB5_TOK_HDR_LEN + headskip, movelen); |
| 576 | 577 | buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip; |
| 577 | 578 | buf->len -= GSS_KRB5_TOK_HDR_LEN + headskip; |
| 578 | 579 | |
| 579 | 580 | /* Trim off the trailing "extra count" and checksum blob */ |
| 580 | − xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip); | |
| 581 | + buf->len -= ec + GSS_KRB5_TOK_HDR_LEN + tailskip; | |
| 582 | + | |
| 581 | 583 | return GSS_S_COMPLETE; |
| 582 | 584 | } |
| 583 | 585 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_mech_switch.c |
| 3 | 4 | * |
| @@ -5,32 +6,6 @@ · 1 unmodified line | ||
| 5 | 6 | * All rights reserved. |
| 6 | 7 | * |
| 7 | 8 | * J. Bruce Fields <bfields@umich.edu> |
| 8 | − * | |
| 9 | − * Redistribution and use in source and binary forms, with or without | |
| 10 | − * modification, are permitted provided that the following conditions | |
| 11 | − * are met: | |
| 12 | − * | |
| 13 | − * 1. Redistributions of source code must retain the above copyright | |
| 14 | − * notice, this list of conditions and the following disclaimer. | |
| 15 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 16 | − * notice, this list of conditions and the following disclaimer in the | |
| 17 | − * documentation and/or other materials provided with the distribution. | |
| 18 | − * 3. Neither the name of the University nor the names of its | |
| 19 | − * contributors may be used to endorse or promote products derived | |
| 20 | − * from this software without specific prior written permission. | |
| 21 | − * | |
| 22 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 23 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 24 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 25 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 26 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 27 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 28 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 29 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 30 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 31 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 32 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 33 | − * | |
| 34 | 9 | */ |
| 35 | 10 | |
| 36 | 11 | #include <linux/types.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_rpc_upcall.c |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #include <linux/types.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_rpc_upcall.h |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #ifndef _GSS_RPC_UPCALL_H |
| @@ -45,4 +32,5 @@ void gssp_free_upcall_data(struct gssp_upcall_data *data); · 23 unmodified lines | ||
| 45 | 32 | void init_gssp_clnt(struct sunrpc_net *); |
| 46 | 33 | int set_gssp_clnt(struct net *); |
| 47 | 34 | void clear_gssp_clnt(struct sunrpc_net *); |
| 35 | + | |
| 48 | 36 | #endif /* _GSS_RPC_UPCALL_H */ |
| @@ -1,21 +1,8 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | 2 | /* |
| 2 | 3 | * GSS Proxy upcall module |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #include <linux/sunrpc/svcauth.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * GSS Proxy upcall module |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #ifndef _LINUX_GSS_RPC_XDR_H |
| @@ -262,6 +249,4 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, · 240 unmodified lines | ||
| 262 | 249 | #define GSSX_ARG_wrap_size_limit_sz 0 |
| 263 | 250 | #define GSSX_RES_wrap_size_limit_sz 0 |
| 264 | 251 | |
| 265 | − | |
| 266 | − | |
| 267 | 252 | #endif /* _LINUX_GSS_RPC_XDR_H */ |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 1 | 2 | /* |
| 2 | 3 | * Neil Brown <neilb@cse.unsw.edu.au> |
| 3 | 4 | * J. Bruce Fields <bfields@umich.edu> |
| @@ -896,7 +897,7 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g · 892 unmodified lines | ||
| 896 | 897 | if (svc_getnl(&buf->head[0]) != seq) |
| 897 | 898 | goto out; |
| 898 | 899 | /* trim off the mic and padding at the end before returning */ |
| 899 | − xdr_buf_trim(buf, round_up_to_quad(mic.len) + 4); | |
| 900 | + buf->len -= 4 + round_up_to_quad(mic.len); | |
| 900 | 901 | stat = 0; |
| 901 | 902 | out: |
| 902 | 903 | kfree(mic.data); |
| @@ -0,0 +1,11 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +/* | |
| 3 | + * Copyright (c) 2018, 2019 Oracle. All rights reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#include <linux/sunrpc/clnt.h> | |
| 7 | +#include <linux/sunrpc/sched.h> | |
| 8 | +#include <linux/sunrpc/gss_err.h> | |
| 9 | + | |
| 10 | +#define CREATE_TRACE_POINTS | |
| 11 | +#include <trace/events/rpcgss.h> | |
| @@ -59,15 +59,21 @@ nul_match(struct auth_cred *acred, struct rpc_cred *cred, int taskflags) · 58 unmodified lines | ||
| 59 | 59 | /* |
| 60 | 60 | * Marshal credential. |
| 61 | 61 | */ |
| 62 | −static __be32 * | |
| 63 | −nul_marshal(struct rpc_task *task, __be32 *p) | |
| 62 | +static int | |
| 63 | +nul_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 64 | 64 | { |
| 65 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 66 | − *p++ = 0; | |
| 67 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 68 | − *p++ = 0; | |
| 69 | − | |
| 70 | − return p; | |
| 65 | + __be32 *p; | |
| 66 | + | |
| 67 | + p = xdr_reserve_space(xdr, 4 * sizeof(*p)); | |
| 68 | + if (!p) | |
| 69 | + return -EMSGSIZE; | |
| 70 | + /* Credential */ | |
| 71 | + *p++ = rpc_auth_null; | |
| 72 | + *p++ = xdr_zero; | |
| 73 | + /* Verifier */ | |
| 74 | + *p++ = rpc_auth_null; | |
| 75 | + *p = xdr_zero; | |
| 76 | + return 0; | |
| 71 | 77 | } |
| 72 | 78 | |
| 73 | 79 | /* |
| @@ -80,25 +86,19 @@ nul_refresh(struct rpc_task *task) · 6 unmodified lines | ||
| 80 | 86 | return 0; |
| 81 | 87 | } |
| 82 | 88 | |
| 83 | −static __be32 * | |
| 84 | −nul_validate(struct rpc_task *task, __be32 *p) | |
| 89 | +static int | |
| 90 | +nul_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 85 | 91 | { |
| 86 | − rpc_authflavor_t flavor; | |
| 87 | − u32 size; | |
| 88 | − | |
| 89 | − flavor = ntohl(*p++); | |
| 90 | − if (flavor != RPC_AUTH_NULL) { | |
| 91 | − printk("RPC: bad verf flavor: %u\n", flavor); | |
| 92 | − return ERR_PTR(-EIO); | |
| 93 | − } | |
| 94 | − | |
| 95 | − size = ntohl(*p++); | |
| 96 | − if (size != 0) { | |
| 97 | − printk("RPC: bad verf size: %u\n", size); | |
| 98 | − return ERR_PTR(-EIO); | |
| 99 | − } | |
| 100 | − | |
| 101 | − return p; | |
| 92 | + __be32 *p; | |
| 93 | + | |
| 94 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 95 | + if (!p) | |
| 96 | + return -EIO; | |
| 97 | + if (*p++ != rpc_auth_null) | |
| 98 | + return -EIO; | |
| 99 | + if (*p != xdr_zero) | |
| 100 | + return -EIO; | |
| 101 | + return 0; | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | const struct rpc_authops authnull_ops = { |
| @@ -114,6 +114,8 @@ static · 9 unmodified lines | ||
| 114 | 114 | struct rpc_auth null_auth = { |
| 115 | 115 | .au_cslack = NUL_CALLSLACK, |
| 116 | 116 | .au_rslack = NUL_REPLYSLACK, |
| 117 | + .au_verfsize = NUL_REPLYSLACK, | |
| 118 | + .au_ralign = NUL_REPLYSLACK, | |
| 117 | 119 | .au_ops = &authnull_ops, |
| 118 | 120 | .au_flavor = RPC_AUTH_NULL, |
| 119 | 121 | .au_count = REFCOUNT_INIT(1), |
| @@ -125,8 +127,10 @@ const struct rpc_credops null_credops = { · 5 unmodified lines | ||
| 125 | 127 | .crdestroy = nul_destroy_cred, |
| 126 | 128 | .crmatch = nul_match, |
| 127 | 129 | .crmarshal = nul_marshal, |
| 130 | + .crwrap_req = rpcauth_wrap_req_encode, | |
| 128 | 131 | .crrefresh = nul_refresh, |
| 129 | 132 | .crvalidate = nul_validate, |
| 133 | + .crunwrap_resp = rpcauth_unwrap_resp_decode, | |
| 130 | 134 | }; |
| 131 | 135 | |
| 132 | 136 | static |
| @@ -28,8 +28,6 @@ static mempool_t *unix_pool; · 27 unmodified lines | ||
| 28 | 28 | static struct rpc_auth * |
| 29 | 29 | unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) |
| 30 | 30 | { |
| 31 | − dprintk("RPC: creating UNIX authenticator for client %p\n", | |
| 32 | − clnt); | |
| 33 | 31 | refcount_inc(&unix_auth.au_count); |
| 34 | 32 | return &unix_auth; |
| 35 | 33 | } |
| @@ -37,7 +35,6 @@ unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 1 unmodified line | ||
| 37 | 35 | static void |
| 38 | 36 | unx_destroy(struct rpc_auth *auth) |
| 39 | 37 | { |
| 40 | − dprintk("RPC: destroying UNIX authenticator %p\n", auth); | |
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | /* |
| @@ -48,10 +45,6 @@ unx_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) · 4 unmodified lines | ||
| 48 | 45 | { |
| 49 | 46 | struct rpc_cred *ret = mempool_alloc(unix_pool, GFP_NOFS); |
| 50 | 47 | |
| 51 | − dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", | |
| 52 | − from_kuid(&init_user_ns, acred->cred->fsuid), | |
| 53 | − from_kgid(&init_user_ns, acred->cred->fsgid)); | |
| 54 | − | |
| 55 | 48 | rpcauth_init_cred(ret, acred, auth, &unix_credops); |
| 56 | 49 | ret->cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; |
| 57 | 50 | return ret; |
| @@ -61,7 +54,7 @@ static void · 3 unmodified lines | ||
| 61 | 54 | unx_free_cred_callback(struct rcu_head *head) |
| 62 | 55 | { |
| 63 | 56 | struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); |
| 64 | − dprintk("RPC: unx_free_cred %p\n", rpc_cred); | |
| 57 | + | |
| 65 | 58 | put_cred(rpc_cred->cr_cred); |
| 66 | 59 | mempool_free(rpc_cred, unix_pool); |
| 67 | 60 | } |
| @@ -87,7 +80,7 @@ unx_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) · 19 unmodified lines | ||
| 87 | 80 | if (!uid_eq(cred->cr_cred->fsuid, acred->cred->fsuid) || !gid_eq(cred->cr_cred->fsgid, acred->cred->fsgid)) |
| 88 | 81 | return 0; |
| 89 | 82 | |
| 90 | − if (acred->cred && acred->cred->group_info != NULL) | |
| 83 | + if (acred->cred->group_info != NULL) | |
| 91 | 84 | groups = acred->cred->group_info->ngroups; |
| 92 | 85 | if (groups > UNX_NGROUPS) |
| 93 | 86 | groups = UNX_NGROUPS; |
| @@ -106,37 +99,55 @@ unx_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) · 12 unmodified lines | ||
| 106 | 99 | * Marshal credentials. |
| 107 | 100 | * Maybe we should keep a cached credential for performance reasons. |
| 108 | 101 | */ |
| 109 | −static __be32 * | |
| 110 | −unx_marshal(struct rpc_task *task, __be32 *p) | |
| 102 | +static int | |
| 103 | +unx_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 111 | 104 | { |
| 112 | 105 | struct rpc_clnt *clnt = task->tk_client; |
| 113 | 106 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 114 | − __be32 *base, *hold; | |
| 107 | + __be32 *p, *cred_len, *gidarr_len; | |
| 115 | 108 | int i; |
| 116 | 109 | struct group_info *gi = cred->cr_cred->group_info; |
| 117 | 110 | |
| 118 | − *p++ = htonl(RPC_AUTH_UNIX); | |
| 119 | − base = p++; | |
| 120 | − *p++ = htonl(jiffies/HZ); | |
| 121 | − | |
| 122 | − /* | |
| 123 | − * Copy the UTS nodename captured when the client was created. | |
| 124 | − */ | |
| 125 | − p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); | |
| 126 | − | |
| 127 | − *p++ = htonl((u32) from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 128 | − *p++ = htonl((u32) from_kgid(&init_user_ns, cred->cr_cred->fsgid)); | |
| 129 | − hold = p++; | |
| 111 | + /* Credential */ | |
| 112 | + | |
| 113 | + p = xdr_reserve_space(xdr, 3 * sizeof(*p)); | |
| 114 | + if (!p) | |
| 115 | + goto marshal_failed; | |
| 116 | + *p++ = rpc_auth_unix; | |
| 117 | + cred_len = p++; | |
| 118 | + *p++ = xdr_zero; /* stamp */ | |
| 119 | + if (xdr_stream_encode_opaque(xdr, clnt->cl_nodename, | |
| 120 | + clnt->cl_nodelen) < 0) | |
| 121 | + goto marshal_failed; | |
| 122 | + p = xdr_reserve_space(xdr, 3 * sizeof(*p)); | |
| 123 | + if (!p) | |
| 124 | + goto marshal_failed; | |
| 125 | + *p++ = cpu_to_be32(from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 126 | + *p++ = cpu_to_be32(from_kgid(&init_user_ns, cred->cr_cred->fsgid)); | |
| 127 | + | |
| 128 | + gidarr_len = p++; | |
| 130 | 129 | if (gi) |
| 131 | 130 | for (i = 0; i < UNX_NGROUPS && i < gi->ngroups; i++) |
| 132 | − *p++ = htonl((u32) from_kgid(&init_user_ns, gi->gid[i])); | |
| 133 | − *hold = htonl(p - hold - 1); /* gid array length */ | |
| 134 | − *base = htonl((p - base - 1) << 2); /* cred length */ | |
| 131 | + *p++ = cpu_to_be32(from_kgid(&init_user_ns, | |
| 132 | + gi->gid[i])); | |
| 133 | + *gidarr_len = cpu_to_be32(p - gidarr_len - 1); | |
| 134 | + *cred_len = cpu_to_be32((p - cred_len - 1) << 2); | |
| 135 | + p = xdr_reserve_space(xdr, (p - gidarr_len - 1) << 2); | |
| 136 | + if (!p) | |
| 137 | + goto marshal_failed; | |
| 138 | + | |
| 139 | + /* Verifier */ | |
| 140 | + | |
| 141 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 142 | + if (!p) | |
| 143 | + goto marshal_failed; | |
| 144 | + *p++ = rpc_auth_null; | |
| 145 | + *p = xdr_zero; | |
| 135 | 146 | |
| 136 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 137 | − *p++ = htonl(0); | |
| 147 | + return 0; | |
| 138 | 148 | |
| 139 | − return p; | |
| 149 | +marshal_failed: | |
| 150 | + return -EMSGSIZE; | |
| 140 | 151 | } |
| 141 | 152 | |
| 142 | 153 | /* |
| @@ -149,29 +160,35 @@ unx_refresh(struct rpc_task *task) · 6 unmodified lines | ||
| 149 | 160 | return 0; |
| 150 | 161 | } |
| 151 | 162 | |
| 152 | −static __be32 * | |
| 153 | −unx_validate(struct rpc_task *task, __be32 *p) | |
| 163 | +static int | |
| 164 | +unx_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 154 | 165 | { |
| 155 | − rpc_authflavor_t flavor; | |
| 156 | − u32 size; | |
| 157 | − | |
| 158 | − flavor = ntohl(*p++); | |
| 159 | − if (flavor != RPC_AUTH_NULL && | |
| 160 | − flavor != RPC_AUTH_UNIX && | |
| 161 | − flavor != RPC_AUTH_SHORT) { | |
| 162 | − printk("RPC: bad verf flavor: %u\n", flavor); | |
| 163 | − return ERR_PTR(-EIO); | |
| 164 | − } | |
| 165 | − | |
| 166 | − size = ntohl(*p++); | |
| 167 | − if (size > RPC_MAX_AUTH_SIZE) { | |
| 168 | − printk("RPC: giant verf size: %u\n", size); | |
| 169 | − return ERR_PTR(-EIO); | |
| 166 | + struct rpc_auth *auth = task->tk_rqstp->rq_cred->cr_auth; | |
| 167 | + __be32 *p; | |
| 168 | + u32 size; | |
| 169 | + | |
| 170 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 171 | + if (!p) | |
| 172 | + return -EIO; | |
| 173 | + switch (*p++) { | |
| 174 | + case rpc_auth_null: | |
| 175 | + case rpc_auth_unix: | |
| 176 | + case rpc_auth_short: | |
| 177 | + break; | |
| 178 | + default: | |
| 179 | + return -EIO; | |
| 170 | 180 | } |
| 171 | − task->tk_rqstp->rq_cred->cr_auth->au_rslack = (size >> 2) + 2; | |
| 172 | − p += (size >> 2); | |
| 173 | − | |
| 174 | − return p; | |
| 181 | + size = be32_to_cpup(p); | |
| 182 | + if (size > RPC_MAX_AUTH_SIZE) | |
| 183 | + return -EIO; | |
| 184 | + p = xdr_inline_decode(xdr, size); | |
| 185 | + if (!p) | |
| 186 | + return -EIO; | |
| 187 | + | |
| 188 | + auth->au_verfsize = XDR_QUADLEN(size) + 2; | |
| 189 | + auth->au_rslack = XDR_QUADLEN(size) + 2; | |
| 190 | + auth->au_ralign = XDR_QUADLEN(size) + 2; | |
| 191 | + return 0; | |
| 175 | 192 | } |
| 176 | 193 | |
| 177 | 194 | int __init rpc_init_authunix(void) |
| @@ -198,6 +215,7 @@ static · 20 unmodified lines | ||
| 198 | 215 | struct rpc_auth unix_auth = { |
| 199 | 216 | .au_cslack = UNX_CALLSLACK, |
| 200 | 217 | .au_rslack = NUL_REPLYSLACK, |
| 218 | + .au_verfsize = NUL_REPLYSLACK, | |
| 201 | 219 | .au_ops = &authunix_ops, |
| 202 | 220 | .au_flavor = RPC_AUTH_UNIX, |
| 203 | 221 | .au_count = REFCOUNT_INIT(1), |
| @@ -209,6 +227,8 @@ const struct rpc_credops unix_credops = { · 5 unmodified lines | ||
| 209 | 227 | .crdestroy = unx_destroy_cred, |
| 210 | 228 | .crmatch = unx_match, |
| 211 | 229 | .crmarshal = unx_marshal, |
| 230 | + .crwrap_req = rpcauth_wrap_req_encode, | |
| 212 | 231 | .crrefresh = unx_refresh, |
| 213 | 232 | .crvalidate = unx_validate, |
| 233 | + .crunwrap_resp = rpcauth_unwrap_resp_decode, | |
| 214 | 234 | }; |
| @@ -235,7 +235,8 @@ out: · 234 unmodified lines | ||
| 235 | 235 | list_empty(&xprt->bc_pa_list) ? "true" : "false"); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | −static struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt, __be32 xid) | |
| 238 | +static struct rpc_rqst *xprt_get_bc_request(struct rpc_xprt *xprt, __be32 xid, | |
| 239 | + struct rpc_rqst *new) | |
| 239 | 240 | { |
| 240 | 241 | struct rpc_rqst *req = NULL; |
| 241 | 242 | |
| @@ -243,22 +244,20 @@ static struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt, __be32 xid) · 1 unmodified line | ||
| 243 | 244 | if (atomic_read(&xprt->bc_free_slots) <= 0) |
| 244 | 245 | goto not_found; |
| 245 | 246 | if (list_empty(&xprt->bc_pa_list)) { |
| 246 | − req = xprt_alloc_bc_req(xprt, GFP_ATOMIC); | |
| 247 | − if (!req) | |
| 247 | + if (!new) | |
| 248 | 248 | goto not_found; |
| 249 | − list_add_tail(&req->rq_bc_pa_list, &xprt->bc_pa_list); | |
| 249 | + list_add_tail(&new->rq_bc_pa_list, &xprt->bc_pa_list); | |
| 250 | 250 | xprt->bc_alloc_count++; |
| 251 | 251 | } |
| 252 | 252 | req = list_first_entry(&xprt->bc_pa_list, struct rpc_rqst, |
| 253 | 253 | rq_bc_pa_list); |
| 254 | 254 | req->rq_reply_bytes_recvd = 0; |
| 255 | − req->rq_bytes_sent = 0; | |
| 256 | 255 | memcpy(&req->rq_private_buf, &req->rq_rcv_buf, |
| 257 | 256 | sizeof(req->rq_private_buf)); |
| 258 | 257 | req->rq_xid = xid; |
| 259 | 258 | req->rq_connect_cookie = xprt->connect_cookie; |
| 260 | −not_found: | |
| 261 | 259 | dprintk("RPC: backchannel req=%p\n", req); |
| 260 | +not_found: | |
| 262 | 261 | return req; |
| 263 | 262 | } |
| 264 | 263 | |
| @@ -321,18 +320,27 @@ void xprt_free_bc_rqst(struct rpc_rqst *req) · 56 unmodified lines | ||
| 321 | 320 | */ |
| 322 | 321 | struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid) |
| 323 | 322 | { |
| 324 | − struct rpc_rqst *req; | |
| 325 | − | |
| 326 | − spin_lock(&xprt->bc_pa_lock); | |
| 327 | − list_for_each_entry(req, &xprt->bc_pa_list, rq_bc_pa_list) { | |
| 328 | − if (req->rq_connect_cookie != xprt->connect_cookie) | |
| 329 | − continue; | |
| 330 | − if (req->rq_xid == xid) | |
| 331 | − goto found; | |
| 332 | − } | |
| 333 | − req = xprt_alloc_bc_request(xprt, xid); | |
| 323 | + struct rpc_rqst *req, *new = NULL; | |
| 324 | + | |
| 325 | + do { | |
| 326 | + spin_lock(&xprt->bc_pa_lock); | |
| 327 | + list_for_each_entry(req, &xprt->bc_pa_list, rq_bc_pa_list) { | |
| 328 | + if (req->rq_connect_cookie != xprt->connect_cookie) | |
| 329 | + continue; | |
| 330 | + if (req->rq_xid == xid) | |
| 331 | + goto found; | |
| 332 | + } | |
| 333 | + req = xprt_get_bc_request(xprt, xid, new); | |
| 334 | 334 | found: |
| 335 | − spin_unlock(&xprt->bc_pa_lock); | |
| 335 | + spin_unlock(&xprt->bc_pa_lock); | |
| 336 | + if (new) { | |
| 337 | + if (req != new) | |
| 338 | + xprt_free_bc_rqst(new); | |
| 339 | + break; | |
| 340 | + } else if (req) | |
| 341 | + break; | |
| 342 | + new = xprt_alloc_bc_req(xprt, GFP_KERNEL); | |
| 343 | + } while (new); | |
| 336 | 344 | return req; |
| 337 | 345 | } |
| 338 | 346 | |
| @@ -66,20 +66,19 @@ static void call_decode(struct rpc_task *task); · 65 unmodified lines | ||
| 66 | 66 | static void call_bind(struct rpc_task *task); |
| 67 | 67 | static void call_bind_status(struct rpc_task *task); |
| 68 | 68 | static void call_transmit(struct rpc_task *task); |
| 69 | −#if defined(CONFIG_SUNRPC_BACKCHANNEL) | |
| 70 | −static void call_bc_transmit(struct rpc_task *task); | |
| 71 | −#endif /* CONFIG_SUNRPC_BACKCHANNEL */ | |
| 72 | 69 | static void call_status(struct rpc_task *task); |
| 73 | 70 | static void call_transmit_status(struct rpc_task *task); |
| 74 | 71 | static void call_refresh(struct rpc_task *task); |
| 75 | 72 | static void call_refreshresult(struct rpc_task *task); |
| 76 | −static void call_timeout(struct rpc_task *task); | |
| 77 | 73 | static void call_connect(struct rpc_task *task); |
| 78 | 74 | static void call_connect_status(struct rpc_task *task); |
| 79 | 75 | |
| 80 | −static __be32 *rpc_encode_header(struct rpc_task *task); | |
| 81 | −static __be32 *rpc_verify_header(struct rpc_task *task); | |
| 76 | +static int rpc_encode_header(struct rpc_task *task, | |
| 77 | + struct xdr_stream *xdr); | |
| 78 | +static int rpc_decode_header(struct rpc_task *task, | |
| 79 | + struct xdr_stream *xdr); | |
| 82 | 80 | static int rpc_ping(struct rpc_clnt *clnt); |
| 81 | +static void rpc_check_timeout(struct rpc_task *task); | |
| 83 | 82 | |
| 84 | 83 | static void rpc_register_client(struct rpc_clnt *clnt) |
| 85 | 84 | { |
| @@ -834,9 +833,6 @@ void rpc_killall_tasks(struct rpc_clnt *clnt) · 748 unmodified lines | ||
| 834 | 833 | if (!(rovr->tk_flags & RPC_TASK_KILLED)) { |
| 835 | 834 | rovr->tk_flags |= RPC_TASK_KILLED; |
| 836 | 835 | rpc_exit(rovr, -EIO); |
| 837 | − if (RPC_IS_QUEUED(rovr)) | |
| 838 | − rpc_wake_up_queued_task(rovr->tk_waitqueue, | |
| 839 | − rovr); | |
| 840 | 836 | } |
| 841 | 837 | } |
| 842 | 838 | spin_unlock(&clnt->cl_lock); |
| @@ -1131,6 +1127,8 @@ rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags, · 288 unmodified lines | ||
| 1131 | 1127 | EXPORT_SYMBOL_GPL(rpc_call_async); |
| 1132 | 1128 | |
| 1133 | 1129 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) |
| 1130 | +static void call_bc_encode(struct rpc_task *task); | |
| 1131 | + | |
| 1134 | 1132 | /** |
| 1135 | 1133 | * rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run |
| 1136 | 1134 | * rpc_execute against it |
| @@ -1152,7 +1150,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req) · 15 unmodified lines | ||
| 1152 | 1150 | task = rpc_new_task(&task_setup_data); |
| 1153 | 1151 | xprt_init_bc_request(req, task); |
| 1154 | 1152 | |
| 1155 | − task->tk_action = call_bc_transmit; | |
| 1153 | + task->tk_action = call_bc_encode; | |
| 1156 | 1154 | atomic_inc(&task->tk_count); |
| 1157 | 1155 | WARN_ON_ONCE(atomic_read(&task->tk_count) != 2); |
| 1158 | 1156 | rpc_execute(task); |
| @@ -1162,6 +1160,29 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req) · 3 unmodified lines | ||
| 1162 | 1160 | } |
| 1163 | 1161 | #endif /* CONFIG_SUNRPC_BACKCHANNEL */ |
| 1164 | 1162 | |
| 1163 | +/** | |
| 1164 | + * rpc_prepare_reply_pages - Prepare to receive a reply data payload into pages | |
| 1165 | + * @req: RPC request to prepare | |
| 1166 | + * @pages: vector of struct page pointers | |
| 1167 | + * @base: offset in first page where receive should start, in bytes | |
| 1168 | + * @len: expected size of the upper layer data payload, in bytes | |
| 1169 | + * @hdrsize: expected size of upper layer reply header, in XDR words | |
| 1170 | + * | |
| 1171 | + */ | |
| 1172 | +void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, | |
| 1173 | + unsigned int base, unsigned int len, | |
| 1174 | + unsigned int hdrsize) | |
| 1175 | +{ | |
| 1176 | + /* Subtract one to force an extra word of buffer space for the | |
| 1177 | + * payload's XDR pad to fall into the rcv_buf's tail iovec. | |
| 1178 | + */ | |
| 1179 | + hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1; | |
| 1180 | + | |
| 1181 | + xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len); | |
| 1182 | + trace_rpc_reply_pages(req); | |
| 1183 | +} | |
| 1184 | +EXPORT_SYMBOL_GPL(rpc_prepare_reply_pages); | |
| 1185 | + | |
| 1165 | 1186 | void |
| 1166 | 1187 | rpc_call_start(struct rpc_task *task) |
| 1167 | 1188 | { |
| @@ -1519,6 +1540,7 @@ call_start(struct rpc_task *task) · 351 unmodified lines | ||
| 1519 | 1540 | clnt->cl_stats->rpccnt++; |
| 1520 | 1541 | task->tk_action = call_reserve; |
| 1521 | 1542 | rpc_task_set_transport(task, clnt); |
| 1543 | + call_reserve(task); | |
| 1522 | 1544 | } |
| 1523 | 1545 | |
| 1524 | 1546 | /* |
| @@ -1532,6 +1554,9 @@ call_reserve(struct rpc_task *task) · 7 unmodified lines | ||
| 1532 | 1554 | task->tk_status = 0; |
| 1533 | 1555 | task->tk_action = call_reserveresult; |
| 1534 | 1556 | xprt_reserve(task); |
| 1557 | + if (rpc_task_need_resched(task)) | |
| 1558 | + return; | |
| 1559 | + call_reserveresult(task); | |
| 1535 | 1560 | } |
| 1536 | 1561 | |
| 1537 | 1562 | static void call_retry_reserve(struct rpc_task *task); |
| @@ -1554,6 +1579,7 @@ call_reserveresult(struct rpc_task *task) · 16 unmodified lines | ||
| 1554 | 1579 | if (status >= 0) { |
| 1555 | 1580 | if (task->tk_rqstp) { |
| 1556 | 1581 | task->tk_action = call_refresh; |
| 1582 | + call_refresh(task); | |
| 1557 | 1583 | return; |
| 1558 | 1584 | } |
| 1559 | 1585 | |
| @@ -1579,6 +1605,7 @@ call_reserveresult(struct rpc_task *task) · 19 unmodified lines | ||
| 1579 | 1605 | /* fall through */ |
| 1580 | 1606 | case -EAGAIN: /* woken up; retry */ |
| 1581 | 1607 | task->tk_action = call_retry_reserve; |
| 1608 | + call_retry_reserve(task); | |
| 1582 | 1609 | return; |
| 1583 | 1610 | case -EIO: /* probably a shutdown */ |
| 1584 | 1611 | break; |
| @@ -1601,6 +1628,9 @@ call_retry_reserve(struct rpc_task *task) · 16 unmodified lines | ||
| 1601 | 1628 | task->tk_status = 0; |
| 1602 | 1629 | task->tk_action = call_reserveresult; |
| 1603 | 1630 | xprt_retry_reserve(task); |
| 1631 | + if (rpc_task_need_resched(task)) | |
| 1632 | + return; | |
| 1633 | + call_reserveresult(task); | |
| 1604 | 1634 | } |
| 1605 | 1635 | |
| 1606 | 1636 | /* |
| @@ -1615,6 +1645,9 @@ call_refresh(struct rpc_task *task) · 8 unmodified lines | ||
| 1615 | 1645 | task->tk_status = 0; |
| 1616 | 1646 | task->tk_client->cl_stats->rpcauthrefresh++; |
| 1617 | 1647 | rpcauth_refreshcred(task); |
| 1648 | + if (rpc_task_need_resched(task)) | |
| 1649 | + return; | |
| 1650 | + call_refreshresult(task); | |
| 1618 | 1651 | } |
| 1619 | 1652 | |
| 1620 | 1653 | /* |
| @@ -1633,6 +1666,7 @@ call_refreshresult(struct rpc_task *task) · 12 unmodified lines | ||
| 1633 | 1666 | case 0: |
| 1634 | 1667 | if (rpcauth_uptodatecred(task)) { |
| 1635 | 1668 | task->tk_action = call_allocate; |
| 1669 | + call_allocate(task); | |
| 1636 | 1670 | return; |
| 1637 | 1671 | } |
| 1638 | 1672 | /* Use rate-limiting and a max number of retries if refresh |
| @@ -1651,6 +1685,7 @@ call_refreshresult(struct rpc_task *task) · 12 unmodified lines | ||
| 1651 | 1685 | task->tk_cred_retry--; |
| 1652 | 1686 | dprintk("RPC: %5u %s: retry refresh creds\n", |
| 1653 | 1687 | task->tk_pid, __func__); |
| 1688 | + call_refresh(task); | |
| 1654 | 1689 | return; |
| 1655 | 1690 | } |
| 1656 | 1691 | dprintk("RPC: %5u %s: refresh creds failed with error %d\n", |
| @@ -1665,7 +1700,7 @@ call_refreshresult(struct rpc_task *task) · 8 unmodified lines | ||
| 1665 | 1700 | static void |
| 1666 | 1701 | call_allocate(struct rpc_task *task) |
| 1667 | 1702 | { |
| 1668 | − unsigned int slack = task->tk_rqstp->rq_cred->cr_auth->au_cslack; | |
| 1703 | + const struct rpc_auth *auth = task->tk_rqstp->rq_cred->cr_auth; | |
| 1669 | 1704 | struct rpc_rqst *req = task->tk_rqstp; |
| 1670 | 1705 | struct rpc_xprt *xprt = req->rq_xprt; |
| 1671 | 1706 | const struct rpc_procinfo *proc = task->tk_msg.rpc_proc; |
| @@ -1676,8 +1711,10 @@ call_allocate(struct rpc_task *task) · 4 unmodified lines | ||
| 1676 | 1711 | task->tk_status = 0; |
| 1677 | 1712 | task->tk_action = call_encode; |
| 1678 | 1713 | |
| 1679 | − if (req->rq_buffer) | |
| 1714 | + if (req->rq_buffer) { | |
| 1715 | + call_encode(task); | |
| 1680 | 1716 | return; |
| 1717 | + } | |
| 1681 | 1718 | |
| 1682 | 1719 | if (proc->p_proc != 0) { |
| 1683 | 1720 | BUG_ON(proc->p_arglen == 0); |
| @@ -1690,15 +1727,20 @@ call_allocate(struct rpc_task *task) · 6 unmodified lines | ||
| 1690 | 1727 | * and reply headers, and convert both values |
| 1691 | 1728 | * to byte sizes. |
| 1692 | 1729 | */ |
| 1693 | − req->rq_callsize = RPC_CALLHDRSIZE + (slack << 1) + proc->p_arglen; | |
| 1730 | + req->rq_callsize = RPC_CALLHDRSIZE + (auth->au_cslack << 1) + | |
| 1731 | + proc->p_arglen; | |
| 1694 | 1732 | req->rq_callsize <<= 2; |
| 1695 | − req->rq_rcvsize = RPC_REPHDRSIZE + slack + proc->p_replen; | |
| 1733 | + req->rq_rcvsize = RPC_REPHDRSIZE + auth->au_rslack + proc->p_replen; | |
| 1696 | 1734 | req->rq_rcvsize <<= 2; |
| 1697 | 1735 | |
| 1698 | 1736 | status = xprt->ops->buf_alloc(task); |
| 1699 | 1737 | xprt_inject_disconnect(xprt); |
| 1700 | − if (status == 0) | |
| 1738 | + if (status == 0) { | |
| 1739 | + if (rpc_task_need_resched(task)) | |
| 1740 | + return; | |
| 1741 | + call_encode(task); | |
| 1701 | 1742 | return; |
| 1743 | + } | |
| 1702 | 1744 | if (status != -ENOMEM) { |
| 1703 | 1745 | rpc_exit(task, status); |
| 1704 | 1746 | return; |
| @@ -1728,10 +1770,7 @@ static void · 23 unmodified lines | ||
| 1728 | 1770 | rpc_xdr_encode(struct rpc_task *task) |
| 1729 | 1771 | { |
| 1730 | 1772 | struct rpc_rqst *req = task->tk_rqstp; |
| 1731 | − kxdreproc_t encode; | |
| 1732 | − __be32 *p; | |
| 1733 | − | |
| 1734 | − dprint_status(task); | |
| 1773 | + struct xdr_stream xdr; | |
| 1735 | 1774 | |
| 1736 | 1775 | xdr_buf_init(&req->rq_snd_buf, |
| 1737 | 1776 | req->rq_buffer, |
| @@ -1740,18 +1779,13 @@ rpc_xdr_encode(struct rpc_task *task) · 2 unmodified lines | ||
| 1740 | 1779 | req->rq_rbuffer, |
| 1741 | 1780 | req->rq_rcvsize); |
| 1742 | 1781 | |
| 1743 | − p = rpc_encode_header(task); | |
| 1744 | − if (p == NULL) | |
| 1745 | − return; | |
| 1746 | − | |
| 1747 | − encode = task->tk_msg.rpc_proc->p_encode; | |
| 1748 | − if (encode == NULL) | |
| 1782 | + req->rq_snd_buf.head[0].iov_len = 0; | |
| 1783 | + xdr_init_encode(&xdr, &req->rq_snd_buf, | |
| 1784 | + req->rq_snd_buf.head[0].iov_base, req); | |
| 1785 | + if (rpc_encode_header(task, &xdr)) | |
| 1749 | 1786 | return; |
| 1750 | 1787 | |
| 1751 | − task->tk_status = rpcauth_wrap_req(task, encode, req, p, | |
| 1752 | − task->tk_msg.rpc_argp); | |
| 1753 | − if (task->tk_status == 0) | |
| 1754 | − xprt_request_prepare(req); | |
| 1788 | + task->tk_status = rpcauth_wrap_req(task, &xdr); | |
| 1755 | 1789 | } |
| 1756 | 1790 | |
| 1757 | 1791 | /* |
| @@ -1762,6 +1796,7 @@ call_encode(struct rpc_task *task) · 4 unmodified lines | ||
| 1762 | 1796 | { |
| 1763 | 1797 | if (!rpc_task_need_encode(task)) |
| 1764 | 1798 | goto out; |
| 1799 | + dprint_status(task); | |
| 1765 | 1800 | /* Encode here so that rpcsec_gss can use correct sequence number. */ |
| 1766 | 1801 | rpc_xdr_encode(task); |
| 1767 | 1802 | /* Did the encode result in an error condition? */ |
| @@ -1779,6 +1814,8 @@ call_encode(struct rpc_task *task) · 11 unmodified lines | ||
| 1779 | 1814 | rpc_exit(task, task->tk_status); |
| 1780 | 1815 | } |
| 1781 | 1816 | return; |
| 1817 | + } else { | |
| 1818 | + xprt_request_prepare(task->tk_rqstp); | |
| 1782 | 1819 | } |
| 1783 | 1820 | |
| 1784 | 1821 | /* Add task to reply queue before transmission to avoid races */ |
| @@ -1787,6 +1824,25 @@ call_encode(struct rpc_task *task) · 2 unmodified lines | ||
| 1787 | 1824 | xprt_request_enqueue_transmit(task); |
| 1788 | 1825 | out: |
| 1789 | 1826 | task->tk_action = call_bind; |
| 1827 | + call_bind(task); | |
| 1828 | +} | |
| 1829 | + | |
| 1830 | +/* | |
| 1831 | + * Helpers to check if the task was already transmitted, and | |
| 1832 | + * to take action when that is the case. | |
| 1833 | + */ | |
| 1834 | +static bool | |
| 1835 | +rpc_task_transmitted(struct rpc_task *task) | |
| 1836 | +{ | |
| 1837 | + return !test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate); | |
| 1838 | +} | |
| 1839 | + | |
| 1840 | +static void | |
| 1841 | +rpc_task_handle_transmitted(struct rpc_task *task) | |
| 1842 | +{ | |
| 1843 | + xprt_end_transmit(task); | |
| 1844 | + task->tk_action = call_transmit_status; | |
| 1845 | + call_transmit_status(task); | |
| 1790 | 1846 | } |
| 1791 | 1847 | |
| 1792 | 1848 | /* |
| @@ -1797,14 +1853,25 @@ call_bind(struct rpc_task *task) · 4 unmodified lines | ||
| 1797 | 1853 | { |
| 1798 | 1854 | struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; |
| 1799 | 1855 | |
| 1800 | − dprint_status(task); | |
| 1856 | + if (rpc_task_transmitted(task)) { | |
| 1857 | + rpc_task_handle_transmitted(task); | |
| 1858 | + return; | |
| 1859 | + } | |
| 1801 | 1860 | |
| 1802 | − task->tk_action = call_connect; | |
| 1803 | − if (!xprt_bound(xprt)) { | |
| 1804 | − task->tk_action = call_bind_status; | |
| 1805 | − task->tk_timeout = xprt->bind_timeout; | |
| 1806 | − xprt->ops->rpcbind(task); | |
| 1861 | + if (xprt_bound(xprt)) { | |
| 1862 | + task->tk_action = call_connect; | |
| 1863 | + call_connect(task); | |
| 1864 | + return; | |
| 1807 | 1865 | } |
| 1866 | + | |
| 1867 | + dprint_status(task); | |
| 1868 | + | |
| 1869 | + task->tk_action = call_bind_status; | |
| 1870 | + if (!xprt_prepare_transmit(task)) | |
| 1871 | + return; | |
| 1872 | + | |
| 1873 | + task->tk_timeout = xprt->bind_timeout; | |
| 1874 | + xprt->ops->rpcbind(task); | |
| 1808 | 1875 | } |
| 1809 | 1876 | |
| 1810 | 1877 | /* |
| @@ -1815,10 +1882,16 @@ call_bind_status(struct rpc_task *task) · 4 unmodified lines | ||
| 1815 | 1882 | { |
| 1816 | 1883 | int status = -EIO; |
| 1817 | 1884 | |
| 1885 | + if (rpc_task_transmitted(task)) { | |
| 1886 | + rpc_task_handle_transmitted(task); | |
| 1887 | + return; | |
| 1888 | + } | |
| 1889 | + | |
| 1818 | 1890 | if (task->tk_status >= 0) { |
| 1819 | 1891 | dprint_status(task); |
| 1820 | 1892 | task->tk_status = 0; |
| 1821 | 1893 | task->tk_action = call_connect; |
| 1894 | + call_connect(task); | |
| 1822 | 1895 | return; |
| 1823 | 1896 | } |
| 1824 | 1897 | |
| @@ -1841,6 +1914,8 @@ call_bind_status(struct rpc_task *task) · 16 unmodified lines | ||
| 1841 | 1914 | task->tk_rebind_retry--; |
| 1842 | 1915 | rpc_delay(task, 3*HZ); |
| 1843 | 1916 | goto retry_timeout; |
| 1917 | + case -EAGAIN: | |
| 1918 | + goto retry_timeout; | |
| 1844 | 1919 | case -ETIMEDOUT: |
| 1845 | 1920 | dprintk("RPC: %5u rpcbind request timed out\n", |
| 1846 | 1921 | task->tk_pid); |
| @@ -1882,7 +1957,8 @@ call_bind_status(struct rpc_task *task) · 35 unmodified lines | ||
| 1882 | 1957 | |
| 1883 | 1958 | retry_timeout: |
| 1884 | 1959 | task->tk_status = 0; |
| 1885 | − task->tk_action = call_timeout; | |
| 1960 | + task->tk_action = call_bind; | |
| 1961 | + rpc_check_timeout(task); | |
| 1886 | 1962 | } |
| 1887 | 1963 | |
| 1888 | 1964 | /* |
| @@ -1893,21 +1969,31 @@ call_connect(struct rpc_task *task) · 4 unmodified lines | ||
| 1893 | 1969 | { |
| 1894 | 1970 | struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; |
| 1895 | 1971 | |
| 1972 | + if (rpc_task_transmitted(task)) { | |
| 1973 | + rpc_task_handle_transmitted(task); | |
| 1974 | + return; | |
| 1975 | + } | |
| 1976 | + | |
| 1977 | + if (xprt_connected(xprt)) { | |
| 1978 | + task->tk_action = call_transmit; | |
| 1979 | + call_transmit(task); | |
| 1980 | + return; | |
| 1981 | + } | |
| 1982 | + | |
| 1896 | 1983 | dprintk("RPC: %5u call_connect xprt %p %s connected\n", |
| 1897 | 1984 | task->tk_pid, xprt, |
| 1898 | 1985 | (xprt_connected(xprt) ? "is" : "is not")); |
| 1899 | 1986 | |
| 1900 | − task->tk_action = call_transmit; | |
| 1901 | − if (!xprt_connected(xprt)) { | |
| 1902 | − task->tk_action = call_connect_status; | |
| 1903 | − if (task->tk_status < 0) | |
| 1904 | − return; | |
| 1905 | − if (task->tk_flags & RPC_TASK_NOCONNECT) { | |
| 1906 | − rpc_exit(task, -ENOTCONN); | |
| 1907 | − return; | |
| 1908 | − } | |
| 1909 | − xprt_connect(task); | |
| 1987 | + task->tk_action = call_connect_status; | |
| 1988 | + if (task->tk_status < 0) | |
| 1989 | + return; | |
| 1990 | + if (task->tk_flags & RPC_TASK_NOCONNECT) { | |
| 1991 | + rpc_exit(task, -ENOTCONN); | |
| 1992 | + return; | |
| 1910 | 1993 | } |
| 1994 | + if (!xprt_prepare_transmit(task)) | |
| 1995 | + return; | |
| 1996 | + xprt_connect(task); | |
| 1911 | 1997 | } |
| 1912 | 1998 | |
| 1913 | 1999 | /* |
| @@ -1919,10 +2005,8 @@ call_connect_status(struct rpc_task *task) · 5 unmodified lines | ||
| 1919 | 2005 | struct rpc_clnt *clnt = task->tk_client; |
| 1920 | 2006 | int status = task->tk_status; |
| 1921 | 2007 | |
| 1922 | − /* Check if the task was already transmitted */ | |
| 1923 | − if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) { | |
| 1924 | − xprt_end_transmit(task); | |
| 1925 | − task->tk_action = call_transmit_status; | |
| 2008 | + if (rpc_task_transmitted(task)) { | |
| 2009 | + rpc_task_handle_transmitted(task); | |
| 1926 | 2010 | return; |
| 1927 | 2011 | } |
| 1928 | 2012 | |
| @@ -1937,8 +2021,7 @@ call_connect_status(struct rpc_task *task) · 8 unmodified lines | ||
| 1937 | 2021 | break; |
| 1938 | 2022 | if (clnt->cl_autobind) { |
| 1939 | 2023 | rpc_force_rebind(clnt); |
| 1940 | − task->tk_action = call_bind; | |
| 1941 | − return; | |
| 2024 | + goto out_retry; | |
| 1942 | 2025 | } |
| 1943 | 2026 | /* fall through */ |
| 1944 | 2027 | case -ECONNRESET: |
| @@ -1958,16 +2041,20 @@ call_connect_status(struct rpc_task *task) · 13 unmodified lines | ||
| 1958 | 2041 | /* fall through */ |
| 1959 | 2042 | case -ENOTCONN: |
| 1960 | 2043 | case -EAGAIN: |
| 1961 | − /* Check for timeouts before looping back to call_bind */ | |
| 1962 | 2044 | case -ETIMEDOUT: |
| 1963 | − task->tk_action = call_timeout; | |
| 1964 | − return; | |
| 2045 | + goto out_retry; | |
| 1965 | 2046 | case 0: |
| 1966 | 2047 | clnt->cl_stats->netreconn++; |
| 1967 | 2048 | task->tk_action = call_transmit; |
| 2049 | + call_transmit(task); | |
| 1968 | 2050 | return; |
| 1969 | 2051 | } |
| 1970 | 2052 | rpc_exit(task, status); |
| 2053 | + return; | |
| 2054 | +out_retry: | |
| 2055 | + /* Check for timeouts before looping back to call_bind */ | |
| 2056 | + task->tk_action = call_bind; | |
| 2057 | + rpc_check_timeout(task); | |
| 1971 | 2058 | } |
| 1972 | 2059 | |
| 1973 | 2060 | /* |
| @@ -1976,16 +2063,28 @@ call_connect_status(struct rpc_task *task) · 2 unmodified lines | ||
| 1976 | 2063 | static void |
| 1977 | 2064 | call_transmit(struct rpc_task *task) |
| 1978 | 2065 | { |
| 2066 | + if (rpc_task_transmitted(task)) { | |
| 2067 | + rpc_task_handle_transmitted(task); | |
| 2068 | + return; | |
| 2069 | + } | |
| 2070 | + | |
| 1979 | 2071 | dprint_status(task); |
| 1980 | 2072 | |
| 2073 | + task->tk_action = call_transmit_status; | |
| 2074 | + if (!xprt_prepare_transmit(task)) | |
| 2075 | + return; | |
| 1981 | 2076 | task->tk_status = 0; |
| 1982 | 2077 | if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) { |
| 1983 | − if (!xprt_prepare_transmit(task)) | |
| 2078 | + if (!xprt_connected(task->tk_xprt)) { | |
| 2079 | + task->tk_status = -ENOTCONN; | |
| 1984 | 2080 | return; |
| 2081 | + } | |
| 1985 | 2082 | xprt_transmit(task); |
| 1986 | 2083 | } |
| 1987 | − task->tk_action = call_transmit_status; | |
| 1988 | 2084 | xprt_end_transmit(task); |
| 2085 | + if (rpc_task_need_resched(task)) | |
| 2086 | + return; | |
| 2087 | + call_transmit_status(task); | |
| 1989 | 2088 | } |
| 1990 | 2089 | |
| 1991 | 2090 | /* |
| @@ -2000,8 +2099,12 @@ call_transmit_status(struct rpc_task *task) · 8 unmodified lines | ||
| 2000 | 2099 | * Common case: success. Force the compiler to put this |
| 2001 | 2100 | * test first. |
| 2002 | 2101 | */ |
| 2003 | − if (task->tk_status == 0) { | |
| 2004 | − xprt_request_wait_receive(task); | |
| 2102 | + if (rpc_task_transmitted(task)) { | |
| 2103 | + if (task->tk_status == 0) | |
| 2104 | + xprt_request_wait_receive(task); | |
| 2105 | + if (rpc_task_need_resched(task)) | |
| 2106 | + return; | |
| 2107 | + call_status(task); | |
| 2005 | 2108 | return; |
| 2006 | 2109 | } |
| 2007 | 2110 | |
| @@ -2038,7 +2141,7 @@ call_transmit_status(struct rpc_task *task) · 30 unmodified lines | ||
| 2038 | 2141 | trace_xprt_ping(task->tk_xprt, |
| 2039 | 2142 | task->tk_status); |
| 2040 | 2143 | rpc_exit(task, task->tk_status); |
| 2041 | − break; | |
| 2144 | + return; | |
| 2042 | 2145 | } |
| 2043 | 2146 | /* fall through */ |
| 2044 | 2147 | case -ECONNRESET: |
| @@ -2046,11 +2149,25 @@ call_transmit_status(struct rpc_task *task) · 1 unmodified line | ||
| 2046 | 2149 | case -EADDRINUSE: |
| 2047 | 2150 | case -ENOTCONN: |
| 2048 | 2151 | case -EPIPE: |
| 2152 | + task->tk_action = call_bind; | |
| 2153 | + task->tk_status = 0; | |
| 2049 | 2154 | break; |
| 2050 | 2155 | } |
| 2156 | + rpc_check_timeout(task); | |
| 2051 | 2157 | } |
| 2052 | 2158 | |
| 2053 | 2159 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) |
| 2160 | +static void call_bc_transmit(struct rpc_task *task); | |
| 2161 | +static void call_bc_transmit_status(struct rpc_task *task); | |
| 2162 | + | |
| 2163 | +static void | |
| 2164 | +call_bc_encode(struct rpc_task *task) | |
| 2165 | +{ | |
| 2166 | + xprt_request_enqueue_transmit(task); | |
| 2167 | + task->tk_action = call_bc_transmit; | |
| 2168 | + call_bc_transmit(task); | |
| 2169 | +} | |
| 2170 | + | |
| 2054 | 2171 | /* |
| 2055 | 2172 | * 5b. Send the backchannel RPC reply. On error, drop the reply. In |
| 2056 | 2173 | * addition, disconnect on connectivity errors. |
| @@ -2058,26 +2175,23 @@ call_transmit_status(struct rpc_task *task) · 1 unmodified line | ||
| 2058 | 2175 | static void |
| 2059 | 2176 | call_bc_transmit(struct rpc_task *task) |
| 2060 | 2177 | { |
| 2061 | − struct rpc_rqst *req = task->tk_rqstp; | |
| 2062 | − | |
| 2063 | − if (rpc_task_need_encode(task)) | |
| 2064 | − xprt_request_enqueue_transmit(task); | |
| 2065 | − if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) | |
| 2066 | − goto out_wakeup; | |
| 2067 | − | |
| 2068 | − if (!xprt_prepare_transmit(task)) | |
| 2069 | − goto out_retry; | |
| 2070 | − | |
| 2071 | − if (task->tk_status < 0) { | |
| 2072 | − printk(KERN_NOTICE "RPC: Could not send backchannel reply " | |
| 2073 | − "error: %d\n", task->tk_status); | |
| 2074 | − goto out_done; | |
| 2178 | + task->tk_action = call_bc_transmit_status; | |
| 2179 | + if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) { | |
| 2180 | + if (!xprt_prepare_transmit(task)) | |
| 2181 | + return; | |
| 2182 | + task->tk_status = 0; | |
| 2183 | + xprt_transmit(task); | |
| 2075 | 2184 | } |
| 2185 | + xprt_end_transmit(task); | |
| 2186 | +} | |
| 2076 | 2187 | |
| 2077 | − xprt_transmit(task); | |
| 2188 | +static void | |
| 2189 | +call_bc_transmit_status(struct rpc_task *task) | |
| 2190 | +{ | |
| 2191 | + struct rpc_rqst *req = task->tk_rqstp; | |
| 2078 | 2192 | |
| 2079 | − xprt_end_transmit(task); | |
| 2080 | 2193 | dprint_status(task); |
| 2194 | + | |
| 2081 | 2195 | switch (task->tk_status) { |
| 2082 | 2196 | case 0: |
| 2083 | 2197 | /* Success */ |
| @@ -2091,8 +2205,14 @@ call_bc_transmit(struct rpc_task *task) · 7 unmodified lines | ||
| 2091 | 2205 | case -ENOTCONN: |
| 2092 | 2206 | case -EPIPE: |
| 2093 | 2207 | break; |
| 2208 | + case -ENOBUFS: | |
| 2209 | + rpc_delay(task, HZ>>2); | |
| 2210 | + /* fall through */ | |
| 2211 | + case -EBADSLT: | |
| 2094 | 2212 | case -EAGAIN: |
| 2095 | − goto out_retry; | |
| 2213 | + task->tk_status = 0; | |
| 2214 | + task->tk_action = call_bc_transmit; | |
| 2215 | + return; | |
| 2096 | 2216 | case -ETIMEDOUT: |
| 2097 | 2217 | /* |
| 2098 | 2218 | * Problem reaching the server. Disconnect and let the |
| @@ -2111,18 +2231,11 @@ call_bc_transmit(struct rpc_task *task) · 12 unmodified lines | ||
| 2111 | 2231 | * We were unable to reply and will have to drop the |
| 2112 | 2232 | * request. The server should reconnect and retransmit. |
| 2113 | 2233 | */ |
| 2114 | − WARN_ON_ONCE(task->tk_status == -EAGAIN); | |
| 2115 | 2234 | printk(KERN_NOTICE "RPC: Could not send backchannel reply " |
| 2116 | 2235 | "error: %d\n", task->tk_status); |
| 2117 | 2236 | break; |
| 2118 | 2237 | } |
| 2119 | −out_wakeup: | |
| 2120 | − rpc_wake_up_queued_task(&req->rq_xprt->pending, task); | |
| 2121 | −out_done: | |
| 2122 | 2238 | task->tk_action = rpc_exit_task; |
| 2123 | − return; | |
| 2124 | −out_retry: | |
| 2125 | − task->tk_status = 0; | |
| 2126 | 2239 | } |
| 2127 | 2240 | #endif /* CONFIG_SUNRPC_BACKCHANNEL */ |
| 2128 | 2241 | |
| @@ -2143,6 +2256,7 @@ call_status(struct rpc_task *task) · 14 unmodified lines | ||
| 2143 | 2256 | status = task->tk_status; |
| 2144 | 2257 | if (status >= 0) { |
| 2145 | 2258 | task->tk_action = call_decode; |
| 2259 | + call_decode(task); | |
| 2146 | 2260 | return; |
| 2147 | 2261 | } |
| 2148 | 2262 | |
| @@ -2154,10 +2268,8 @@ call_status(struct rpc_task *task) · 5 unmodified lines | ||
| 2154 | 2268 | case -EHOSTUNREACH: |
| 2155 | 2269 | case -ENETUNREACH: |
| 2156 | 2270 | case -EPERM: |
| 2157 | − if (RPC_IS_SOFTCONN(task)) { | |
| 2158 | − rpc_exit(task, status); | |
| 2159 | − break; | |
| 2160 | − } | |
| 2271 | + if (RPC_IS_SOFTCONN(task)) | |
| 2272 | + goto out_exit; | |
| 2161 | 2273 | /* |
| 2162 | 2274 | * Delay any retries for 3 seconds, then handle as if it |
| 2163 | 2275 | * were a timeout. |
| @@ -2165,7 +2277,6 @@ call_status(struct rpc_task *task) · 1 unmodified line | ||
| 2165 | 2277 | rpc_delay(task, 3*HZ); |
| 2166 | 2278 | /* fall through */ |
| 2167 | 2279 | case -ETIMEDOUT: |
| 2168 | − task->tk_action = call_timeout; | |
| 2169 | 2280 | break; |
| 2170 | 2281 | case -ECONNREFUSED: |
| 2171 | 2282 | case -ECONNRESET: |
| @@ -2178,34 +2289,30 @@ call_status(struct rpc_task *task) · 6 unmodified lines | ||
| 2178 | 2289 | case -EPIPE: |
| 2179 | 2290 | case -ENOTCONN: |
| 2180 | 2291 | case -EAGAIN: |
| 2181 | − task->tk_action = call_encode; | |
| 2182 | 2292 | break; |
| 2183 | 2293 | case -EIO: |
| 2184 | 2294 | /* shutdown or soft timeout */ |
| 2185 | − rpc_exit(task, status); | |
| 2186 | − break; | |
| 2295 | + goto out_exit; | |
| 2187 | 2296 | default: |
| 2188 | 2297 | if (clnt->cl_chatty) |
| 2189 | 2298 | printk("%s: RPC call returned error %d\n", |
| 2190 | 2299 | clnt->cl_program->name, -status); |
| 2191 | − rpc_exit(task, status); | |
| 2300 | + goto out_exit; | |
| 2192 | 2301 | } |
| 2302 | + task->tk_action = call_encode; | |
| 2303 | + rpc_check_timeout(task); | |
| 2304 | + return; | |
| 2305 | +out_exit: | |
| 2306 | + rpc_exit(task, status); | |
| 2193 | 2307 | } |
| 2194 | 2308 | |
| 2195 | −/* | |
| 2196 | − * 6a. Handle RPC timeout | |
| 2197 | − * We do not release the request slot, so we keep using the | |
| 2198 | − * same XID for all retransmits. | |
| 2199 | − */ | |
| 2200 | 2309 | static void |
| 2201 | −call_timeout(struct rpc_task *task) | |
| 2310 | +rpc_check_timeout(struct rpc_task *task) | |
| 2202 | 2311 | { |
| 2203 | 2312 | struct rpc_clnt *clnt = task->tk_client; |
| 2204 | 2313 | |
| 2205 | − if (xprt_adjust_timeout(task->tk_rqstp) == 0) { | |
| 2206 | − dprintk("RPC: %5u call_timeout (minor)\n", task->tk_pid); | |
| 2207 | − goto retry; | |
| 2208 | − } | |
| 2314 | + if (xprt_adjust_timeout(task->tk_rqstp) == 0) | |
| 2315 | + return; | |
| 2209 | 2316 | |
| 2210 | 2317 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); |
| 2211 | 2318 | task->tk_timeouts++; |
| @@ -2241,10 +2348,6 @@ call_timeout(struct rpc_task *task) · 29 unmodified lines | ||
| 2241 | 2348 | * event? RFC2203 requires the server to drop all such requests. |
| 2242 | 2349 | */ |
| 2243 | 2350 | rpcauth_invalcred(task); |
| 2244 | − | |
| 2245 | −retry: | |
| 2246 | − task->tk_action = call_encode; | |
| 2247 | − task->tk_status = 0; | |
| 2248 | 2351 | } |
| 2249 | 2352 | |
| 2250 | 2353 | /* |
| @@ -2255,12 +2358,11 @@ call_decode(struct rpc_task *task) · 4 unmodified lines | ||
| 2255 | 2358 | { |
| 2256 | 2359 | struct rpc_clnt *clnt = task->tk_client; |
| 2257 | 2360 | struct rpc_rqst *req = task->tk_rqstp; |
| 2258 | − kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode; | |
| 2259 | − __be32 *p; | |
| 2361 | + struct xdr_stream xdr; | |
| 2260 | 2362 | |
| 2261 | 2363 | dprint_status(task); |
| 2262 | 2364 | |
| 2263 | − if (!decode) { | |
| 2365 | + if (!task->tk_msg.rpc_proc->p_decode) { | |
| 2264 | 2366 | task->tk_action = rpc_exit_task; |
| 2265 | 2367 | return; |
| 2266 | 2368 | } |
| @@ -2285,223 +2387,195 @@ call_decode(struct rpc_task *task) · 18 unmodified lines | ||
| 2285 | 2387 | WARN_ON(memcmp(&req->rq_rcv_buf, &req->rq_private_buf, |
| 2286 | 2388 | sizeof(req->rq_rcv_buf)) != 0); |
| 2287 | 2389 | |
| 2288 | − if (req->rq_rcv_buf.len < 12) { | |
| 2289 | − if (!RPC_IS_SOFT(task)) { | |
| 2290 | − task->tk_action = call_encode; | |
| 2291 | − goto out_retry; | |
| 2292 | − } | |
| 2293 | − dprintk("RPC: %s: too small RPC reply size (%d bytes)\n", | |
| 2294 | − clnt->cl_program->name, task->tk_status); | |
| 2295 | − task->tk_action = call_timeout; | |
| 2390 | + if (req->rq_rcv_buf.len < 12) | |
| 2296 | 2391 | goto out_retry; |
| 2297 | − } | |
| 2298 | 2392 | |
| 2299 | − p = rpc_verify_header(task); | |
| 2300 | − if (IS_ERR(p)) { | |
| 2301 | − if (p == ERR_PTR(-EAGAIN)) | |
| 2302 | − goto out_retry; | |
| 2393 | + xdr_init_decode(&xdr, &req->rq_rcv_buf, | |
| 2394 | + req->rq_rcv_buf.head[0].iov_base, req); | |
| 2395 | + switch (rpc_decode_header(task, &xdr)) { | |
| 2396 | + case 0: | |
| 2397 | + task->tk_action = rpc_exit_task; | |
| 2398 | + task->tk_status = rpcauth_unwrap_resp(task, &xdr); | |
| 2399 | + dprintk("RPC: %5u %s result %d\n", | |
| 2400 | + task->tk_pid, __func__, task->tk_status); | |
| 2303 | 2401 | return; |
| 2304 | − } | |
| 2305 | − task->tk_action = rpc_exit_task; | |
| 2306 | − | |
| 2307 | − task->tk_status = rpcauth_unwrap_resp(task, decode, req, p, | |
| 2308 | − task->tk_msg.rpc_resp); | |
| 2309 | − | |
| 2310 | − dprintk("RPC: %5u call_decode result %d\n", task->tk_pid, | |
| 2311 | − task->tk_status); | |
| 2312 | − return; | |
| 2402 | + case -EAGAIN: | |
| 2313 | 2403 | out_retry: |
| 2314 | − task->tk_status = 0; | |
| 2315 | − /* Note: rpc_verify_header() may have freed the RPC slot */ | |
| 2316 | − if (task->tk_rqstp == req) { | |
| 2317 | − xdr_free_bvec(&req->rq_rcv_buf); | |
| 2318 | − req->rq_reply_bytes_recvd = req->rq_rcv_buf.len = 0; | |
| 2319 | − if (task->tk_client->cl_discrtry) | |
| 2320 | − xprt_conditional_disconnect(req->rq_xprt, | |
| 2321 | − req->rq_connect_cookie); | |
| 2404 | + task->tk_status = 0; | |
| 2405 | + /* Note: rpc_decode_header() may have freed the RPC slot */ | |
| 2406 | + if (task->tk_rqstp == req) { | |
| 2407 | + xdr_free_bvec(&req->rq_rcv_buf); | |
| 2408 | + req->rq_reply_bytes_recvd = 0; | |
| 2409 | + req->rq_rcv_buf.len = 0; | |
| 2410 | + if (task->tk_client->cl_discrtry) | |
| 2411 | + xprt_conditional_disconnect(req->rq_xprt, | |
| 2412 | + req->rq_connect_cookie); | |
| 2413 | + } | |
| 2414 | + task->tk_action = call_encode; | |
| 2415 | + rpc_check_timeout(task); | |
| 2322 | 2416 | } |
| 2323 | 2417 | } |
| 2324 | 2418 | |
| 2325 | −static __be32 * | |
| 2326 | −rpc_encode_header(struct rpc_task *task) | |
| 2419 | +static int | |
| 2420 | +rpc_encode_header(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2327 | 2421 | { |
| 2328 | 2422 | struct rpc_clnt *clnt = task->tk_client; |
| 2329 | 2423 | struct rpc_rqst *req = task->tk_rqstp; |
| 2330 | − __be32 *p = req->rq_svec[0].iov_base; | |
| 2331 | − | |
| 2332 | − /* FIXME: check buffer size? */ | |
| 2333 | − | |
| 2334 | − p = xprt_skip_transport_header(req->rq_xprt, p); | |
| 2335 | − *p++ = req->rq_xid; /* XID */ | |
| 2336 | − *p++ = htonl(RPC_CALL); /* CALL */ | |
| 2337 | − *p++ = htonl(RPC_VERSION); /* RPC version */ | |
| 2338 | − *p++ = htonl(clnt->cl_prog); /* program number */ | |
| 2339 | − *p++ = htonl(clnt->cl_vers); /* program version */ | |
| 2340 | − *p++ = htonl(task->tk_msg.rpc_proc->p_proc); /* procedure */ | |
| 2341 | − p = rpcauth_marshcred(task, p); | |
| 2342 | − if (p) | |
| 2343 | − req->rq_slen = xdr_adjust_iovec(&req->rq_svec[0], p); | |
| 2344 | − return p; | |
| 2424 | + __be32 *p; | |
| 2425 | + int error; | |
| 2426 | + | |
| 2427 | + error = -EMSGSIZE; | |
| 2428 | + p = xdr_reserve_space(xdr, RPC_CALLHDRSIZE << 2); | |
| 2429 | + if (!p) | |
| 2430 | + goto out_fail; | |
| 2431 | + *p++ = req->rq_xid; | |
| 2432 | + *p++ = rpc_call; | |
| 2433 | + *p++ = cpu_to_be32(RPC_VERSION); | |
| 2434 | + *p++ = cpu_to_be32(clnt->cl_prog); | |
| 2435 | + *p++ = cpu_to_be32(clnt->cl_vers); | |
| 2436 | + *p = cpu_to_be32(task->tk_msg.rpc_proc->p_proc); | |
| 2437 | + | |
| 2438 | + error = rpcauth_marshcred(task, xdr); | |
| 2439 | + if (error < 0) | |
| 2440 | + goto out_fail; | |
| 2441 | + return 0; | |
| 2442 | +out_fail: | |
| 2443 | + trace_rpc_bad_callhdr(task); | |
| 2444 | + rpc_exit(task, error); | |
| 2445 | + return error; | |
| 2345 | 2446 | } |
| 2346 | 2447 | |
| 2347 | −static __be32 * | |
| 2348 | −rpc_verify_header(struct rpc_task *task) | |
| 2448 | +static noinline int | |
| 2449 | +rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2349 | 2450 | { |
| 2350 | 2451 | struct rpc_clnt *clnt = task->tk_client; |
| 2351 | − struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0]; | |
| 2352 | − int len = task->tk_rqstp->rq_rcv_buf.len >> 2; | |
| 2353 | − __be32 *p = iov->iov_base; | |
| 2354 | − u32 n; | |
| 2355 | 2452 | int error = -EACCES; |
| 2453 | + __be32 *p; | |
| 2356 | 2454 | |
| 2357 | − if ((task->tk_rqstp->rq_rcv_buf.len & 3) != 0) { | |
| 2358 | − /* RFC-1014 says that the representation of XDR data must be a | |
| 2359 | − * multiple of four bytes | |
| 2360 | − * - if it isn't pointer subtraction in the NFS client may give | |
| 2361 | − * undefined results | |
| 2362 | − */ | |
| 2363 | − dprintk("RPC: %5u %s: XDR representation not a multiple of" | |
| 2364 | − " 4 bytes: 0x%x\n", task->tk_pid, __func__, | |
| 2365 | − task->tk_rqstp->rq_rcv_buf.len); | |
| 2366 | − error = -EIO; | |
| 2367 | − goto out_err; | |
| 2368 | − } | |
| 2369 | − if ((len -= 3) < 0) | |
| 2370 | − goto out_overflow; | |
| 2371 | − | |
| 2372 | − p += 1; /* skip XID */ | |
| 2373 | − if ((n = ntohl(*p++)) != RPC_REPLY) { | |
| 2374 | − dprintk("RPC: %5u %s: not an RPC reply: %x\n", | |
| 2375 | − task->tk_pid, __func__, n); | |
| 2376 | − error = -EIO; | |
| 2377 | − goto out_garbage; | |
| 2378 | − } | |
| 2379 | − | |
| 2380 | − if ((n = ntohl(*p++)) != RPC_MSG_ACCEPTED) { | |
| 2381 | − if (--len < 0) | |
| 2382 | − goto out_overflow; | |
| 2383 | − switch ((n = ntohl(*p++))) { | |
| 2384 | − case RPC_AUTH_ERROR: | |
| 2385 | − break; | |
| 2386 | − case RPC_MISMATCH: | |
| 2387 | − dprintk("RPC: %5u %s: RPC call version mismatch!\n", | |
| 2388 | − task->tk_pid, __func__); | |
| 2389 | − error = -EPROTONOSUPPORT; | |
| 2390 | − goto out_err; | |
| 2391 | − default: | |
| 2392 | − dprintk("RPC: %5u %s: RPC call rejected, " | |
| 2393 | − "unknown error: %x\n", | |
| 2394 | − task->tk_pid, __func__, n); | |
| 2395 | − error = -EIO; | |
| 2396 | − goto out_err; | |
| 2397 | − } | |
| 2398 | − if (--len < 0) | |
| 2399 | − goto out_overflow; | |
| 2400 | − switch ((n = ntohl(*p++))) { | |
| 2401 | − case RPC_AUTH_REJECTEDCRED: | |
| 2402 | − case RPC_AUTH_REJECTEDVERF: | |
| 2403 | − case RPCSEC_GSS_CREDPROBLEM: | |
| 2404 | − case RPCSEC_GSS_CTXPROBLEM: | |
| 2405 | − if (!task->tk_cred_retry) | |
| 2406 | − break; | |
| 2407 | − task->tk_cred_retry--; | |
| 2408 | − dprintk("RPC: %5u %s: retry stale creds\n", | |
| 2409 | − task->tk_pid, __func__); | |
| 2410 | − rpcauth_invalcred(task); | |
| 2411 | − /* Ensure we obtain a new XID! */ | |
| 2412 | − xprt_release(task); | |
| 2413 | − task->tk_action = call_reserve; | |
| 2414 | − goto out_retry; | |
| 2415 | − case RPC_AUTH_BADCRED: | |
| 2416 | − case RPC_AUTH_BADVERF: | |
| 2417 | − /* possibly garbled cred/verf? */ | |
| 2418 | − if (!task->tk_garb_retry) | |
| 2419 | − break; | |
| 2420 | − task->tk_garb_retry--; | |
| 2421 | − dprintk("RPC: %5u %s: retry garbled creds\n", | |
| 2422 | − task->tk_pid, __func__); | |
| 2423 | − task->tk_action = call_encode; | |
| 2424 | − goto out_retry; | |
| 2425 | − case RPC_AUTH_TOOWEAK: | |
| 2426 | − printk(KERN_NOTICE "RPC: server %s requires stronger " | |
| 2427 | − "authentication.\n", | |
| 2428 | − task->tk_xprt->servername); | |
| 2429 | − break; | |
| 2430 | − default: | |
| 2431 | − dprintk("RPC: %5u %s: unknown auth error: %x\n", | |
| 2432 | − task->tk_pid, __func__, n); | |
| 2433 | − error = -EIO; | |
| 2434 | − } | |
| 2435 | − dprintk("RPC: %5u %s: call rejected %d\n", | |
| 2436 | − task->tk_pid, __func__, n); | |
| 2437 | − goto out_err; | |
| 2438 | − } | |
| 2439 | − p = rpcauth_checkverf(task, p); | |
| 2440 | − if (IS_ERR(p)) { | |
| 2441 | − error = PTR_ERR(p); | |
| 2442 | − dprintk("RPC: %5u %s: auth check failed with %d\n", | |
| 2443 | − task->tk_pid, __func__, error); | |
| 2444 | − goto out_garbage; /* bad verifier, retry */ | |
| 2445 | − } | |
| 2446 | − len = p - (__be32 *)iov->iov_base - 1; | |
| 2447 | − if (len < 0) | |
| 2448 | − goto out_overflow; | |
| 2449 | − switch ((n = ntohl(*p++))) { | |
| 2450 | − case RPC_SUCCESS: | |
| 2451 | − return p; | |
| 2452 | − case RPC_PROG_UNAVAIL: | |
| 2453 | − dprintk("RPC: %5u %s: program %u is unsupported " | |
| 2454 | − "by server %s\n", task->tk_pid, __func__, | |
| 2455 | − (unsigned int)clnt->cl_prog, | |
| 2456 | − task->tk_xprt->servername); | |
| 2455 | + /* RFC-1014 says that the representation of XDR data must be a | |
| 2456 | + * multiple of four bytes | |
| 2457 | + * - if it isn't pointer subtraction in the NFS client may give | |
| 2458 | + * undefined results | |
| 2459 | + */ | |
| 2460 | + if (task->tk_rqstp->rq_rcv_buf.len & 3) | |
| 2461 | + goto out_badlen; | |
| 2462 | + | |
| 2463 | + p = xdr_inline_decode(xdr, 3 * sizeof(*p)); | |
| 2464 | + if (!p) | |
| 2465 | + goto out_unparsable; | |
| 2466 | + p++; /* skip XID */ | |
| 2467 | + if (*p++ != rpc_reply) | |
| 2468 | + goto out_unparsable; | |
| 2469 | + if (*p++ != rpc_msg_accepted) | |
| 2470 | + goto out_msg_denied; | |
| 2471 | + | |
| 2472 | + error = rpcauth_checkverf(task, xdr); | |
| 2473 | + if (error) | |
| 2474 | + goto out_verifier; | |
| 2475 | + | |
| 2476 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2477 | + if (!p) | |
| 2478 | + goto out_unparsable; | |
| 2479 | + switch (*p) { | |
| 2480 | + case rpc_success: | |
| 2481 | + return 0; | |
| 2482 | + case rpc_prog_unavail: | |
| 2483 | + trace_rpc__prog_unavail(task); | |
| 2457 | 2484 | error = -EPFNOSUPPORT; |
| 2458 | 2485 | goto out_err; |
| 2459 | − case RPC_PROG_MISMATCH: | |
| 2460 | − dprintk("RPC: %5u %s: program %u, version %u unsupported " | |
| 2461 | − "by server %s\n", task->tk_pid, __func__, | |
| 2462 | − (unsigned int)clnt->cl_prog, | |
| 2463 | − (unsigned int)clnt->cl_vers, | |
| 2464 | − task->tk_xprt->servername); | |
| 2486 | + case rpc_prog_mismatch: | |
| 2487 | + trace_rpc__prog_mismatch(task); | |
| 2465 | 2488 | error = -EPROTONOSUPPORT; |
| 2466 | 2489 | goto out_err; |
| 2467 | − case RPC_PROC_UNAVAIL: | |
| 2468 | − dprintk("RPC: %5u %s: proc %s unsupported by program %u, " | |
| 2469 | − "version %u on server %s\n", | |
| 2470 | − task->tk_pid, __func__, | |
| 2471 | − rpc_proc_name(task), | |
| 2472 | − clnt->cl_prog, clnt->cl_vers, | |
| 2473 | − task->tk_xprt->servername); | |
| 2490 | + case rpc_proc_unavail: | |
| 2491 | + trace_rpc__proc_unavail(task); | |
| 2474 | 2492 | error = -EOPNOTSUPP; |
| 2475 | 2493 | goto out_err; |
| 2476 | − case RPC_GARBAGE_ARGS: | |
| 2477 | − dprintk("RPC: %5u %s: server saw garbage\n", | |
| 2478 | − task->tk_pid, __func__); | |
| 2479 | − break; /* retry */ | |
| 2494 | + case rpc_garbage_args: | |
| 2495 | + trace_rpc__garbage_args(task); | |
| 2496 | + break; | |
| 2480 | 2497 | default: |
| 2481 | − dprintk("RPC: %5u %s: server accept status: %x\n", | |
| 2482 | − task->tk_pid, __func__, n); | |
| 2483 | − /* Also retry */ | |
| 2498 | + trace_rpc__unparsable(task); | |
| 2484 | 2499 | } |
| 2485 | 2500 | |
| 2486 | 2501 | out_garbage: |
| 2487 | 2502 | clnt->cl_stats->rpcgarbage++; |
| 2488 | 2503 | if (task->tk_garb_retry) { |
| 2489 | 2504 | task->tk_garb_retry--; |
| 2490 | − dprintk("RPC: %5u %s: retrying\n", | |
| 2491 | − task->tk_pid, __func__); | |
| 2492 | 2505 | task->tk_action = call_encode; |
| 2493 | −out_retry: | |
| 2494 | − return ERR_PTR(-EAGAIN); | |
| 2506 | + return -EAGAIN; | |
| 2495 | 2507 | } |
| 2496 | 2508 | out_err: |
| 2497 | 2509 | rpc_exit(task, error); |
| 2498 | − dprintk("RPC: %5u %s: call failed with error %d\n", task->tk_pid, | |
| 2499 | − __func__, error); | |
| 2500 | − return ERR_PTR(error); | |
| 2501 | −out_overflow: | |
| 2502 | − dprintk("RPC: %5u %s: server reply was truncated.\n", task->tk_pid, | |
| 2503 | − __func__); | |
| 2510 | + return error; | |
| 2511 | + | |
| 2512 | +out_badlen: | |
| 2513 | + trace_rpc__unparsable(task); | |
| 2514 | + error = -EIO; | |
| 2515 | + goto out_err; | |
| 2516 | + | |
| 2517 | +out_unparsable: | |
| 2518 | + trace_rpc__unparsable(task); | |
| 2519 | + error = -EIO; | |
| 2520 | + goto out_garbage; | |
| 2521 | + | |
| 2522 | +out_verifier: | |
| 2523 | + trace_rpc_bad_verifier(task); | |
| 2504 | 2524 | goto out_garbage; |
| 2525 | + | |
| 2526 | +out_msg_denied: | |
| 2527 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2528 | + if (!p) | |
| 2529 | + goto out_unparsable; | |
| 2530 | + switch (*p++) { | |
| 2531 | + case rpc_auth_error: | |
| 2532 | + break; | |
| 2533 | + case rpc_mismatch: | |
| 2534 | + trace_rpc__mismatch(task); | |
| 2535 | + error = -EPROTONOSUPPORT; | |
| 2536 | + goto out_err; | |
| 2537 | + default: | |
| 2538 | + trace_rpc__unparsable(task); | |
| 2539 | + error = -EIO; | |
| 2540 | + goto out_err; | |
| 2541 | + } | |
| 2542 | + | |
| 2543 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2544 | + if (!p) | |
| 2545 | + goto out_unparsable; | |
| 2546 | + switch (*p++) { | |
| 2547 | + case rpc_autherr_rejectedcred: | |
| 2548 | + case rpc_autherr_rejectedverf: | |
| 2549 | + case rpcsec_gsserr_credproblem: | |
| 2550 | + case rpcsec_gsserr_ctxproblem: | |
| 2551 | + if (!task->tk_cred_retry) | |
| 2552 | + break; | |
| 2553 | + task->tk_cred_retry--; | |
| 2554 | + trace_rpc__stale_creds(task); | |
| 2555 | + rpcauth_invalcred(task); | |
| 2556 | + /* Ensure we obtain a new XID! */ | |
| 2557 | + xprt_release(task); | |
| 2558 | + task->tk_action = call_reserve; | |
| 2559 | + return -EAGAIN; | |
| 2560 | + case rpc_autherr_badcred: | |
| 2561 | + case rpc_autherr_badverf: | |
| 2562 | + /* possibly garbled cred/verf? */ | |
| 2563 | + if (!task->tk_garb_retry) | |
| 2564 | + break; | |
| 2565 | + task->tk_garb_retry--; | |
| 2566 | + trace_rpc__bad_creds(task); | |
| 2567 | + task->tk_action = call_encode; | |
| 2568 | + return -EAGAIN; | |
| 2569 | + case rpc_autherr_tooweak: | |
| 2570 | + trace_rpc__auth_tooweak(task); | |
| 2571 | + pr_warn("RPC: server %s requires stronger authentication.\n", | |
| 2572 | + task->tk_xprt->servername); | |
| 2573 | + break; | |
| 2574 | + default: | |
| 2575 | + trace_rpc__unparsable(task); | |
| 2576 | + error = -EIO; | |
| 2577 | + } | |
| 2578 | + goto out_err; | |
| 2505 | 2579 | } |
| 2506 | 2580 | |
| 2507 | 2581 | static void rpcproc_encode_null(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <linux/spinlock.h> |
| 20 | 20 | #include <linux/mutex.h> |
| 21 | 21 | #include <linux/freezer.h> |
| 22 | +#include <linux/sched/mm.h> | |
| 22 | 23 | |
| 23 | 24 | #include <linux/sunrpc/clnt.h> |
| 24 | 25 | |
| @@ -784,8 +785,7 @@ void rpc_exit(struct rpc_task *task, int status) · 759 unmodified lines | ||
| 784 | 785 | { |
| 785 | 786 | task->tk_status = status; |
| 786 | 787 | task->tk_action = rpc_exit_task; |
| 787 | − if (RPC_IS_QUEUED(task)) | |
| 788 | − rpc_wake_up_queued_task(task->tk_waitqueue, task); | |
| 788 | + rpc_wake_up_queued_task(task->tk_waitqueue, task); | |
| 789 | 789 | } |
| 790 | 790 | EXPORT_SYMBOL_GPL(rpc_exit); |
| 791 | 791 | |
| @@ -902,7 +902,10 @@ void rpc_execute(struct rpc_task *task) · 110 unmodified lines | ||
| 902 | 902 | |
| 903 | 903 | static void rpc_async_schedule(struct work_struct *work) |
| 904 | 904 | { |
| 905 | + unsigned int pflags = memalloc_nofs_save(); | |
| 906 | + | |
| 905 | 907 | __rpc_execute(container_of(work, struct rpc_task, u.tk_work)); |
| 908 | + memalloc_nofs_restore(pflags); | |
| 906 | 909 | } |
| 907 | 910 | |
| 908 | 911 | /** |
| @@ -921,16 +924,13 @@ static void rpc_async_schedule(struct work_struct *work) · 12 unmodified lines | ||
| 921 | 924 | * Most requests are 'small' (under 2KiB) and can be serviced from a |
| 922 | 925 | * mempool, ensuring that NFS reads and writes can always proceed, |
| 923 | 926 | * and that there is good locality of reference for these buffers. |
| 924 | − * | |
| 925 | − * In order to avoid memory starvation triggering more writebacks of | |
| 926 | − * NFS requests, we avoid using GFP_KERNEL. | |
| 927 | 927 | */ |
| 928 | 928 | int rpc_malloc(struct rpc_task *task) |
| 929 | 929 | { |
| 930 | 930 | struct rpc_rqst *rqst = task->tk_rqstp; |
| 931 | 931 | size_t size = rqst->rq_callsize + rqst->rq_rcvsize; |
| 932 | 932 | struct rpc_buffer *buf; |
| 933 | − gfp_t gfp = GFP_NOIO | __GFP_NOWARN; | |
| 933 | + gfp_t gfp = GFP_NOFS; | |
| 934 | 934 | |
| 935 | 935 | if (RPC_IS_SWAPPER(task)) |
| 936 | 936 | gfp = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN; |
| @@ -1011,7 +1011,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta · 74 unmodified lines | ||
| 1011 | 1011 | static struct rpc_task * |
| 1012 | 1012 | rpc_alloc_task(void) |
| 1013 | 1013 | { |
| 1014 | − return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOIO); | |
| 1014 | + return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS); | |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /* |
| @@ -1067,7 +1067,10 @@ static void rpc_free_task(struct rpc_task *task) · 49 unmodified lines | ||
| 1067 | 1067 | |
| 1068 | 1068 | static void rpc_async_release(struct work_struct *work) |
| 1069 | 1069 | { |
| 1070 | + unsigned int pflags = memalloc_nofs_save(); | |
| 1071 | + | |
| 1070 | 1072 | rpc_free_task(container_of(work, struct rpc_task, u.tk_work)); |
| 1073 | + memalloc_nofs_restore(pflags); | |
| 1071 | 1074 | } |
| 1072 | 1075 | |
| 1073 | 1076 | static void rpc_release_resources_task(struct rpc_task *task) |
| @@ -1144,17 +1144,6 @@ void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) · 1143 unmodified lines | ||
| 1144 | 1144 | static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {} |
| 1145 | 1145 | #endif |
| 1146 | 1146 | |
| 1147 | −/* | |
| 1148 | − * Setup response header for TCP, it has a 4B record length field. | |
| 1149 | − */ | |
| 1150 | −static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp) | |
| 1151 | −{ | |
| 1152 | − struct kvec *resv = &rqstp->rq_res.head[0]; | |
| 1153 | − | |
| 1154 | − /* tcp needs a space for the record length... */ | |
| 1155 | − svc_putnl(resv, 0); | |
| 1156 | −} | |
| 1157 | − | |
| 1158 | 1147 | /* |
| 1159 | 1148 | * Common routine for processing the RPC request. |
| 1160 | 1149 | */ |
| @@ -1182,10 +1171,6 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) · 21 unmodified lines | ||
| 1182 | 1171 | set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); |
| 1183 | 1172 | clear_bit(RQ_DROPME, &rqstp->rq_flags); |
| 1184 | 1173 | |
| 1185 | − /* Setup reply header */ | |
| 1186 | − if (rqstp->rq_prot == IPPROTO_TCP) | |
| 1187 | − svc_tcp_prep_reply_hdr(rqstp); | |
| 1188 | − | |
| 1189 | 1174 | svc_putu32(resv, rqstp->rq_xid); |
| 1190 | 1175 | |
| 1191 | 1176 | vers = svc_getnl(argv); |
| @@ -1443,6 +1428,10 @@ svc_process(struct svc_rqst *rqstp) · 251 unmodified lines | ||
| 1443 | 1428 | goto out_drop; |
| 1444 | 1429 | } |
| 1445 | 1430 | |
| 1431 | + /* Reserve space for the record marker */ | |
| 1432 | + if (rqstp->rq_prot == IPPROTO_TCP) | |
| 1433 | + svc_putnl(resv, 0); | |
| 1434 | + | |
| 1446 | 1435 | /* Returns 1 for send, 0 for drop */ |
| 1447 | 1436 | if (likely(svc_process_common(rqstp, argv, resv))) |
| 1448 | 1437 | return svc_send(rqstp); |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <linux/sunrpc/xdr.h> |
| 17 | 17 | #include <linux/sunrpc/msg_prot.h> |
| 18 | 18 | #include <linux/bvec.h> |
| 19 | +#include <trace/events/sunrpc.h> | |
| 19 | 20 | |
| 20 | 21 | /* |
| 21 | 22 | * XDR functions for basic NFS types |
| @@ -162,6 +163,15 @@ xdr_free_bvec(struct xdr_buf *buf) · 140 unmodified lines | ||
| 162 | 163 | buf->bvec = NULL; |
| 163 | 164 | } |
| 164 | 165 | |
| 166 | +/** | |
| 167 | + * xdr_inline_pages - Prepare receive buffer for a large reply | |
| 168 | + * @xdr: xdr_buf into which reply will be placed | |
| 169 | + * @offset: expected offset where data payload will start, in bytes | |
| 170 | + * @pages: vector of struct page pointers | |
| 171 | + * @base: offset in first page where receive should start, in bytes | |
| 172 | + * @len: expected size of the upper layer data payload, in bytes | |
| 173 | + * | |
| 174 | + */ | |
| 165 | 175 | void |
| 166 | 176 | xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset, |
| 167 | 177 | struct page **pages, unsigned int base, unsigned int len) |
| @@ -179,6 +189,8 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset, · 11 unmodified lines | ||
| 179 | 189 | |
| 180 | 190 | tail->iov_base = buf + offset; |
| 181 | 191 | tail->iov_len = buflen - offset; |
| 192 | + if ((xdr->page_len & 3) == 0) | |
| 193 | + tail->iov_len -= sizeof(__be32); | |
| 182 | 194 | |
| 183 | 195 | xdr->buflen += len; |
| 184 | 196 | } |
| @@ -346,13 +358,15 @@ EXPORT_SYMBOL_GPL(_copy_from_pages); · 161 unmodified lines | ||
| 346 | 358 | * 'len' bytes. The extra data is not lost, but is instead |
| 347 | 359 | * moved into the inlined pages and/or the tail. |
| 348 | 360 | */ |
| 349 | −static void | |
| 361 | +static unsigned int | |
| 350 | 362 | xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) |
| 351 | 363 | { |
| 352 | 364 | struct kvec *head, *tail; |
| 353 | 365 | size_t copy, offs; |
| 354 | 366 | unsigned int pglen = buf->page_len; |
| 367 | + unsigned int result; | |
| 355 | 368 | |
| 369 | + result = 0; | |
| 356 | 370 | tail = buf->tail; |
| 357 | 371 | head = buf->head; |
| 358 | 372 | |
| @@ -366,6 +380,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 7 unmodified lines | ||
| 366 | 380 | copy = tail->iov_len - len; |
| 367 | 381 | memmove((char *)tail->iov_base + len, |
| 368 | 382 | tail->iov_base, copy); |
| 383 | + result += copy; | |
| 369 | 384 | } |
| 370 | 385 | /* Copy from the inlined pages into the tail */ |
| 371 | 386 | copy = len; |
| @@ -376,11 +391,13 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 4 unmodified lines | ||
| 376 | 391 | copy = 0; |
| 377 | 392 | else if (copy > tail->iov_len - offs) |
| 378 | 393 | copy = tail->iov_len - offs; |
| 379 | − if (copy != 0) | |
| 394 | + if (copy != 0) { | |
| 380 | 395 | _copy_from_pages((char *)tail->iov_base + offs, |
| 381 | 396 | buf->pages, |
| 382 | 397 | buf->page_base + pglen + offs - len, |
| 383 | 398 | copy); |
| 399 | + result += copy; | |
| 400 | + } | |
| 384 | 401 | /* Do we also need to copy data from the head into the tail ? */ |
| 385 | 402 | if (len > pglen) { |
| 386 | 403 | offs = copy = len - pglen; |
| @@ -390,6 +407,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 3 unmodified lines | ||
| 390 | 407 | (char *)head->iov_base + |
| 391 | 408 | head->iov_len - offs, |
| 392 | 409 | copy); |
| 410 | + result += copy; | |
| 393 | 411 | } |
| 394 | 412 | } |
| 395 | 413 | /* Now handle pages */ |
| @@ -405,12 +423,15 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 9 unmodified lines | ||
| 405 | 423 | _copy_to_pages(buf->pages, buf->page_base, |
| 406 | 424 | (char *)head->iov_base + head->iov_len - len, |
| 407 | 425 | copy); |
| 426 | + result += copy; | |
| 408 | 427 | } |
| 409 | 428 | head->iov_len -= len; |
| 410 | 429 | buf->buflen -= len; |
| 411 | 430 | /* Have we truncated the message? */ |
| 412 | 431 | if (buf->len > buf->buflen) |
| 413 | 432 | buf->len = buf->buflen; |
| 433 | + | |
| 434 | + return result; | |
| 414 | 435 | } |
| 415 | 436 | |
| 416 | 437 | /** |
| @@ -422,14 +443,16 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 5 unmodified lines | ||
| 422 | 443 | * 'len' bytes. The extra data is not lost, but is instead |
| 423 | 444 | * moved into the tail. |
| 424 | 445 | */ |
| 425 | −static void | |
| 446 | +static unsigned int | |
| 426 | 447 | xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) |
| 427 | 448 | { |
| 428 | 449 | struct kvec *tail; |
| 429 | 450 | size_t copy; |
| 430 | 451 | unsigned int pglen = buf->page_len; |
| 431 | 452 | unsigned int tailbuf_len; |
| 453 | + unsigned int result; | |
| 432 | 454 | |
| 455 | + result = 0; | |
| 433 | 456 | tail = buf->tail; |
| 434 | 457 | BUG_ON (len > pglen); |
| 435 | 458 | |
| @@ -447,18 +470,22 @@ xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) · 11 unmodified lines | ||
| 447 | 470 | if (tail->iov_len > len) { |
| 448 | 471 | char *p = (char *)tail->iov_base + len; |
| 449 | 472 | memmove(p, tail->iov_base, tail->iov_len - len); |
| 473 | + result += tail->iov_len - len; | |
| 450 | 474 | } else |
| 451 | 475 | copy = tail->iov_len; |
| 452 | 476 | /* Copy from the inlined pages into the tail */ |
| 453 | 477 | _copy_from_pages((char *)tail->iov_base, |
| 454 | 478 | buf->pages, buf->page_base + pglen - len, |
| 455 | 479 | copy); |
| 480 | + result += copy; | |
| 456 | 481 | } |
| 457 | 482 | buf->page_len -= len; |
| 458 | 483 | buf->buflen -= len; |
| 459 | 484 | /* Have we truncated the message? */ |
| 460 | 485 | if (buf->len > buf->buflen) |
| 461 | 486 | buf->len = buf->buflen; |
| 487 | + | |
| 488 | + return result; | |
| 462 | 489 | } |
| 463 | 490 | |
| 464 | 491 | void |
| @@ -483,6 +510,7 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos); · 18 unmodified lines | ||
| 483 | 510 | * @xdr: pointer to xdr_stream struct |
| 484 | 511 | * @buf: pointer to XDR buffer in which to encode data |
| 485 | 512 | * @p: current pointer inside XDR buffer |
| 513 | + * @rqst: pointer to controlling rpc_rqst, for debugging | |
| 486 | 514 | * |
| 487 | 515 | * Note: at the moment the RPC client only passes the length of our |
| 488 | 516 | * scratch buffer in the xdr_buf's header kvec. Previously this |
| @@ -491,7 +519,8 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos); · 2 unmodified lines | ||
| 491 | 519 | * of the buffer length, and takes care of adjusting the kvec |
| 492 | 520 | * length for us. |
| 493 | 521 | */ |
| 494 | −void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) | |
| 522 | +void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, | |
| 523 | + struct rpc_rqst *rqst) | |
| 495 | 524 | { |
| 496 | 525 | struct kvec *iov = buf->head; |
| 497 | 526 | int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; |
| @@ -513,6 +542,7 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) · 15 unmodified lines | ||
| 513 | 542 | buf->len += len; |
| 514 | 543 | iov->iov_len += len; |
| 515 | 544 | } |
| 545 | + xdr->rqst = rqst; | |
| 516 | 546 | } |
| 517 | 547 | EXPORT_SYMBOL_GPL(xdr_init_encode); |
| 518 | 548 | |
| @@ -551,9 +581,9 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, · 32 unmodified lines | ||
| 551 | 581 | int frag1bytes, frag2bytes; |
| 552 | 582 | |
| 553 | 583 | if (nbytes > PAGE_SIZE) |
| 554 | − return NULL; /* Bigger buffers require special handling */ | |
| 584 | + goto out_overflow; /* Bigger buffers require special handling */ | |
| 555 | 585 | if (xdr->buf->len + nbytes > xdr->buf->buflen) |
| 556 | − return NULL; /* Sorry, we're totally out of space */ | |
| 586 | + goto out_overflow; /* Sorry, we're totally out of space */ | |
| 557 | 587 | frag1bytes = (xdr->end - xdr->p) << 2; |
| 558 | 588 | frag2bytes = nbytes - frag1bytes; |
| 559 | 589 | if (xdr->iov) |
| @@ -582,6 +612,9 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, · 22 unmodified lines | ||
| 582 | 612 | xdr->buf->page_len += frag2bytes; |
| 583 | 613 | xdr->buf->len += nbytes; |
| 584 | 614 | return p; |
| 615 | +out_overflow: | |
| 616 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 617 | + return NULL; | |
| 585 | 618 | } |
| 586 | 619 | |
| 587 | 620 | /** |
| @@ -819,8 +852,10 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr) · 231 unmodified lines | ||
| 819 | 852 | * @xdr: pointer to xdr_stream struct |
| 820 | 853 | * @buf: pointer to XDR buffer from which to decode data |
| 821 | 854 | * @p: current pointer inside XDR buffer |
| 855 | + * @rqst: pointer to controlling rpc_rqst, for debugging | |
| 822 | 856 | */ |
| 823 | −void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) | |
| 857 | +void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, | |
| 858 | + struct rpc_rqst *rqst) | |
| 824 | 859 | { |
| 825 | 860 | xdr->buf = buf; |
| 826 | 861 | xdr->scratch.iov_base = NULL; |
| @@ -836,6 +871,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) · 9 unmodified lines | ||
| 836 | 871 | xdr->nwords -= p - xdr->p; |
| 837 | 872 | xdr->p = p; |
| 838 | 873 | } |
| 874 | + xdr->rqst = rqst; | |
| 839 | 875 | } |
| 840 | 876 | EXPORT_SYMBOL_GPL(xdr_init_decode); |
| 841 | 877 | |
| @@ -854,7 +890,7 @@ void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, · 12 unmodified lines | ||
| 854 | 890 | buf->page_len = len; |
| 855 | 891 | buf->buflen = len; |
| 856 | 892 | buf->len = len; |
| 857 | − xdr_init_decode(xdr, buf, NULL); | |
| 893 | + xdr_init_decode(xdr, buf, NULL, NULL); | |
| 858 | 894 | } |
| 859 | 895 | EXPORT_SYMBOL_GPL(xdr_init_decode_pages); |
| 860 | 896 | |
| @@ -896,20 +932,23 @@ static __be32 *xdr_copy_to_scratch(struct xdr_stream *xdr, size_t nbytes) · 35 unmodified lines | ||
| 896 | 932 | size_t cplen = (char *)xdr->end - (char *)xdr->p; |
| 897 | 933 | |
| 898 | 934 | if (nbytes > xdr->scratch.iov_len) |
| 899 | − return NULL; | |
| 935 | + goto out_overflow; | |
| 900 | 936 | p = __xdr_inline_decode(xdr, cplen); |
| 901 | 937 | if (p == NULL) |
| 902 | 938 | return NULL; |
| 903 | 939 | memcpy(cpdest, p, cplen); |
| 940 | + if (!xdr_set_next_buffer(xdr)) | |
| 941 | + goto out_overflow; | |
| 904 | 942 | cpdest += cplen; |
| 905 | 943 | nbytes -= cplen; |
| 906 | − if (!xdr_set_next_buffer(xdr)) | |
| 907 | − return NULL; | |
| 908 | 944 | p = __xdr_inline_decode(xdr, nbytes); |
| 909 | 945 | if (p == NULL) |
| 910 | 946 | return NULL; |
| 911 | 947 | memcpy(cpdest, p, nbytes); |
| 912 | 948 | return xdr->scratch.iov_base; |
| 949 | +out_overflow: | |
| 950 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 951 | + return NULL; | |
| 913 | 952 | } |
| 914 | 953 | |
| 915 | 954 | /** |
| @@ -926,14 +965,17 @@ __be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) · 10 unmodified lines | ||
| 926 | 965 | { |
| 927 | 966 | __be32 *p; |
| 928 | 967 | |
| 929 | − if (nbytes == 0) | |
| 968 | + if (unlikely(nbytes == 0)) | |
| 930 | 969 | return xdr->p; |
| 931 | 970 | if (xdr->p == xdr->end && !xdr_set_next_buffer(xdr)) |
| 932 | − return NULL; | |
| 971 | + goto out_overflow; | |
| 933 | 972 | p = __xdr_inline_decode(xdr, nbytes); |
| 934 | 973 | if (p != NULL) |
| 935 | 974 | return p; |
| 936 | 975 | return xdr_copy_to_scratch(xdr, nbytes); |
| 976 | +out_overflow: | |
| 977 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 978 | + return NULL; | |
| 937 | 979 | } |
| 938 | 980 | EXPORT_SYMBOL_GPL(xdr_inline_decode); |
| 939 | 981 | |
| @@ -943,13 +985,17 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) · 3 unmodified lines | ||
| 943 | 985 | struct kvec *iov; |
| 944 | 986 | unsigned int nwords = XDR_QUADLEN(len); |
| 945 | 987 | unsigned int cur = xdr_stream_pos(xdr); |
| 988 | + unsigned int copied, offset; | |
| 946 | 989 | |
| 947 | 990 | if (xdr->nwords == 0) |
| 948 | 991 | return 0; |
| 992 | + | |
| 949 | 993 | /* Realign pages to current pointer position */ |
| 950 | − iov = buf->head; | |
| 994 | + iov = buf->head; | |
| 951 | 995 | if (iov->iov_len > cur) { |
| 952 | − xdr_shrink_bufhead(buf, iov->iov_len - cur); | |
| 996 | + offset = iov->iov_len - cur; | |
| 997 | + copied = xdr_shrink_bufhead(buf, offset); | |
| 998 | + trace_rpc_xdr_alignment(xdr, offset, copied); | |
| 953 | 999 | xdr->nwords = XDR_QUADLEN(buf->len - cur); |
| 954 | 1000 | } |
| 955 | 1001 | |
| @@ -961,7 +1007,9 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) · 5 unmodified lines | ||
| 961 | 1007 | len = buf->page_len; |
| 962 | 1008 | else if (nwords < xdr->nwords) { |
| 963 | 1009 | /* Truncate page data and move it into the tail */ |
| 964 | − xdr_shrink_pagelen(buf, buf->page_len - len); | |
| 1010 | + offset = buf->page_len - len; | |
| 1011 | + copied = xdr_shrink_pagelen(buf, offset); | |
| 1012 | + trace_rpc_xdr_alignment(xdr, offset, copied); | |
| 965 | 1013 | xdr->nwords = XDR_QUADLEN(buf->len - cur); |
| 966 | 1014 | } |
| 967 | 1015 | return len; |
| @@ -1102,47 +1150,6 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, · 134 unmodified lines | ||
| 1102 | 1150 | } |
| 1103 | 1151 | EXPORT_SYMBOL_GPL(xdr_buf_subsegment); |
| 1104 | 1152 | |
| 1105 | −/** | |
| 1106 | − * xdr_buf_trim - lop at most "len" bytes off the end of "buf" | |
| 1107 | − * @buf: buf to be trimmed | |
| 1108 | − * @len: number of bytes to reduce "buf" by | |
| 1109 | − * | |
| 1110 | − * Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note | |
| 1111 | − * that it's possible that we'll trim less than that amount if the xdr_buf is | |
| 1112 | − * too small, or if (for instance) it's all in the head and the parser has | |
| 1113 | − * already read too far into it. | |
| 1114 | − */ | |
| 1115 | −void xdr_buf_trim(struct xdr_buf *buf, unsigned int len) | |
| 1116 | −{ | |
| 1117 | − size_t cur; | |
| 1118 | − unsigned int trim = len; | |
| 1119 | − | |
| 1120 | − if (buf->tail[0].iov_len) { | |
| 1121 | − cur = min_t(size_t, buf->tail[0].iov_len, trim); | |
| 1122 | − buf->tail[0].iov_len -= cur; | |
| 1123 | − trim -= cur; | |
| 1124 | − if (!trim) | |
| 1125 | − goto fix_len; | |
| 1126 | − } | |
| 1127 | − | |
| 1128 | − if (buf->page_len) { | |
| 1129 | − cur = min_t(unsigned int, buf->page_len, trim); | |
| 1130 | − buf->page_len -= cur; | |
| 1131 | − trim -= cur; | |
| 1132 | − if (!trim) | |
| 1133 | − goto fix_len; | |
| 1134 | − } | |
| 1135 | − | |
| 1136 | − if (buf->head[0].iov_len) { | |
| 1137 | − cur = min_t(size_t, buf->head[0].iov_len, trim); | |
| 1138 | − buf->head[0].iov_len -= cur; | |
| 1139 | − trim -= cur; | |
| 1140 | − } | |
| 1141 | −fix_len: | |
| 1142 | − buf->len -= (len - trim); | |
| 1143 | −} | |
| 1144 | −EXPORT_SYMBOL_GPL(xdr_buf_trim); | |
| 1145 | − | |
| 1146 | 1153 | static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len) |
| 1147 | 1154 | { |
| 1148 | 1155 | unsigned int this_len; |
| @@ -49,6 +49,7 @@ · 48 unmodified lines | ||
| 49 | 49 | #include <linux/sunrpc/metrics.h> |
| 50 | 50 | #include <linux/sunrpc/bc_xprt.h> |
| 51 | 51 | #include <linux/rcupdate.h> |
| 52 | +#include <linux/sched/mm.h> | |
| 52 | 53 | |
| 53 | 54 | #include <trace/events/sunrpc.h> |
| 54 | 55 | |
| @@ -643,11 +644,13 @@ static void xprt_autoclose(struct work_struct *work) · 588 unmodified lines | ||
| 643 | 644 | { |
| 644 | 645 | struct rpc_xprt *xprt = |
| 645 | 646 | container_of(work, struct rpc_xprt, task_cleanup); |
| 647 | + unsigned int pflags = memalloc_nofs_save(); | |
| 646 | 648 | |
| 647 | 649 | clear_bit(XPRT_CLOSE_WAIT, &xprt->state); |
| 648 | 650 | xprt->ops->close(xprt); |
| 649 | 651 | xprt_release_write(xprt, NULL); |
| 650 | 652 | wake_up_bit(&xprt->state, XPRT_LOCKED); |
| 653 | + memalloc_nofs_restore(pflags); | |
| 651 | 654 | } |
| 652 | 655 | |
| 653 | 656 | /** |
| @@ -1165,6 +1168,7 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 511 unmodified lines | ||
| 1165 | 1168 | /* Note: req is added _before_ pos */ |
| 1166 | 1169 | list_add_tail(&req->rq_xmit, &pos->rq_xmit); |
| 1167 | 1170 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1171 | + trace_xprt_enq_xmit(task, 1); | |
| 1168 | 1172 | goto out; |
| 1169 | 1173 | } |
| 1170 | 1174 | } else if (RPC_IS_SWAPPER(task)) { |
| @@ -1176,6 +1180,7 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 5 unmodified lines | ||
| 1176 | 1180 | /* Note: req is added _before_ pos */ |
| 1177 | 1181 | list_add_tail(&req->rq_xmit, &pos->rq_xmit); |
| 1178 | 1182 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1183 | + trace_xprt_enq_xmit(task, 2); | |
| 1179 | 1184 | goto out; |
| 1180 | 1185 | } |
| 1181 | 1186 | } else if (!req->rq_seqno) { |
| @@ -1184,11 +1189,13 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 2 unmodified lines | ||
| 1184 | 1189 | continue; |
| 1185 | 1190 | list_add_tail(&req->rq_xmit2, &pos->rq_xmit2); |
| 1186 | 1191 | INIT_LIST_HEAD(&req->rq_xmit); |
| 1192 | + trace_xprt_enq_xmit(task, 3); | |
| 1187 | 1193 | goto out; |
| 1188 | 1194 | } |
| 1189 | 1195 | } |
| 1190 | 1196 | list_add_tail(&req->rq_xmit, &xprt->xmit_queue); |
| 1191 | 1197 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1198 | + trace_xprt_enq_xmit(task, 4); | |
| 1192 | 1199 | out: |
| 1193 | 1200 | set_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate); |
| 1194 | 1201 | spin_unlock(&xprt->queue_lock); |
| @@ -1313,8 +1320,6 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 118 unmodified lines | ||
| 1313 | 1320 | int is_retrans = RPC_WAS_SENT(task); |
| 1314 | 1321 | int status; |
| 1315 | 1322 | |
| 1316 | − dprintk("RPC: %5u xprt_transmit(%u)\n", task->tk_pid, req->rq_slen); | |
| 1317 | − | |
| 1318 | 1323 | if (!req->rq_bytes_sent) { |
| 1319 | 1324 | if (xprt_request_data_received(task)) { |
| 1320 | 1325 | status = 0; |
| @@ -1325,6 +1330,13 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 4 unmodified lines | ||
| 1325 | 1330 | status = -EBADMSG; |
| 1326 | 1331 | goto out_dequeue; |
| 1327 | 1332 | } |
| 1333 | + if (task->tk_ops->rpc_call_prepare_transmit) { | |
| 1334 | + task->tk_ops->rpc_call_prepare_transmit(task, | |
| 1335 | + task->tk_calldata); | |
| 1336 | + status = task->tk_status; | |
| 1337 | + if (status < 0) | |
| 1338 | + goto out_dequeue; | |
| 1339 | + } | |
| 1328 | 1340 | } |
| 1329 | 1341 | |
| 1330 | 1342 | /* |
| @@ -1336,9 +1348,9 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 5 unmodified lines | ||
| 1336 | 1348 | |
| 1337 | 1349 | connect_cookie = xprt->connect_cookie; |
| 1338 | 1350 | status = xprt->ops->send_request(req); |
| 1339 | − trace_xprt_transmit(xprt, req->rq_xid, status); | |
| 1340 | 1351 | if (status != 0) { |
| 1341 | 1352 | req->rq_ntrans--; |
| 1353 | + trace_xprt_transmit(req, status); | |
| 1342 | 1354 | return status; |
| 1343 | 1355 | } |
| 1344 | 1356 | |
| @@ -1347,7 +1359,6 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 2 unmodified lines | ||
| 1347 | 1359 | |
| 1348 | 1360 | xprt_inject_disconnect(xprt); |
| 1349 | 1361 | |
| 1350 | − dprintk("RPC: %5u xmit complete\n", task->tk_pid); | |
| 1351 | 1362 | task->tk_flags |= RPC_TASK_SENT; |
| 1352 | 1363 | spin_lock_bh(&xprt->transport_lock); |
| 1353 | 1364 | |
| @@ -1360,6 +1371,7 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 6 unmodified lines | ||
| 1360 | 1371 | |
| 1361 | 1372 | req->rq_connect_cookie = connect_cookie; |
| 1362 | 1373 | out_dequeue: |
| 1374 | + trace_xprt_transmit(req, status); | |
| 1363 | 1375 | xprt_request_dequeue_transmit(task); |
| 1364 | 1376 | rpc_wake_up_queued_task_set_status(&xprt->sending, task, status); |
| 1365 | 1377 | return status; |
| @@ -1599,7 +1611,6 @@ xprt_request_init(struct rpc_task *task) · 233 unmodified lines | ||
| 1599 | 1611 | req->rq_buffer = NULL; |
| 1600 | 1612 | req->rq_xid = xprt_alloc_xid(xprt); |
| 1601 | 1613 | xprt_init_connect_cookie(req, xprt); |
| 1602 | − req->rq_bytes_sent = 0; | |
| 1603 | 1614 | req->rq_snd_buf.len = 0; |
| 1604 | 1615 | req->rq_snd_buf.buflen = 0; |
| 1605 | 1616 | req->rq_rcv_buf.len = 0; |
| @@ -1721,6 +1732,7 @@ void xprt_release(struct rpc_task *task) · 115 unmodified lines | ||
| 1721 | 1732 | xprt->ops->buf_free(task); |
| 1722 | 1733 | xprt_inject_disconnect(xprt); |
| 1723 | 1734 | xdr_free_bvec(&req->rq_rcv_buf); |
| 1735 | + xdr_free_bvec(&req->rq_snd_buf); | |
| 1724 | 1736 | if (req->rq_cred != NULL) |
| 1725 | 1737 | put_rpccred(req->rq_cred); |
| 1726 | 1738 | task->tk_rqstp = NULL; |
| @@ -1749,7 +1761,6 @@ xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task) · 22 unmodified lines | ||
| 1749 | 1761 | */ |
| 1750 | 1762 | xbufp->len = xbufp->head[0].iov_len + xbufp->page_len + |
| 1751 | 1763 | xbufp->tail[0].iov_len; |
| 1752 | − req->rq_bytes_sent = 0; | |
| 1753 | 1764 | } |
| 1754 | 1765 | #endif |
| 1755 | 1766 | |
| @@ -123,7 +123,7 @@ static int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst) · 122 unmodified lines | ||
| 123 | 123 | |
| 124 | 124 | rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0); |
| 125 | 125 | xdr_init_encode(&req->rl_stream, &req->rl_hdrbuf, |
| 126 | − req->rl_rdmabuf->rg_base); | |
| 126 | + req->rl_rdmabuf->rg_base, rqst); | |
| 127 | 127 | |
| 128 | 128 | p = xdr_reserve_space(&req->rl_stream, 28); |
| 129 | 129 | if (unlikely(!p)) |
| @@ -267,7 +267,6 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt, · 137 unmodified lines | ||
| 267 | 267 | |
| 268 | 268 | /* Prepare rqst */ |
| 269 | 269 | rqst->rq_reply_bytes_recvd = 0; |
| 270 | − rqst->rq_bytes_sent = 0; | |
| 271 | 270 | rqst->rq_xid = *p; |
| 272 | 271 | |
| 273 | 272 | rqst->rq_private_buf.len = size; |
| @@ -391,7 +391,7 @@ frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc) · 390 unmodified lines | ||
| 391 | 391 | */ |
| 392 | 392 | struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, |
| 393 | 393 | struct rpcrdma_mr_seg *seg, |
| 394 | − int nsegs, bool writing, u32 xid, | |
| 394 | + int nsegs, bool writing, __be32 xid, | |
| 395 | 395 | struct rpcrdma_mr **out) |
| 396 | 396 | { |
| 397 | 397 | struct rpcrdma_ia *ia = &r_xprt->rx_ia; |
| @@ -446,7 +446,7 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, · 48 unmodified lines | ||
| 446 | 446 | goto out_mapmr_err; |
| 447 | 447 | |
| 448 | 448 | ibmr->iova &= 0x00000000ffffffff; |
| 449 | − ibmr->iova |= ((u64)cpu_to_be32(xid)) << 32; | |
| 449 | + ibmr->iova |= ((u64)be32_to_cpu(xid)) << 32; | |
| 450 | 450 | key = (u8)(ibmr->rkey & 0x000000FF); |
| 451 | 451 | ib_update_fast_reg_key(ibmr, ++key); |
| 452 | 452 | |
| @@ -164,6 +164,21 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, · 163 unmodified lines | ||
| 164 | 164 | return rqst->rq_rcv_buf.buflen <= ia->ri_max_inline_read; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | +/* The client is required to provide a Reply chunk if the maximum | |
| 168 | + * size of the non-payload part of the RPC Reply is larger than | |
| 169 | + * the inline threshold. | |
| 170 | + */ | |
| 171 | +static bool | |
| 172 | +rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt, | |
| 173 | + const struct rpc_rqst *rqst) | |
| 174 | +{ | |
| 175 | + const struct xdr_buf *buf = &rqst->rq_rcv_buf; | |
| 176 | + const struct rpcrdma_ia *ia = &r_xprt->rx_ia; | |
| 177 | + | |
| 178 | + return buf->head[0].iov_len + buf->tail[0].iov_len < | |
| 179 | + ia->ri_max_inline_read; | |
| 180 | +} | |
| 181 | + | |
| 167 | 182 | /* Split @vec on page boundaries into SGEs. FMR registers pages, not |
| 168 | 183 | * a byte range. Other modes coalesce these SGEs into a single MR |
| 169 | 184 | * when they can. |
| @@ -733,7 +748,7 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst) · 563 unmodified lines | ||
| 733 | 748 | |
| 734 | 749 | rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0); |
| 735 | 750 | xdr_init_encode(xdr, &req->rl_hdrbuf, |
| 736 | − req->rl_rdmabuf->rg_base); | |
| 751 | + req->rl_rdmabuf->rg_base, rqst); | |
| 737 | 752 | |
| 738 | 753 | /* Fixed header fields */ |
| 739 | 754 | ret = -EMSGSIZE; |
| @@ -762,7 +777,8 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst) · 22 unmodified lines | ||
| 762 | 777 | */ |
| 763 | 778 | if (rpcrdma_results_inline(r_xprt, rqst)) |
| 764 | 779 | wtype = rpcrdma_noch; |
| 765 | − else if (ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ) | |
| 780 | + else if ((ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ) && | |
| 781 | + rpcrdma_nonpayload_inline(r_xprt, rqst)) | |
| 766 | 782 | wtype = rpcrdma_writech; |
| 767 | 783 | else |
| 768 | 784 | wtype = rpcrdma_replych; |
| @@ -1313,7 +1329,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep) · 544 unmodified lines | ||
| 1313 | 1329 | |
| 1314 | 1330 | /* Fixed transport header fields */ |
| 1315 | 1331 | xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf, |
| 1316 | − rep->rr_hdrbuf.head[0].iov_base); | |
| 1332 | + rep->rr_hdrbuf.head[0].iov_base, NULL); | |
| 1317 | 1333 | p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p)); |
| 1318 | 1334 | if (unlikely(!p)) |
| 1319 | 1335 | goto out_shortreply; |
| @@ -304,7 +304,6 @@ xprt_setup_rdma_bc(struct xprt_create *args) · 303 unmodified lines | ||
| 304 | 304 | xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO; |
| 305 | 305 | |
| 306 | 306 | xprt->prot = XPRT_TRANSPORT_BC_RDMA; |
| 307 | − xprt->tsh_size = 0; | |
| 308 | 307 | xprt->ops = &xprt_rdma_bc_procs; |
| 309 | 308 | |
| 310 | 309 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); |
| @@ -332,7 +332,6 @@ xprt_setup_rdma(struct xprt_create *args) · 331 unmodified lines | ||
| 332 | 332 | xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO; |
| 333 | 333 | |
| 334 | 334 | xprt->resvport = 0; /* privileged port not needed */ |
| 335 | − xprt->tsh_size = 0; /* RPC-RDMA handles framing */ | |
| 336 | 335 | xprt->ops = &xprt_rdma_procs; |
| 337 | 336 | |
| 338 | 337 | /* |
| @@ -738,7 +737,6 @@ xprt_rdma_send_request(struct rpc_rqst *rqst) · 399 unmodified lines | ||
| 738 | 737 | goto drop_connection; |
| 739 | 738 | |
| 740 | 739 | rqst->rq_xmit_bytes_sent += rqst->rq_snd_buf.len; |
| 741 | − rqst->rq_bytes_sent = 0; | |
| 742 | 740 | |
| 743 | 741 | /* An RPC with no reply will throw off credit accounting, |
| 744 | 742 | * so drop the connection to reset the credit grant. |
| @@ -1481,6 +1481,8 @@ rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp) · 1480 unmodified lines | ||
| 1481 | 1481 | if (ep->rep_receive_count > needed) |
| 1482 | 1482 | goto out; |
| 1483 | 1483 | needed -= ep->rep_receive_count; |
| 1484 | + if (!temp) | |
| 1485 | + needed += RPCRDMA_MAX_RECV_BATCH; | |
| 1484 | 1486 | |
| 1485 | 1487 | count = 0; |
| 1486 | 1488 | wr = NULL; |
| @@ -205,6 +205,16 @@ struct rpcrdma_rep { · 204 unmodified lines | ||
| 205 | 205 | struct ib_recv_wr rr_recv_wr; |
| 206 | 206 | }; |
| 207 | 207 | |
| 208 | +/* To reduce the rate at which a transport invokes ib_post_recv | |
| 209 | + * (and thus the hardware doorbell rate), xprtrdma posts Receive | |
| 210 | + * WRs in batches. | |
| 211 | + * | |
| 212 | + * Setting this to zero disables Receive post batching. | |
| 213 | + */ | |
| 214 | +enum { | |
| 215 | + RPCRDMA_MAX_RECV_BATCH = 7, | |
| 216 | +}; | |
| 217 | + | |
| 208 | 218 | /* struct rpcrdma_sendctx - DMA mapped SGEs to unmap after Send completes |
| 209 | 219 | */ |
| 210 | 220 | struct rpcrdma_req; |
| @@ -577,7 +587,7 @@ void frwr_release_mr(struct rpcrdma_mr *mr); · 366 unmodified lines | ||
| 577 | 587 | size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt); |
| 578 | 588 | struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, |
| 579 | 589 | struct rpcrdma_mr_seg *seg, |
| 580 | − int nsegs, bool writing, u32 xid, | |
| 590 | + int nsegs, bool writing, __be32 xid, | |
| 581 | 591 | struct rpcrdma_mr **mr); |
| 582 | 592 | int frwr_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req); |
| 583 | 593 | void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs); |
| @@ -50,6 +50,7 @@ · 49 unmodified lines | ||
| 50 | 50 | #include <linux/bvec.h> |
| 51 | 51 | #include <linux/highmem.h> |
| 52 | 52 | #include <linux/uio.h> |
| 53 | +#include <linux/sched/mm.h> | |
| 53 | 54 | |
| 54 | 55 | #include <trace/events/sunrpc.h> |
| 55 | 56 | |
| @@ -404,8 +405,8 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags, · 348 unmodified lines | ||
| 404 | 405 | size_t want, seek_init = seek, offset = 0; |
| 405 | 406 | ssize_t ret; |
| 406 | 407 | |
| 407 | − if (seek < buf->head[0].iov_len) { | |
| 408 | − want = min_t(size_t, count, buf->head[0].iov_len); | |
| 408 | + want = min_t(size_t, count, buf->head[0].iov_len); | |
| 409 | + if (seek < want) { | |
| 409 | 410 | ret = xs_read_kvec(sock, msg, flags, &buf->head[0], want, seek); |
| 410 | 411 | if (ret <= 0) |
| 411 | 412 | goto sock_err; |
| @@ -416,13 +417,13 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags, · 4 unmodified lines | ||
| 416 | 417 | goto out; |
| 417 | 418 | seek = 0; |
| 418 | 419 | } else { |
| 419 | − seek -= buf->head[0].iov_len; | |
| 420 | − offset += buf->head[0].iov_len; | |
| 420 | + seek -= want; | |
| 421 | + offset += want; | |
| 421 | 422 | } |
| 422 | 423 | |
| 423 | 424 | want = xs_alloc_sparse_pages(buf, |
| 424 | 425 | min_t(size_t, count - offset, buf->page_len), |
| 425 | − GFP_NOWAIT); | |
| 426 | + GFP_KERNEL); | |
| 426 | 427 | if (seek < want) { |
| 427 | 428 | ret = xs_read_bvec(sock, msg, flags, buf->bvec, |
| 428 | 429 | xdr_buf_pagecount(buf), |
| @@ -442,8 +443,8 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags, · 13 unmodified lines | ||
| 442 | 443 | offset += want; |
| 443 | 444 | } |
| 444 | 445 | |
| 445 | − if (seek < buf->tail[0].iov_len) { | |
| 446 | − want = min_t(size_t, count - offset, buf->tail[0].iov_len); | |
| 446 | + want = min_t(size_t, count - offset, buf->tail[0].iov_len); | |
| 447 | + if (seek < want) { | |
| 447 | 448 | ret = xs_read_kvec(sock, msg, flags, &buf->tail[0], want, seek); |
| 448 | 449 | if (ret <= 0) |
| 449 | 450 | goto sock_err; |
| @@ -453,7 +454,7 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags, · 3 unmodified lines | ||
| 453 | 454 | if (ret != want) |
| 454 | 455 | goto out; |
| 455 | 456 | } else |
| 456 | − offset += buf->tail[0].iov_len; | |
| 457 | + offset = seek_init; | |
| 457 | 458 | ret = -EMSGSIZE; |
| 458 | 459 | out: |
| 459 | 460 | *read = offset - seek_init; |
| @@ -481,6 +482,14 @@ xs_read_stream_request_done(struct sock_xprt *transport) · 21 unmodified lines | ||
| 481 | 482 | return transport->recv.fraghdr & cpu_to_be32(RPC_LAST_STREAM_FRAGMENT); |
| 482 | 483 | } |
| 483 | 484 | |
| 485 | +static void | |
| 486 | +xs_read_stream_check_eor(struct sock_xprt *transport, | |
| 487 | + struct msghdr *msg) | |
| 488 | +{ | |
| 489 | + if (xs_read_stream_request_done(transport)) | |
| 490 | + msg->msg_flags |= MSG_EOR; | |
| 491 | +} | |
| 492 | + | |
| 484 | 493 | static ssize_t |
| 485 | 494 | xs_read_stream_request(struct sock_xprt *transport, struct msghdr *msg, |
| 486 | 495 | int flags, struct rpc_rqst *req) |
| @@ -492,17 +501,21 @@ xs_read_stream_request(struct sock_xprt *transport, struct msghdr *msg, · 5 unmodified lines | ||
| 492 | 501 | xs_read_header(transport, buf); |
| 493 | 502 | |
| 494 | 503 | want = transport->recv.len - transport->recv.offset; |
| 495 | − ret = xs_read_xdr_buf(transport->sock, msg, flags, buf, | |
| 496 | − transport->recv.copied + want, transport->recv.copied, | |
| 497 | − &read); | |
| 498 | − transport->recv.offset += read; | |
| 499 | − transport->recv.copied += read; | |
| 500 | − if (transport->recv.offset == transport->recv.len) { | |
| 501 | − if (xs_read_stream_request_done(transport)) | |
| 502 | − msg->msg_flags |= MSG_EOR; | |
| 503 | − return read; | |
| 504 | + if (want != 0) { | |
| 505 | + ret = xs_read_xdr_buf(transport->sock, msg, flags, buf, | |
| 506 | + transport->recv.copied + want, | |
| 507 | + transport->recv.copied, | |
| 508 | + &read); | |
| 509 | + transport->recv.offset += read; | |
| 510 | + transport->recv.copied += read; | |
| 504 | 511 | } |
| 505 | 512 | |
| 513 | + if (transport->recv.offset == transport->recv.len) | |
| 514 | + xs_read_stream_check_eor(transport, msg); | |
| 515 | + | |
| 516 | + if (want == 0) | |
| 517 | + return 0; | |
| 518 | + | |
| 506 | 519 | switch (ret) { |
| 507 | 520 | default: |
| 508 | 521 | break; |
| @@ -655,13 +668,35 @@ out_err: · 146 unmodified lines | ||
| 655 | 668 | return ret != 0 ? ret : -ESHUTDOWN; |
| 656 | 669 | } |
| 657 | 670 | |
| 671 | +static __poll_t xs_poll_socket(struct sock_xprt *transport) | |
| 672 | +{ | |
| 673 | + return transport->sock->ops->poll(transport->file, transport->sock, | |
| 674 | + NULL); | |
| 675 | +} | |
| 676 | + | |
| 677 | +static bool xs_poll_socket_readable(struct sock_xprt *transport) | |
| 678 | +{ | |
| 679 | + __poll_t events = xs_poll_socket(transport); | |
| 680 | + | |
| 681 | + return (events & (EPOLLIN | EPOLLRDNORM)) && !(events & EPOLLRDHUP); | |
| 682 | +} | |
| 683 | + | |
| 684 | +static void xs_poll_check_readable(struct sock_xprt *transport) | |
| 685 | +{ | |
| 686 | + | |
| 687 | + clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); | |
| 688 | + if (!xs_poll_socket_readable(transport)) | |
| 689 | + return; | |
| 690 | + if (!test_and_set_bit(XPRT_SOCK_DATA_READY, &transport->sock_state)) | |
| 691 | + queue_work(xprtiod_workqueue, &transport->recv_worker); | |
| 692 | +} | |
| 693 | + | |
| 658 | 694 | static void xs_stream_data_receive(struct sock_xprt *transport) |
| 659 | 695 | { |
| 660 | 696 | size_t read = 0; |
| 661 | 697 | ssize_t ret = 0; |
| 662 | 698 | |
| 663 | 699 | mutex_lock(&transport->recv_mutex); |
| 664 | − clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); | |
| 665 | 700 | if (transport->sock == NULL) |
| 666 | 701 | goto out; |
| 667 | 702 | for (;;) { |
| @@ -671,6 +706,10 @@ static void xs_stream_data_receive(struct sock_xprt *transport) · 3 unmodified lines | ||
| 671 | 706 | read += ret; |
| 672 | 707 | cond_resched(); |
| 673 | 708 | } |
| 709 | + if (ret == -ESHUTDOWN) | |
| 710 | + kernel_sock_shutdown(transport->sock, SHUT_RDWR); | |
| 711 | + else | |
| 712 | + xs_poll_check_readable(transport); | |
| 674 | 713 | out: |
| 675 | 714 | mutex_unlock(&transport->recv_mutex); |
| 676 | 715 | trace_xs_stream_read_data(&transport->xprt, ret, read); |
| @@ -680,7 +719,10 @@ static void xs_stream_data_receive_workfn(struct work_struct *work) · 3 unmodified lines | ||
| 680 | 719 | { |
| 681 | 720 | struct sock_xprt *transport = |
| 682 | 721 | container_of(work, struct sock_xprt, recv_worker); |
| 722 | + unsigned int pflags = memalloc_nofs_save(); | |
| 723 | + | |
| 683 | 724 | xs_stream_data_receive(transport); |
| 725 | + memalloc_nofs_restore(pflags); | |
| 684 | 726 | } |
| 685 | 727 | |
| 686 | 728 | static void |
| @@ -690,65 +732,65 @@ xs_stream_reset_connect(struct sock_xprt *transport) · 3 unmodified lines | ||
| 690 | 732 | transport->recv.len = 0; |
| 691 | 733 | transport->recv.copied = 0; |
| 692 | 734 | transport->xmit.offset = 0; |
| 735 | +} | |
| 736 | + | |
| 737 | +static void | |
| 738 | +xs_stream_start_connect(struct sock_xprt *transport) | |
| 739 | +{ | |
| 693 | 740 | transport->xprt.stat.connect_count++; |
| 694 | 741 | transport->xprt.stat.connect_start = jiffies; |
| 695 | 742 | } |
| 696 | 743 | |
| 697 | 744 | #define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL) |
| 698 | 745 | |
| 699 | −static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen, struct kvec *vec, unsigned int base, int more) | |
| 746 | +static int xs_sendmsg(struct socket *sock, struct msghdr *msg, size_t seek) | |
| 700 | 747 | { |
| 701 | − struct msghdr msg = { | |
| 702 | − .msg_name = addr, | |
| 703 | − .msg_namelen = addrlen, | |
| 704 | − .msg_flags = XS_SENDMSG_FLAGS | (more ? MSG_MORE : 0), | |
| 705 | − }; | |
| 706 | − struct kvec iov = { | |
| 707 | − .iov_base = vec->iov_base + base, | |
| 708 | − .iov_len = vec->iov_len - base, | |
| 709 | − }; | |
| 748 | + if (seek) | |
| 749 | + iov_iter_advance(&msg->msg_iter, seek); | |
| 750 | + return sock_sendmsg(sock, msg); | |
| 751 | +} | |
| 710 | 752 | |
| 711 | − if (iov.iov_len != 0) | |
| 712 | − return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len); | |
| 713 | − return kernel_sendmsg(sock, &msg, NULL, 0, 0); | |
| 753 | +static int xs_send_kvec(struct socket *sock, struct msghdr *msg, struct kvec *vec, size_t seek) | |
| 754 | +{ | |
| 755 | + iov_iter_kvec(&msg->msg_iter, WRITE, vec, 1, vec->iov_len); | |
| 756 | + return xs_sendmsg(sock, msg, seek); | |
| 714 | 757 | } |
| 715 | 758 | |
| 716 | −static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy, int *sent_p) | |
| 759 | +static int xs_send_pagedata(struct socket *sock, struct msghdr *msg, struct xdr_buf *xdr, size_t base) | |
| 717 | 760 | { |
| 718 | − ssize_t (*do_sendpage)(struct socket *sock, struct page *page, | |
| 719 | − int offset, size_t size, int flags); | |
| 720 | − struct page **ppage; | |
| 721 | − unsigned int remainder; | |
| 722 | 761 | int err; |
| 723 | 762 | |
| 724 | − remainder = xdr->page_len - base; | |
| 725 | − base += xdr->page_base; | |
| 726 | − ppage = xdr->pages + (base >> PAGE_SHIFT); | |
| 727 | − base &= ~PAGE_MASK; | |
| 728 | − do_sendpage = sock->ops->sendpage; | |
| 729 | − if (!zerocopy) | |
| 730 | − do_sendpage = sock_no_sendpage; | |
| 731 | − for(;;) { | |
| 732 | − unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder); | |
| 733 | − int flags = XS_SENDMSG_FLAGS; | |
| 763 | + err = xdr_alloc_bvec(xdr, GFP_KERNEL); | |
| 764 | + if (err < 0) | |
| 765 | + return err; | |
| 734 | 766 | |
| 735 | − remainder -= len; | |
| 736 | − if (more) | |
| 737 | − flags |= MSG_MORE; | |
| 738 | − if (remainder != 0) | |
| 739 | − flags |= MSG_SENDPAGE_NOTLAST | MSG_MORE; | |
| 740 | − err = do_sendpage(sock, *ppage, base, len, flags); | |
| 741 | − if (remainder == 0 || err != len) | |
| 742 | − break; | |
| 743 | − *sent_p += err; | |
| 744 | − ppage++; | |
| 745 | − base = 0; | |
| 746 | − } | |
| 747 | − if (err > 0) { | |
| 748 | − *sent_p += err; | |
| 749 | − err = 0; | |
| 750 | − } | |
| 751 | − return err; | |
| 767 | + iov_iter_bvec(&msg->msg_iter, WRITE, xdr->bvec, | |
| 768 | + xdr_buf_pagecount(xdr), | |
| 769 | + xdr->page_len + xdr->page_base); | |
| 770 | + return xs_sendmsg(sock, msg, base + xdr->page_base); | |
| 771 | +} | |
| 772 | + | |
| 773 | +#define xs_record_marker_len() sizeof(rpc_fraghdr) | |
| 774 | + | |
| 775 | +/* Common case: | |
| 776 | + * - stream transport | |
| 777 | + * - sending from byte 0 of the message | |
| 778 | + * - the message is wholly contained in @xdr's head iovec | |
| 779 | + */ | |
| 780 | +static int xs_send_rm_and_kvec(struct socket *sock, struct msghdr *msg, | |
| 781 | + rpc_fraghdr marker, struct kvec *vec, size_t base) | |
| 782 | +{ | |
| 783 | + struct kvec iov[2] = { | |
| 784 | + [0] = { | |
| 785 | + .iov_base = &marker, | |
| 786 | + .iov_len = sizeof(marker) | |
| 787 | + }, | |
| 788 | + [1] = *vec, | |
| 789 | + }; | |
| 790 | + size_t len = iov[0].iov_len + iov[1].iov_len; | |
| 791 | + | |
| 792 | + iov_iter_kvec(&msg->msg_iter, WRITE, iov, 2, len); | |
| 793 | + return xs_sendmsg(sock, msg, base); | |
| 752 | 794 | } |
| 753 | 795 | |
| 754 | 796 | /** |
| @@ -758,49 +800,60 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i · 3 unmodified lines | ||
| 758 | 800 | * @addrlen: UDP only -- length of destination address |
| 759 | 801 | * @xdr: buffer containing this request |
| 760 | 802 | * @base: starting position in the buffer |
| 761 | − * @zerocopy: true if it is safe to use sendpage() | |
| 803 | + * @rm: stream record marker field | |
| 762 | 804 | * @sent_p: return the total number of bytes successfully queued for sending |
| 763 | 805 | * |
| 764 | 806 | */ |
| 765 | −static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy, int *sent_p) | |
| 807 | +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, rpc_fraghdr rm, int *sent_p) | |
| 766 | 808 | { |
| 767 | − unsigned int remainder = xdr->len - base; | |
| 809 | + struct msghdr msg = { | |
| 810 | + .msg_name = addr, | |
| 811 | + .msg_namelen = addrlen, | |
| 812 | + .msg_flags = XS_SENDMSG_FLAGS | MSG_MORE, | |
| 813 | + }; | |
| 814 | + unsigned int rmsize = rm ? sizeof(rm) : 0; | |
| 815 | + unsigned int remainder = rmsize + xdr->len - base; | |
| 816 | + unsigned int want; | |
| 768 | 817 | int err = 0; |
| 769 | − int sent = 0; | |
| 770 | 818 | |
| 771 | 819 | if (unlikely(!sock)) |
| 772 | 820 | return -ENOTSOCK; |
| 773 | 821 | |
| 774 | − if (base != 0) { | |
| 775 | − addr = NULL; | |
| 776 | − addrlen = 0; | |
| 777 | − } | |
| 778 | − | |
| 779 | − if (base < xdr->head[0].iov_len || addr != NULL) { | |
| 780 | − unsigned int len = xdr->head[0].iov_len - base; | |
| 822 | + want = xdr->head[0].iov_len + rmsize; | |
| 823 | + if (base < want) { | |
| 824 | + unsigned int len = want - base; | |
| 781 | 825 | remainder -= len; |
| 782 | − err = xs_send_kvec(sock, addr, addrlen, &xdr->head[0], base, remainder != 0); | |
| 826 | + if (remainder == 0) | |
| 827 | + msg.msg_flags &= ~MSG_MORE; | |
| 828 | + if (rmsize) | |
| 829 | + err = xs_send_rm_and_kvec(sock, &msg, rm, | |
| 830 | + &xdr->head[0], base); | |
| 831 | + else | |
| 832 | + err = xs_send_kvec(sock, &msg, &xdr->head[0], base); | |
| 783 | 833 | if (remainder == 0 || err != len) |
| 784 | 834 | goto out; |
| 785 | 835 | *sent_p += err; |
| 786 | 836 | base = 0; |
| 787 | 837 | } else |
| 788 | − base -= xdr->head[0].iov_len; | |
| 838 | + base -= want; | |
| 789 | 839 | |
| 790 | 840 | if (base < xdr->page_len) { |
| 791 | 841 | unsigned int len = xdr->page_len - base; |
| 792 | 842 | remainder -= len; |
| 793 | − err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy, &sent); | |
| 794 | − *sent_p += sent; | |
| 795 | − if (remainder == 0 || sent != len) | |
| 843 | + if (remainder == 0) | |
| 844 | + msg.msg_flags &= ~MSG_MORE; | |
| 845 | + err = xs_send_pagedata(sock, &msg, xdr, base); | |
| 846 | + if (remainder == 0 || err != len) | |
| 796 | 847 | goto out; |
| 848 | + *sent_p += err; | |
| 797 | 849 | base = 0; |
| 798 | 850 | } else |
| 799 | 851 | base -= xdr->page_len; |
| 800 | 852 | |
| 801 | 853 | if (base >= xdr->tail[0].iov_len) |
| 802 | 854 | return 0; |
| 803 | − err = xs_send_kvec(sock, NULL, 0, &xdr->tail[0], base, 0); | |
| 855 | + msg.msg_flags &= ~MSG_MORE; | |
| 856 | + err = xs_send_kvec(sock, &msg, &xdr->tail[0], base); | |
| 804 | 857 | out: |
| 805 | 858 | if (err > 0) { |
| 806 | 859 | *sent_p += err; |
| @@ -856,7 +909,7 @@ static int xs_nospace(struct rpc_rqst *req) · 49 unmodified lines | ||
| 856 | 909 | static void |
| 857 | 910 | xs_stream_prepare_request(struct rpc_rqst *req) |
| 858 | 911 | { |
| 859 | − req->rq_task->tk_status = xdr_alloc_bvec(&req->rq_rcv_buf, GFP_NOIO); | |
| 912 | + req->rq_task->tk_status = xdr_alloc_bvec(&req->rq_rcv_buf, GFP_KERNEL); | |
| 860 | 913 | } |
| 861 | 914 | |
| 862 | 915 | /* |
| @@ -870,13 +923,14 @@ xs_send_request_was_aborted(struct sock_xprt *transport, struct rpc_rqst *req) · 7 unmodified lines | ||
| 870 | 923 | } |
| 871 | 924 | |
| 872 | 925 | /* |
| 873 | − * Construct a stream transport record marker in @buf. | |
| 926 | + * Return the stream record marker field for a record of length < 2^31-1 | |
| 874 | 927 | */ |
| 875 | −static inline void xs_encode_stream_record_marker(struct xdr_buf *buf) | |
| 928 | +static rpc_fraghdr | |
| 929 | +xs_stream_record_marker(struct xdr_buf *xdr) | |
| 876 | 930 | { |
| 877 | − u32 reclen = buf->len - sizeof(rpc_fraghdr); | |
| 878 | − rpc_fraghdr *base = buf->head[0].iov_base; | |
| 879 | − *base = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen); | |
| 931 | + if (!xdr->len) | |
| 932 | + return 0; | |
| 933 | + return cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | (u32)xdr->len); | |
| 880 | 934 | } |
| 881 | 935 | |
| 882 | 936 | /** |
| @@ -905,15 +959,14 @@ static int xs_local_send_request(struct rpc_rqst *req) · 22 unmodified lines | ||
| 905 | 959 | return -ENOTCONN; |
| 906 | 960 | } |
| 907 | 961 | |
| 908 | − xs_encode_stream_record_marker(&req->rq_snd_buf); | |
| 909 | − | |
| 910 | 962 | xs_pktdump("packet data:", |
| 911 | 963 | req->rq_svec->iov_base, req->rq_svec->iov_len); |
| 912 | 964 | |
| 913 | 965 | req->rq_xtime = ktime_get(); |
| 914 | 966 | status = xs_sendpages(transport->sock, NULL, 0, xdr, |
| 915 | 967 | transport->xmit.offset, |
| 916 | − true, &sent); | |
| 968 | + xs_stream_record_marker(xdr), | |
| 969 | + &sent); | |
| 917 | 970 | dprintk("RPC: %s(%u) = %d\n", |
| 918 | 971 | __func__, xdr->len - transport->xmit.offset, status); |
| 919 | 972 | |
| @@ -925,7 +978,6 @@ static int xs_local_send_request(struct rpc_rqst *req) · 5 unmodified lines | ||
| 925 | 978 | req->rq_bytes_sent = transport->xmit.offset; |
| 926 | 979 | if (likely(req->rq_bytes_sent >= req->rq_slen)) { |
| 927 | 980 | req->rq_xmit_bytes_sent += transport->xmit.offset; |
| 928 | − req->rq_bytes_sent = 0; | |
| 929 | 981 | transport->xmit.offset = 0; |
| 930 | 982 | return 0; |
| 931 | 983 | } |
| @@ -981,7 +1033,7 @@ static int xs_udp_send_request(struct rpc_rqst *req) · 49 unmodified lines | ||
| 981 | 1033 | |
| 982 | 1034 | req->rq_xtime = ktime_get(); |
| 983 | 1035 | status = xs_sendpages(transport->sock, xs_addr(xprt), xprt->addrlen, |
| 984 | − xdr, 0, true, &sent); | |
| 1036 | + xdr, 0, 0, &sent); | |
| 985 | 1037 | |
| 986 | 1038 | dprintk("RPC: xs_udp_send_request(%u) = %d\n", |
| 987 | 1039 | xdr->len, status); |
| @@ -1045,7 +1097,6 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 57 unmodified lines | ||
| 1045 | 1097 | struct rpc_xprt *xprt = req->rq_xprt; |
| 1046 | 1098 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); |
| 1047 | 1099 | struct xdr_buf *xdr = &req->rq_snd_buf; |
| 1048 | − bool zerocopy = true; | |
| 1049 | 1100 | bool vm_wait = false; |
| 1050 | 1101 | int status; |
| 1051 | 1102 | int sent; |
| @@ -1057,17 +1108,9 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 5 unmodified lines | ||
| 1057 | 1108 | return -ENOTCONN; |
| 1058 | 1109 | } |
| 1059 | 1110 | |
| 1060 | − xs_encode_stream_record_marker(&req->rq_snd_buf); | |
| 1061 | − | |
| 1062 | 1111 | xs_pktdump("packet data:", |
| 1063 | 1112 | req->rq_svec->iov_base, |
| 1064 | 1113 | req->rq_svec->iov_len); |
| 1065 | − /* Don't use zero copy if this is a resend. If the RPC call | |
| 1066 | − * completes while the socket holds a reference to the pages, | |
| 1067 | − * then we may end up resending corrupted data. | |
| 1068 | − */ | |
| 1069 | − if (req->rq_task->tk_flags & RPC_TASK_SENT) | |
| 1070 | − zerocopy = false; | |
| 1071 | 1114 | |
| 1072 | 1115 | if (test_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state)) |
| 1073 | 1116 | xs_tcp_set_socket_timeouts(xprt, transport->sock); |
| @@ -1080,7 +1123,8 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 6 unmodified lines | ||
| 1080 | 1123 | sent = 0; |
| 1081 | 1124 | status = xs_sendpages(transport->sock, NULL, 0, xdr, |
| 1082 | 1125 | transport->xmit.offset, |
| 1083 | − zerocopy, &sent); | |
| 1126 | + xs_stream_record_marker(xdr), | |
| 1127 | + &sent); | |
| 1084 | 1128 | |
| 1085 | 1129 | dprintk("RPC: xs_tcp_send_request(%u) = %d\n", |
| 1086 | 1130 | xdr->len - transport->xmit.offset, status); |
| @@ -1091,7 +1135,6 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 4 unmodified lines | ||
| 1091 | 1135 | req->rq_bytes_sent = transport->xmit.offset; |
| 1092 | 1136 | if (likely(req->rq_bytes_sent >= req->rq_slen)) { |
| 1093 | 1137 | req->rq_xmit_bytes_sent += transport->xmit.offset; |
| 1094 | − req->rq_bytes_sent = 0; | |
| 1095 | 1138 | transport->xmit.offset = 0; |
| 1096 | 1139 | return 0; |
| 1097 | 1140 | } |
| @@ -1211,6 +1254,7 @@ static void xs_reset_transport(struct sock_xprt *transport) · 113 unmodified lines | ||
| 1211 | 1254 | struct socket *sock = transport->sock; |
| 1212 | 1255 | struct sock *sk = transport->inet; |
| 1213 | 1256 | struct rpc_xprt *xprt = &transport->xprt; |
| 1257 | + struct file *filp = transport->file; | |
| 1214 | 1258 | |
| 1215 | 1259 | if (sk == NULL) |
| 1216 | 1260 | return; |
| @@ -1224,6 +1268,7 @@ static void xs_reset_transport(struct sock_xprt *transport) · 7 unmodified lines | ||
| 1224 | 1268 | write_lock_bh(&sk->sk_callback_lock); |
| 1225 | 1269 | transport->inet = NULL; |
| 1226 | 1270 | transport->sock = NULL; |
| 1271 | + transport->file = NULL; | |
| 1227 | 1272 | |
| 1228 | 1273 | sk->sk_user_data = NULL; |
| 1229 | 1274 | |
| @@ -1231,10 +1276,12 @@ static void xs_reset_transport(struct sock_xprt *transport) · 1 unmodified line | ||
| 1231 | 1276 | xprt_clear_connected(xprt); |
| 1232 | 1277 | write_unlock_bh(&sk->sk_callback_lock); |
| 1233 | 1278 | xs_sock_reset_connection_flags(xprt); |
| 1279 | + /* Reset stream record info */ | |
| 1280 | + xs_stream_reset_connect(transport); | |
| 1234 | 1281 | mutex_unlock(&transport->recv_mutex); |
| 1235 | 1282 | |
| 1236 | 1283 | trace_rpc_socket_close(xprt, sock); |
| 1237 | − sock_release(sock); | |
| 1284 | + fput(filp); | |
| 1238 | 1285 | |
| 1239 | 1286 | xprt_disconnect_done(xprt); |
| 1240 | 1287 | } |
| @@ -1358,7 +1405,6 @@ static void xs_udp_data_receive(struct sock_xprt *transport) · 117 unmodified lines | ||
| 1358 | 1405 | int err; |
| 1359 | 1406 | |
| 1360 | 1407 | mutex_lock(&transport->recv_mutex); |
| 1361 | − clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); | |
| 1362 | 1408 | sk = transport->inet; |
| 1363 | 1409 | if (sk == NULL) |
| 1364 | 1410 | goto out; |
| @@ -1370,6 +1416,7 @@ static void xs_udp_data_receive(struct sock_xprt *transport) · 5 unmodified lines | ||
| 1370 | 1416 | consume_skb(skb); |
| 1371 | 1417 | cond_resched(); |
| 1372 | 1418 | } |
| 1419 | + xs_poll_check_readable(transport); | |
| 1373 | 1420 | out: |
| 1374 | 1421 | mutex_unlock(&transport->recv_mutex); |
| 1375 | 1422 | } |
| @@ -1378,7 +1425,10 @@ static void xs_udp_data_receive_workfn(struct work_struct *work) · 2 unmodified lines | ||
| 1378 | 1425 | { |
| 1379 | 1426 | struct sock_xprt *transport = |
| 1380 | 1427 | container_of(work, struct sock_xprt, recv_worker); |
| 1428 | + unsigned int pflags = memalloc_nofs_save(); | |
| 1429 | + | |
| 1381 | 1430 | xs_udp_data_receive(transport); |
| 1431 | + memalloc_nofs_restore(pflags); | |
| 1382 | 1432 | } |
| 1383 | 1433 | |
| 1384 | 1434 | /** |
| @@ -1826,6 +1876,7 @@ static struct socket *xs_create_sock(struct rpc_xprt *xprt, · 441 unmodified lines | ||
| 1826 | 1876 | struct sock_xprt *transport, int family, int type, |
| 1827 | 1877 | int protocol, bool reuseport) |
| 1828 | 1878 | { |
| 1879 | + struct file *filp; | |
| 1829 | 1880 | struct socket *sock; |
| 1830 | 1881 | int err; |
| 1831 | 1882 | |
| @@ -1846,6 +1897,11 @@ static struct socket *xs_create_sock(struct rpc_xprt *xprt, · 14 unmodified lines | ||
| 1846 | 1897 | goto out; |
| 1847 | 1898 | } |
| 1848 | 1899 | |
| 1900 | + filp = sock_alloc_file(sock, O_NONBLOCK, NULL); | |
| 1901 | + if (IS_ERR(filp)) | |
| 1902 | + return ERR_CAST(filp); | |
| 1903 | + transport->file = filp; | |
| 1904 | + | |
| 1849 | 1905 | return sock; |
| 1850 | 1906 | out: |
| 1851 | 1907 | return ERR_PTR(err); |
| @@ -1869,7 +1925,6 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt, · 17 unmodified lines | ||
| 1869 | 1925 | sk->sk_write_space = xs_udp_write_space; |
| 1870 | 1926 | sock_set_flag(sk, SOCK_FASYNC); |
| 1871 | 1927 | sk->sk_error_report = xs_error_report; |
| 1872 | − sk->sk_allocation = GFP_NOIO; | |
| 1873 | 1928 | |
| 1874 | 1929 | xprt_clear_connected(xprt); |
| 1875 | 1930 | |
| @@ -1880,7 +1935,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt, · 4 unmodified lines | ||
| 1880 | 1935 | write_unlock_bh(&sk->sk_callback_lock); |
| 1881 | 1936 | } |
| 1882 | 1937 | |
| 1883 | − xs_stream_reset_connect(transport); | |
| 1938 | + xs_stream_start_connect(transport); | |
| 1884 | 1939 | |
| 1885 | 1940 | return kernel_connect(sock, xs_addr(xprt), xprt->addrlen, 0); |
| 1886 | 1941 | } |
| @@ -1892,6 +1947,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt, · 5 unmodified lines | ||
| 1892 | 1947 | static int xs_local_setup_socket(struct sock_xprt *transport) |
| 1893 | 1948 | { |
| 1894 | 1949 | struct rpc_xprt *xprt = &transport->xprt; |
| 1950 | + struct file *filp; | |
| 1895 | 1951 | struct socket *sock; |
| 1896 | 1952 | int status = -EIO; |
| 1897 | 1953 | |
| @@ -1904,6 +1960,13 @@ static int xs_local_setup_socket(struct sock_xprt *transport) · 6 unmodified lines | ||
| 1904 | 1960 | } |
| 1905 | 1961 | xs_reclassify_socket(AF_LOCAL, sock); |
| 1906 | 1962 | |
| 1963 | + filp = sock_alloc_file(sock, O_NONBLOCK, NULL); | |
| 1964 | + if (IS_ERR(filp)) { | |
| 1965 | + status = PTR_ERR(filp); | |
| 1966 | + goto out; | |
| 1967 | + } | |
| 1968 | + transport->file = filp; | |
| 1969 | + | |
| 1907 | 1970 | dprintk("RPC: worker connecting xprt %p via AF_LOCAL to %s\n", |
| 1908 | 1971 | xprt, xprt->address_strings[RPC_DISPLAY_ADDR]); |
| 1909 | 1972 | |
| @@ -2057,7 +2120,6 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) · 147 unmodified lines | ||
| 2057 | 2120 | sk->sk_data_ready = xs_data_ready; |
| 2058 | 2121 | sk->sk_write_space = xs_udp_write_space; |
| 2059 | 2122 | sock_set_flag(sk, SOCK_FASYNC); |
| 2060 | − sk->sk_allocation = GFP_NOIO; | |
| 2061 | 2123 | |
| 2062 | 2124 | xprt_set_connected(xprt); |
| 2063 | 2125 | |
| @@ -2220,7 +2282,6 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) · 156 unmodified lines | ||
| 2220 | 2282 | sk->sk_write_space = xs_tcp_write_space; |
| 2221 | 2283 | sock_set_flag(sk, SOCK_FASYNC); |
| 2222 | 2284 | sk->sk_error_report = xs_error_report; |
| 2223 | − sk->sk_allocation = GFP_NOIO; | |
| 2224 | 2285 | |
| 2225 | 2286 | /* socket options */ |
| 2226 | 2287 | sock_reset_flag(sk, SOCK_LINGER); |
| @@ -2240,8 +2301,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) · 13 unmodified lines | ||
| 2240 | 2301 | |
| 2241 | 2302 | xs_set_memalloc(xprt); |
| 2242 | 2303 | |
| 2243 | − /* Reset TCP record info */ | |
| 2244 | − xs_stream_reset_connect(transport); | |
| 2304 | + xs_stream_start_connect(transport); | |
| 2245 | 2305 | |
| 2246 | 2306 | /* Tell the socket layer to start connecting... */ |
| 2247 | 2307 | set_bit(XPRT_SOCK_CONNECTING, &transport->sock_state); |
| @@ -2534,26 +2594,35 @@ static int bc_sendto(struct rpc_rqst *req) · 286 unmodified lines | ||
| 2534 | 2594 | { |
| 2535 | 2595 | int len; |
| 2536 | 2596 | struct xdr_buf *xbufp = &req->rq_snd_buf; |
| 2537 | − struct rpc_xprt *xprt = req->rq_xprt; | |
| 2538 | 2597 | struct sock_xprt *transport = |
| 2539 | − container_of(xprt, struct sock_xprt, xprt); | |
| 2540 | − struct socket *sock = transport->sock; | |
| 2598 | + container_of(req->rq_xprt, struct sock_xprt, xprt); | |
| 2541 | 2599 | unsigned long headoff; |
| 2542 | 2600 | unsigned long tailoff; |
| 2601 | + struct page *tailpage; | |
| 2602 | + struct msghdr msg = { | |
| 2603 | + .msg_flags = MSG_MORE | |
| 2604 | + }; | |
| 2605 | + rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | | |
| 2606 | + (u32)xbufp->len); | |
| 2607 | + struct kvec iov = { | |
| 2608 | + .iov_base = &marker, | |
| 2609 | + .iov_len = sizeof(marker), | |
| 2610 | + }; | |
| 2543 | 2611 | |
| 2544 | − xs_encode_stream_record_marker(xbufp); | |
| 2612 | + len = kernel_sendmsg(transport->sock, &msg, &iov, 1, iov.iov_len); | |
| 2613 | + if (len != iov.iov_len) | |
| 2614 | + return -EAGAIN; | |
| 2545 | 2615 | |
| 2616 | + tailpage = NULL; | |
| 2617 | + if (xbufp->tail[0].iov_len) | |
| 2618 | + tailpage = virt_to_page(xbufp->tail[0].iov_base); | |
| 2546 | 2619 | tailoff = (unsigned long)xbufp->tail[0].iov_base & ~PAGE_MASK; |
| 2547 | 2620 | headoff = (unsigned long)xbufp->head[0].iov_base & ~PAGE_MASK; |
| 2548 | − len = svc_send_common(sock, xbufp, | |
| 2621 | + len = svc_send_common(transport->sock, xbufp, | |
| 2549 | 2622 | virt_to_page(xbufp->head[0].iov_base), headoff, |
| 2550 | − xbufp->tail[0].iov_base, tailoff); | |
| 2551 | − | |
| 2552 | − if (len != xbufp->len) { | |
| 2553 | − printk(KERN_NOTICE "Error sending entire callback!\n"); | |
| 2554 | − len = -EAGAIN; | |
| 2555 | − } | |
| 2556 | − | |
| 2623 | + tailpage, tailoff); | |
| 2624 | + if (len != xbufp->len) | |
| 2625 | + return -EAGAIN; | |
| 2557 | 2626 | return len; |
| 2558 | 2627 | } |
| 2559 | 2628 | |
| @@ -2793,7 +2862,6 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) · 233 unmodified lines | ||
| 2793 | 2862 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2794 | 2863 | |
| 2795 | 2864 | xprt->prot = 0; |
| 2796 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 2797 | 2865 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 2798 | 2866 | |
| 2799 | 2867 | xprt->bind_timeout = XS_BIND_TO; |
| @@ -2862,7 +2930,6 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) · 62 unmodified lines | ||
| 2862 | 2930 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2863 | 2931 | |
| 2864 | 2932 | xprt->prot = IPPROTO_UDP; |
| 2865 | − xprt->tsh_size = 0; | |
| 2866 | 2933 | /* XXX: header size can vary due to auth type, IPv6, etc. */ |
| 2867 | 2934 | xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); |
| 2868 | 2935 | |
| @@ -2942,7 +3009,6 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) · 73 unmodified lines | ||
| 2942 | 3009 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2943 | 3010 | |
| 2944 | 3011 | xprt->prot = IPPROTO_TCP; |
| 2945 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 2946 | 3012 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 2947 | 3013 | |
| 2948 | 3014 | xprt->bind_timeout = XS_BIND_TO; |
| @@ -3015,7 +3081,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) · 66 unmodified lines | ||
| 3015 | 3081 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 3016 | 3082 | |
| 3017 | 3083 | xprt->prot = IPPROTO_TCP; |
| 3018 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 3019 | 3084 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 3020 | 3085 | xprt->timeout = &xs_tcp_default_timeout; |
| 3021 | 3086 | |