| .. | .. |
|---|
| 63 | 63 | #include "callback.h" |
|---|
| 64 | 64 | #include "pnfs.h" |
|---|
| 65 | 65 | #include "netns.h" |
|---|
| 66 | +#include "sysfs.h" |
|---|
| 66 | 67 | #include "nfs4idmap.h" |
|---|
| 67 | 68 | #include "nfs4session.h" |
|---|
| 68 | 69 | #include "fscache.h" |
|---|
| 70 | +#include "nfs42.h" |
|---|
| 69 | 71 | |
|---|
| 70 | 72 | #include "nfs4trace.h" |
|---|
| 73 | + |
|---|
| 74 | +#ifdef CONFIG_NFS_V4_2 |
|---|
| 75 | +#include "nfs42.h" |
|---|
| 76 | +#endif /* CONFIG_NFS_V4_2 */ |
|---|
| 71 | 77 | |
|---|
| 72 | 78 | #define NFSDBG_FACILITY NFSDBG_PROC |
|---|
| 73 | 79 | |
|---|
| .. | .. |
|---|
| 91 | 97 | static int _nfs4_recover_proc_open(struct nfs4_opendata *data); |
|---|
| 92 | 98 | static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); |
|---|
| 93 | 99 | static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr); |
|---|
| 94 | | -static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode); |
|---|
| 95 | 100 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode); |
|---|
| 96 | | -static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
|---|
| 101 | +static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, |
|---|
| 97 | 102 | struct nfs_fattr *fattr, struct iattr *sattr, |
|---|
| 98 | 103 | struct nfs_open_context *ctx, struct nfs4_label *ilabel, |
|---|
| 99 | 104 | struct nfs4_label *olabel); |
|---|
| 100 | 105 | #ifdef CONFIG_NFS_V4_1 |
|---|
| 101 | 106 | static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, |
|---|
| 102 | | - struct rpc_cred *cred, |
|---|
| 107 | + const struct cred *cred, |
|---|
| 103 | 108 | struct nfs4_slot *slot, |
|---|
| 104 | 109 | bool is_privileged); |
|---|
| 105 | 110 | static int nfs41_test_stateid(struct nfs_server *, nfs4_stateid *, |
|---|
| 106 | | - struct rpc_cred *); |
|---|
| 111 | + const struct cred *); |
|---|
| 107 | 112 | static int nfs41_free_stateid(struct nfs_server *, const nfs4_stateid *, |
|---|
| 108 | | - struct rpc_cred *, bool); |
|---|
| 113 | + const struct cred *, bool); |
|---|
| 109 | 114 | #endif |
|---|
| 115 | +static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], |
|---|
| 116 | + const __u32 *src, struct inode *inode, |
|---|
| 117 | + struct nfs_server *server, |
|---|
| 118 | + struct nfs4_label *label); |
|---|
| 110 | 119 | |
|---|
| 111 | 120 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
|---|
| 112 | 121 | static inline struct nfs4_label * |
|---|
| .. | .. |
|---|
| 257 | 266 | | FATTR4_WORD1_FS_LAYOUT_TYPES, |
|---|
| 258 | 267 | FATTR4_WORD2_LAYOUT_BLKSIZE |
|---|
| 259 | 268 | | FATTR4_WORD2_CLONE_BLKSIZE |
|---|
| 269 | + | FATTR4_WORD2_XATTR_SUPPORT |
|---|
| 260 | 270 | }; |
|---|
| 261 | 271 | |
|---|
| 262 | 272 | const u32 nfs4_fs_locations_bitmap[3] = { |
|---|
| .. | .. |
|---|
| 359 | 369 | kunmap_atomic(start); |
|---|
| 360 | 370 | } |
|---|
| 361 | 371 | |
|---|
| 372 | +static void nfs4_fattr_set_prechange(struct nfs_fattr *fattr, u64 version) |
|---|
| 373 | +{ |
|---|
| 374 | + if (!(fattr->valid & NFS_ATTR_FATTR_PRECHANGE)) { |
|---|
| 375 | + fattr->pre_change_attr = version; |
|---|
| 376 | + fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; |
|---|
| 377 | + } |
|---|
| 378 | +} |
|---|
| 379 | + |
|---|
| 362 | 380 | static void nfs4_test_and_free_stateid(struct nfs_server *server, |
|---|
| 363 | 381 | nfs4_stateid *stateid, |
|---|
| 364 | | - struct rpc_cred *cred) |
|---|
| 382 | + const struct cred *cred) |
|---|
| 365 | 383 | { |
|---|
| 366 | 384 | const struct nfs4_minor_version_ops *ops = server->nfs_client->cl_mvops; |
|---|
| 367 | 385 | |
|---|
| .. | .. |
|---|
| 370 | 388 | |
|---|
| 371 | 389 | static void __nfs4_free_revoked_stateid(struct nfs_server *server, |
|---|
| 372 | 390 | nfs4_stateid *stateid, |
|---|
| 373 | | - struct rpc_cred *cred) |
|---|
| 391 | + const struct cred *cred) |
|---|
| 374 | 392 | { |
|---|
| 375 | 393 | stateid->type = NFS4_REVOKED_STATEID_TYPE; |
|---|
| 376 | 394 | nfs4_test_and_free_stateid(server, stateid, cred); |
|---|
| .. | .. |
|---|
| 378 | 396 | |
|---|
| 379 | 397 | static void nfs4_free_revoked_stateid(struct nfs_server *server, |
|---|
| 380 | 398 | const nfs4_stateid *stateid, |
|---|
| 381 | | - struct rpc_cred *cred) |
|---|
| 399 | + const struct cred *cred) |
|---|
| 382 | 400 | { |
|---|
| 383 | 401 | nfs4_stateid tmp; |
|---|
| 384 | 402 | |
|---|
| .. | .. |
|---|
| 400 | 418 | return ret; |
|---|
| 401 | 419 | } |
|---|
| 402 | 420 | |
|---|
| 403 | | -static int nfs4_delay(struct rpc_clnt *clnt, long *timeout) |
|---|
| 421 | +static int nfs4_delay_killable(long *timeout) |
|---|
| 404 | 422 | { |
|---|
| 405 | | - int res = 0; |
|---|
| 406 | | - |
|---|
| 407 | 423 | might_sleep(); |
|---|
| 408 | 424 | |
|---|
| 409 | 425 | freezable_schedule_timeout_killable_unsafe( |
|---|
| 410 | 426 | nfs4_update_delay(timeout)); |
|---|
| 411 | | - if (fatal_signal_pending(current)) |
|---|
| 412 | | - res = -ERESTARTSYS; |
|---|
| 413 | | - return res; |
|---|
| 427 | + if (!__fatal_signal_pending(current)) |
|---|
| 428 | + return 0; |
|---|
| 429 | + return -EINTR; |
|---|
| 430 | +} |
|---|
| 431 | + |
|---|
| 432 | +static int nfs4_delay_interruptible(long *timeout) |
|---|
| 433 | +{ |
|---|
| 434 | + might_sleep(); |
|---|
| 435 | + |
|---|
| 436 | + freezable_schedule_timeout_interruptible_unsafe(nfs4_update_delay(timeout)); |
|---|
| 437 | + if (!signal_pending(current)) |
|---|
| 438 | + return 0; |
|---|
| 439 | + return __fatal_signal_pending(current) ? -EINTR :-ERESTARTSYS; |
|---|
| 440 | +} |
|---|
| 441 | + |
|---|
| 442 | +static int nfs4_delay(long *timeout, bool interruptible) |
|---|
| 443 | +{ |
|---|
| 444 | + if (interruptible) |
|---|
| 445 | + return nfs4_delay_interruptible(timeout); |
|---|
| 446 | + return nfs4_delay_killable(timeout); |
|---|
| 447 | +} |
|---|
| 448 | + |
|---|
| 449 | +static const nfs4_stateid * |
|---|
| 450 | +nfs4_recoverable_stateid(const nfs4_stateid *stateid) |
|---|
| 451 | +{ |
|---|
| 452 | + if (!stateid) |
|---|
| 453 | + return NULL; |
|---|
| 454 | + switch (stateid->type) { |
|---|
| 455 | + case NFS4_OPEN_STATEID_TYPE: |
|---|
| 456 | + case NFS4_LOCK_STATEID_TYPE: |
|---|
| 457 | + case NFS4_DELEGATION_STATEID_TYPE: |
|---|
| 458 | + return stateid; |
|---|
| 459 | + default: |
|---|
| 460 | + break; |
|---|
| 461 | + } |
|---|
| 462 | + return NULL; |
|---|
| 414 | 463 | } |
|---|
| 415 | 464 | |
|---|
| 416 | 465 | /* This is the error handling routine for processes that are allowed |
|---|
| .. | .. |
|---|
| 421 | 470 | { |
|---|
| 422 | 471 | struct nfs_client *clp = server->nfs_client; |
|---|
| 423 | 472 | struct nfs4_state *state = exception->state; |
|---|
| 424 | | - const nfs4_stateid *stateid = exception->stateid; |
|---|
| 473 | + const nfs4_stateid *stateid; |
|---|
| 425 | 474 | struct inode *inode = exception->inode; |
|---|
| 426 | 475 | int ret = errorcode; |
|---|
| 427 | 476 | |
|---|
| .. | .. |
|---|
| 429 | 478 | exception->recovering = 0; |
|---|
| 430 | 479 | exception->retry = 0; |
|---|
| 431 | 480 | |
|---|
| 481 | + stateid = nfs4_recoverable_stateid(exception->stateid); |
|---|
| 432 | 482 | if (stateid == NULL && state != NULL) |
|---|
| 433 | | - stateid = &state->stateid; |
|---|
| 483 | + stateid = nfs4_recoverable_stateid(&state->stateid); |
|---|
| 434 | 484 | |
|---|
| 435 | 485 | switch(errorcode) { |
|---|
| 436 | 486 | case 0: |
|---|
| .. | .. |
|---|
| 444 | 494 | case -NFS4ERR_ADMIN_REVOKED: |
|---|
| 445 | 495 | case -NFS4ERR_EXPIRED: |
|---|
| 446 | 496 | case -NFS4ERR_BAD_STATEID: |
|---|
| 497 | + case -NFS4ERR_PARTNER_NO_AUTH: |
|---|
| 447 | 498 | if (inode != NULL && stateid != NULL) { |
|---|
| 448 | 499 | nfs_inode_find_state_and_recover(inode, |
|---|
| 449 | 500 | stateid); |
|---|
| 450 | 501 | goto wait_on_recovery; |
|---|
| 451 | 502 | } |
|---|
| 452 | | - /* Fall through */ |
|---|
| 503 | + fallthrough; |
|---|
| 453 | 504 | case -NFS4ERR_OPENMODE: |
|---|
| 454 | 505 | if (inode) { |
|---|
| 455 | 506 | int err; |
|---|
| .. | .. |
|---|
| 489 | 540 | case -NFS4ERR_DEADSESSION: |
|---|
| 490 | 541 | case -NFS4ERR_SEQ_FALSE_RETRY: |
|---|
| 491 | 542 | case -NFS4ERR_SEQ_MISORDERED: |
|---|
| 492 | | - dprintk("%s ERROR: %d Reset session\n", __func__, |
|---|
| 493 | | - errorcode); |
|---|
| 494 | | - nfs4_schedule_session_recovery(clp->cl_session, errorcode); |
|---|
| 543 | + /* Handled in nfs41_sequence_process() */ |
|---|
| 495 | 544 | goto wait_on_recovery; |
|---|
| 496 | 545 | #endif /* defined(CONFIG_NFS_V4_1) */ |
|---|
| 497 | 546 | case -NFS4ERR_FILE_OPEN: |
|---|
| .. | .. |
|---|
| 502 | 551 | ret = -EBUSY; |
|---|
| 503 | 552 | break; |
|---|
| 504 | 553 | } |
|---|
| 505 | | - /* Fall through */ |
|---|
| 554 | + fallthrough; |
|---|
| 506 | 555 | case -NFS4ERR_DELAY: |
|---|
| 507 | 556 | nfs_inc_server_stats(server, NFSIOS_DELAY); |
|---|
| 508 | | - /* Fall through */ |
|---|
| 557 | + fallthrough; |
|---|
| 509 | 558 | case -NFS4ERR_GRACE: |
|---|
| 510 | 559 | case -NFS4ERR_LAYOUTTRYLATER: |
|---|
| 511 | 560 | case -NFS4ERR_RECALLCONFLICT: |
|---|
| .. | .. |
|---|
| 546 | 595 | |
|---|
| 547 | 596 | ret = nfs4_do_handle_exception(server, errorcode, exception); |
|---|
| 548 | 597 | if (exception->delay) { |
|---|
| 549 | | - ret = nfs4_delay(server->client, &exception->timeout); |
|---|
| 598 | + ret = nfs4_delay(&exception->timeout, |
|---|
| 599 | + exception->interruptible); |
|---|
| 550 | 600 | goto out_retry; |
|---|
| 551 | 601 | } |
|---|
| 552 | 602 | if (exception->recovering) { |
|---|
| .. | .. |
|---|
| 734 | 784 | res->sr_slot = NULL; |
|---|
| 735 | 785 | } |
|---|
| 736 | 786 | |
|---|
| 787 | +static void nfs4_slot_sequence_record_sent(struct nfs4_slot *slot, |
|---|
| 788 | + u32 seqnr) |
|---|
| 789 | +{ |
|---|
| 790 | + if ((s32)(seqnr - slot->seq_nr_highest_sent) > 0) |
|---|
| 791 | + slot->seq_nr_highest_sent = seqnr; |
|---|
| 792 | +} |
|---|
| 793 | +static void nfs4_slot_sequence_acked(struct nfs4_slot *slot, u32 seqnr) |
|---|
| 794 | +{ |
|---|
| 795 | + nfs4_slot_sequence_record_sent(slot, seqnr); |
|---|
| 796 | + slot->seq_nr_last_acked = seqnr; |
|---|
| 797 | +} |
|---|
| 798 | + |
|---|
| 799 | +static void nfs4_probe_sequence(struct nfs_client *client, const struct cred *cred, |
|---|
| 800 | + struct nfs4_slot *slot) |
|---|
| 801 | +{ |
|---|
| 802 | + struct rpc_task *task = _nfs41_proc_sequence(client, cred, slot, true); |
|---|
| 803 | + if (!IS_ERR(task)) |
|---|
| 804 | + rpc_put_task_async(task); |
|---|
| 805 | +} |
|---|
| 806 | + |
|---|
| 737 | 807 | static int nfs41_sequence_process(struct rpc_task *task, |
|---|
| 738 | 808 | struct nfs4_sequence_res *res) |
|---|
| 739 | 809 | { |
|---|
| 740 | 810 | struct nfs4_session *session; |
|---|
| 741 | 811 | struct nfs4_slot *slot = res->sr_slot; |
|---|
| 742 | 812 | struct nfs_client *clp; |
|---|
| 743 | | - bool interrupted = false; |
|---|
| 813 | + int status; |
|---|
| 744 | 814 | int ret = 1; |
|---|
| 745 | 815 | |
|---|
| 746 | 816 | if (slot == NULL) |
|---|
| 747 | 817 | goto out_noaction; |
|---|
| 748 | 818 | /* don't increment the sequence number if the task wasn't sent */ |
|---|
| 749 | | - if (!RPC_WAS_SENT(task)) |
|---|
| 819 | + if (!RPC_WAS_SENT(task) || slot->seq_done) |
|---|
| 750 | 820 | goto out; |
|---|
| 751 | 821 | |
|---|
| 752 | 822 | session = slot->table->session; |
|---|
| 753 | | - |
|---|
| 754 | | - if (slot->interrupted) { |
|---|
| 755 | | - if (res->sr_status != -NFS4ERR_DELAY) |
|---|
| 756 | | - slot->interrupted = 0; |
|---|
| 757 | | - interrupted = true; |
|---|
| 758 | | - } |
|---|
| 823 | + clp = session->clp; |
|---|
| 759 | 824 | |
|---|
| 760 | 825 | trace_nfs4_sequence_done(session, res); |
|---|
| 826 | + |
|---|
| 827 | + status = res->sr_status; |
|---|
| 828 | + if (task->tk_status == -NFS4ERR_DEADSESSION) |
|---|
| 829 | + status = -NFS4ERR_DEADSESSION; |
|---|
| 830 | + |
|---|
| 761 | 831 | /* Check the SEQUENCE operation status */ |
|---|
| 762 | | - switch (res->sr_status) { |
|---|
| 832 | + switch (status) { |
|---|
| 763 | 833 | case 0: |
|---|
| 834 | + /* Mark this sequence number as having been acked */ |
|---|
| 835 | + nfs4_slot_sequence_acked(slot, slot->seq_nr); |
|---|
| 764 | 836 | /* Update the slot's sequence and clientid lease timer */ |
|---|
| 765 | 837 | slot->seq_done = 1; |
|---|
| 766 | | - clp = session->clp; |
|---|
| 767 | 838 | do_renew_lease(clp, res->sr_timestamp); |
|---|
| 768 | 839 | /* Check sequence flags */ |
|---|
| 769 | 840 | nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags, |
|---|
| .. | .. |
|---|
| 775 | 846 | * sr_status remains 1 if an RPC level error occurred. |
|---|
| 776 | 847 | * The server may or may not have processed the sequence |
|---|
| 777 | 848 | * operation.. |
|---|
| 778 | | - * Mark the slot as having hosted an interrupted RPC call. |
|---|
| 779 | 849 | */ |
|---|
| 780 | | - slot->interrupted = 1; |
|---|
| 850 | + nfs4_slot_sequence_record_sent(slot, slot->seq_nr); |
|---|
| 851 | + slot->seq_done = 1; |
|---|
| 781 | 852 | goto out; |
|---|
| 782 | 853 | case -NFS4ERR_DELAY: |
|---|
| 783 | 854 | /* The server detected a resend of the RPC call and |
|---|
| .. | .. |
|---|
| 795 | 866 | * The server thinks we tried to replay a request. |
|---|
| 796 | 867 | * Retry the call after bumping the sequence ID. |
|---|
| 797 | 868 | */ |
|---|
| 869 | + nfs4_slot_sequence_acked(slot, slot->seq_nr); |
|---|
| 798 | 870 | goto retry_new_seq; |
|---|
| 799 | 871 | case -NFS4ERR_BADSLOT: |
|---|
| 800 | 872 | /* |
|---|
| .. | .. |
|---|
| 805 | 877 | goto session_recover; |
|---|
| 806 | 878 | goto retry_nowait; |
|---|
| 807 | 879 | case -NFS4ERR_SEQ_MISORDERED: |
|---|
| 880 | + nfs4_slot_sequence_record_sent(slot, slot->seq_nr); |
|---|
| 808 | 881 | /* |
|---|
| 809 | | - * Was the last operation on this sequence interrupted? |
|---|
| 810 | | - * If so, retry after bumping the sequence number. |
|---|
| 882 | + * Were one or more calls using this slot interrupted? |
|---|
| 883 | + * If the server never received the request, then our |
|---|
| 884 | + * transmitted slot sequence number may be too high. However, |
|---|
| 885 | + * if the server did receive the request then it might |
|---|
| 886 | + * accidentally give us a reply with a mismatched operation. |
|---|
| 887 | + * We can sort this out by sending a lone sequence operation |
|---|
| 888 | + * to the server on the same slot. |
|---|
| 811 | 889 | */ |
|---|
| 812 | | - if (interrupted) |
|---|
| 813 | | - goto retry_new_seq; |
|---|
| 814 | | - /* |
|---|
| 815 | | - * Could this slot have been previously retired? |
|---|
| 816 | | - * If so, then the server may be expecting seq_nr = 1! |
|---|
| 817 | | - */ |
|---|
| 818 | | - if (slot->seq_nr != 1) { |
|---|
| 819 | | - slot->seq_nr = 1; |
|---|
| 890 | + if ((s32)(slot->seq_nr - slot->seq_nr_last_acked) > 1) { |
|---|
| 891 | + slot->seq_nr--; |
|---|
| 892 | + if (task->tk_msg.rpc_proc != &nfs4_procedures[NFSPROC4_CLNT_SEQUENCE]) { |
|---|
| 893 | + nfs4_probe_sequence(clp, task->tk_msg.rpc_cred, slot); |
|---|
| 894 | + res->sr_slot = NULL; |
|---|
| 895 | + } |
|---|
| 820 | 896 | goto retry_nowait; |
|---|
| 821 | 897 | } |
|---|
| 898 | + /* |
|---|
| 899 | + * RFC5661: |
|---|
| 900 | + * A retry might be sent while the original request is |
|---|
| 901 | + * still in progress on the replier. The replier SHOULD |
|---|
| 902 | + * deal with the issue by returning NFS4ERR_DELAY as the |
|---|
| 903 | + * reply to SEQUENCE or CB_SEQUENCE operation, but |
|---|
| 904 | + * implementations MAY return NFS4ERR_SEQ_MISORDERED. |
|---|
| 905 | + * |
|---|
| 906 | + * Restart the search after a delay. |
|---|
| 907 | + */ |
|---|
| 908 | + slot->seq_nr = slot->seq_nr_highest_sent; |
|---|
| 909 | + goto out_retry; |
|---|
| 910 | + case -NFS4ERR_BADSESSION: |
|---|
| 911 | + case -NFS4ERR_DEADSESSION: |
|---|
| 912 | + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
|---|
| 822 | 913 | goto session_recover; |
|---|
| 823 | 914 | default: |
|---|
| 824 | 915 | /* Just update the slot sequence no. */ |
|---|
| .. | .. |
|---|
| 830 | 921 | out_noaction: |
|---|
| 831 | 922 | return ret; |
|---|
| 832 | 923 | session_recover: |
|---|
| 833 | | - nfs4_schedule_session_recovery(session, res->sr_status); |
|---|
| 834 | | - goto retry_nowait; |
|---|
| 924 | + nfs4_schedule_session_recovery(session, status); |
|---|
| 925 | + dprintk("%s ERROR: %d Reset session\n", __func__, status); |
|---|
| 926 | + nfs41_sequence_free_slot(res); |
|---|
| 927 | + goto out; |
|---|
| 835 | 928 | retry_new_seq: |
|---|
| 836 | 929 | ++slot->seq_nr; |
|---|
| 837 | 930 | retry_nowait: |
|---|
| .. | .. |
|---|
| 910 | 1003 | .rpc_call_done = nfs41_call_sync_done, |
|---|
| 911 | 1004 | }; |
|---|
| 912 | 1005 | |
|---|
| 913 | | -static void |
|---|
| 914 | | -nfs4_sequence_process_interrupted(struct nfs_client *client, |
|---|
| 915 | | - struct nfs4_slot *slot, struct rpc_cred *cred) |
|---|
| 916 | | -{ |
|---|
| 917 | | - struct rpc_task *task; |
|---|
| 918 | | - |
|---|
| 919 | | - task = _nfs41_proc_sequence(client, cred, slot, true); |
|---|
| 920 | | - if (!IS_ERR(task)) |
|---|
| 921 | | - rpc_put_task_async(task); |
|---|
| 922 | | -} |
|---|
| 923 | | - |
|---|
| 924 | 1006 | #else /* !CONFIG_NFS_V4_1 */ |
|---|
| 925 | 1007 | |
|---|
| 926 | 1008 | static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res) |
|---|
| .. | .. |
|---|
| 940 | 1022 | return nfs40_sequence_done(task, res); |
|---|
| 941 | 1023 | } |
|---|
| 942 | 1024 | EXPORT_SYMBOL_GPL(nfs4_sequence_done); |
|---|
| 943 | | - |
|---|
| 944 | | -static void |
|---|
| 945 | | -nfs4_sequence_process_interrupted(struct nfs_client *client, |
|---|
| 946 | | - struct nfs4_slot *slot, struct rpc_cred *cred) |
|---|
| 947 | | -{ |
|---|
| 948 | | - WARN_ON_ONCE(1); |
|---|
| 949 | | - slot->interrupted = 0; |
|---|
| 950 | | -} |
|---|
| 951 | 1025 | |
|---|
| 952 | 1026 | #endif /* !CONFIG_NFS_V4_1 */ |
|---|
| 953 | 1027 | |
|---|
| .. | .. |
|---|
| 984 | 1058 | if (res->sr_slot != NULL) |
|---|
| 985 | 1059 | goto out_start; |
|---|
| 986 | 1060 | |
|---|
| 987 | | - if (session) { |
|---|
| 1061 | + if (session) |
|---|
| 988 | 1062 | tbl = &session->fc_slot_table; |
|---|
| 989 | | - task->tk_timeout = 0; |
|---|
| 1063 | + |
|---|
| 1064 | + spin_lock(&tbl->slot_tbl_lock); |
|---|
| 1065 | + /* The state manager will wait until the slot table is empty */ |
|---|
| 1066 | + if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) |
|---|
| 1067 | + goto out_sleep; |
|---|
| 1068 | + |
|---|
| 1069 | + slot = nfs4_alloc_slot(tbl); |
|---|
| 1070 | + if (IS_ERR(slot)) { |
|---|
| 1071 | + if (slot == ERR_PTR(-ENOMEM)) |
|---|
| 1072 | + goto out_sleep_timeout; |
|---|
| 1073 | + goto out_sleep; |
|---|
| 990 | 1074 | } |
|---|
| 991 | | - |
|---|
| 992 | | - for (;;) { |
|---|
| 993 | | - spin_lock(&tbl->slot_tbl_lock); |
|---|
| 994 | | - /* The state manager will wait until the slot table is empty */ |
|---|
| 995 | | - if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) |
|---|
| 996 | | - goto out_sleep; |
|---|
| 997 | | - |
|---|
| 998 | | - slot = nfs4_alloc_slot(tbl); |
|---|
| 999 | | - if (IS_ERR(slot)) { |
|---|
| 1000 | | - /* Try again in 1/4 second */ |
|---|
| 1001 | | - if (slot == ERR_PTR(-ENOMEM)) |
|---|
| 1002 | | - task->tk_timeout = HZ >> 2; |
|---|
| 1003 | | - goto out_sleep; |
|---|
| 1004 | | - } |
|---|
| 1005 | | - spin_unlock(&tbl->slot_tbl_lock); |
|---|
| 1006 | | - |
|---|
| 1007 | | - if (likely(!slot->interrupted)) |
|---|
| 1008 | | - break; |
|---|
| 1009 | | - nfs4_sequence_process_interrupted(client, |
|---|
| 1010 | | - slot, task->tk_msg.rpc_cred); |
|---|
| 1011 | | - } |
|---|
| 1075 | + spin_unlock(&tbl->slot_tbl_lock); |
|---|
| 1012 | 1076 | |
|---|
| 1013 | 1077 | nfs4_sequence_attach_slot(args, res, slot); |
|---|
| 1014 | 1078 | |
|---|
| .. | .. |
|---|
| 1017 | 1081 | nfs41_sequence_res_init(res); |
|---|
| 1018 | 1082 | rpc_call_start(task); |
|---|
| 1019 | 1083 | return 0; |
|---|
| 1020 | | - |
|---|
| 1084 | +out_sleep_timeout: |
|---|
| 1085 | + /* Try again in 1/4 second */ |
|---|
| 1086 | + if (args->sa_privileged) |
|---|
| 1087 | + rpc_sleep_on_priority_timeout(&tbl->slot_tbl_waitq, task, |
|---|
| 1088 | + jiffies + (HZ >> 2), RPC_PRIORITY_PRIVILEGED); |
|---|
| 1089 | + else |
|---|
| 1090 | + rpc_sleep_on_timeout(&tbl->slot_tbl_waitq, task, |
|---|
| 1091 | + NULL, jiffies + (HZ >> 2)); |
|---|
| 1092 | + spin_unlock(&tbl->slot_tbl_lock); |
|---|
| 1093 | + return -EAGAIN; |
|---|
| 1021 | 1094 | out_sleep: |
|---|
| 1022 | 1095 | if (args->sa_privileged) |
|---|
| 1023 | 1096 | rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task, |
|---|
| 1024 | | - NULL, RPC_PRIORITY_PRIVILEGED); |
|---|
| 1097 | + RPC_PRIORITY_PRIVILEGED); |
|---|
| 1025 | 1098 | else |
|---|
| 1026 | 1099 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); |
|---|
| 1027 | 1100 | spin_unlock(&tbl->slot_tbl_lock); |
|---|
| .. | .. |
|---|
| 1047 | 1120 | .rpc_call_done = nfs40_call_sync_done, |
|---|
| 1048 | 1121 | }; |
|---|
| 1049 | 1122 | |
|---|
| 1050 | | -static int nfs4_call_sync_sequence(struct rpc_clnt *clnt, |
|---|
| 1051 | | - struct nfs_server *server, |
|---|
| 1052 | | - struct rpc_message *msg, |
|---|
| 1053 | | - struct nfs4_sequence_args *args, |
|---|
| 1054 | | - struct nfs4_sequence_res *res) |
|---|
| 1123 | +static int nfs4_call_sync_custom(struct rpc_task_setup *task_setup) |
|---|
| 1055 | 1124 | { |
|---|
| 1056 | 1125 | int ret; |
|---|
| 1057 | 1126 | struct rpc_task *task; |
|---|
| 1127 | + |
|---|
| 1128 | + task = rpc_run_task(task_setup); |
|---|
| 1129 | + if (IS_ERR(task)) |
|---|
| 1130 | + return PTR_ERR(task); |
|---|
| 1131 | + |
|---|
| 1132 | + ret = task->tk_status; |
|---|
| 1133 | + rpc_put_task(task); |
|---|
| 1134 | + return ret; |
|---|
| 1135 | +} |
|---|
| 1136 | + |
|---|
| 1137 | +static int nfs4_do_call_sync(struct rpc_clnt *clnt, |
|---|
| 1138 | + struct nfs_server *server, |
|---|
| 1139 | + struct rpc_message *msg, |
|---|
| 1140 | + struct nfs4_sequence_args *args, |
|---|
| 1141 | + struct nfs4_sequence_res *res, |
|---|
| 1142 | + unsigned short task_flags) |
|---|
| 1143 | +{ |
|---|
| 1058 | 1144 | struct nfs_client *clp = server->nfs_client; |
|---|
| 1059 | 1145 | struct nfs4_call_sync_data data = { |
|---|
| 1060 | 1146 | .seq_server = server, |
|---|
| .. | .. |
|---|
| 1065 | 1151 | .rpc_client = clnt, |
|---|
| 1066 | 1152 | .rpc_message = msg, |
|---|
| 1067 | 1153 | .callback_ops = clp->cl_mvops->call_sync_ops, |
|---|
| 1068 | | - .callback_data = &data |
|---|
| 1154 | + .callback_data = &data, |
|---|
| 1155 | + .flags = task_flags, |
|---|
| 1069 | 1156 | }; |
|---|
| 1070 | 1157 | |
|---|
| 1071 | | - task = rpc_run_task(&task_setup); |
|---|
| 1072 | | - if (IS_ERR(task)) |
|---|
| 1073 | | - ret = PTR_ERR(task); |
|---|
| 1074 | | - else { |
|---|
| 1075 | | - ret = task->tk_status; |
|---|
| 1076 | | - rpc_put_task(task); |
|---|
| 1077 | | - } |
|---|
| 1078 | | - return ret; |
|---|
| 1158 | + return nfs4_call_sync_custom(&task_setup); |
|---|
| 1079 | 1159 | } |
|---|
| 1160 | + |
|---|
| 1161 | +static int nfs4_call_sync_sequence(struct rpc_clnt *clnt, |
|---|
| 1162 | + struct nfs_server *server, |
|---|
| 1163 | + struct rpc_message *msg, |
|---|
| 1164 | + struct nfs4_sequence_args *args, |
|---|
| 1165 | + struct nfs4_sequence_res *res) |
|---|
| 1166 | +{ |
|---|
| 1167 | + return nfs4_do_call_sync(clnt, server, msg, args, res, 0); |
|---|
| 1168 | +} |
|---|
| 1169 | + |
|---|
| 1080 | 1170 | |
|---|
| 1081 | 1171 | int nfs4_call_sync(struct rpc_clnt *clnt, |
|---|
| 1082 | 1172 | struct nfs_server *server, |
|---|
| .. | .. |
|---|
| 1104 | 1194 | } |
|---|
| 1105 | 1195 | |
|---|
| 1106 | 1196 | static void |
|---|
| 1107 | | -update_changeattr_locked(struct inode *dir, struct nfs4_change_info *cinfo, |
|---|
| 1197 | +nfs4_update_changeattr_locked(struct inode *inode, |
|---|
| 1198 | + struct nfs4_change_info *cinfo, |
|---|
| 1108 | 1199 | unsigned long timestamp, unsigned long cache_validity) |
|---|
| 1109 | 1200 | { |
|---|
| 1110 | | - struct nfs_inode *nfsi = NFS_I(dir); |
|---|
| 1201 | + struct nfs_inode *nfsi = NFS_I(inode); |
|---|
| 1111 | 1202 | |
|---|
| 1112 | 1203 | nfsi->cache_validity |= NFS_INO_INVALID_CTIME |
|---|
| 1113 | 1204 | | NFS_INO_INVALID_MTIME |
|---|
| 1114 | | - | NFS_INO_INVALID_DATA |
|---|
| 1115 | 1205 | | cache_validity; |
|---|
| 1116 | | - if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(dir)) { |
|---|
| 1206 | + |
|---|
| 1207 | + if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(inode)) { |
|---|
| 1117 | 1208 | nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; |
|---|
| 1118 | 1209 | nfsi->attrtimeo_timestamp = jiffies; |
|---|
| 1119 | 1210 | } else { |
|---|
| 1120 | | - nfs_force_lookup_revalidate(dir); |
|---|
| 1121 | | - if (cinfo->before != inode_peek_iversion_raw(dir)) |
|---|
| 1211 | + if (S_ISDIR(inode->i_mode)) { |
|---|
| 1212 | + nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
|---|
| 1213 | + nfs_force_lookup_revalidate(inode); |
|---|
| 1214 | + } else { |
|---|
| 1215 | + if (!NFS_PROTO(inode)->have_delegation(inode, |
|---|
| 1216 | + FMODE_READ)) |
|---|
| 1217 | + nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
|---|
| 1218 | + } |
|---|
| 1219 | + |
|---|
| 1220 | + if (cinfo->before != inode_peek_iversion_raw(inode)) |
|---|
| 1122 | 1221 | nfsi->cache_validity |= NFS_INO_INVALID_ACCESS | |
|---|
| 1123 | | - NFS_INO_INVALID_ACL; |
|---|
| 1222 | + NFS_INO_INVALID_ACL | |
|---|
| 1223 | + NFS_INO_INVALID_XATTR; |
|---|
| 1124 | 1224 | } |
|---|
| 1125 | | - inode_set_iversion_raw(dir, cinfo->after); |
|---|
| 1225 | + inode_set_iversion_raw(inode, cinfo->after); |
|---|
| 1126 | 1226 | nfsi->read_cache_jiffies = timestamp; |
|---|
| 1127 | 1227 | nfsi->attr_gencount = nfs_inc_attr_generation_counter(); |
|---|
| 1128 | 1228 | nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE; |
|---|
| 1129 | | - nfs_fscache_invalidate(dir); |
|---|
| 1229 | + |
|---|
| 1230 | + if (nfsi->cache_validity & NFS_INO_INVALID_DATA) |
|---|
| 1231 | + nfs_fscache_invalidate(inode); |
|---|
| 1130 | 1232 | } |
|---|
| 1131 | 1233 | |
|---|
| 1132 | | -static void |
|---|
| 1133 | | -update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo, |
|---|
| 1234 | +void |
|---|
| 1235 | +nfs4_update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo, |
|---|
| 1134 | 1236 | unsigned long timestamp, unsigned long cache_validity) |
|---|
| 1135 | 1237 | { |
|---|
| 1136 | 1238 | spin_lock(&dir->i_lock); |
|---|
| 1137 | | - update_changeattr_locked(dir, cinfo, timestamp, cache_validity); |
|---|
| 1239 | + nfs4_update_changeattr_locked(dir, cinfo, timestamp, cache_validity); |
|---|
| 1138 | 1240 | spin_unlock(&dir->i_lock); |
|---|
| 1139 | 1241 | } |
|---|
| 1140 | 1242 | |
|---|
| .. | .. |
|---|
| 1154 | 1256 | server->caps &= ~NFS_CAP_ATOMIC_OPEN_V1; |
|---|
| 1155 | 1257 | exception->retry = 1; |
|---|
| 1156 | 1258 | return true; |
|---|
| 1259 | +} |
|---|
| 1260 | + |
|---|
| 1261 | +static fmode_t _nfs4_ctx_to_accessmode(const struct nfs_open_context *ctx) |
|---|
| 1262 | +{ |
|---|
| 1263 | + return ctx->mode & (FMODE_READ|FMODE_WRITE|FMODE_EXEC); |
|---|
| 1264 | +} |
|---|
| 1265 | + |
|---|
| 1266 | +static fmode_t _nfs4_ctx_to_openmode(const struct nfs_open_context *ctx) |
|---|
| 1267 | +{ |
|---|
| 1268 | + fmode_t ret = ctx->mode & (FMODE_READ|FMODE_WRITE); |
|---|
| 1269 | + |
|---|
| 1270 | + return (ctx->mode & FMODE_EXEC) ? FMODE_READ | ret : ret; |
|---|
| 1157 | 1271 | } |
|---|
| 1158 | 1272 | |
|---|
| 1159 | 1273 | static u32 |
|---|
| .. | .. |
|---|
| 1275 | 1389 | NFS4_ACCESS_MODIFY | |
|---|
| 1276 | 1390 | NFS4_ACCESS_EXTEND | |
|---|
| 1277 | 1391 | NFS4_ACCESS_EXECUTE; |
|---|
| 1392 | +#ifdef CONFIG_NFS_V4_2 |
|---|
| 1393 | + if (server->caps & NFS_CAP_XATTR) |
|---|
| 1394 | + p->o_arg.access |= NFS4_ACCESS_XAREAD | |
|---|
| 1395 | + NFS4_ACCESS_XAWRITE | |
|---|
| 1396 | + NFS4_ACCESS_XALIST; |
|---|
| 1397 | +#endif |
|---|
| 1278 | 1398 | } |
|---|
| 1279 | 1399 | } |
|---|
| 1280 | 1400 | p->o_arg.clientid = server->nfs_client->cl_clientid; |
|---|
| .. | .. |
|---|
| 1404 | 1524 | case NFS4_OPEN_CLAIM_PREVIOUS: |
|---|
| 1405 | 1525 | if (!test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags)) |
|---|
| 1406 | 1526 | break; |
|---|
| 1407 | | - /* Fall through */ |
|---|
| 1527 | + fallthrough; |
|---|
| 1408 | 1528 | default: |
|---|
| 1409 | 1529 | return 0; |
|---|
| 1410 | 1530 | } |
|---|
| .. | .. |
|---|
| 1446 | 1566 | wake_up_all(&state->waitq); |
|---|
| 1447 | 1567 | } |
|---|
| 1448 | 1568 | |
|---|
| 1449 | | -static void nfs_state_log_out_of_order_open_stateid(struct nfs4_state *state, |
|---|
| 1450 | | - const nfs4_stateid *stateid) |
|---|
| 1451 | | -{ |
|---|
| 1452 | | - u32 state_seqid = be32_to_cpu(state->open_stateid.seqid); |
|---|
| 1453 | | - u32 stateid_seqid = be32_to_cpu(stateid->seqid); |
|---|
| 1454 | | - |
|---|
| 1455 | | - if (stateid_seqid == state_seqid + 1U || |
|---|
| 1456 | | - (stateid_seqid == 1U && state_seqid == 0xffffffffU)) |
|---|
| 1457 | | - nfs_state_log_update_open_stateid(state); |
|---|
| 1458 | | - else |
|---|
| 1459 | | - set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); |
|---|
| 1460 | | -} |
|---|
| 1461 | | - |
|---|
| 1462 | 1569 | static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) |
|---|
| 1463 | 1570 | { |
|---|
| 1464 | 1571 | struct nfs_client *clp = state->owner->so_server->nfs_client; |
|---|
| .. | .. |
|---|
| 1484 | 1591 | * i.e. The stateid seqids have to be initialised to 1, and |
|---|
| 1485 | 1592 | * are then incremented on every state transition. |
|---|
| 1486 | 1593 | */ |
|---|
| 1487 | | -static bool nfs_need_update_open_stateid(struct nfs4_state *state, |
|---|
| 1594 | +static bool nfs_stateid_is_sequential(struct nfs4_state *state, |
|---|
| 1488 | 1595 | const nfs4_stateid *stateid) |
|---|
| 1489 | 1596 | { |
|---|
| 1490 | | - if (test_bit(NFS_OPEN_STATE, &state->flags) == 0 || |
|---|
| 1491 | | - !nfs4_stateid_match_other(stateid, &state->open_stateid)) { |
|---|
| 1492 | | - if (stateid->seqid == cpu_to_be32(1)) |
|---|
| 1493 | | - nfs_state_log_update_open_stateid(state); |
|---|
| 1494 | | - else |
|---|
| 1495 | | - set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); |
|---|
| 1496 | | - return true; |
|---|
| 1597 | + if (test_bit(NFS_OPEN_STATE, &state->flags)) { |
|---|
| 1598 | + /* The common case - we're updating to a new sequence number */ |
|---|
| 1599 | + if (nfs4_stateid_match_other(stateid, &state->open_stateid)) { |
|---|
| 1600 | + if (nfs4_stateid_is_next(&state->open_stateid, stateid)) |
|---|
| 1601 | + return true; |
|---|
| 1602 | + return false; |
|---|
| 1603 | + } |
|---|
| 1604 | + /* The server returned a new stateid */ |
|---|
| 1497 | 1605 | } |
|---|
| 1498 | | - |
|---|
| 1499 | | - if (nfs4_stateid_is_newer(stateid, &state->open_stateid)) { |
|---|
| 1500 | | - nfs_state_log_out_of_order_open_stateid(state, stateid); |
|---|
| 1606 | + /* This is the first OPEN in this generation */ |
|---|
| 1607 | + if (stateid->seqid == cpu_to_be32(1)) |
|---|
| 1501 | 1608 | return true; |
|---|
| 1502 | | - } |
|---|
| 1503 | 1609 | return false; |
|---|
| 1504 | 1610 | } |
|---|
| 1505 | 1611 | |
|---|
| .. | .. |
|---|
| 1563 | 1669 | |
|---|
| 1564 | 1670 | static void nfs_set_open_stateid_locked(struct nfs4_state *state, |
|---|
| 1565 | 1671 | const nfs4_stateid *stateid, nfs4_stateid *freeme) |
|---|
| 1672 | + __must_hold(&state->owner->so_lock) |
|---|
| 1673 | + __must_hold(&state->seqlock) |
|---|
| 1674 | + __must_hold(RCU) |
|---|
| 1675 | + |
|---|
| 1566 | 1676 | { |
|---|
| 1567 | 1677 | DEFINE_WAIT(wait); |
|---|
| 1568 | 1678 | int status = 0; |
|---|
| 1569 | 1679 | for (;;) { |
|---|
| 1570 | 1680 | |
|---|
| 1571 | | - if (!nfs_need_update_open_stateid(state, stateid)) |
|---|
| 1572 | | - return; |
|---|
| 1573 | | - if (!test_bit(NFS_STATE_CHANGE_WAIT, &state->flags)) |
|---|
| 1681 | + if (nfs_stateid_is_sequential(state, stateid)) |
|---|
| 1574 | 1682 | break; |
|---|
| 1683 | + |
|---|
| 1575 | 1684 | if (status) |
|---|
| 1576 | 1685 | break; |
|---|
| 1577 | 1686 | /* Rely on seqids for serialisation with NFSv4.0 */ |
|---|
| 1578 | 1687 | if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client)) |
|---|
| 1579 | 1688 | break; |
|---|
| 1580 | 1689 | |
|---|
| 1690 | + set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); |
|---|
| 1581 | 1691 | prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); |
|---|
| 1582 | 1692 | /* |
|---|
| 1583 | 1693 | * Ensure we process the state changes in the same order |
|---|
| .. | .. |
|---|
| 1588 | 1698 | spin_unlock(&state->owner->so_lock); |
|---|
| 1589 | 1699 | rcu_read_unlock(); |
|---|
| 1590 | 1700 | trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); |
|---|
| 1591 | | - if (!signal_pending(current)) { |
|---|
| 1701 | + |
|---|
| 1702 | + if (!fatal_signal_pending(current)) { |
|---|
| 1592 | 1703 | if (schedule_timeout(5*HZ) == 0) |
|---|
| 1593 | 1704 | status = -EAGAIN; |
|---|
| 1594 | 1705 | else |
|---|
| .. | .. |
|---|
| 1639 | 1750 | write_sequnlock(&state->seqlock); |
|---|
| 1640 | 1751 | } |
|---|
| 1641 | 1752 | |
|---|
| 1753 | +static void nfs_state_clear_open_state_flags(struct nfs4_state *state) |
|---|
| 1754 | +{ |
|---|
| 1755 | + clear_bit(NFS_O_RDWR_STATE, &state->flags); |
|---|
| 1756 | + clear_bit(NFS_O_WRONLY_STATE, &state->flags); |
|---|
| 1757 | + clear_bit(NFS_O_RDONLY_STATE, &state->flags); |
|---|
| 1758 | + clear_bit(NFS_OPEN_STATE, &state->flags); |
|---|
| 1759 | +} |
|---|
| 1760 | + |
|---|
| 1642 | 1761 | static void nfs_state_set_delegation(struct nfs4_state *state, |
|---|
| 1643 | 1762 | const nfs4_stateid *deleg_stateid, |
|---|
| 1644 | 1763 | fmode_t fmode) |
|---|
| .. | .. |
|---|
| 1661 | 1780 | write_sequnlock(&state->seqlock); |
|---|
| 1662 | 1781 | } |
|---|
| 1663 | 1782 | |
|---|
| 1664 | | -static int update_open_stateid(struct nfs4_state *state, |
|---|
| 1783 | +int update_open_stateid(struct nfs4_state *state, |
|---|
| 1665 | 1784 | const nfs4_stateid *open_stateid, |
|---|
| 1666 | 1785 | const nfs4_stateid *delegation, |
|---|
| 1667 | 1786 | fmode_t fmode) |
|---|
| .. | .. |
|---|
| 1682 | 1801 | ret = 1; |
|---|
| 1683 | 1802 | } |
|---|
| 1684 | 1803 | |
|---|
| 1685 | | - deleg_cur = rcu_dereference(nfsi->delegation); |
|---|
| 1804 | + deleg_cur = nfs4_get_valid_delegation(state->inode); |
|---|
| 1686 | 1805 | if (deleg_cur == NULL) |
|---|
| 1687 | 1806 | goto no_delegation; |
|---|
| 1688 | 1807 | |
|---|
| .. | .. |
|---|
| 1694 | 1813 | |
|---|
| 1695 | 1814 | if (delegation == NULL) |
|---|
| 1696 | 1815 | delegation = &deleg_cur->stateid; |
|---|
| 1697 | | - else if (!nfs4_stateid_match(&deleg_cur->stateid, delegation)) |
|---|
| 1816 | + else if (!nfs4_stateid_match_other(&deleg_cur->stateid, delegation)) |
|---|
| 1698 | 1817 | goto no_delegation_unlock; |
|---|
| 1699 | 1818 | |
|---|
| 1700 | 1819 | nfs_mark_delegation_referenced(deleg_cur); |
|---|
| .. | .. |
|---|
| 1741 | 1860 | |
|---|
| 1742 | 1861 | fmode &= FMODE_READ|FMODE_WRITE; |
|---|
| 1743 | 1862 | rcu_read_lock(); |
|---|
| 1744 | | - delegation = rcu_dereference(NFS_I(inode)->delegation); |
|---|
| 1863 | + delegation = nfs4_get_valid_delegation(inode); |
|---|
| 1745 | 1864 | if (delegation == NULL || (delegation->type & fmode) == fmode) { |
|---|
| 1746 | 1865 | rcu_read_unlock(); |
|---|
| 1747 | 1866 | return; |
|---|
| .. | .. |
|---|
| 1792 | 1911 | out: |
|---|
| 1793 | 1912 | return ERR_PTR(ret); |
|---|
| 1794 | 1913 | out_return_state: |
|---|
| 1795 | | - atomic_inc(&state->count); |
|---|
| 1914 | + refcount_inc(&state->count); |
|---|
| 1796 | 1915 | return state; |
|---|
| 1797 | 1916 | } |
|---|
| 1798 | 1917 | |
|---|
| .. | .. |
|---|
| 1862 | 1981 | if (data->o_res.delegation_type != 0) |
|---|
| 1863 | 1982 | nfs4_opendata_check_deleg(data, state); |
|---|
| 1864 | 1983 | update: |
|---|
| 1865 | | - update_open_stateid(state, &data->o_res.stateid, NULL, |
|---|
| 1866 | | - data->o_arg.fmode); |
|---|
| 1867 | | - atomic_inc(&state->count); |
|---|
| 1984 | + if (!update_open_stateid(state, &data->o_res.stateid, |
|---|
| 1985 | + NULL, data->o_arg.fmode)) |
|---|
| 1986 | + return ERR_PTR(-EAGAIN); |
|---|
| 1987 | + refcount_inc(&state->count); |
|---|
| 1868 | 1988 | |
|---|
| 1869 | 1989 | return state; |
|---|
| 1870 | 1990 | } |
|---|
| .. | .. |
|---|
| 1902 | 2022 | return ERR_CAST(inode); |
|---|
| 1903 | 2023 | if (data->state != NULL && data->state->inode == inode) { |
|---|
| 1904 | 2024 | state = data->state; |
|---|
| 1905 | | - atomic_inc(&state->count); |
|---|
| 2025 | + refcount_inc(&state->count); |
|---|
| 1906 | 2026 | } else |
|---|
| 1907 | 2027 | state = nfs4_get_open_state(inode, data->owner); |
|---|
| 1908 | 2028 | iput(inode); |
|---|
| .. | .. |
|---|
| 1928 | 2048 | |
|---|
| 1929 | 2049 | if (data->o_res.delegation_type != 0) |
|---|
| 1930 | 2050 | nfs4_opendata_check_deleg(data, state); |
|---|
| 1931 | | - update_open_stateid(state, &data->o_res.stateid, NULL, |
|---|
| 1932 | | - data->o_arg.fmode); |
|---|
| 2051 | + if (!update_open_stateid(state, &data->o_res.stateid, |
|---|
| 2052 | + NULL, data->o_arg.fmode)) { |
|---|
| 2053 | + nfs4_put_open_state(state); |
|---|
| 2054 | + state = ERR_PTR(-EAGAIN); |
|---|
| 2055 | + } |
|---|
| 1933 | 2056 | out: |
|---|
| 1934 | 2057 | nfs_release_seqid(data->o_arg.seqid); |
|---|
| 1935 | 2058 | return state; |
|---|
| .. | .. |
|---|
| 1948 | 2071 | return ret; |
|---|
| 1949 | 2072 | } |
|---|
| 1950 | 2073 | |
|---|
| 1951 | | -static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) |
|---|
| 2074 | +static struct nfs_open_context * |
|---|
| 2075 | +nfs4_state_find_open_context_mode(struct nfs4_state *state, fmode_t mode) |
|---|
| 1952 | 2076 | { |
|---|
| 1953 | 2077 | struct nfs_inode *nfsi = NFS_I(state->inode); |
|---|
| 1954 | 2078 | struct nfs_open_context *ctx; |
|---|
| 1955 | 2079 | |
|---|
| 1956 | | - spin_lock(&state->inode->i_lock); |
|---|
| 1957 | | - list_for_each_entry(ctx, &nfsi->open_files, list) { |
|---|
| 2080 | + rcu_read_lock(); |
|---|
| 2081 | + list_for_each_entry_rcu(ctx, &nfsi->open_files, list) { |
|---|
| 1958 | 2082 | if (ctx->state != state) |
|---|
| 1959 | 2083 | continue; |
|---|
| 1960 | | - get_nfs_open_context(ctx); |
|---|
| 1961 | | - spin_unlock(&state->inode->i_lock); |
|---|
| 2084 | + if ((ctx->mode & mode) != mode) |
|---|
| 2085 | + continue; |
|---|
| 2086 | + if (!get_nfs_open_context(ctx)) |
|---|
| 2087 | + continue; |
|---|
| 2088 | + rcu_read_unlock(); |
|---|
| 1962 | 2089 | return ctx; |
|---|
| 1963 | 2090 | } |
|---|
| 1964 | | - spin_unlock(&state->inode->i_lock); |
|---|
| 2091 | + rcu_read_unlock(); |
|---|
| 1965 | 2092 | return ERR_PTR(-ENOENT); |
|---|
| 2093 | +} |
|---|
| 2094 | + |
|---|
| 2095 | +static struct nfs_open_context * |
|---|
| 2096 | +nfs4_state_find_open_context(struct nfs4_state *state) |
|---|
| 2097 | +{ |
|---|
| 2098 | + struct nfs_open_context *ctx; |
|---|
| 2099 | + |
|---|
| 2100 | + ctx = nfs4_state_find_open_context_mode(state, FMODE_READ|FMODE_WRITE); |
|---|
| 2101 | + if (!IS_ERR(ctx)) |
|---|
| 2102 | + return ctx; |
|---|
| 2103 | + ctx = nfs4_state_find_open_context_mode(state, FMODE_WRITE); |
|---|
| 2104 | + if (!IS_ERR(ctx)) |
|---|
| 2105 | + return ctx; |
|---|
| 2106 | + return nfs4_state_find_open_context_mode(state, FMODE_READ); |
|---|
| 1966 | 2107 | } |
|---|
| 1967 | 2108 | |
|---|
| 1968 | 2109 | static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context *ctx, |
|---|
| .. | .. |
|---|
| 1975 | 2116 | if (opendata == NULL) |
|---|
| 1976 | 2117 | return ERR_PTR(-ENOMEM); |
|---|
| 1977 | 2118 | opendata->state = state; |
|---|
| 1978 | | - atomic_inc(&state->count); |
|---|
| 2119 | + refcount_inc(&state->count); |
|---|
| 1979 | 2120 | return opendata; |
|---|
| 1980 | 2121 | } |
|---|
| 1981 | 2122 | |
|---|
| .. | .. |
|---|
| 2011 | 2152 | { |
|---|
| 2012 | 2153 | int ret; |
|---|
| 2013 | 2154 | |
|---|
| 2014 | | - /* Don't trigger recovery in nfs_test_and_clear_all_open_stateid */ |
|---|
| 2015 | | - clear_bit(NFS_O_RDWR_STATE, &state->flags); |
|---|
| 2016 | | - clear_bit(NFS_O_WRONLY_STATE, &state->flags); |
|---|
| 2017 | | - clear_bit(NFS_O_RDONLY_STATE, &state->flags); |
|---|
| 2018 | 2155 | /* memory barrier prior to reading state->n_* */ |
|---|
| 2019 | | - clear_bit(NFS_DELEGATED_STATE, &state->flags); |
|---|
| 2020 | | - clear_bit(NFS_OPEN_STATE, &state->flags); |
|---|
| 2021 | 2156 | smp_rmb(); |
|---|
| 2022 | 2157 | ret = nfs4_open_recover_helper(opendata, FMODE_READ|FMODE_WRITE); |
|---|
| 2023 | 2158 | if (ret != 0) |
|---|
| .. | .. |
|---|
| 2093 | 2228 | ctx = nfs4_state_find_open_context(state); |
|---|
| 2094 | 2229 | if (IS_ERR(ctx)) |
|---|
| 2095 | 2230 | return -EAGAIN; |
|---|
| 2231 | + clear_bit(NFS_DELEGATED_STATE, &state->flags); |
|---|
| 2232 | + nfs_state_clear_open_state_flags(state); |
|---|
| 2096 | 2233 | ret = nfs4_do_open_reclaim(ctx, state); |
|---|
| 2097 | 2234 | put_nfs_open_context(ctx); |
|---|
| 2098 | 2235 | return ret; |
|---|
| .. | .. |
|---|
| 2108 | 2245 | case -ENOENT: |
|---|
| 2109 | 2246 | case -EAGAIN: |
|---|
| 2110 | 2247 | case -ESTALE: |
|---|
| 2248 | + case -ETIMEDOUT: |
|---|
| 2111 | 2249 | break; |
|---|
| 2112 | 2250 | case -NFS4ERR_BADSESSION: |
|---|
| 2113 | 2251 | case -NFS4ERR_BADSLOT: |
|---|
| 2114 | 2252 | case -NFS4ERR_BAD_HIGH_SLOT: |
|---|
| 2115 | 2253 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
|---|
| 2116 | 2254 | case -NFS4ERR_DEADSESSION: |
|---|
| 2117 | | - nfs4_schedule_session_recovery(server->nfs_client->cl_session, err); |
|---|
| 2118 | 2255 | return -EAGAIN; |
|---|
| 2119 | 2256 | case -NFS4ERR_STALE_CLIENTID: |
|---|
| 2120 | 2257 | case -NFS4ERR_STALE_STATEID: |
|---|
| .. | .. |
|---|
| 2251 | 2388 | .callback_ops = &nfs4_open_confirm_ops, |
|---|
| 2252 | 2389 | .callback_data = data, |
|---|
| 2253 | 2390 | .workqueue = nfsiod_workqueue, |
|---|
| 2254 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 2391 | + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, |
|---|
| 2255 | 2392 | }; |
|---|
| 2256 | 2393 | int status; |
|---|
| 2257 | 2394 | |
|---|
| .. | .. |
|---|
| 2308 | 2445 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
|---|
| 2309 | 2446 | case NFS4_OPEN_CLAIM_DELEG_PREV_FH: |
|---|
| 2310 | 2447 | data->o_arg.open_bitmap = &nfs4_open_noattr_bitmap[0]; |
|---|
| 2311 | | - /* Fall through */ |
|---|
| 2448 | + fallthrough; |
|---|
| 2312 | 2449 | case NFS4_OPEN_CLAIM_FH: |
|---|
| 2313 | 2450 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; |
|---|
| 2314 | 2451 | } |
|---|
| .. | .. |
|---|
| 2416 | 2553 | .callback_ops = &nfs4_open_ops, |
|---|
| 2417 | 2554 | .callback_data = data, |
|---|
| 2418 | 2555 | .workqueue = nfsiod_workqueue, |
|---|
| 2419 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 2556 | + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, |
|---|
| 2420 | 2557 | }; |
|---|
| 2421 | 2558 | int status; |
|---|
| 2422 | 2559 | |
|---|
| .. | .. |
|---|
| 2428 | 2565 | if (!ctx) { |
|---|
| 2429 | 2566 | nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 1); |
|---|
| 2430 | 2567 | data->is_recover = true; |
|---|
| 2568 | + task_setup_data.flags |= RPC_TASK_TIMEOUT; |
|---|
| 2431 | 2569 | } else { |
|---|
| 2432 | 2570 | nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 0); |
|---|
| 2433 | 2571 | pnfs_lgopen_prepare(data, ctx); |
|---|
| .. | .. |
|---|
| 2472 | 2610 | * Note that in the non-execute case, we want to turn off permission |
|---|
| 2473 | 2611 | * checking if we just created a new file (POSIX open() semantics). |
|---|
| 2474 | 2612 | */ |
|---|
| 2475 | | -static int nfs4_opendata_access(struct rpc_cred *cred, |
|---|
| 2613 | +static int nfs4_opendata_access(const struct cred *cred, |
|---|
| 2476 | 2614 | struct nfs4_opendata *opendata, |
|---|
| 2477 | 2615 | struct nfs4_state *state, fmode_t fmode, |
|---|
| 2478 | 2616 | int openflags) |
|---|
| .. | .. |
|---|
| 2541 | 2679 | data->file_created = true; |
|---|
| 2542 | 2680 | if (data->file_created || |
|---|
| 2543 | 2681 | inode_peek_iversion_raw(dir) != o_res->cinfo.after) |
|---|
| 2544 | | - update_changeattr(dir, &o_res->cinfo, |
|---|
| 2545 | | - o_res->f_attr->time_start, 0); |
|---|
| 2682 | + nfs4_update_changeattr(dir, &o_res->cinfo, |
|---|
| 2683 | + o_res->f_attr->time_start, |
|---|
| 2684 | + NFS_INO_INVALID_DATA); |
|---|
| 2546 | 2685 | } |
|---|
| 2547 | 2686 | if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) |
|---|
| 2548 | 2687 | server->caps &= ~NFS_CAP_POSIX_LOCK; |
|---|
| .. | .. |
|---|
| 2634 | 2773 | { |
|---|
| 2635 | 2774 | /* NFSv4.0 doesn't allow for delegation recovery on open expire */ |
|---|
| 2636 | 2775 | nfs40_clear_delegation_stateid(state); |
|---|
| 2776 | + nfs_state_clear_open_state_flags(state); |
|---|
| 2637 | 2777 | return nfs4_open_expired(sp, state); |
|---|
| 2638 | 2778 | } |
|---|
| 2639 | 2779 | |
|---|
| 2640 | 2780 | static int nfs40_test_and_free_expired_stateid(struct nfs_server *server, |
|---|
| 2641 | 2781 | nfs4_stateid *stateid, |
|---|
| 2642 | | - struct rpc_cred *cred) |
|---|
| 2782 | + const struct cred *cred) |
|---|
| 2643 | 2783 | { |
|---|
| 2644 | 2784 | return -NFS4ERR_BAD_STATEID; |
|---|
| 2645 | 2785 | } |
|---|
| .. | .. |
|---|
| 2647 | 2787 | #if defined(CONFIG_NFS_V4_1) |
|---|
| 2648 | 2788 | static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, |
|---|
| 2649 | 2789 | nfs4_stateid *stateid, |
|---|
| 2650 | | - struct rpc_cred *cred) |
|---|
| 2790 | + const struct cred *cred) |
|---|
| 2651 | 2791 | { |
|---|
| 2652 | 2792 | int status; |
|---|
| 2653 | 2793 | |
|---|
| .. | .. |
|---|
| 2676 | 2816 | return -NFS4ERR_EXPIRED; |
|---|
| 2677 | 2817 | } |
|---|
| 2678 | 2818 | |
|---|
| 2679 | | -static void nfs41_check_delegation_stateid(struct nfs4_state *state) |
|---|
| 2819 | +static int nfs41_check_delegation_stateid(struct nfs4_state *state) |
|---|
| 2680 | 2820 | { |
|---|
| 2681 | 2821 | struct nfs_server *server = NFS_SERVER(state->inode); |
|---|
| 2682 | 2822 | nfs4_stateid stateid; |
|---|
| 2683 | 2823 | struct nfs_delegation *delegation; |
|---|
| 2684 | | - struct rpc_cred *cred; |
|---|
| 2685 | | - int status; |
|---|
| 2824 | + const struct cred *cred = NULL; |
|---|
| 2825 | + int status, ret = NFS_OK; |
|---|
| 2686 | 2826 | |
|---|
| 2687 | 2827 | /* Get the delegation credential for use by test/free_stateid */ |
|---|
| 2688 | 2828 | rcu_read_lock(); |
|---|
| .. | .. |
|---|
| 2690 | 2830 | if (delegation == NULL) { |
|---|
| 2691 | 2831 | rcu_read_unlock(); |
|---|
| 2692 | 2832 | nfs_state_clear_delegation(state); |
|---|
| 2693 | | - return; |
|---|
| 2833 | + return NFS_OK; |
|---|
| 2694 | 2834 | } |
|---|
| 2695 | 2835 | |
|---|
| 2836 | + spin_lock(&delegation->lock); |
|---|
| 2696 | 2837 | nfs4_stateid_copy(&stateid, &delegation->stateid); |
|---|
| 2697 | | - if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { |
|---|
| 2698 | | - rcu_read_unlock(); |
|---|
| 2699 | | - nfs_state_clear_delegation(state); |
|---|
| 2700 | | - return; |
|---|
| 2701 | | - } |
|---|
| 2702 | 2838 | |
|---|
| 2703 | 2839 | if (!test_and_clear_bit(NFS_DELEGATION_TEST_EXPIRED, |
|---|
| 2704 | 2840 | &delegation->flags)) { |
|---|
| 2841 | + spin_unlock(&delegation->lock); |
|---|
| 2705 | 2842 | rcu_read_unlock(); |
|---|
| 2706 | | - return; |
|---|
| 2843 | + return NFS_OK; |
|---|
| 2707 | 2844 | } |
|---|
| 2708 | 2845 | |
|---|
| 2709 | | - cred = get_rpccred(delegation->cred); |
|---|
| 2846 | + if (delegation->cred) |
|---|
| 2847 | + cred = get_cred(delegation->cred); |
|---|
| 2848 | + spin_unlock(&delegation->lock); |
|---|
| 2710 | 2849 | rcu_read_unlock(); |
|---|
| 2711 | 2850 | status = nfs41_test_and_free_expired_stateid(server, &stateid, cred); |
|---|
| 2712 | 2851 | trace_nfs4_test_delegation_stateid(state, NULL, status); |
|---|
| 2713 | 2852 | if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) |
|---|
| 2714 | 2853 | nfs_finish_clear_delegation_stateid(state, &stateid); |
|---|
| 2854 | + else |
|---|
| 2855 | + ret = status; |
|---|
| 2715 | 2856 | |
|---|
| 2716 | | - put_rpccred(cred); |
|---|
| 2857 | + put_cred(cred); |
|---|
| 2858 | + return ret; |
|---|
| 2859 | +} |
|---|
| 2860 | + |
|---|
| 2861 | +static void nfs41_delegation_recover_stateid(struct nfs4_state *state) |
|---|
| 2862 | +{ |
|---|
| 2863 | + nfs4_stateid tmp; |
|---|
| 2864 | + |
|---|
| 2865 | + if (test_bit(NFS_DELEGATED_STATE, &state->flags) && |
|---|
| 2866 | + nfs4_copy_delegation_stateid(state->inode, state->state, |
|---|
| 2867 | + &tmp, NULL) && |
|---|
| 2868 | + nfs4_stateid_match_other(&state->stateid, &tmp)) |
|---|
| 2869 | + nfs_state_set_delegation(state, &tmp, state->state); |
|---|
| 2870 | + else |
|---|
| 2871 | + nfs_state_clear_delegation(state); |
|---|
| 2717 | 2872 | } |
|---|
| 2718 | 2873 | |
|---|
| 2719 | 2874 | /** |
|---|
| .. | .. |
|---|
| 2736 | 2891 | spin_lock(&state->state_lock); |
|---|
| 2737 | 2892 | list_for_each_entry(lsp, &state->lock_states, ls_locks) { |
|---|
| 2738 | 2893 | if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags)) { |
|---|
| 2739 | | - struct rpc_cred *cred = lsp->ls_state->owner->so_cred; |
|---|
| 2894 | + const struct cred *cred = lsp->ls_state->owner->so_cred; |
|---|
| 2740 | 2895 | |
|---|
| 2741 | 2896 | refcount_inc(&lsp->ls_count); |
|---|
| 2742 | 2897 | spin_unlock(&state->state_lock); |
|---|
| .. | .. |
|---|
| 2780 | 2935 | { |
|---|
| 2781 | 2936 | struct nfs_server *server = NFS_SERVER(state->inode); |
|---|
| 2782 | 2937 | nfs4_stateid *stateid = &state->open_stateid; |
|---|
| 2783 | | - struct rpc_cred *cred = state->owner->so_cred; |
|---|
| 2938 | + const struct cred *cred = state->owner->so_cred; |
|---|
| 2784 | 2939 | int status; |
|---|
| 2785 | 2940 | |
|---|
| 2786 | | - if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) { |
|---|
| 2787 | | - if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) { |
|---|
| 2788 | | - if (nfs4_have_delegation(state->inode, state->state)) |
|---|
| 2789 | | - return NFS_OK; |
|---|
| 2790 | | - return -NFS4ERR_OPENMODE; |
|---|
| 2791 | | - } |
|---|
| 2941 | + if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) |
|---|
| 2792 | 2942 | return -NFS4ERR_BAD_STATEID; |
|---|
| 2793 | | - } |
|---|
| 2794 | 2943 | status = nfs41_test_and_free_expired_stateid(server, stateid, cred); |
|---|
| 2795 | 2944 | trace_nfs4_test_open_stateid(state, NULL, status); |
|---|
| 2796 | 2945 | if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) { |
|---|
| 2797 | | - clear_bit(NFS_O_RDONLY_STATE, &state->flags); |
|---|
| 2798 | | - clear_bit(NFS_O_WRONLY_STATE, &state->flags); |
|---|
| 2799 | | - clear_bit(NFS_O_RDWR_STATE, &state->flags); |
|---|
| 2800 | | - clear_bit(NFS_OPEN_STATE, &state->flags); |
|---|
| 2946 | + nfs_state_clear_open_state_flags(state); |
|---|
| 2801 | 2947 | stateid->type = NFS4_INVALID_STATEID_TYPE; |
|---|
| 2802 | 2948 | return status; |
|---|
| 2803 | 2949 | } |
|---|
| .. | .. |
|---|
| 2810 | 2956 | { |
|---|
| 2811 | 2957 | int status; |
|---|
| 2812 | 2958 | |
|---|
| 2813 | | - nfs41_check_delegation_stateid(state); |
|---|
| 2959 | + status = nfs41_check_delegation_stateid(state); |
|---|
| 2960 | + if (status != NFS_OK) |
|---|
| 2961 | + return status; |
|---|
| 2962 | + nfs41_delegation_recover_stateid(state); |
|---|
| 2963 | + |
|---|
| 2814 | 2964 | status = nfs41_check_expired_locks(state); |
|---|
| 2815 | 2965 | if (status != NFS_OK) |
|---|
| 2816 | 2966 | return status; |
|---|
| .. | .. |
|---|
| 2863 | 3013 | } |
|---|
| 2864 | 3014 | |
|---|
| 2865 | 3015 | static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, |
|---|
| 2866 | | - fmode_t fmode, |
|---|
| 2867 | | - int flags, |
|---|
| 2868 | | - struct nfs_open_context *ctx) |
|---|
| 3016 | + int flags, struct nfs_open_context *ctx) |
|---|
| 2869 | 3017 | { |
|---|
| 2870 | 3018 | struct nfs4_state_owner *sp = opendata->owner; |
|---|
| 2871 | 3019 | struct nfs_server *server = sp->so_server; |
|---|
| 2872 | 3020 | struct dentry *dentry; |
|---|
| 2873 | 3021 | struct nfs4_state *state; |
|---|
| 3022 | + fmode_t acc_mode = _nfs4_ctx_to_accessmode(ctx); |
|---|
| 3023 | + struct inode *dir = d_inode(opendata->dir); |
|---|
| 3024 | + unsigned long dir_verifier; |
|---|
| 2874 | 3025 | unsigned int seq; |
|---|
| 2875 | 3026 | int ret; |
|---|
| 2876 | 3027 | |
|---|
| 2877 | | - seq = raw_seqcount_begin(&sp->so_reclaim_seqlock.seqcount); |
|---|
| 3028 | + seq = raw_seqcount_begin(&sp->so_reclaim_seqcount); |
|---|
| 3029 | + dir_verifier = nfs_save_change_attribute(dir); |
|---|
| 2878 | 3030 | |
|---|
| 2879 | 3031 | ret = _nfs4_proc_open(opendata, ctx); |
|---|
| 2880 | 3032 | if (ret != 0) |
|---|
| .. | .. |
|---|
| 2902 | 3054 | dput(ctx->dentry); |
|---|
| 2903 | 3055 | ctx->dentry = dentry = alias; |
|---|
| 2904 | 3056 | } |
|---|
| 2905 | | - nfs_set_verifier(dentry, |
|---|
| 2906 | | - nfs_save_change_attribute(d_inode(opendata->dir))); |
|---|
| 3057 | + } |
|---|
| 3058 | + |
|---|
| 3059 | + switch(opendata->o_arg.claim) { |
|---|
| 3060 | + default: |
|---|
| 3061 | + break; |
|---|
| 3062 | + case NFS4_OPEN_CLAIM_NULL: |
|---|
| 3063 | + case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
|---|
| 3064 | + case NFS4_OPEN_CLAIM_DELEGATE_PREV: |
|---|
| 3065 | + if (!opendata->rpc_done) |
|---|
| 3066 | + break; |
|---|
| 3067 | + if (opendata->o_res.delegation_type != 0) |
|---|
| 3068 | + dir_verifier = nfs_save_change_attribute(dir); |
|---|
| 3069 | + nfs_set_verifier(dentry, dir_verifier); |
|---|
| 2907 | 3070 | } |
|---|
| 2908 | 3071 | |
|---|
| 2909 | 3072 | /* Parse layoutget results before we check for access */ |
|---|
| 2910 | 3073 | pnfs_parse_lgopen(state->inode, opendata->lgp, ctx); |
|---|
| 2911 | 3074 | |
|---|
| 2912 | | - ret = nfs4_opendata_access(sp->so_cred, opendata, state, fmode, flags); |
|---|
| 3075 | + ret = nfs4_opendata_access(sp->so_cred, opendata, state, |
|---|
| 3076 | + acc_mode, flags); |
|---|
| 2913 | 3077 | if (ret != 0) |
|---|
| 2914 | 3078 | goto out; |
|---|
| 2915 | 3079 | |
|---|
| 2916 | 3080 | if (d_inode(dentry) == state->inode) { |
|---|
| 2917 | 3081 | nfs_inode_attach_open_context(ctx); |
|---|
| 2918 | | - if (read_seqretry(&sp->so_reclaim_seqlock, seq)) |
|---|
| 3082 | + if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) |
|---|
| 2919 | 3083 | nfs4_schedule_stateid_recovery(server, state); |
|---|
| 2920 | 3084 | } |
|---|
| 2921 | 3085 | |
|---|
| 2922 | 3086 | out: |
|---|
| 2923 | | - if (!opendata->cancelled) |
|---|
| 3087 | + if (!opendata->cancelled) { |
|---|
| 3088 | + if (opendata->lgp) { |
|---|
| 3089 | + nfs4_lgopen_release(opendata->lgp); |
|---|
| 3090 | + opendata->lgp = NULL; |
|---|
| 3091 | + } |
|---|
| 2924 | 3092 | nfs4_sequence_free_slot(&opendata->o_res.seq_res); |
|---|
| 3093 | + } |
|---|
| 2925 | 3094 | return ret; |
|---|
| 2926 | 3095 | } |
|---|
| 2927 | 3096 | |
|---|
| .. | .. |
|---|
| 2939 | 3108 | struct nfs_server *server = NFS_SERVER(dir); |
|---|
| 2940 | 3109 | struct nfs4_opendata *opendata; |
|---|
| 2941 | 3110 | struct dentry *dentry = ctx->dentry; |
|---|
| 2942 | | - struct rpc_cred *cred = ctx->cred; |
|---|
| 3111 | + const struct cred *cred = ctx->cred; |
|---|
| 2943 | 3112 | struct nfs4_threshold **ctx_th = &ctx->mdsthreshold; |
|---|
| 2944 | | - fmode_t fmode = ctx->mode & (FMODE_READ|FMODE_WRITE|FMODE_EXEC); |
|---|
| 3113 | + fmode_t fmode = _nfs4_ctx_to_openmode(ctx); |
|---|
| 2945 | 3114 | enum open_claim_type4 claim = NFS4_OPEN_CLAIM_NULL; |
|---|
| 2946 | 3115 | struct iattr *sattr = c->sattr; |
|---|
| 2947 | 3116 | struct nfs4_label *label = c->label; |
|---|
| .. | .. |
|---|
| 2987 | 3156 | if (d_really_is_positive(dentry)) |
|---|
| 2988 | 3157 | opendata->state = nfs4_get_open_state(d_inode(dentry), sp); |
|---|
| 2989 | 3158 | |
|---|
| 2990 | | - status = _nfs4_open_and_get_state(opendata, fmode, flags, ctx); |
|---|
| 3159 | + status = _nfs4_open_and_get_state(opendata, flags, ctx); |
|---|
| 2991 | 3160 | if (status != 0) |
|---|
| 2992 | 3161 | goto err_free_label; |
|---|
| 2993 | 3162 | state = ctx->state; |
|---|
| .. | .. |
|---|
| 3047 | 3216 | int *opened) |
|---|
| 3048 | 3217 | { |
|---|
| 3049 | 3218 | struct nfs_server *server = NFS_SERVER(dir); |
|---|
| 3050 | | - struct nfs4_exception exception = { }; |
|---|
| 3219 | + struct nfs4_exception exception = { |
|---|
| 3220 | + .interruptible = true, |
|---|
| 3221 | + }; |
|---|
| 3051 | 3222 | struct nfs4_state *res; |
|---|
| 3052 | 3223 | struct nfs4_open_createattrs c = { |
|---|
| 3053 | 3224 | .label = label, |
|---|
| .. | .. |
|---|
| 3114 | 3285 | static int _nfs4_do_setattr(struct inode *inode, |
|---|
| 3115 | 3286 | struct nfs_setattrargs *arg, |
|---|
| 3116 | 3287 | struct nfs_setattrres *res, |
|---|
| 3117 | | - struct rpc_cred *cred, |
|---|
| 3288 | + const struct cred *cred, |
|---|
| 3118 | 3289 | struct nfs_open_context *ctx) |
|---|
| 3119 | 3290 | { |
|---|
| 3120 | 3291 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| .. | .. |
|---|
| 3124 | 3295 | .rpc_resp = res, |
|---|
| 3125 | 3296 | .rpc_cred = cred, |
|---|
| 3126 | 3297 | }; |
|---|
| 3127 | | - struct rpc_cred *delegation_cred = NULL; |
|---|
| 3298 | + const struct cred *delegation_cred = NULL; |
|---|
| 3128 | 3299 | unsigned long timestamp = jiffies; |
|---|
| 3129 | 3300 | bool truncate; |
|---|
| 3130 | 3301 | int status; |
|---|
| .. | .. |
|---|
| 3152 | 3323 | nfs_put_lock_context(l_ctx); |
|---|
| 3153 | 3324 | if (status == -EIO) |
|---|
| 3154 | 3325 | return -EBADF; |
|---|
| 3326 | + else if (status == -EAGAIN) |
|---|
| 3327 | + goto zero_stateid; |
|---|
| 3155 | 3328 | } else { |
|---|
| 3156 | 3329 | zero_stateid: |
|---|
| 3157 | 3330 | nfs4_stateid_copy(&arg->stateid, &zero_stateid); |
|---|
| .. | .. |
|---|
| 3161 | 3334 | |
|---|
| 3162 | 3335 | status = nfs4_call_sync(server->client, server, &msg, &arg->seq_args, &res->seq_res, 1); |
|---|
| 3163 | 3336 | |
|---|
| 3164 | | - put_rpccred(delegation_cred); |
|---|
| 3337 | + put_cred(delegation_cred); |
|---|
| 3165 | 3338 | if (status == 0 && ctx != NULL) |
|---|
| 3166 | 3339 | renew_lease(server, timestamp); |
|---|
| 3167 | 3340 | trace_nfs4_setattr(inode, &arg->stateid, status); |
|---|
| 3168 | 3341 | return status; |
|---|
| 3169 | 3342 | } |
|---|
| 3170 | 3343 | |
|---|
| 3171 | | -static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
|---|
| 3344 | +static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, |
|---|
| 3172 | 3345 | struct nfs_fattr *fattr, struct iattr *sattr, |
|---|
| 3173 | 3346 | struct nfs_open_context *ctx, struct nfs4_label *ilabel, |
|---|
| 3174 | 3347 | struct nfs4_label *olabel) |
|---|
| .. | .. |
|---|
| 3232 | 3405 | return pnfs_wait_on_layoutreturn(inode, task); |
|---|
| 3233 | 3406 | } |
|---|
| 3234 | 3407 | |
|---|
| 3408 | +/* |
|---|
| 3409 | + * Update the seqid of an open stateid |
|---|
| 3410 | + */ |
|---|
| 3411 | +static void nfs4_sync_open_stateid(nfs4_stateid *dst, |
|---|
| 3412 | + struct nfs4_state *state) |
|---|
| 3413 | +{ |
|---|
| 3414 | + __be32 seqid_open; |
|---|
| 3415 | + u32 dst_seqid; |
|---|
| 3416 | + int seq; |
|---|
| 3417 | + |
|---|
| 3418 | + for (;;) { |
|---|
| 3419 | + if (!nfs4_valid_open_stateid(state)) |
|---|
| 3420 | + break; |
|---|
| 3421 | + seq = read_seqbegin(&state->seqlock); |
|---|
| 3422 | + if (!nfs4_state_match_open_stateid_other(state, dst)) { |
|---|
| 3423 | + nfs4_stateid_copy(dst, &state->open_stateid); |
|---|
| 3424 | + if (read_seqretry(&state->seqlock, seq)) |
|---|
| 3425 | + continue; |
|---|
| 3426 | + break; |
|---|
| 3427 | + } |
|---|
| 3428 | + seqid_open = state->open_stateid.seqid; |
|---|
| 3429 | + if (read_seqretry(&state->seqlock, seq)) |
|---|
| 3430 | + continue; |
|---|
| 3431 | + |
|---|
| 3432 | + dst_seqid = be32_to_cpu(dst->seqid); |
|---|
| 3433 | + if ((s32)(dst_seqid - be32_to_cpu(seqid_open)) < 0) |
|---|
| 3434 | + dst->seqid = seqid_open; |
|---|
| 3435 | + break; |
|---|
| 3436 | + } |
|---|
| 3437 | +} |
|---|
| 3438 | + |
|---|
| 3439 | +/* |
|---|
| 3440 | + * Update the seqid of an open stateid after receiving |
|---|
| 3441 | + * NFS4ERR_OLD_STATEID |
|---|
| 3442 | + */ |
|---|
| 3443 | +static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst, |
|---|
| 3444 | + struct nfs4_state *state) |
|---|
| 3445 | +{ |
|---|
| 3446 | + __be32 seqid_open; |
|---|
| 3447 | + u32 dst_seqid; |
|---|
| 3448 | + bool ret; |
|---|
| 3449 | + int seq, status = -EAGAIN; |
|---|
| 3450 | + DEFINE_WAIT(wait); |
|---|
| 3451 | + |
|---|
| 3452 | + for (;;) { |
|---|
| 3453 | + ret = false; |
|---|
| 3454 | + if (!nfs4_valid_open_stateid(state)) |
|---|
| 3455 | + break; |
|---|
| 3456 | + seq = read_seqbegin(&state->seqlock); |
|---|
| 3457 | + if (!nfs4_state_match_open_stateid_other(state, dst)) { |
|---|
| 3458 | + if (read_seqretry(&state->seqlock, seq)) |
|---|
| 3459 | + continue; |
|---|
| 3460 | + break; |
|---|
| 3461 | + } |
|---|
| 3462 | + |
|---|
| 3463 | + write_seqlock(&state->seqlock); |
|---|
| 3464 | + seqid_open = state->open_stateid.seqid; |
|---|
| 3465 | + |
|---|
| 3466 | + dst_seqid = be32_to_cpu(dst->seqid); |
|---|
| 3467 | + |
|---|
| 3468 | + /* Did another OPEN bump the state's seqid? try again: */ |
|---|
| 3469 | + if ((s32)(be32_to_cpu(seqid_open) - dst_seqid) > 0) { |
|---|
| 3470 | + dst->seqid = seqid_open; |
|---|
| 3471 | + write_sequnlock(&state->seqlock); |
|---|
| 3472 | + ret = true; |
|---|
| 3473 | + break; |
|---|
| 3474 | + } |
|---|
| 3475 | + |
|---|
| 3476 | + /* server says we're behind but we haven't seen the update yet */ |
|---|
| 3477 | + set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); |
|---|
| 3478 | + prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); |
|---|
| 3479 | + write_sequnlock(&state->seqlock); |
|---|
| 3480 | + trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); |
|---|
| 3481 | + |
|---|
| 3482 | + if (fatal_signal_pending(current)) |
|---|
| 3483 | + status = -EINTR; |
|---|
| 3484 | + else |
|---|
| 3485 | + if (schedule_timeout(5*HZ) != 0) |
|---|
| 3486 | + status = 0; |
|---|
| 3487 | + |
|---|
| 3488 | + finish_wait(&state->waitq, &wait); |
|---|
| 3489 | + |
|---|
| 3490 | + if (!status) |
|---|
| 3491 | + continue; |
|---|
| 3492 | + if (status == -EINTR) |
|---|
| 3493 | + break; |
|---|
| 3494 | + |
|---|
| 3495 | + /* we slept the whole 5 seconds, we must have lost a seqid */ |
|---|
| 3496 | + dst->seqid = cpu_to_be32(dst_seqid + 1); |
|---|
| 3497 | + ret = true; |
|---|
| 3498 | + break; |
|---|
| 3499 | + } |
|---|
| 3500 | + |
|---|
| 3501 | + return ret; |
|---|
| 3502 | +} |
|---|
| 3503 | + |
|---|
| 3235 | 3504 | struct nfs4_closedata { |
|---|
| 3236 | 3505 | struct inode *inode; |
|---|
| 3237 | 3506 | struct nfs4_state *state; |
|---|
| .. | .. |
|---|
| 3282 | 3551 | trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); |
|---|
| 3283 | 3552 | |
|---|
| 3284 | 3553 | /* Handle Layoutreturn errors */ |
|---|
| 3285 | | - if (calldata->arg.lr_args && task->tk_status != 0) { |
|---|
| 3286 | | - switch (calldata->res.lr_ret) { |
|---|
| 3287 | | - default: |
|---|
| 3288 | | - calldata->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; |
|---|
| 3289 | | - break; |
|---|
| 3290 | | - case 0: |
|---|
| 3291 | | - calldata->arg.lr_args = NULL; |
|---|
| 3292 | | - calldata->res.lr_res = NULL; |
|---|
| 3293 | | - break; |
|---|
| 3294 | | - case -NFS4ERR_OLD_STATEID: |
|---|
| 3295 | | - if (nfs4_layoutreturn_refresh_stateid(&calldata->arg.lr_args->stateid, |
|---|
| 3296 | | - &calldata->arg.lr_args->range, |
|---|
| 3297 | | - calldata->inode)) |
|---|
| 3298 | | - goto lr_restart; |
|---|
| 3299 | | - /* Fallthrough */ |
|---|
| 3300 | | - case -NFS4ERR_ADMIN_REVOKED: |
|---|
| 3301 | | - case -NFS4ERR_DELEG_REVOKED: |
|---|
| 3302 | | - case -NFS4ERR_EXPIRED: |
|---|
| 3303 | | - case -NFS4ERR_BAD_STATEID: |
|---|
| 3304 | | - case -NFS4ERR_UNKNOWN_LAYOUTTYPE: |
|---|
| 3305 | | - case -NFS4ERR_WRONG_CRED: |
|---|
| 3306 | | - calldata->arg.lr_args = NULL; |
|---|
| 3307 | | - calldata->res.lr_res = NULL; |
|---|
| 3308 | | - goto lr_restart; |
|---|
| 3309 | | - } |
|---|
| 3310 | | - } |
|---|
| 3554 | + if (pnfs_roc_done(task, &calldata->arg.lr_args, &calldata->res.lr_res, |
|---|
| 3555 | + &calldata->res.lr_ret) == -EAGAIN) |
|---|
| 3556 | + goto out_restart; |
|---|
| 3311 | 3557 | |
|---|
| 3312 | 3558 | /* hmm. we are done with the inode, and in the process of freeing |
|---|
| 3313 | 3559 | * the state_owner. we keep this around to process errors |
|---|
| .. | .. |
|---|
| 3327 | 3573 | break; |
|---|
| 3328 | 3574 | case -NFS4ERR_OLD_STATEID: |
|---|
| 3329 | 3575 | /* Did we race with OPEN? */ |
|---|
| 3330 | | - if (nfs4_refresh_open_stateid(&calldata->arg.stateid, |
|---|
| 3576 | + if (nfs4_refresh_open_old_stateid(&calldata->arg.stateid, |
|---|
| 3331 | 3577 | state)) |
|---|
| 3332 | 3578 | goto out_restart; |
|---|
| 3333 | 3579 | goto out_release; |
|---|
| .. | .. |
|---|
| 3337 | 3583 | nfs4_free_revoked_stateid(server, |
|---|
| 3338 | 3584 | &calldata->arg.stateid, |
|---|
| 3339 | 3585 | task->tk_msg.rpc_cred); |
|---|
| 3340 | | - /* Fallthrough */ |
|---|
| 3586 | + fallthrough; |
|---|
| 3341 | 3587 | case -NFS4ERR_BAD_STATEID: |
|---|
| 3342 | | - break; |
|---|
| 3588 | + if (calldata->arg.fmode == 0) |
|---|
| 3589 | + break; |
|---|
| 3590 | + fallthrough; |
|---|
| 3343 | 3591 | default: |
|---|
| 3344 | 3592 | task->tk_status = nfs4_async_handle_exception(task, |
|---|
| 3345 | 3593 | server, task->tk_status, &exception); |
|---|
| .. | .. |
|---|
| 3354 | 3602 | nfs_refresh_inode(calldata->inode, &calldata->fattr); |
|---|
| 3355 | 3603 | dprintk("%s: done, ret = %d!\n", __func__, task->tk_status); |
|---|
| 3356 | 3604 | return; |
|---|
| 3357 | | -lr_restart: |
|---|
| 3358 | | - calldata->res.lr_ret = 0; |
|---|
| 3359 | 3605 | out_restart: |
|---|
| 3360 | 3606 | task->tk_status = 0; |
|---|
| 3361 | 3607 | rpc_restart_call_prepare(task); |
|---|
| .. | .. |
|---|
| 3367 | 3613 | struct nfs4_closedata *calldata = data; |
|---|
| 3368 | 3614 | struct nfs4_state *state = calldata->state; |
|---|
| 3369 | 3615 | struct inode *inode = calldata->inode; |
|---|
| 3616 | + struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 3370 | 3617 | struct pnfs_layout_hdr *lo; |
|---|
| 3371 | 3618 | bool is_rdonly, is_wronly, is_rdwr; |
|---|
| 3372 | 3619 | int call_close = 0; |
|---|
| .. | .. |
|---|
| 3396 | 3643 | } else if (is_rdwr) |
|---|
| 3397 | 3644 | calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; |
|---|
| 3398 | 3645 | |
|---|
| 3399 | | - if (!nfs4_valid_open_stateid(state) || |
|---|
| 3400 | | - !nfs4_refresh_open_stateid(&calldata->arg.stateid, state)) |
|---|
| 3646 | + nfs4_sync_open_stateid(&calldata->arg.stateid, state); |
|---|
| 3647 | + if (!nfs4_valid_open_stateid(state)) |
|---|
| 3401 | 3648 | call_close = 0; |
|---|
| 3402 | 3649 | spin_unlock(&state->owner->so_lock); |
|---|
| 3403 | 3650 | |
|---|
| .. | .. |
|---|
| 3422 | 3669 | |
|---|
| 3423 | 3670 | if (calldata->arg.fmode == 0 || calldata->arg.fmode == FMODE_READ) { |
|---|
| 3424 | 3671 | /* Close-to-open cache consistency revalidation */ |
|---|
| 3425 | | - if (!nfs4_have_delegation(inode, FMODE_READ)) |
|---|
| 3426 | | - calldata->arg.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask; |
|---|
| 3427 | | - else |
|---|
| 3672 | + if (!nfs4_have_delegation(inode, FMODE_READ)) { |
|---|
| 3673 | + nfs4_bitmask_set(calldata->arg.bitmask_store, |
|---|
| 3674 | + server->cache_consistency_bitmask, |
|---|
| 3675 | + inode, server, NULL); |
|---|
| 3676 | + calldata->arg.bitmask = calldata->arg.bitmask_store; |
|---|
| 3677 | + } else |
|---|
| 3428 | 3678 | calldata->arg.bitmask = NULL; |
|---|
| 3429 | 3679 | } |
|---|
| 3430 | 3680 | |
|---|
| .. | .. |
|---|
| 3483 | 3733 | .rpc_message = &msg, |
|---|
| 3484 | 3734 | .callback_ops = &nfs4_close_ops, |
|---|
| 3485 | 3735 | .workqueue = nfsiod_workqueue, |
|---|
| 3486 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 3736 | + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, |
|---|
| 3487 | 3737 | }; |
|---|
| 3488 | 3738 | int status = -ENOMEM; |
|---|
| 3489 | 3739 | |
|---|
| .. | .. |
|---|
| 3562 | 3812 | if (ctx->state == NULL) |
|---|
| 3563 | 3813 | return; |
|---|
| 3564 | 3814 | if (is_sync) |
|---|
| 3565 | | - nfs4_close_sync(ctx->state, ctx->mode); |
|---|
| 3815 | + nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx)); |
|---|
| 3566 | 3816 | else |
|---|
| 3567 | | - nfs4_close_state(ctx->state, ctx->mode); |
|---|
| 3817 | + nfs4_close_state(ctx->state, _nfs4_ctx_to_openmode(ctx)); |
|---|
| 3568 | 3818 | } |
|---|
| 3569 | 3819 | |
|---|
| 3570 | 3820 | #define FATTR4_WORD1_NFS40_MASK (2*FATTR4_WORD1_MOUNTED_ON_FILEID - 1UL) |
|---|
| 3571 | 3821 | #define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL) |
|---|
| 3572 | | -#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_MODE_UMASK - 1UL) |
|---|
| 3822 | +#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_XATTR_SUPPORT - 1UL) |
|---|
| 3573 | 3823 | |
|---|
| 3574 | 3824 | static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) |
|---|
| 3575 | 3825 | { |
|---|
| .. | .. |
|---|
| 3667 | 3917 | |
|---|
| 3668 | 3918 | int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) |
|---|
| 3669 | 3919 | { |
|---|
| 3670 | | - struct nfs4_exception exception = { }; |
|---|
| 3920 | + struct nfs4_exception exception = { |
|---|
| 3921 | + .interruptible = true, |
|---|
| 3922 | + }; |
|---|
| 3671 | 3923 | int err; |
|---|
| 3672 | 3924 | do { |
|---|
| 3673 | 3925 | err = nfs4_handle_exception(server, |
|---|
| .. | .. |
|---|
| 3709 | 3961 | static int nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle, |
|---|
| 3710 | 3962 | struct nfs_fsinfo *info) |
|---|
| 3711 | 3963 | { |
|---|
| 3712 | | - struct nfs4_exception exception = { }; |
|---|
| 3964 | + struct nfs4_exception exception = { |
|---|
| 3965 | + .interruptible = true, |
|---|
| 3966 | + }; |
|---|
| 3713 | 3967 | int err; |
|---|
| 3714 | 3968 | do { |
|---|
| 3715 | 3969 | err = _nfs4_lookup_root(server, fhandle, info); |
|---|
| .. | .. |
|---|
| 3784 | 4038 | } |
|---|
| 3785 | 4039 | |
|---|
| 3786 | 4040 | /* |
|---|
| 3787 | | - * -EACCESS could mean that the user doesn't have correct permissions |
|---|
| 4041 | + * -EACCES could mean that the user doesn't have correct permissions |
|---|
| 3788 | 4042 | * to access the mount. It could also mean that we tried to mount |
|---|
| 3789 | 4043 | * with a gss auth flavor, but rpc.gssd isn't running. Either way, |
|---|
| 3790 | 4044 | * existing mount programs don't handle -EACCES very well so it should |
|---|
| .. | .. |
|---|
| 3830 | 4084 | { |
|---|
| 3831 | 4085 | int error; |
|---|
| 3832 | 4086 | struct nfs_fattr *fattr = info->fattr; |
|---|
| 3833 | | - struct nfs4_label *label = NULL; |
|---|
| 4087 | + struct nfs4_label *label = fattr->label; |
|---|
| 3834 | 4088 | |
|---|
| 3835 | 4089 | error = nfs4_server_capabilities(server, mntfh); |
|---|
| 3836 | 4090 | if (error < 0) { |
|---|
| .. | .. |
|---|
| 3838 | 4092 | return error; |
|---|
| 3839 | 4093 | } |
|---|
| 3840 | 4094 | |
|---|
| 3841 | | - label = nfs4_label_alloc(server, GFP_KERNEL); |
|---|
| 3842 | | - if (IS_ERR(label)) |
|---|
| 3843 | | - return PTR_ERR(label); |
|---|
| 3844 | | - |
|---|
| 3845 | 4095 | error = nfs4_proc_getattr(server, mntfh, fattr, label, NULL); |
|---|
| 3846 | 4096 | if (error < 0) { |
|---|
| 3847 | 4097 | dprintk("nfs4_get_root: getattr error = %d\n", -error); |
|---|
| 3848 | | - goto err_free_label; |
|---|
| 4098 | + goto out; |
|---|
| 3849 | 4099 | } |
|---|
| 3850 | 4100 | |
|---|
| 3851 | 4101 | if (fattr->valid & NFS_ATTR_FATTR_FSID && |
|---|
| 3852 | 4102 | !nfs_fsid_equal(&server->fsid, &fattr->fsid)) |
|---|
| 3853 | 4103 | memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid)); |
|---|
| 3854 | 4104 | |
|---|
| 3855 | | -err_free_label: |
|---|
| 3856 | | - nfs4_label_free(label); |
|---|
| 3857 | | - |
|---|
| 4105 | +out: |
|---|
| 3858 | 4106 | return error; |
|---|
| 3859 | 4107 | } |
|---|
| 3860 | 4108 | |
|---|
| .. | .. |
|---|
| 3925 | 4173 | .rpc_argp = &args, |
|---|
| 3926 | 4174 | .rpc_resp = &res, |
|---|
| 3927 | 4175 | }; |
|---|
| 4176 | + unsigned short task_flags = 0; |
|---|
| 4177 | + |
|---|
| 4178 | + /* Is this is an attribute revalidation, subject to softreval? */ |
|---|
| 4179 | + if (inode && (server->flags & NFS_MOUNT_SOFTREVAL)) |
|---|
| 4180 | + task_flags |= RPC_TASK_TIMEOUT; |
|---|
| 3928 | 4181 | |
|---|
| 3929 | 4182 | nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode); |
|---|
| 3930 | 4183 | |
|---|
| 3931 | 4184 | nfs_fattr_init(fattr); |
|---|
| 3932 | | - return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); |
|---|
| 4185 | + nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0); |
|---|
| 4186 | + return nfs4_do_call_sync(server->client, server, &msg, |
|---|
| 4187 | + &args.seq_args, &res.seq_res, task_flags); |
|---|
| 3933 | 4188 | } |
|---|
| 3934 | 4189 | |
|---|
| 3935 | | -static int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, |
|---|
| 4190 | +int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, |
|---|
| 3936 | 4191 | struct nfs_fattr *fattr, struct nfs4_label *label, |
|---|
| 3937 | 4192 | struct inode *inode) |
|---|
| 3938 | 4193 | { |
|---|
| 3939 | | - struct nfs4_exception exception = { }; |
|---|
| 4194 | + struct nfs4_exception exception = { |
|---|
| 4195 | + .interruptible = true, |
|---|
| 4196 | + }; |
|---|
| 3940 | 4197 | int err; |
|---|
| 3941 | 4198 | do { |
|---|
| 3942 | 4199 | err = _nfs4_proc_getattr(server, fhandle, fattr, label, inode); |
|---|
| .. | .. |
|---|
| 3969 | 4226 | struct iattr *sattr) |
|---|
| 3970 | 4227 | { |
|---|
| 3971 | 4228 | struct inode *inode = d_inode(dentry); |
|---|
| 3972 | | - struct rpc_cred *cred = NULL; |
|---|
| 4229 | + const struct cred *cred = NULL; |
|---|
| 3973 | 4230 | struct nfs_open_context *ctx = NULL; |
|---|
| 3974 | 4231 | struct nfs4_label *label = NULL; |
|---|
| 3975 | 4232 | int status; |
|---|
| .. | .. |
|---|
| 4015 | 4272 | } |
|---|
| 4016 | 4273 | |
|---|
| 4017 | 4274 | static int _nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, |
|---|
| 4018 | | - const struct qstr *name, struct nfs_fh *fhandle, |
|---|
| 4275 | + struct dentry *dentry, struct nfs_fh *fhandle, |
|---|
| 4019 | 4276 | struct nfs_fattr *fattr, struct nfs4_label *label) |
|---|
| 4020 | 4277 | { |
|---|
| 4021 | 4278 | struct nfs_server *server = NFS_SERVER(dir); |
|---|
| .. | .. |
|---|
| 4023 | 4280 | struct nfs4_lookup_arg args = { |
|---|
| 4024 | 4281 | .bitmask = server->attr_bitmask, |
|---|
| 4025 | 4282 | .dir_fh = NFS_FH(dir), |
|---|
| 4026 | | - .name = name, |
|---|
| 4283 | + .name = &dentry->d_name, |
|---|
| 4027 | 4284 | }; |
|---|
| 4028 | 4285 | struct nfs4_lookup_res res = { |
|---|
| 4029 | 4286 | .server = server, |
|---|
| .. | .. |
|---|
| 4036 | 4293 | .rpc_argp = &args, |
|---|
| 4037 | 4294 | .rpc_resp = &res, |
|---|
| 4038 | 4295 | }; |
|---|
| 4296 | + unsigned short task_flags = 0; |
|---|
| 4297 | + |
|---|
| 4298 | + /* Is this is an attribute revalidation, subject to softreval? */ |
|---|
| 4299 | + if (nfs_lookup_is_soft_revalidate(dentry)) |
|---|
| 4300 | + task_flags |= RPC_TASK_TIMEOUT; |
|---|
| 4039 | 4301 | |
|---|
| 4040 | 4302 | args.bitmask = nfs4_bitmask(server, label); |
|---|
| 4041 | 4303 | |
|---|
| 4042 | 4304 | nfs_fattr_init(fattr); |
|---|
| 4043 | 4305 | |
|---|
| 4044 | | - dprintk("NFS call lookup %s\n", name->name); |
|---|
| 4045 | | - status = nfs4_call_sync(clnt, server, &msg, &args.seq_args, &res.seq_res, 0); |
|---|
| 4306 | + dprintk("NFS call lookup %pd2\n", dentry); |
|---|
| 4307 | + nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0); |
|---|
| 4308 | + status = nfs4_do_call_sync(clnt, server, &msg, |
|---|
| 4309 | + &args.seq_args, &res.seq_res, task_flags); |
|---|
| 4046 | 4310 | dprintk("NFS reply lookup: %d\n", status); |
|---|
| 4047 | 4311 | return status; |
|---|
| 4048 | 4312 | } |
|---|
| .. | .. |
|---|
| 4056 | 4320 | } |
|---|
| 4057 | 4321 | |
|---|
| 4058 | 4322 | static int nfs4_proc_lookup_common(struct rpc_clnt **clnt, struct inode *dir, |
|---|
| 4059 | | - const struct qstr *name, struct nfs_fh *fhandle, |
|---|
| 4323 | + struct dentry *dentry, struct nfs_fh *fhandle, |
|---|
| 4060 | 4324 | struct nfs_fattr *fattr, struct nfs4_label *label) |
|---|
| 4061 | 4325 | { |
|---|
| 4062 | | - struct nfs4_exception exception = { }; |
|---|
| 4326 | + struct nfs4_exception exception = { |
|---|
| 4327 | + .interruptible = true, |
|---|
| 4328 | + }; |
|---|
| 4063 | 4329 | struct rpc_clnt *client = *clnt; |
|---|
| 4330 | + const struct qstr *name = &dentry->d_name; |
|---|
| 4064 | 4331 | int err; |
|---|
| 4065 | 4332 | do { |
|---|
| 4066 | | - err = _nfs4_proc_lookup(client, dir, name, fhandle, fattr, label); |
|---|
| 4333 | + err = _nfs4_proc_lookup(client, dir, dentry, fhandle, fattr, label); |
|---|
| 4067 | 4334 | trace_nfs4_lookup(dir, name, err); |
|---|
| 4068 | 4335 | switch (err) { |
|---|
| 4069 | 4336 | case -NFS4ERR_BADNAME: |
|---|
| .. | .. |
|---|
| 4098 | 4365 | return err; |
|---|
| 4099 | 4366 | } |
|---|
| 4100 | 4367 | |
|---|
| 4101 | | -static int nfs4_proc_lookup(struct inode *dir, const struct qstr *name, |
|---|
| 4368 | +static int nfs4_proc_lookup(struct inode *dir, struct dentry *dentry, |
|---|
| 4102 | 4369 | struct nfs_fh *fhandle, struct nfs_fattr *fattr, |
|---|
| 4103 | 4370 | struct nfs4_label *label) |
|---|
| 4104 | 4371 | { |
|---|
| 4105 | 4372 | int status; |
|---|
| 4106 | 4373 | struct rpc_clnt *client = NFS_CLIENT(dir); |
|---|
| 4107 | 4374 | |
|---|
| 4108 | | - status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, label); |
|---|
| 4375 | + status = nfs4_proc_lookup_common(&client, dir, dentry, fhandle, fattr, label); |
|---|
| 4109 | 4376 | if (client != NFS_CLIENT(dir)) { |
|---|
| 4110 | 4377 | rpc_shutdown_client(client); |
|---|
| 4111 | 4378 | nfs_fixup_secinfo_attributes(fattr); |
|---|
| .. | .. |
|---|
| 4114 | 4381 | } |
|---|
| 4115 | 4382 | |
|---|
| 4116 | 4383 | struct rpc_clnt * |
|---|
| 4117 | | -nfs4_proc_lookup_mountpoint(struct inode *dir, const struct qstr *name, |
|---|
| 4384 | +nfs4_proc_lookup_mountpoint(struct inode *dir, struct dentry *dentry, |
|---|
| 4118 | 4385 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) |
|---|
| 4119 | 4386 | { |
|---|
| 4120 | 4387 | struct rpc_clnt *client = NFS_CLIENT(dir); |
|---|
| 4121 | 4388 | int status; |
|---|
| 4122 | 4389 | |
|---|
| 4123 | | - status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL); |
|---|
| 4390 | + status = nfs4_proc_lookup_common(&client, dir, dentry, fhandle, fattr, NULL); |
|---|
| 4124 | 4391 | if (status < 0) |
|---|
| 4125 | 4392 | return ERR_PTR(status); |
|---|
| 4126 | 4393 | return (client == NFS_CLIENT(dir)) ? rpc_clone_client(client) : client; |
|---|
| .. | .. |
|---|
| 4163 | 4430 | static int nfs4_proc_lookupp(struct inode *inode, struct nfs_fh *fhandle, |
|---|
| 4164 | 4431 | struct nfs_fattr *fattr, struct nfs4_label *label) |
|---|
| 4165 | 4432 | { |
|---|
| 4166 | | - struct nfs4_exception exception = { }; |
|---|
| 4433 | + struct nfs4_exception exception = { |
|---|
| 4434 | + .interruptible = true, |
|---|
| 4435 | + }; |
|---|
| 4167 | 4436 | int err; |
|---|
| 4168 | 4437 | do { |
|---|
| 4169 | 4438 | err = _nfs4_proc_lookupp(inode, fhandle, fattr, label); |
|---|
| .. | .. |
|---|
| 4198 | 4467 | return -ENOMEM; |
|---|
| 4199 | 4468 | args.bitmask = server->cache_consistency_bitmask; |
|---|
| 4200 | 4469 | } |
|---|
| 4201 | | - |
|---|
| 4202 | 4470 | status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); |
|---|
| 4203 | 4471 | if (!status) { |
|---|
| 4204 | 4472 | nfs_access_set_mask(entry, res.access); |
|---|
| .. | .. |
|---|
| 4211 | 4479 | |
|---|
| 4212 | 4480 | static int nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) |
|---|
| 4213 | 4481 | { |
|---|
| 4214 | | - struct nfs4_exception exception = { }; |
|---|
| 4482 | + struct nfs4_exception exception = { |
|---|
| 4483 | + .interruptible = true, |
|---|
| 4484 | + }; |
|---|
| 4215 | 4485 | int err; |
|---|
| 4216 | 4486 | do { |
|---|
| 4217 | 4487 | err = _nfs4_proc_access(inode, entry); |
|---|
| .. | .. |
|---|
| 4266 | 4536 | static int nfs4_proc_readlink(struct inode *inode, struct page *page, |
|---|
| 4267 | 4537 | unsigned int pgbase, unsigned int pglen) |
|---|
| 4268 | 4538 | { |
|---|
| 4269 | | - struct nfs4_exception exception = { }; |
|---|
| 4539 | + struct nfs4_exception exception = { |
|---|
| 4540 | + .interruptible = true, |
|---|
| 4541 | + }; |
|---|
| 4270 | 4542 | int err; |
|---|
| 4271 | 4543 | do { |
|---|
| 4272 | 4544 | err = _nfs4_proc_readlink(inode, page, pgbase, pglen); |
|---|
| .. | .. |
|---|
| 4331 | 4603 | status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1); |
|---|
| 4332 | 4604 | if (status == 0) { |
|---|
| 4333 | 4605 | spin_lock(&dir->i_lock); |
|---|
| 4334 | | - update_changeattr_locked(dir, &res.cinfo, timestamp, 0); |
|---|
| 4606 | + nfs4_update_changeattr_locked(dir, &res.cinfo, timestamp, |
|---|
| 4607 | + NFS_INO_INVALID_DATA); |
|---|
| 4335 | 4608 | /* Removing a directory decrements nlink in the parent */ |
|---|
| 4336 | 4609 | if (ftype == NF4DIR && dir->i_nlink > 2) |
|---|
| 4337 | 4610 | nfs4_dec_nlink_locked(dir); |
|---|
| .. | .. |
|---|
| 4342 | 4615 | |
|---|
| 4343 | 4616 | static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) |
|---|
| 4344 | 4617 | { |
|---|
| 4345 | | - struct nfs4_exception exception = { }; |
|---|
| 4618 | + struct nfs4_exception exception = { |
|---|
| 4619 | + .interruptible = true, |
|---|
| 4620 | + }; |
|---|
| 4346 | 4621 | struct inode *inode = d_inode(dentry); |
|---|
| 4347 | 4622 | int err; |
|---|
| 4348 | 4623 | |
|---|
| .. | .. |
|---|
| 4363 | 4638 | |
|---|
| 4364 | 4639 | static int nfs4_proc_rmdir(struct inode *dir, const struct qstr *name) |
|---|
| 4365 | 4640 | { |
|---|
| 4366 | | - struct nfs4_exception exception = { }; |
|---|
| 4641 | + struct nfs4_exception exception = { |
|---|
| 4642 | + .interruptible = true, |
|---|
| 4643 | + }; |
|---|
| 4367 | 4644 | int err; |
|---|
| 4368 | 4645 | |
|---|
| 4369 | 4646 | do { |
|---|
| .. | .. |
|---|
| 4411 | 4688 | &data->timeout) == -EAGAIN) |
|---|
| 4412 | 4689 | return 0; |
|---|
| 4413 | 4690 | if (task->tk_status == 0) |
|---|
| 4414 | | - update_changeattr(dir, &res->cinfo, |
|---|
| 4415 | | - res->dir_attr->time_start, 0); |
|---|
| 4691 | + nfs4_update_changeattr(dir, &res->cinfo, |
|---|
| 4692 | + res->dir_attr->time_start, |
|---|
| 4693 | + NFS_INO_INVALID_DATA); |
|---|
| 4416 | 4694 | return 1; |
|---|
| 4417 | 4695 | } |
|---|
| 4418 | 4696 | |
|---|
| .. | .. |
|---|
| 4456 | 4734 | if (task->tk_status == 0) { |
|---|
| 4457 | 4735 | if (new_dir != old_dir) { |
|---|
| 4458 | 4736 | /* Note: If we moved a directory, nlink will change */ |
|---|
| 4459 | | - update_changeattr(old_dir, &res->old_cinfo, |
|---|
| 4737 | + nfs4_update_changeattr(old_dir, &res->old_cinfo, |
|---|
| 4460 | 4738 | res->old_fattr->time_start, |
|---|
| 4461 | | - NFS_INO_INVALID_OTHER); |
|---|
| 4462 | | - update_changeattr(new_dir, &res->new_cinfo, |
|---|
| 4739 | + NFS_INO_INVALID_OTHER | |
|---|
| 4740 | + NFS_INO_INVALID_DATA); |
|---|
| 4741 | + nfs4_update_changeattr(new_dir, &res->new_cinfo, |
|---|
| 4463 | 4742 | res->new_fattr->time_start, |
|---|
| 4464 | | - NFS_INO_INVALID_OTHER); |
|---|
| 4743 | + NFS_INO_INVALID_OTHER | |
|---|
| 4744 | + NFS_INO_INVALID_DATA); |
|---|
| 4465 | 4745 | } else |
|---|
| 4466 | | - update_changeattr(old_dir, &res->old_cinfo, |
|---|
| 4746 | + nfs4_update_changeattr(old_dir, &res->old_cinfo, |
|---|
| 4467 | 4747 | res->old_fattr->time_start, |
|---|
| 4468 | | - 0); |
|---|
| 4748 | + NFS_INO_INVALID_DATA); |
|---|
| 4469 | 4749 | } |
|---|
| 4470 | 4750 | return 1; |
|---|
| 4471 | 4751 | } |
|---|
| .. | .. |
|---|
| 4506 | 4786 | |
|---|
| 4507 | 4787 | status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); |
|---|
| 4508 | 4788 | if (!status) { |
|---|
| 4509 | | - update_changeattr(dir, &res.cinfo, res.fattr->time_start, 0); |
|---|
| 4789 | + nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start, |
|---|
| 4790 | + NFS_INO_INVALID_DATA); |
|---|
| 4510 | 4791 | status = nfs_post_op_update_inode(inode, res.fattr); |
|---|
| 4511 | 4792 | if (!status) |
|---|
| 4512 | 4793 | nfs_setsecurity(inode, res.fattr, res.label); |
|---|
| .. | .. |
|---|
| 4522 | 4803 | |
|---|
| 4523 | 4804 | static int nfs4_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name) |
|---|
| 4524 | 4805 | { |
|---|
| 4525 | | - struct nfs4_exception exception = { }; |
|---|
| 4806 | + struct nfs4_exception exception = { |
|---|
| 4807 | + .interruptible = true, |
|---|
| 4808 | + }; |
|---|
| 4526 | 4809 | int err; |
|---|
| 4527 | 4810 | do { |
|---|
| 4528 | 4811 | err = nfs4_handle_exception(NFS_SERVER(inode), |
|---|
| .. | .. |
|---|
| 4582 | 4865 | &data->arg.seq_args, &data->res.seq_res, 1); |
|---|
| 4583 | 4866 | if (status == 0) { |
|---|
| 4584 | 4867 | spin_lock(&dir->i_lock); |
|---|
| 4585 | | - update_changeattr_locked(dir, &data->res.dir_cinfo, |
|---|
| 4586 | | - data->res.fattr->time_start, 0); |
|---|
| 4868 | + nfs4_update_changeattr_locked(dir, &data->res.dir_cinfo, |
|---|
| 4869 | + data->res.fattr->time_start, |
|---|
| 4870 | + NFS_INO_INVALID_DATA); |
|---|
| 4587 | 4871 | /* Creating a directory bumps nlink in the parent */ |
|---|
| 4588 | 4872 | if (data->arg.ftype == NF4DIR) |
|---|
| 4589 | 4873 | nfs4_inc_nlink_locked(dir); |
|---|
| .. | .. |
|---|
| 4629 | 4913 | static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, |
|---|
| 4630 | 4914 | struct page *page, unsigned int len, struct iattr *sattr) |
|---|
| 4631 | 4915 | { |
|---|
| 4632 | | - struct nfs4_exception exception = { }; |
|---|
| 4916 | + struct nfs4_exception exception = { |
|---|
| 4917 | + .interruptible = true, |
|---|
| 4918 | + }; |
|---|
| 4633 | 4919 | struct nfs4_label l, *label = NULL; |
|---|
| 4634 | 4920 | int err; |
|---|
| 4635 | 4921 | |
|---|
| .. | .. |
|---|
| 4668 | 4954 | struct iattr *sattr) |
|---|
| 4669 | 4955 | { |
|---|
| 4670 | 4956 | struct nfs_server *server = NFS_SERVER(dir); |
|---|
| 4671 | | - struct nfs4_exception exception = { }; |
|---|
| 4957 | + struct nfs4_exception exception = { |
|---|
| 4958 | + .interruptible = true, |
|---|
| 4959 | + }; |
|---|
| 4672 | 4960 | struct nfs4_label l, *label = NULL; |
|---|
| 4673 | 4961 | int err; |
|---|
| 4674 | 4962 | |
|---|
| .. | .. |
|---|
| 4687 | 4975 | return err; |
|---|
| 4688 | 4976 | } |
|---|
| 4689 | 4977 | |
|---|
| 4690 | | -static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, |
|---|
| 4978 | +static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, |
|---|
| 4691 | 4979 | u64 cookie, struct page **pages, unsigned int count, bool plus) |
|---|
| 4692 | 4980 | { |
|---|
| 4693 | 4981 | struct inode *dir = d_inode(dentry); |
|---|
| .. | .. |
|---|
| 4731 | 5019 | return status; |
|---|
| 4732 | 5020 | } |
|---|
| 4733 | 5021 | |
|---|
| 4734 | | -static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, |
|---|
| 5022 | +static int nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, |
|---|
| 4735 | 5023 | u64 cookie, struct page **pages, unsigned int count, bool plus) |
|---|
| 4736 | 5024 | { |
|---|
| 4737 | | - struct nfs4_exception exception = { }; |
|---|
| 5025 | + struct nfs4_exception exception = { |
|---|
| 5026 | + .interruptible = true, |
|---|
| 5027 | + }; |
|---|
| 4738 | 5028 | int err; |
|---|
| 4739 | 5029 | do { |
|---|
| 4740 | 5030 | err = _nfs4_proc_readdir(dentry, cred, cookie, |
|---|
| .. | .. |
|---|
| 4785 | 5075 | struct iattr *sattr, dev_t rdev) |
|---|
| 4786 | 5076 | { |
|---|
| 4787 | 5077 | struct nfs_server *server = NFS_SERVER(dir); |
|---|
| 4788 | | - struct nfs4_exception exception = { }; |
|---|
| 5078 | + struct nfs4_exception exception = { |
|---|
| 5079 | + .interruptible = true, |
|---|
| 5080 | + }; |
|---|
| 4789 | 5081 | struct nfs4_label l, *label = NULL; |
|---|
| 4790 | 5082 | int err; |
|---|
| 4791 | 5083 | |
|---|
| .. | .. |
|---|
| 4827 | 5119 | |
|---|
| 4828 | 5120 | static int nfs4_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsstat *fsstat) |
|---|
| 4829 | 5121 | { |
|---|
| 4830 | | - struct nfs4_exception exception = { }; |
|---|
| 5122 | + struct nfs4_exception exception = { |
|---|
| 5123 | + .interruptible = true, |
|---|
| 5124 | + }; |
|---|
| 4831 | 5125 | int err; |
|---|
| 4832 | 5126 | do { |
|---|
| 4833 | 5127 | err = nfs4_handle_exception(server, |
|---|
| .. | .. |
|---|
| 4858 | 5152 | |
|---|
| 4859 | 5153 | static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *fsinfo) |
|---|
| 4860 | 5154 | { |
|---|
| 4861 | | - struct nfs4_exception exception = { }; |
|---|
| 4862 | | - unsigned long now = jiffies; |
|---|
| 5155 | + struct nfs4_exception exception = { |
|---|
| 5156 | + .interruptible = true, |
|---|
| 5157 | + }; |
|---|
| 4863 | 5158 | int err; |
|---|
| 4864 | 5159 | |
|---|
| 4865 | 5160 | do { |
|---|
| 4866 | 5161 | err = _nfs4_do_fsinfo(server, fhandle, fsinfo); |
|---|
| 4867 | 5162 | trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err); |
|---|
| 4868 | 5163 | if (err == 0) { |
|---|
| 4869 | | - nfs4_set_lease_period(server->nfs_client, |
|---|
| 4870 | | - fsinfo->lease_time * HZ, |
|---|
| 4871 | | - now); |
|---|
| 5164 | + nfs4_set_lease_period(server->nfs_client, fsinfo->lease_time * HZ); |
|---|
| 4872 | 5165 | break; |
|---|
| 4873 | 5166 | } |
|---|
| 4874 | 5167 | err = nfs4_handle_exception(server, err, &exception); |
|---|
| .. | .. |
|---|
| 4920 | 5213 | static int nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, |
|---|
| 4921 | 5214 | struct nfs_pathconf *pathconf) |
|---|
| 4922 | 5215 | { |
|---|
| 4923 | | - struct nfs4_exception exception = { }; |
|---|
| 5216 | + struct nfs4_exception exception = { |
|---|
| 5217 | + .interruptible = true, |
|---|
| 5218 | + }; |
|---|
| 4924 | 5219 | int err; |
|---|
| 4925 | 5220 | |
|---|
| 4926 | 5221 | do { |
|---|
| .. | .. |
|---|
| 4945 | 5240 | const struct nfs_lock_context *l_ctx, |
|---|
| 4946 | 5241 | fmode_t fmode) |
|---|
| 4947 | 5242 | { |
|---|
| 4948 | | - nfs4_stateid current_stateid; |
|---|
| 5243 | + nfs4_stateid _current_stateid; |
|---|
| 4949 | 5244 | |
|---|
| 4950 | 5245 | /* If the current stateid represents a lost lock, then exit */ |
|---|
| 4951 | | - if (nfs4_set_rw_stateid(¤t_stateid, ctx, l_ctx, fmode) == -EIO) |
|---|
| 5246 | + if (nfs4_set_rw_stateid(&_current_stateid, ctx, l_ctx, fmode) == -EIO) |
|---|
| 4952 | 5247 | return true; |
|---|
| 4953 | | - return nfs4_stateid_match(stateid, ¤t_stateid); |
|---|
| 5248 | + return nfs4_stateid_match(stateid, &_current_stateid); |
|---|
| 4954 | 5249 | } |
|---|
| 4955 | 5250 | |
|---|
| 4956 | 5251 | static bool nfs4_error_stateid_expired(int err) |
|---|
| .. | .. |
|---|
| 5006 | 5301 | return true; |
|---|
| 5007 | 5302 | } |
|---|
| 5008 | 5303 | |
|---|
| 5304 | +static bool nfs4_read_plus_not_supported(struct rpc_task *task, |
|---|
| 5305 | + struct nfs_pgio_header *hdr) |
|---|
| 5306 | +{ |
|---|
| 5307 | + struct nfs_server *server = NFS_SERVER(hdr->inode); |
|---|
| 5308 | + struct rpc_message *msg = &task->tk_msg; |
|---|
| 5309 | + |
|---|
| 5310 | + if (msg->rpc_proc == &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS] && |
|---|
| 5311 | + server->caps & NFS_CAP_READ_PLUS && task->tk_status == -ENOTSUPP) { |
|---|
| 5312 | + server->caps &= ~NFS_CAP_READ_PLUS; |
|---|
| 5313 | + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
|---|
| 5314 | + rpc_restart_call_prepare(task); |
|---|
| 5315 | + return true; |
|---|
| 5316 | + } |
|---|
| 5317 | + return false; |
|---|
| 5318 | +} |
|---|
| 5319 | + |
|---|
| 5009 | 5320 | static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
|---|
| 5010 | 5321 | { |
|---|
| 5011 | | - |
|---|
| 5012 | 5322 | dprintk("--> %s\n", __func__); |
|---|
| 5013 | 5323 | |
|---|
| 5014 | 5324 | if (!nfs4_sequence_done(task, &hdr->res.seq_res)) |
|---|
| 5015 | 5325 | return -EAGAIN; |
|---|
| 5016 | 5326 | if (nfs4_read_stateid_changed(task, &hdr->args)) |
|---|
| 5327 | + return -EAGAIN; |
|---|
| 5328 | + if (nfs4_read_plus_not_supported(task, hdr)) |
|---|
| 5017 | 5329 | return -EAGAIN; |
|---|
| 5018 | 5330 | if (task->tk_status > 0) |
|---|
| 5019 | 5331 | nfs_invalidate_atime(hdr->inode); |
|---|
| .. | .. |
|---|
| 5021 | 5333 | nfs4_read_done_cb(task, hdr); |
|---|
| 5022 | 5334 | } |
|---|
| 5023 | 5335 | |
|---|
| 5336 | +#if defined CONFIG_NFS_V4_2 && defined CONFIG_NFS_V4_2_READ_PLUS |
|---|
| 5337 | +static void nfs42_read_plus_support(struct nfs_server *server, struct rpc_message *msg) |
|---|
| 5338 | +{ |
|---|
| 5339 | + if (server->caps & NFS_CAP_READ_PLUS) |
|---|
| 5340 | + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS]; |
|---|
| 5341 | + else |
|---|
| 5342 | + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
|---|
| 5343 | +} |
|---|
| 5344 | +#else |
|---|
| 5345 | +static void nfs42_read_plus_support(struct nfs_server *server, struct rpc_message *msg) |
|---|
| 5346 | +{ |
|---|
| 5347 | + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
|---|
| 5348 | +} |
|---|
| 5349 | +#endif /* CONFIG_NFS_V4_2 */ |
|---|
| 5350 | + |
|---|
| 5024 | 5351 | static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr, |
|---|
| 5025 | 5352 | struct rpc_message *msg) |
|---|
| 5026 | 5353 | { |
|---|
| 5027 | 5354 | hdr->timestamp = jiffies; |
|---|
| 5028 | 5355 | if (!hdr->pgio_done_cb) |
|---|
| 5029 | 5356 | hdr->pgio_done_cb = nfs4_read_done_cb; |
|---|
| 5030 | | - msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
|---|
| 5357 | + nfs42_read_plus_support(NFS_SERVER(hdr->inode), msg); |
|---|
| 5031 | 5358 | nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); |
|---|
| 5032 | 5359 | } |
|---|
| 5033 | 5360 | |
|---|
| .. | .. |
|---|
| 5111 | 5438 | return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; |
|---|
| 5112 | 5439 | } |
|---|
| 5113 | 5440 | |
|---|
| 5441 | +static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, |
|---|
| 5442 | + struct inode *inode, struct nfs_server *server, |
|---|
| 5443 | + struct nfs4_label *label) |
|---|
| 5444 | +{ |
|---|
| 5445 | + unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); |
|---|
| 5446 | + unsigned int i; |
|---|
| 5447 | + |
|---|
| 5448 | + memcpy(bitmask, src, sizeof(*bitmask) * NFS4_BITMASK_SZ); |
|---|
| 5449 | + |
|---|
| 5450 | + if (cache_validity & (NFS_INO_INVALID_CHANGE | NFS_INO_REVAL_PAGECACHE)) |
|---|
| 5451 | + bitmask[0] |= FATTR4_WORD0_CHANGE; |
|---|
| 5452 | + if (cache_validity & NFS_INO_INVALID_ATIME) |
|---|
| 5453 | + bitmask[1] |= FATTR4_WORD1_TIME_ACCESS; |
|---|
| 5454 | + if (cache_validity & NFS_INO_INVALID_OTHER) |
|---|
| 5455 | + bitmask[1] |= FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | |
|---|
| 5456 | + FATTR4_WORD1_OWNER_GROUP | |
|---|
| 5457 | + FATTR4_WORD1_NUMLINKS; |
|---|
| 5458 | + if (label && label->len && cache_validity & NFS_INO_INVALID_LABEL) |
|---|
| 5459 | + bitmask[2] |= FATTR4_WORD2_SECURITY_LABEL; |
|---|
| 5460 | + if (cache_validity & NFS_INO_INVALID_CTIME) |
|---|
| 5461 | + bitmask[1] |= FATTR4_WORD1_TIME_METADATA; |
|---|
| 5462 | + if (cache_validity & NFS_INO_INVALID_MTIME) |
|---|
| 5463 | + bitmask[1] |= FATTR4_WORD1_TIME_MODIFY; |
|---|
| 5464 | + if (cache_validity & NFS_INO_INVALID_BLOCKS) |
|---|
| 5465 | + bitmask[1] |= FATTR4_WORD1_SPACE_USED; |
|---|
| 5466 | + |
|---|
| 5467 | + if (nfs4_have_delegation(inode, FMODE_READ) && |
|---|
| 5468 | + !(cache_validity & NFS_INO_REVAL_FORCED)) |
|---|
| 5469 | + bitmask[0] &= ~FATTR4_WORD0_SIZE; |
|---|
| 5470 | + else if (cache_validity & |
|---|
| 5471 | + (NFS_INO_INVALID_SIZE | NFS_INO_REVAL_PAGECACHE)) |
|---|
| 5472 | + bitmask[0] |= FATTR4_WORD0_SIZE; |
|---|
| 5473 | + |
|---|
| 5474 | + for (i = 0; i < NFS4_BITMASK_SZ; i++) |
|---|
| 5475 | + bitmask[i] &= server->attr_bitmask[i]; |
|---|
| 5476 | +} |
|---|
| 5477 | + |
|---|
| 5114 | 5478 | static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr, |
|---|
| 5115 | 5479 | struct rpc_message *msg, |
|---|
| 5116 | 5480 | struct rpc_clnt **clnt) |
|---|
| .. | .. |
|---|
| 5120 | 5484 | if (!nfs4_write_need_cache_consistency_data(hdr)) { |
|---|
| 5121 | 5485 | hdr->args.bitmask = NULL; |
|---|
| 5122 | 5486 | hdr->res.fattr = NULL; |
|---|
| 5123 | | - } else |
|---|
| 5124 | | - hdr->args.bitmask = server->cache_consistency_bitmask; |
|---|
| 5487 | + } else { |
|---|
| 5488 | + nfs4_bitmask_set(hdr->args.bitmask_store, |
|---|
| 5489 | + server->cache_consistency_bitmask, |
|---|
| 5490 | + hdr->inode, server, NULL); |
|---|
| 5491 | + hdr->args.bitmask = hdr->args.bitmask_store; |
|---|
| 5492 | + } |
|---|
| 5125 | 5493 | |
|---|
| 5126 | 5494 | if (!hdr->pgio_done_cb) |
|---|
| 5127 | 5495 | hdr->pgio_done_cb = nfs4_write_done_cb; |
|---|
| .. | .. |
|---|
| 5259 | 5627 | .rpc_release = nfs4_renew_release, |
|---|
| 5260 | 5628 | }; |
|---|
| 5261 | 5629 | |
|---|
| 5262 | | -static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) |
|---|
| 5630 | +static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags) |
|---|
| 5263 | 5631 | { |
|---|
| 5264 | 5632 | struct rpc_message msg = { |
|---|
| 5265 | 5633 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], |
|---|
| .. | .. |
|---|
| 5283 | 5651 | &nfs4_renew_ops, data); |
|---|
| 5284 | 5652 | } |
|---|
| 5285 | 5653 | |
|---|
| 5286 | | -static int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) |
|---|
| 5654 | +static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred) |
|---|
| 5287 | 5655 | { |
|---|
| 5288 | 5656 | struct rpc_message msg = { |
|---|
| 5289 | 5657 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], |
|---|
| .. | .. |
|---|
| 5311 | 5679 | */ |
|---|
| 5312 | 5680 | #define NFS4ACL_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE) |
|---|
| 5313 | 5681 | |
|---|
| 5314 | | -static int buf_to_pages_noslab(const void *buf, size_t buflen, |
|---|
| 5682 | +int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen, |
|---|
| 5315 | 5683 | struct page **pages) |
|---|
| 5316 | 5684 | { |
|---|
| 5317 | 5685 | struct page *newpage, **spages; |
|---|
| .. | .. |
|---|
| 5343 | 5711 | struct nfs4_cached_acl { |
|---|
| 5344 | 5712 | int cached; |
|---|
| 5345 | 5713 | size_t len; |
|---|
| 5346 | | - char data[0]; |
|---|
| 5714 | + char data[]; |
|---|
| 5347 | 5715 | }; |
|---|
| 5348 | 5716 | |
|---|
| 5349 | 5717 | static void nfs4_set_cached_acl(struct inode *inode, struct nfs4_cached_acl *acl) |
|---|
| .. | .. |
|---|
| 5420 | 5788 | */ |
|---|
| 5421 | 5789 | static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen) |
|---|
| 5422 | 5790 | { |
|---|
| 5423 | | - struct page *pages[NFS4ACL_MAXPAGES + 1] = {NULL, }; |
|---|
| 5791 | + struct page **pages; |
|---|
| 5424 | 5792 | struct nfs_getaclargs args = { |
|---|
| 5425 | 5793 | .fh = NFS_FH(inode), |
|---|
| 5426 | | - .acl_pages = pages, |
|---|
| 5427 | 5794 | .acl_len = buflen, |
|---|
| 5428 | 5795 | }; |
|---|
| 5429 | 5796 | struct nfs_getaclres res = { |
|---|
| .. | .. |
|---|
| 5434 | 5801 | .rpc_argp = &args, |
|---|
| 5435 | 5802 | .rpc_resp = &res, |
|---|
| 5436 | 5803 | }; |
|---|
| 5437 | | - unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE) + 1; |
|---|
| 5804 | + unsigned int npages; |
|---|
| 5438 | 5805 | int ret = -ENOMEM, i; |
|---|
| 5806 | + struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 5439 | 5807 | |
|---|
| 5440 | | - if (npages > ARRAY_SIZE(pages)) |
|---|
| 5441 | | - return -ERANGE; |
|---|
| 5808 | + if (buflen == 0) |
|---|
| 5809 | + buflen = server->rsize; |
|---|
| 5810 | + |
|---|
| 5811 | + npages = DIV_ROUND_UP(buflen, PAGE_SIZE) + 1; |
|---|
| 5812 | + pages = kmalloc_array(npages, sizeof(struct page *), GFP_NOFS); |
|---|
| 5813 | + if (!pages) |
|---|
| 5814 | + return -ENOMEM; |
|---|
| 5815 | + |
|---|
| 5816 | + args.acl_pages = pages; |
|---|
| 5442 | 5817 | |
|---|
| 5443 | 5818 | for (i = 0; i < npages; i++) { |
|---|
| 5444 | 5819 | pages[i] = alloc_page(GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 5484 | 5859 | __free_page(pages[i]); |
|---|
| 5485 | 5860 | if (res.acl_scratch) |
|---|
| 5486 | 5861 | __free_page(res.acl_scratch); |
|---|
| 5862 | + kfree(pages); |
|---|
| 5487 | 5863 | return ret; |
|---|
| 5488 | 5864 | } |
|---|
| 5489 | 5865 | |
|---|
| 5490 | 5866 | static ssize_t nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen) |
|---|
| 5491 | 5867 | { |
|---|
| 5492 | | - struct nfs4_exception exception = { }; |
|---|
| 5868 | + struct nfs4_exception exception = { |
|---|
| 5869 | + .interruptible = true, |
|---|
| 5870 | + }; |
|---|
| 5493 | 5871 | ssize_t ret; |
|---|
| 5494 | 5872 | do { |
|---|
| 5495 | 5873 | ret = __nfs4_get_acl_uncached(inode, buf, buflen); |
|---|
| .. | .. |
|---|
| 5546 | 5924 | return -EOPNOTSUPP; |
|---|
| 5547 | 5925 | if (npages > ARRAY_SIZE(pages)) |
|---|
| 5548 | 5926 | return -ERANGE; |
|---|
| 5549 | | - i = buf_to_pages_noslab(buf, buflen, arg.acl_pages); |
|---|
| 5927 | + i = nfs4_buf_to_pages_noslab(buf, buflen, arg.acl_pages); |
|---|
| 5550 | 5928 | if (i < 0) |
|---|
| 5551 | 5929 | return i; |
|---|
| 5552 | 5930 | nfs4_inode_make_writeable(inode); |
|---|
| .. | .. |
|---|
| 5632 | 6010 | static int nfs4_get_security_label(struct inode *inode, void *buf, |
|---|
| 5633 | 6011 | size_t buflen) |
|---|
| 5634 | 6012 | { |
|---|
| 5635 | | - struct nfs4_exception exception = { }; |
|---|
| 6013 | + struct nfs4_exception exception = { |
|---|
| 6014 | + .interruptible = true, |
|---|
| 6015 | + }; |
|---|
| 5636 | 6016 | int err; |
|---|
| 5637 | 6017 | |
|---|
| 5638 | 6018 | if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) |
|---|
| .. | .. |
|---|
| 5707 | 6087 | { |
|---|
| 5708 | 6088 | struct nfs4_label ilabel, *olabel = NULL; |
|---|
| 5709 | 6089 | struct nfs_fattr fattr; |
|---|
| 5710 | | - struct rpc_cred *cred; |
|---|
| 5711 | 6090 | int status; |
|---|
| 5712 | 6091 | |
|---|
| 5713 | 6092 | if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) |
|---|
| .. | .. |
|---|
| 5719 | 6098 | ilabel.lfs = 0; |
|---|
| 5720 | 6099 | ilabel.label = (char *)buf; |
|---|
| 5721 | 6100 | ilabel.len = buflen; |
|---|
| 5722 | | - |
|---|
| 5723 | | - cred = rpc_lookup_cred(); |
|---|
| 5724 | | - if (IS_ERR(cred)) |
|---|
| 5725 | | - return PTR_ERR(cred); |
|---|
| 5726 | 6101 | |
|---|
| 5727 | 6102 | olabel = nfs4_label_alloc(NFS_SERVER(inode), GFP_KERNEL); |
|---|
| 5728 | 6103 | if (IS_ERR(olabel)) { |
|---|
| .. | .. |
|---|
| 5736 | 6111 | |
|---|
| 5737 | 6112 | nfs4_label_free(olabel); |
|---|
| 5738 | 6113 | out: |
|---|
| 5739 | | - put_rpccred(cred); |
|---|
| 5740 | 6114 | return status; |
|---|
| 5741 | 6115 | } |
|---|
| 5742 | 6116 | #endif /* CONFIG_NFS_V4_SECURITY_LABEL */ |
|---|
| .. | .. |
|---|
| 5762 | 6136 | memcpy(bootverf->data, verf, sizeof(bootverf->data)); |
|---|
| 5763 | 6137 | } |
|---|
| 5764 | 6138 | |
|---|
| 6139 | +static size_t |
|---|
| 6140 | +nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen) |
|---|
| 6141 | +{ |
|---|
| 6142 | + struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
|---|
| 6143 | + struct nfs_netns_client *nn_clp = nn->nfs_client; |
|---|
| 6144 | + const char *id; |
|---|
| 6145 | + |
|---|
| 6146 | + buf[0] = '\0'; |
|---|
| 6147 | + |
|---|
| 6148 | + if (nn_clp) { |
|---|
| 6149 | + rcu_read_lock(); |
|---|
| 6150 | + id = rcu_dereference(nn_clp->identifier); |
|---|
| 6151 | + if (id) |
|---|
| 6152 | + strscpy(buf, id, buflen); |
|---|
| 6153 | + rcu_read_unlock(); |
|---|
| 6154 | + } |
|---|
| 6155 | + |
|---|
| 6156 | + if (nfs4_client_id_uniquifier[0] != '\0' && buf[0] == '\0') |
|---|
| 6157 | + strscpy(buf, nfs4_client_id_uniquifier, buflen); |
|---|
| 6158 | + |
|---|
| 6159 | + return strlen(buf); |
|---|
| 6160 | +} |
|---|
| 6161 | + |
|---|
| 5765 | 6162 | static int |
|---|
| 5766 | 6163 | nfs4_init_nonuniform_client_string(struct nfs_client *clp) |
|---|
| 5767 | 6164 | { |
|---|
| 6165 | + char buf[NFS4_CLIENT_ID_UNIQ_LEN]; |
|---|
| 6166 | + size_t buflen; |
|---|
| 5768 | 6167 | size_t len; |
|---|
| 5769 | 6168 | char *str; |
|---|
| 5770 | 6169 | |
|---|
| .. | .. |
|---|
| 5778 | 6177 | strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) + |
|---|
| 5779 | 6178 | 1; |
|---|
| 5780 | 6179 | rcu_read_unlock(); |
|---|
| 5781 | | - if (nfs4_client_id_uniquifier[0] != '\0') |
|---|
| 5782 | | - len += strlen(nfs4_client_id_uniquifier) + 1; |
|---|
| 6180 | + |
|---|
| 6181 | + buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf)); |
|---|
| 6182 | + if (buflen) |
|---|
| 6183 | + len += buflen + 1; |
|---|
| 6184 | + |
|---|
| 5783 | 6185 | if (len > NFS4_OPAQUE_LIMIT + 1) |
|---|
| 5784 | 6186 | return -EINVAL; |
|---|
| 5785 | 6187 | |
|---|
| .. | .. |
|---|
| 5793 | 6195 | return -ENOMEM; |
|---|
| 5794 | 6196 | |
|---|
| 5795 | 6197 | rcu_read_lock(); |
|---|
| 5796 | | - if (nfs4_client_id_uniquifier[0] != '\0') |
|---|
| 6198 | + if (buflen) |
|---|
| 5797 | 6199 | scnprintf(str, len, "Linux NFSv4.0 %s/%s/%s", |
|---|
| 5798 | | - clp->cl_rpcclient->cl_nodename, |
|---|
| 5799 | | - nfs4_client_id_uniquifier, |
|---|
| 6200 | + clp->cl_rpcclient->cl_nodename, buf, |
|---|
| 5800 | 6201 | rpc_peeraddr2str(clp->cl_rpcclient, |
|---|
| 5801 | 6202 | RPC_DISPLAY_ADDR)); |
|---|
| 5802 | 6203 | else |
|---|
| .. | .. |
|---|
| 5811 | 6212 | } |
|---|
| 5812 | 6213 | |
|---|
| 5813 | 6214 | static int |
|---|
| 5814 | | -nfs4_init_uniquifier_client_string(struct nfs_client *clp) |
|---|
| 5815 | | -{ |
|---|
| 5816 | | - size_t len; |
|---|
| 5817 | | - char *str; |
|---|
| 5818 | | - |
|---|
| 5819 | | - len = 10 + 10 + 1 + 10 + 1 + |
|---|
| 5820 | | - strlen(nfs4_client_id_uniquifier) + 1 + |
|---|
| 5821 | | - strlen(clp->cl_rpcclient->cl_nodename) + 1; |
|---|
| 5822 | | - |
|---|
| 5823 | | - if (len > NFS4_OPAQUE_LIMIT + 1) |
|---|
| 5824 | | - return -EINVAL; |
|---|
| 5825 | | - |
|---|
| 5826 | | - /* |
|---|
| 5827 | | - * Since this string is allocated at mount time, and held until the |
|---|
| 5828 | | - * nfs_client is destroyed, we can use GFP_KERNEL here w/o worrying |
|---|
| 5829 | | - * about a memory-reclaim deadlock. |
|---|
| 5830 | | - */ |
|---|
| 5831 | | - str = kmalloc(len, GFP_KERNEL); |
|---|
| 5832 | | - if (!str) |
|---|
| 5833 | | - return -ENOMEM; |
|---|
| 5834 | | - |
|---|
| 5835 | | - scnprintf(str, len, "Linux NFSv%u.%u %s/%s", |
|---|
| 5836 | | - clp->rpc_ops->version, clp->cl_minorversion, |
|---|
| 5837 | | - nfs4_client_id_uniquifier, |
|---|
| 5838 | | - clp->cl_rpcclient->cl_nodename); |
|---|
| 5839 | | - clp->cl_owner_id = str; |
|---|
| 5840 | | - return 0; |
|---|
| 5841 | | -} |
|---|
| 5842 | | - |
|---|
| 5843 | | -static int |
|---|
| 5844 | 6215 | nfs4_init_uniform_client_string(struct nfs_client *clp) |
|---|
| 5845 | 6216 | { |
|---|
| 6217 | + char buf[NFS4_CLIENT_ID_UNIQ_LEN]; |
|---|
| 6218 | + size_t buflen; |
|---|
| 5846 | 6219 | size_t len; |
|---|
| 5847 | 6220 | char *str; |
|---|
| 5848 | 6221 | |
|---|
| 5849 | 6222 | if (clp->cl_owner_id != NULL) |
|---|
| 5850 | 6223 | return 0; |
|---|
| 5851 | 6224 | |
|---|
| 5852 | | - if (nfs4_client_id_uniquifier[0] != '\0') |
|---|
| 5853 | | - return nfs4_init_uniquifier_client_string(clp); |
|---|
| 5854 | | - |
|---|
| 5855 | 6225 | len = 10 + 10 + 1 + 10 + 1 + |
|---|
| 5856 | 6226 | strlen(clp->cl_rpcclient->cl_nodename) + 1; |
|---|
| 6227 | + |
|---|
| 6228 | + buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf)); |
|---|
| 6229 | + if (buflen) |
|---|
| 6230 | + len += buflen + 1; |
|---|
| 5857 | 6231 | |
|---|
| 5858 | 6232 | if (len > NFS4_OPAQUE_LIMIT + 1) |
|---|
| 5859 | 6233 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 5867 | 6241 | if (!str) |
|---|
| 5868 | 6242 | return -ENOMEM; |
|---|
| 5869 | 6243 | |
|---|
| 5870 | | - scnprintf(str, len, "Linux NFSv%u.%u %s", |
|---|
| 5871 | | - clp->rpc_ops->version, clp->cl_minorversion, |
|---|
| 5872 | | - clp->cl_rpcclient->cl_nodename); |
|---|
| 6244 | + if (buflen) |
|---|
| 6245 | + scnprintf(str, len, "Linux NFSv%u.%u %s/%s", |
|---|
| 6246 | + clp->rpc_ops->version, clp->cl_minorversion, |
|---|
| 6247 | + buf, clp->cl_rpcclient->cl_nodename); |
|---|
| 6248 | + else |
|---|
| 6249 | + scnprintf(str, len, "Linux NFSv%u.%u %s", |
|---|
| 6250 | + clp->rpc_ops->version, clp->cl_minorversion, |
|---|
| 6251 | + clp->cl_rpcclient->cl_nodename); |
|---|
| 5873 | 6252 | clp->cl_owner_id = str; |
|---|
| 5874 | 6253 | return 0; |
|---|
| 5875 | 6254 | } |
|---|
| .. | .. |
|---|
| 5905 | 6284 | * @clp: state data structure |
|---|
| 5906 | 6285 | * @program: RPC program for NFSv4 callback service |
|---|
| 5907 | 6286 | * @port: IP port number for NFS4 callback service |
|---|
| 5908 | | - * @cred: RPC credential to use for this call |
|---|
| 6287 | + * @cred: credential to use for this call |
|---|
| 5909 | 6288 | * @res: where to place the result |
|---|
| 5910 | 6289 | * |
|---|
| 5911 | 6290 | * Returns zero, a negative errno, or a negative NFS4ERR status code. |
|---|
| 5912 | 6291 | */ |
|---|
| 5913 | 6292 | int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, |
|---|
| 5914 | | - unsigned short port, struct rpc_cred *cred, |
|---|
| 6293 | + unsigned short port, const struct cred *cred, |
|---|
| 5915 | 6294 | struct nfs4_setclientid_res *res) |
|---|
| 5916 | 6295 | { |
|---|
| 5917 | 6296 | nfs4_verifier sc_verifier; |
|---|
| .. | .. |
|---|
| 5926 | 6305 | .rpc_resp = res, |
|---|
| 5927 | 6306 | .rpc_cred = cred, |
|---|
| 5928 | 6307 | }; |
|---|
| 5929 | | - struct rpc_task *task; |
|---|
| 5930 | 6308 | struct rpc_task_setup task_setup_data = { |
|---|
| 5931 | 6309 | .rpc_client = clp->cl_rpcclient, |
|---|
| 5932 | 6310 | .rpc_message = &msg, |
|---|
| 5933 | 6311 | .callback_ops = &nfs4_setclientid_ops, |
|---|
| 5934 | 6312 | .callback_data = &setclientid, |
|---|
| 5935 | | - .flags = RPC_TASK_TIMEOUT, |
|---|
| 6313 | + .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN, |
|---|
| 5936 | 6314 | }; |
|---|
| 6315 | + unsigned long now = jiffies; |
|---|
| 5937 | 6316 | int status; |
|---|
| 5938 | 6317 | |
|---|
| 5939 | 6318 | /* nfs_client_id4 */ |
|---|
| .. | .. |
|---|
| 5959 | 6338 | dprintk("NFS call setclientid auth=%s, '%s'\n", |
|---|
| 5960 | 6339 | clp->cl_rpcclient->cl_auth->au_ops->au_name, |
|---|
| 5961 | 6340 | clp->cl_owner_id); |
|---|
| 5962 | | - task = rpc_run_task(&task_setup_data); |
|---|
| 5963 | | - if (IS_ERR(task)) { |
|---|
| 5964 | | - status = PTR_ERR(task); |
|---|
| 5965 | | - goto out; |
|---|
| 5966 | | - } |
|---|
| 5967 | | - status = task->tk_status; |
|---|
| 6341 | + |
|---|
| 6342 | + status = nfs4_call_sync_custom(&task_setup_data); |
|---|
| 5968 | 6343 | if (setclientid.sc_cred) { |
|---|
| 5969 | 6344 | kfree(clp->cl_acceptor); |
|---|
| 5970 | 6345 | clp->cl_acceptor = rpcauth_stringify_acceptor(setclientid.sc_cred); |
|---|
| 5971 | 6346 | put_rpccred(setclientid.sc_cred); |
|---|
| 5972 | 6347 | } |
|---|
| 5973 | | - rpc_put_task(task); |
|---|
| 6348 | + |
|---|
| 6349 | + if (status == 0) |
|---|
| 6350 | + do_renew_lease(clp, now); |
|---|
| 5974 | 6351 | out: |
|---|
| 5975 | 6352 | trace_nfs4_setclientid(clp, status); |
|---|
| 5976 | 6353 | dprintk("NFS reply setclientid: %d\n", status); |
|---|
| .. | .. |
|---|
| 5980 | 6357 | /** |
|---|
| 5981 | 6358 | * nfs4_proc_setclientid_confirm - Confirm client ID |
|---|
| 5982 | 6359 | * @clp: state data structure |
|---|
| 5983 | | - * @res: result of a previous SETCLIENTID |
|---|
| 5984 | | - * @cred: RPC credential to use for this call |
|---|
| 6360 | + * @arg: result of a previous SETCLIENTID |
|---|
| 6361 | + * @cred: credential to use for this call |
|---|
| 5985 | 6362 | * |
|---|
| 5986 | 6363 | * Returns zero, a negative errno, or a negative NFS4ERR status code. |
|---|
| 5987 | 6364 | */ |
|---|
| 5988 | 6365 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, |
|---|
| 5989 | 6366 | struct nfs4_setclientid_res *arg, |
|---|
| 5990 | | - struct rpc_cred *cred) |
|---|
| 6367 | + const struct cred *cred) |
|---|
| 5991 | 6368 | { |
|---|
| 5992 | 6369 | struct rpc_message msg = { |
|---|
| 5993 | 6370 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], |
|---|
| .. | .. |
|---|
| 5999 | 6376 | dprintk("NFS call setclientid_confirm auth=%s, (client ID %llx)\n", |
|---|
| 6000 | 6377 | clp->cl_rpcclient->cl_auth->au_ops->au_name, |
|---|
| 6001 | 6378 | clp->cl_clientid); |
|---|
| 6002 | | - status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); |
|---|
| 6379 | + status = rpc_call_sync(clp->cl_rpcclient, &msg, |
|---|
| 6380 | + RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN); |
|---|
| 6003 | 6381 | trace_nfs4_setclientid_confirm(clp, status); |
|---|
| 6004 | 6382 | dprintk("NFS reply setclientid_confirm: %d\n", status); |
|---|
| 6005 | 6383 | return status; |
|---|
| .. | .. |
|---|
| 6038 | 6416 | trace_nfs4_delegreturn_exit(&data->args, &data->res, task->tk_status); |
|---|
| 6039 | 6417 | |
|---|
| 6040 | 6418 | /* Handle Layoutreturn errors */ |
|---|
| 6041 | | - if (data->args.lr_args && task->tk_status != 0) { |
|---|
| 6042 | | - switch(data->res.lr_ret) { |
|---|
| 6043 | | - default: |
|---|
| 6044 | | - data->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; |
|---|
| 6045 | | - break; |
|---|
| 6046 | | - case 0: |
|---|
| 6047 | | - data->args.lr_args = NULL; |
|---|
| 6048 | | - data->res.lr_res = NULL; |
|---|
| 6049 | | - break; |
|---|
| 6050 | | - case -NFS4ERR_OLD_STATEID: |
|---|
| 6051 | | - if (nfs4_layoutreturn_refresh_stateid(&data->args.lr_args->stateid, |
|---|
| 6052 | | - &data->args.lr_args->range, |
|---|
| 6053 | | - data->inode)) |
|---|
| 6054 | | - goto lr_restart; |
|---|
| 6055 | | - /* Fallthrough */ |
|---|
| 6056 | | - case -NFS4ERR_ADMIN_REVOKED: |
|---|
| 6057 | | - case -NFS4ERR_DELEG_REVOKED: |
|---|
| 6058 | | - case -NFS4ERR_EXPIRED: |
|---|
| 6059 | | - case -NFS4ERR_BAD_STATEID: |
|---|
| 6060 | | - case -NFS4ERR_UNKNOWN_LAYOUTTYPE: |
|---|
| 6061 | | - case -NFS4ERR_WRONG_CRED: |
|---|
| 6062 | | - data->args.lr_args = NULL; |
|---|
| 6063 | | - data->res.lr_res = NULL; |
|---|
| 6064 | | - goto lr_restart; |
|---|
| 6065 | | - } |
|---|
| 6066 | | - } |
|---|
| 6419 | + if (pnfs_roc_done(task, &data->args.lr_args, &data->res.lr_res, |
|---|
| 6420 | + &data->res.lr_ret) == -EAGAIN) |
|---|
| 6421 | + goto out_restart; |
|---|
| 6067 | 6422 | |
|---|
| 6068 | 6423 | switch (task->tk_status) { |
|---|
| 6069 | 6424 | case 0: |
|---|
| .. | .. |
|---|
| 6075 | 6430 | nfs4_free_revoked_stateid(data->res.server, |
|---|
| 6076 | 6431 | data->args.stateid, |
|---|
| 6077 | 6432 | task->tk_msg.rpc_cred); |
|---|
| 6078 | | - /* Fallthrough */ |
|---|
| 6433 | + fallthrough; |
|---|
| 6079 | 6434 | case -NFS4ERR_BAD_STATEID: |
|---|
| 6080 | 6435 | case -NFS4ERR_STALE_STATEID: |
|---|
| 6436 | + case -ETIMEDOUT: |
|---|
| 6081 | 6437 | task->tk_status = 0; |
|---|
| 6082 | 6438 | break; |
|---|
| 6083 | 6439 | case -NFS4ERR_OLD_STATEID: |
|---|
| 6084 | | - if (nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) |
|---|
| 6085 | | - goto out_restart; |
|---|
| 6086 | | - task->tk_status = 0; |
|---|
| 6087 | | - break; |
|---|
| 6440 | + if (!nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) |
|---|
| 6441 | + nfs4_stateid_seqid_inc(&data->stateid); |
|---|
| 6442 | + if (data->args.bitmask) { |
|---|
| 6443 | + data->args.bitmask = NULL; |
|---|
| 6444 | + data->res.fattr = NULL; |
|---|
| 6445 | + } |
|---|
| 6446 | + goto out_restart; |
|---|
| 6088 | 6447 | case -NFS4ERR_ACCESS: |
|---|
| 6089 | 6448 | if (data->args.bitmask) { |
|---|
| 6090 | 6449 | data->args.bitmask = NULL; |
|---|
| 6091 | 6450 | data->res.fattr = NULL; |
|---|
| 6092 | 6451 | goto out_restart; |
|---|
| 6093 | 6452 | } |
|---|
| 6094 | | - /* Fallthrough */ |
|---|
| 6453 | + fallthrough; |
|---|
| 6095 | 6454 | default: |
|---|
| 6096 | 6455 | task->tk_status = nfs4_async_handle_exception(task, |
|---|
| 6097 | 6456 | data->res.server, task->tk_status, |
|---|
| .. | .. |
|---|
| 6099 | 6458 | if (exception.retry) |
|---|
| 6100 | 6459 | goto out_restart; |
|---|
| 6101 | 6460 | } |
|---|
| 6461 | + nfs_delegation_mark_returned(data->inode, data->args.stateid); |
|---|
| 6102 | 6462 | data->rpc_status = task->tk_status; |
|---|
| 6103 | 6463 | return; |
|---|
| 6104 | | -lr_restart: |
|---|
| 6105 | | - data->res.lr_ret = 0; |
|---|
| 6106 | 6464 | out_restart: |
|---|
| 6107 | 6465 | task->tk_status = 0; |
|---|
| 6108 | 6466 | rpc_restart_call_prepare(task); |
|---|
| .. | .. |
|---|
| 6113 | 6471 | struct nfs4_delegreturndata *data = calldata; |
|---|
| 6114 | 6472 | struct inode *inode = data->inode; |
|---|
| 6115 | 6473 | |
|---|
| 6474 | + if (data->lr.roc) |
|---|
| 6475 | + pnfs_roc_release(&data->lr.arg, &data->lr.res, |
|---|
| 6476 | + data->res.lr_ret); |
|---|
| 6116 | 6477 | if (inode) { |
|---|
| 6117 | | - if (data->lr.roc) |
|---|
| 6118 | | - pnfs_roc_release(&data->lr.arg, &data->lr.res, |
|---|
| 6119 | | - data->res.lr_ret); |
|---|
| 6120 | | - nfs_post_op_update_inode_force_wcc(inode, &data->fattr); |
|---|
| 6478 | + nfs4_fattr_set_prechange(&data->fattr, |
|---|
| 6479 | + inode_peek_iversion_raw(inode)); |
|---|
| 6480 | + nfs_refresh_inode(inode, &data->fattr); |
|---|
| 6121 | 6481 | nfs_iput_and_deactive(inode); |
|---|
| 6122 | 6482 | } |
|---|
| 6123 | 6483 | kfree(calldata); |
|---|
| .. | .. |
|---|
| 6153 | 6513 | .rpc_release = nfs4_delegreturn_release, |
|---|
| 6154 | 6514 | }; |
|---|
| 6155 | 6515 | |
|---|
| 6156 | | -static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync) |
|---|
| 6516 | +static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) |
|---|
| 6157 | 6517 | { |
|---|
| 6158 | 6518 | struct nfs4_delegreturndata *data; |
|---|
| 6159 | 6519 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| .. | .. |
|---|
| 6166 | 6526 | .rpc_client = server->client, |
|---|
| 6167 | 6527 | .rpc_message = &msg, |
|---|
| 6168 | 6528 | .callback_ops = &nfs4_delegreturn_ops, |
|---|
| 6169 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 6529 | + .flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT, |
|---|
| 6170 | 6530 | }; |
|---|
| 6171 | 6531 | int status = 0; |
|---|
| 6172 | 6532 | |
|---|
| .. | .. |
|---|
| 6180 | 6540 | |
|---|
| 6181 | 6541 | data->args.fhandle = &data->fh; |
|---|
| 6182 | 6542 | data->args.stateid = &data->stateid; |
|---|
| 6183 | | - data->args.bitmask = server->cache_consistency_bitmask; |
|---|
| 6543 | + nfs4_bitmask_set(data->args.bitmask_store, |
|---|
| 6544 | + server->cache_consistency_bitmask, inode, server, |
|---|
| 6545 | + NULL); |
|---|
| 6546 | + data->args.bitmask = data->args.bitmask_store; |
|---|
| 6184 | 6547 | nfs_copy_fh(&data->fh, NFS_FH(inode)); |
|---|
| 6185 | 6548 | nfs4_stateid_copy(&data->stateid, stateid); |
|---|
| 6186 | 6549 | data->res.fattr = &data->fattr; |
|---|
| .. | .. |
|---|
| 6190 | 6553 | nfs_fattr_init(data->res.fattr); |
|---|
| 6191 | 6554 | data->timestamp = jiffies; |
|---|
| 6192 | 6555 | data->rpc_status = 0; |
|---|
| 6193 | | - data->lr.roc = pnfs_roc(inode, &data->lr.arg, &data->lr.res, cred); |
|---|
| 6194 | 6556 | data->inode = nfs_igrab_and_active(inode); |
|---|
| 6195 | | - if (data->inode) { |
|---|
| 6557 | + if (data->inode || issync) { |
|---|
| 6558 | + data->lr.roc = pnfs_roc(inode, &data->lr.arg, &data->lr.res, |
|---|
| 6559 | + cred); |
|---|
| 6196 | 6560 | if (data->lr.roc) { |
|---|
| 6197 | 6561 | data->args.lr_args = &data->lr.arg; |
|---|
| 6198 | 6562 | data->res.lr_res = &data->lr.res; |
|---|
| 6199 | 6563 | } |
|---|
| 6200 | | - } else if (data->lr.roc) { |
|---|
| 6201 | | - pnfs_roc_release(&data->lr.arg, &data->lr.res, 0); |
|---|
| 6202 | | - data->lr.roc = false; |
|---|
| 6203 | 6564 | } |
|---|
| 6204 | 6565 | |
|---|
| 6205 | 6566 | if (!data->inode) |
|---|
| .. | .. |
|---|
| 6225 | 6586 | return status; |
|---|
| 6226 | 6587 | } |
|---|
| 6227 | 6588 | |
|---|
| 6228 | | -int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync) |
|---|
| 6589 | +int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) |
|---|
| 6229 | 6590 | { |
|---|
| 6230 | 6591 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 6231 | 6592 | struct nfs4_exception exception = { }; |
|---|
| .. | .. |
|---|
| 6288 | 6649 | |
|---|
| 6289 | 6650 | static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) |
|---|
| 6290 | 6651 | { |
|---|
| 6291 | | - struct nfs4_exception exception = { }; |
|---|
| 6652 | + struct nfs4_exception exception = { |
|---|
| 6653 | + .interruptible = true, |
|---|
| 6654 | + }; |
|---|
| 6292 | 6655 | int err; |
|---|
| 6293 | 6656 | |
|---|
| 6294 | 6657 | do { |
|---|
| .. | .. |
|---|
| 6298 | 6661 | &exception); |
|---|
| 6299 | 6662 | } while (exception.retry); |
|---|
| 6300 | 6663 | return err; |
|---|
| 6664 | +} |
|---|
| 6665 | + |
|---|
| 6666 | +/* |
|---|
| 6667 | + * Update the seqid of a lock stateid after receiving |
|---|
| 6668 | + * NFS4ERR_OLD_STATEID |
|---|
| 6669 | + */ |
|---|
| 6670 | +static bool nfs4_refresh_lock_old_stateid(nfs4_stateid *dst, |
|---|
| 6671 | + struct nfs4_lock_state *lsp) |
|---|
| 6672 | +{ |
|---|
| 6673 | + struct nfs4_state *state = lsp->ls_state; |
|---|
| 6674 | + bool ret = false; |
|---|
| 6675 | + |
|---|
| 6676 | + spin_lock(&state->state_lock); |
|---|
| 6677 | + if (!nfs4_stateid_match_other(dst, &lsp->ls_stateid)) |
|---|
| 6678 | + goto out; |
|---|
| 6679 | + if (!nfs4_stateid_is_newer(&lsp->ls_stateid, dst)) |
|---|
| 6680 | + nfs4_stateid_seqid_inc(dst); |
|---|
| 6681 | + else |
|---|
| 6682 | + dst->seqid = lsp->ls_stateid.seqid; |
|---|
| 6683 | + ret = true; |
|---|
| 6684 | +out: |
|---|
| 6685 | + spin_unlock(&state->state_lock); |
|---|
| 6686 | + return ret; |
|---|
| 6687 | +} |
|---|
| 6688 | + |
|---|
| 6689 | +static bool nfs4_sync_lock_stateid(nfs4_stateid *dst, |
|---|
| 6690 | + struct nfs4_lock_state *lsp) |
|---|
| 6691 | +{ |
|---|
| 6692 | + struct nfs4_state *state = lsp->ls_state; |
|---|
| 6693 | + bool ret; |
|---|
| 6694 | + |
|---|
| 6695 | + spin_lock(&state->state_lock); |
|---|
| 6696 | + ret = !nfs4_stateid_match_other(dst, &lsp->ls_stateid); |
|---|
| 6697 | + nfs4_stateid_copy(dst, &lsp->ls_stateid); |
|---|
| 6698 | + spin_unlock(&state->state_lock); |
|---|
| 6699 | + return ret; |
|---|
| 6301 | 6700 | } |
|---|
| 6302 | 6701 | |
|---|
| 6303 | 6702 | struct nfs4_unlockdata { |
|---|
| .. | .. |
|---|
| 6317 | 6716 | struct nfs_seqid *seqid) |
|---|
| 6318 | 6717 | { |
|---|
| 6319 | 6718 | struct nfs4_unlockdata *p; |
|---|
| 6320 | | - struct inode *inode = lsp->ls_state->inode; |
|---|
| 6719 | + struct nfs4_state *state = lsp->ls_state; |
|---|
| 6720 | + struct inode *inode = state->inode; |
|---|
| 6321 | 6721 | |
|---|
| 6322 | 6722 | p = kzalloc(sizeof(*p), GFP_NOFS); |
|---|
| 6323 | 6723 | if (p == NULL) |
|---|
| .. | .. |
|---|
| 6327 | 6727 | p->arg.seqid = seqid; |
|---|
| 6328 | 6728 | p->res.seqid = seqid; |
|---|
| 6329 | 6729 | p->lsp = lsp; |
|---|
| 6330 | | - refcount_inc(&lsp->ls_count); |
|---|
| 6331 | 6730 | /* Ensure we don't close file until we're done freeing locks! */ |
|---|
| 6332 | 6731 | p->ctx = get_nfs_open_context(ctx); |
|---|
| 6333 | 6732 | p->l_ctx = nfs_get_lock_context(ctx); |
|---|
| 6334 | | - memcpy(&p->fl, fl, sizeof(p->fl)); |
|---|
| 6733 | + locks_init_lock(&p->fl); |
|---|
| 6734 | + locks_copy_lock(&p->fl, fl); |
|---|
| 6335 | 6735 | p->server = NFS_SERVER(inode); |
|---|
| 6736 | + spin_lock(&state->state_lock); |
|---|
| 6737 | + nfs4_stateid_copy(&p->arg.stateid, &lsp->ls_stateid); |
|---|
| 6738 | + spin_unlock(&state->state_lock); |
|---|
| 6336 | 6739 | return p; |
|---|
| 6337 | 6740 | } |
|---|
| 6338 | 6741 | |
|---|
| .. | .. |
|---|
| 6363 | 6766 | if (nfs4_update_lock_stateid(calldata->lsp, |
|---|
| 6364 | 6767 | &calldata->res.stateid)) |
|---|
| 6365 | 6768 | break; |
|---|
| 6366 | | - /* Fall through */ |
|---|
| 6769 | + fallthrough; |
|---|
| 6367 | 6770 | case -NFS4ERR_ADMIN_REVOKED: |
|---|
| 6368 | 6771 | case -NFS4ERR_EXPIRED: |
|---|
| 6369 | 6772 | nfs4_free_revoked_stateid(calldata->server, |
|---|
| 6370 | 6773 | &calldata->arg.stateid, |
|---|
| 6371 | 6774 | task->tk_msg.rpc_cred); |
|---|
| 6372 | | - /* Fall through */ |
|---|
| 6775 | + fallthrough; |
|---|
| 6373 | 6776 | case -NFS4ERR_BAD_STATEID: |
|---|
| 6374 | | - case -NFS4ERR_OLD_STATEID: |
|---|
| 6375 | 6777 | case -NFS4ERR_STALE_STATEID: |
|---|
| 6376 | | - if (!nfs4_stateid_match(&calldata->arg.stateid, |
|---|
| 6377 | | - &calldata->lsp->ls_stateid)) |
|---|
| 6778 | + if (nfs4_sync_lock_stateid(&calldata->arg.stateid, |
|---|
| 6779 | + calldata->lsp)) |
|---|
| 6780 | + rpc_restart_call_prepare(task); |
|---|
| 6781 | + break; |
|---|
| 6782 | + case -NFS4ERR_OLD_STATEID: |
|---|
| 6783 | + if (nfs4_refresh_lock_old_stateid(&calldata->arg.stateid, |
|---|
| 6784 | + calldata->lsp)) |
|---|
| 6378 | 6785 | rpc_restart_call_prepare(task); |
|---|
| 6379 | 6786 | break; |
|---|
| 6380 | 6787 | default: |
|---|
| .. | .. |
|---|
| 6397 | 6804 | |
|---|
| 6398 | 6805 | if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) |
|---|
| 6399 | 6806 | goto out_wait; |
|---|
| 6400 | | - nfs4_stateid_copy(&calldata->arg.stateid, &calldata->lsp->ls_stateid); |
|---|
| 6401 | 6807 | if (test_bit(NFS_LOCK_INITIALIZED, &calldata->lsp->ls_flags) == 0) { |
|---|
| 6402 | 6808 | /* Note: exit _without_ running nfs4_locku_done */ |
|---|
| 6403 | 6809 | goto out_no_action; |
|---|
| .. | .. |
|---|
| 6551 | 6957 | p->res.lock_seqid = p->arg.lock_seqid; |
|---|
| 6552 | 6958 | p->lsp = lsp; |
|---|
| 6553 | 6959 | p->server = server; |
|---|
| 6554 | | - refcount_inc(&lsp->ls_count); |
|---|
| 6555 | 6960 | p->ctx = get_nfs_open_context(ctx); |
|---|
| 6556 | | - memcpy(&p->fl, fl, sizeof(p->fl)); |
|---|
| 6961 | + locks_init_lock(&p->fl); |
|---|
| 6962 | + locks_copy_lock(&p->fl, fl); |
|---|
| 6557 | 6963 | return p; |
|---|
| 6558 | 6964 | out_free_seqid: |
|---|
| 6559 | 6965 | nfs_free_seqid(p->arg.open_seqid); |
|---|
| .. | .. |
|---|
| 6608 | 7014 | { |
|---|
| 6609 | 7015 | struct nfs4_lockdata *data = calldata; |
|---|
| 6610 | 7016 | struct nfs4_lock_state *lsp = data->lsp; |
|---|
| 7017 | + struct nfs_server *server = NFS_SERVER(d_inode(data->ctx->dentry)); |
|---|
| 6611 | 7018 | |
|---|
| 6612 | 7019 | dprintk("%s: begin!\n", __func__); |
|---|
| 6613 | 7020 | |
|---|
| .. | .. |
|---|
| 6617 | 7024 | data->rpc_status = task->tk_status; |
|---|
| 6618 | 7025 | switch (task->tk_status) { |
|---|
| 6619 | 7026 | case 0: |
|---|
| 6620 | | - renew_lease(NFS_SERVER(d_inode(data->ctx->dentry)), |
|---|
| 6621 | | - data->timestamp); |
|---|
| 7027 | + renew_lease(server, data->timestamp); |
|---|
| 6622 | 7028 | if (data->arg.new_lock && !data->cancelled) { |
|---|
| 6623 | 7029 | data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS); |
|---|
| 6624 | 7030 | if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0) |
|---|
| .. | .. |
|---|
| 6638 | 7044 | if (data->arg.new_lock_owner != 0) { |
|---|
| 6639 | 7045 | if (!nfs4_stateid_match(&data->arg.open_stateid, |
|---|
| 6640 | 7046 | &lsp->ls_state->open_stateid)) |
|---|
| 7047 | + goto out_restart; |
|---|
| 7048 | + else if (nfs4_async_handle_error(task, server, lsp->ls_state, NULL) == -EAGAIN) |
|---|
| 6641 | 7049 | goto out_restart; |
|---|
| 6642 | 7050 | } else if (!nfs4_stateid_match(&data->arg.lock_stateid, |
|---|
| 6643 | 7051 | &lsp->ls_stateid)) |
|---|
| .. | .. |
|---|
| 6693 | 7101 | case -NFS4ERR_STALE_STATEID: |
|---|
| 6694 | 7102 | lsp->ls_seqid.flags &= ~NFS_SEQID_CONFIRMED; |
|---|
| 6695 | 7103 | nfs4_schedule_lease_recovery(server->nfs_client); |
|---|
| 6696 | | - }; |
|---|
| 7104 | + } |
|---|
| 6697 | 7105 | } |
|---|
| 6698 | 7106 | |
|---|
| 6699 | 7107 | static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_type) |
|---|
| .. | .. |
|---|
| 6709 | 7117 | .rpc_message = &msg, |
|---|
| 6710 | 7118 | .callback_ops = &nfs4_lock_ops, |
|---|
| 6711 | 7119 | .workqueue = nfsiod_workqueue, |
|---|
| 6712 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 7120 | + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, |
|---|
| 6713 | 7121 | }; |
|---|
| 6714 | 7122 | int ret; |
|---|
| 6715 | 7123 | |
|---|
| .. | .. |
|---|
| 6852 | 7260 | struct nfs4_exception exception = { |
|---|
| 6853 | 7261 | .state = state, |
|---|
| 6854 | 7262 | .inode = state->inode, |
|---|
| 7263 | + .interruptible = true, |
|---|
| 6855 | 7264 | }; |
|---|
| 6856 | 7265 | int err; |
|---|
| 6857 | 7266 | |
|---|
| .. | .. |
|---|
| 7136 | 7545 | |
|---|
| 7137 | 7546 | static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler, |
|---|
| 7138 | 7547 | struct dentry *unused, struct inode *inode, |
|---|
| 7139 | | - const char *key, void *buf, size_t buflen) |
|---|
| 7548 | + const char *key, void *buf, size_t buflen, |
|---|
| 7549 | + int flags) |
|---|
| 7140 | 7550 | { |
|---|
| 7141 | 7551 | return nfs4_proc_get_acl(inode, buf, buflen); |
|---|
| 7142 | 7552 | } |
|---|
| .. | .. |
|---|
| 7161 | 7571 | |
|---|
| 7162 | 7572 | static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler, |
|---|
| 7163 | 7573 | struct dentry *unused, struct inode *inode, |
|---|
| 7164 | | - const char *key, void *buf, size_t buflen) |
|---|
| 7574 | + const char *key, void *buf, size_t buflen, |
|---|
| 7575 | + int flags) |
|---|
| 7165 | 7576 | { |
|---|
| 7166 | 7577 | if (security_ismaclabel(key)) |
|---|
| 7167 | 7578 | return nfs4_get_security_label(inode, buf, buflen); |
|---|
| .. | .. |
|---|
| 7175 | 7586 | |
|---|
| 7176 | 7587 | if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) { |
|---|
| 7177 | 7588 | len = security_inode_listsecurity(inode, list, list_len); |
|---|
| 7178 | | - if (list_len && len > list_len) |
|---|
| 7589 | + if (len >= 0 && list_len && len > list_len) |
|---|
| 7179 | 7590 | return -ERANGE; |
|---|
| 7180 | 7591 | } |
|---|
| 7181 | 7592 | return len; |
|---|
| .. | .. |
|---|
| 7196 | 7607 | } |
|---|
| 7197 | 7608 | |
|---|
| 7198 | 7609 | #endif |
|---|
| 7610 | + |
|---|
| 7611 | +#ifdef CONFIG_NFS_V4_2 |
|---|
| 7612 | +static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler, |
|---|
| 7613 | + struct dentry *unused, struct inode *inode, |
|---|
| 7614 | + const char *key, const void *buf, |
|---|
| 7615 | + size_t buflen, int flags) |
|---|
| 7616 | +{ |
|---|
| 7617 | + u32 mask; |
|---|
| 7618 | + int ret; |
|---|
| 7619 | + |
|---|
| 7620 | + if (!nfs_server_capable(inode, NFS_CAP_XATTR)) |
|---|
| 7621 | + return -EOPNOTSUPP; |
|---|
| 7622 | + |
|---|
| 7623 | + /* |
|---|
| 7624 | + * There is no mapping from the MAY_* flags to the NFS_ACCESS_XA* |
|---|
| 7625 | + * flags right now. Handling of xattr operations use the normal |
|---|
| 7626 | + * file read/write permissions. |
|---|
| 7627 | + * |
|---|
| 7628 | + * Just in case the server has other ideas (which RFC 8276 allows), |
|---|
| 7629 | + * do a cached access check for the XA* flags to possibly avoid |
|---|
| 7630 | + * doing an RPC and getting EACCES back. |
|---|
| 7631 | + */ |
|---|
| 7632 | + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { |
|---|
| 7633 | + if (!(mask & NFS_ACCESS_XAWRITE)) |
|---|
| 7634 | + return -EACCES; |
|---|
| 7635 | + } |
|---|
| 7636 | + |
|---|
| 7637 | + if (buf == NULL) { |
|---|
| 7638 | + ret = nfs42_proc_removexattr(inode, key); |
|---|
| 7639 | + if (!ret) |
|---|
| 7640 | + nfs4_xattr_cache_remove(inode, key); |
|---|
| 7641 | + } else { |
|---|
| 7642 | + ret = nfs42_proc_setxattr(inode, key, buf, buflen, flags); |
|---|
| 7643 | + if (!ret) |
|---|
| 7644 | + nfs4_xattr_cache_add(inode, key, buf, NULL, buflen); |
|---|
| 7645 | + } |
|---|
| 7646 | + |
|---|
| 7647 | + return ret; |
|---|
| 7648 | +} |
|---|
| 7649 | + |
|---|
| 7650 | +static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler, |
|---|
| 7651 | + struct dentry *unused, struct inode *inode, |
|---|
| 7652 | + const char *key, void *buf, size_t buflen, |
|---|
| 7653 | + int flags) |
|---|
| 7654 | +{ |
|---|
| 7655 | + u32 mask; |
|---|
| 7656 | + ssize_t ret; |
|---|
| 7657 | + |
|---|
| 7658 | + if (!nfs_server_capable(inode, NFS_CAP_XATTR)) |
|---|
| 7659 | + return -EOPNOTSUPP; |
|---|
| 7660 | + |
|---|
| 7661 | + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { |
|---|
| 7662 | + if (!(mask & NFS_ACCESS_XAREAD)) |
|---|
| 7663 | + return -EACCES; |
|---|
| 7664 | + } |
|---|
| 7665 | + |
|---|
| 7666 | + ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); |
|---|
| 7667 | + if (ret) |
|---|
| 7668 | + return ret; |
|---|
| 7669 | + |
|---|
| 7670 | + ret = nfs4_xattr_cache_get(inode, key, buf, buflen); |
|---|
| 7671 | + if (ret >= 0 || (ret < 0 && ret != -ENOENT)) |
|---|
| 7672 | + return ret; |
|---|
| 7673 | + |
|---|
| 7674 | + ret = nfs42_proc_getxattr(inode, key, buf, buflen); |
|---|
| 7675 | + |
|---|
| 7676 | + return ret; |
|---|
| 7677 | +} |
|---|
| 7678 | + |
|---|
| 7679 | +static ssize_t |
|---|
| 7680 | +nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) |
|---|
| 7681 | +{ |
|---|
| 7682 | + u64 cookie; |
|---|
| 7683 | + bool eof; |
|---|
| 7684 | + ssize_t ret, size; |
|---|
| 7685 | + char *buf; |
|---|
| 7686 | + size_t buflen; |
|---|
| 7687 | + u32 mask; |
|---|
| 7688 | + |
|---|
| 7689 | + if (!nfs_server_capable(inode, NFS_CAP_XATTR)) |
|---|
| 7690 | + return 0; |
|---|
| 7691 | + |
|---|
| 7692 | + if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) { |
|---|
| 7693 | + if (!(mask & NFS_ACCESS_XALIST)) |
|---|
| 7694 | + return 0; |
|---|
| 7695 | + } |
|---|
| 7696 | + |
|---|
| 7697 | + ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); |
|---|
| 7698 | + if (ret) |
|---|
| 7699 | + return ret; |
|---|
| 7700 | + |
|---|
| 7701 | + ret = nfs4_xattr_cache_list(inode, list, list_len); |
|---|
| 7702 | + if (ret >= 0 || (ret < 0 && ret != -ENOENT)) |
|---|
| 7703 | + return ret; |
|---|
| 7704 | + |
|---|
| 7705 | + cookie = 0; |
|---|
| 7706 | + eof = false; |
|---|
| 7707 | + buflen = list_len ? list_len : XATTR_LIST_MAX; |
|---|
| 7708 | + buf = list_len ? list : NULL; |
|---|
| 7709 | + size = 0; |
|---|
| 7710 | + |
|---|
| 7711 | + while (!eof) { |
|---|
| 7712 | + ret = nfs42_proc_listxattrs(inode, buf, buflen, |
|---|
| 7713 | + &cookie, &eof); |
|---|
| 7714 | + if (ret < 0) |
|---|
| 7715 | + return ret; |
|---|
| 7716 | + |
|---|
| 7717 | + if (list_len) { |
|---|
| 7718 | + buf += ret; |
|---|
| 7719 | + buflen -= ret; |
|---|
| 7720 | + } |
|---|
| 7721 | + size += ret; |
|---|
| 7722 | + } |
|---|
| 7723 | + |
|---|
| 7724 | + if (list_len) |
|---|
| 7725 | + nfs4_xattr_cache_set_list(inode, list, size); |
|---|
| 7726 | + |
|---|
| 7727 | + return size; |
|---|
| 7728 | +} |
|---|
| 7729 | + |
|---|
| 7730 | +#else |
|---|
| 7731 | + |
|---|
| 7732 | +static ssize_t |
|---|
| 7733 | +nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) |
|---|
| 7734 | +{ |
|---|
| 7735 | + return 0; |
|---|
| 7736 | +} |
|---|
| 7737 | +#endif /* CONFIG_NFS_V4_2 */ |
|---|
| 7199 | 7738 | |
|---|
| 7200 | 7739 | /* |
|---|
| 7201 | 7740 | * nfs_fhget will use either the mounted_on_fileid or the fileid |
|---|
| .. | .. |
|---|
| 7262 | 7801 | struct nfs4_fs_locations *fs_locations, |
|---|
| 7263 | 7802 | struct page *page) |
|---|
| 7264 | 7803 | { |
|---|
| 7265 | | - struct nfs4_exception exception = { }; |
|---|
| 7804 | + struct nfs4_exception exception = { |
|---|
| 7805 | + .interruptible = true, |
|---|
| 7806 | + }; |
|---|
| 7266 | 7807 | int err; |
|---|
| 7267 | 7808 | do { |
|---|
| 7268 | 7809 | err = _nfs4_proc_fs_locations(client, dir, name, |
|---|
| .. | .. |
|---|
| 7283 | 7824 | */ |
|---|
| 7284 | 7825 | static int _nfs40_proc_get_locations(struct inode *inode, |
|---|
| 7285 | 7826 | struct nfs4_fs_locations *locations, |
|---|
| 7286 | | - struct page *page, struct rpc_cred *cred) |
|---|
| 7827 | + struct page *page, const struct cred *cred) |
|---|
| 7287 | 7828 | { |
|---|
| 7288 | 7829 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7289 | 7830 | struct rpc_clnt *clnt = server->client; |
|---|
| .. | .. |
|---|
| 7340 | 7881 | */ |
|---|
| 7341 | 7882 | static int _nfs41_proc_get_locations(struct inode *inode, |
|---|
| 7342 | 7883 | struct nfs4_fs_locations *locations, |
|---|
| 7343 | | - struct page *page, struct rpc_cred *cred) |
|---|
| 7884 | + struct page *page, const struct cred *cred) |
|---|
| 7344 | 7885 | { |
|---|
| 7345 | 7886 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7346 | 7887 | struct rpc_clnt *clnt = server->client; |
|---|
| .. | .. |
|---|
| 7399 | 7940 | */ |
|---|
| 7400 | 7941 | int nfs4_proc_get_locations(struct inode *inode, |
|---|
| 7401 | 7942 | struct nfs4_fs_locations *locations, |
|---|
| 7402 | | - struct page *page, struct rpc_cred *cred) |
|---|
| 7943 | + struct page *page, const struct cred *cred) |
|---|
| 7403 | 7944 | { |
|---|
| 7404 | 7945 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7405 | 7946 | struct nfs_client *clp = server->nfs_client; |
|---|
| 7406 | 7947 | const struct nfs4_mig_recovery_ops *ops = |
|---|
| 7407 | 7948 | clp->cl_mvops->mig_recovery_ops; |
|---|
| 7408 | | - struct nfs4_exception exception = { }; |
|---|
| 7949 | + struct nfs4_exception exception = { |
|---|
| 7950 | + .interruptible = true, |
|---|
| 7951 | + }; |
|---|
| 7409 | 7952 | int status; |
|---|
| 7410 | 7953 | |
|---|
| 7411 | 7954 | dprintk("%s: FSID %llx:%llx on \"%s\"\n", __func__, |
|---|
| .. | .. |
|---|
| 7430 | 7973 | * is appended to this compound to identify the client ID which is |
|---|
| 7431 | 7974 | * performing recovery. |
|---|
| 7432 | 7975 | */ |
|---|
| 7433 | | -static int _nfs40_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) |
|---|
| 7976 | +static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred) |
|---|
| 7434 | 7977 | { |
|---|
| 7435 | 7978 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7436 | 7979 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; |
|---|
| .. | .. |
|---|
| 7476 | 8019 | * this operation is identified in the SEQUENCE operation in this |
|---|
| 7477 | 8020 | * compound. |
|---|
| 7478 | 8021 | */ |
|---|
| 7479 | | -static int _nfs41_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) |
|---|
| 8022 | +static int _nfs41_proc_fsid_present(struct inode *inode, const struct cred *cred) |
|---|
| 7480 | 8023 | { |
|---|
| 7481 | 8024 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7482 | 8025 | struct rpc_clnt *clnt = server->client; |
|---|
| .. | .. |
|---|
| 7523 | 8066 | * NFS4ERR code if some error occurred on the server, or a |
|---|
| 7524 | 8067 | * negative errno if a local failure occurred. |
|---|
| 7525 | 8068 | */ |
|---|
| 7526 | | -int nfs4_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) |
|---|
| 8069 | +int nfs4_proc_fsid_present(struct inode *inode, const struct cred *cred) |
|---|
| 7527 | 8070 | { |
|---|
| 7528 | 8071 | struct nfs_server *server = NFS_SERVER(inode); |
|---|
| 7529 | 8072 | struct nfs_client *clp = server->nfs_client; |
|---|
| 7530 | 8073 | const struct nfs4_mig_recovery_ops *ops = |
|---|
| 7531 | 8074 | clp->cl_mvops->mig_recovery_ops; |
|---|
| 7532 | | - struct nfs4_exception exception = { }; |
|---|
| 8075 | + struct nfs4_exception exception = { |
|---|
| 8076 | + .interruptible = true, |
|---|
| 8077 | + }; |
|---|
| 7533 | 8078 | int status; |
|---|
| 7534 | 8079 | |
|---|
| 7535 | 8080 | dprintk("%s: FSID %llx:%llx on \"%s\"\n", __func__, |
|---|
| .. | .. |
|---|
| 7547 | 8092 | return status; |
|---|
| 7548 | 8093 | } |
|---|
| 7549 | 8094 | |
|---|
| 7550 | | -/** |
|---|
| 8095 | +/* |
|---|
| 7551 | 8096 | * If 'use_integrity' is true and the state managment nfs_client |
|---|
| 7552 | 8097 | * cl_rpcclient is using krb5i/p, use the integrity protected cl_rpcclient |
|---|
| 7553 | 8098 | * and the machine credential as per RFC3530bis and RFC5661 Security |
|---|
| .. | .. |
|---|
| 7557 | 8102 | static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct nfs4_secinfo_flavors *flavors, bool use_integrity) |
|---|
| 7558 | 8103 | { |
|---|
| 7559 | 8104 | int status; |
|---|
| 8105 | + struct rpc_clnt *clnt = NFS_SERVER(dir)->client; |
|---|
| 8106 | + struct nfs_client *clp = NFS_SERVER(dir)->nfs_client; |
|---|
| 7560 | 8107 | struct nfs4_secinfo_arg args = { |
|---|
| 7561 | 8108 | .dir_fh = NFS_FH(dir), |
|---|
| 7562 | 8109 | .name = name, |
|---|
| .. | .. |
|---|
| 7569 | 8116 | .rpc_argp = &args, |
|---|
| 7570 | 8117 | .rpc_resp = &res, |
|---|
| 7571 | 8118 | }; |
|---|
| 7572 | | - struct rpc_clnt *clnt = NFS_SERVER(dir)->client; |
|---|
| 7573 | | - struct rpc_cred *cred = NULL; |
|---|
| 8119 | + struct nfs4_call_sync_data data = { |
|---|
| 8120 | + .seq_server = NFS_SERVER(dir), |
|---|
| 8121 | + .seq_args = &args.seq_args, |
|---|
| 8122 | + .seq_res = &res.seq_res, |
|---|
| 8123 | + }; |
|---|
| 8124 | + struct rpc_task_setup task_setup = { |
|---|
| 8125 | + .rpc_client = clnt, |
|---|
| 8126 | + .rpc_message = &msg, |
|---|
| 8127 | + .callback_ops = clp->cl_mvops->call_sync_ops, |
|---|
| 8128 | + .callback_data = &data, |
|---|
| 8129 | + .flags = RPC_TASK_NO_ROUND_ROBIN, |
|---|
| 8130 | + }; |
|---|
| 8131 | + const struct cred *cred = NULL; |
|---|
| 7574 | 8132 | |
|---|
| 7575 | 8133 | if (use_integrity) { |
|---|
| 7576 | | - clnt = NFS_SERVER(dir)->nfs_client->cl_rpcclient; |
|---|
| 7577 | | - cred = nfs4_get_clid_cred(NFS_SERVER(dir)->nfs_client); |
|---|
| 8134 | + clnt = clp->cl_rpcclient; |
|---|
| 8135 | + task_setup.rpc_client = clnt; |
|---|
| 8136 | + |
|---|
| 8137 | + cred = nfs4_get_clid_cred(clp); |
|---|
| 7578 | 8138 | msg.rpc_cred = cred; |
|---|
| 7579 | 8139 | } |
|---|
| 7580 | 8140 | |
|---|
| 7581 | 8141 | dprintk("NFS call secinfo %s\n", name->name); |
|---|
| 7582 | 8142 | |
|---|
| 7583 | | - nfs4_state_protect(NFS_SERVER(dir)->nfs_client, |
|---|
| 7584 | | - NFS_SP4_MACH_CRED_SECINFO, &clnt, &msg); |
|---|
| 8143 | + nfs4_state_protect(clp, NFS_SP4_MACH_CRED_SECINFO, &clnt, &msg); |
|---|
| 8144 | + nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0); |
|---|
| 8145 | + status = nfs4_call_sync_custom(&task_setup); |
|---|
| 7585 | 8146 | |
|---|
| 7586 | | - status = nfs4_call_sync(clnt, NFS_SERVER(dir), &msg, &args.seq_args, |
|---|
| 7587 | | - &res.seq_res, 0); |
|---|
| 7588 | 8147 | dprintk("NFS reply secinfo: %d\n", status); |
|---|
| 7589 | 8148 | |
|---|
| 7590 | | - if (cred) |
|---|
| 7591 | | - put_rpccred(cred); |
|---|
| 7592 | | - |
|---|
| 8149 | + put_cred(cred); |
|---|
| 7593 | 8150 | return status; |
|---|
| 7594 | 8151 | } |
|---|
| 7595 | 8152 | |
|---|
| 7596 | 8153 | int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, |
|---|
| 7597 | 8154 | struct nfs4_secinfo_flavors *flavors) |
|---|
| 7598 | 8155 | { |
|---|
| 7599 | | - struct nfs4_exception exception = { }; |
|---|
| 8156 | + struct nfs4_exception exception = { |
|---|
| 8157 | + .interruptible = true, |
|---|
| 8158 | + }; |
|---|
| 7600 | 8159 | int err; |
|---|
| 7601 | 8160 | do { |
|---|
| 7602 | 8161 | err = -NFS4ERR_WRONGSEC; |
|---|
| .. | .. |
|---|
| 7655 | 8214 | static void |
|---|
| 7656 | 8215 | nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata) |
|---|
| 7657 | 8216 | { |
|---|
| 8217 | + struct nfs41_bind_conn_to_session_args *args = task->tk_msg.rpc_argp; |
|---|
| 8218 | + struct nfs41_bind_conn_to_session_res *res = task->tk_msg.rpc_resp; |
|---|
| 8219 | + struct nfs_client *clp = args->client; |
|---|
| 8220 | + |
|---|
| 8221 | + switch (task->tk_status) { |
|---|
| 8222 | + case -NFS4ERR_BADSESSION: |
|---|
| 8223 | + case -NFS4ERR_DEADSESSION: |
|---|
| 8224 | + nfs4_schedule_session_recovery(clp->cl_session, |
|---|
| 8225 | + task->tk_status); |
|---|
| 8226 | + return; |
|---|
| 8227 | + } |
|---|
| 8228 | + if (args->dir == NFS4_CDFC4_FORE_OR_BOTH && |
|---|
| 8229 | + res->dir != NFS4_CDFS4_BOTH) { |
|---|
| 8230 | + rpc_task_close_connection(task); |
|---|
| 8231 | + if (args->retries++ < MAX_BIND_CONN_TO_SESSION_RETRIES) |
|---|
| 8232 | + rpc_restart_call(task); |
|---|
| 8233 | + } |
|---|
| 7658 | 8234 | } |
|---|
| 7659 | 8235 | |
|---|
| 7660 | 8236 | static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = { |
|---|
| .. | .. |
|---|
| 7671 | 8247 | int nfs4_proc_bind_one_conn_to_session(struct rpc_clnt *clnt, |
|---|
| 7672 | 8248 | struct rpc_xprt *xprt, |
|---|
| 7673 | 8249 | struct nfs_client *clp, |
|---|
| 7674 | | - struct rpc_cred *cred) |
|---|
| 8250 | + const struct cred *cred) |
|---|
| 7675 | 8251 | { |
|---|
| 7676 | 8252 | int status; |
|---|
| 7677 | 8253 | struct nfs41_bind_conn_to_session_args args = { |
|---|
| 7678 | 8254 | .client = clp, |
|---|
| 7679 | 8255 | .dir = NFS4_CDFC4_FORE_OR_BOTH, |
|---|
| 8256 | + .retries = 0, |
|---|
| 7680 | 8257 | }; |
|---|
| 7681 | 8258 | struct nfs41_bind_conn_to_session_res res; |
|---|
| 7682 | 8259 | struct rpc_message msg = { |
|---|
| .. | .. |
|---|
| 7733 | 8310 | |
|---|
| 7734 | 8311 | struct rpc_bind_conn_calldata { |
|---|
| 7735 | 8312 | struct nfs_client *clp; |
|---|
| 7736 | | - struct rpc_cred *cred; |
|---|
| 8313 | + const struct cred *cred; |
|---|
| 7737 | 8314 | }; |
|---|
| 7738 | 8315 | |
|---|
| 7739 | 8316 | static int |
|---|
| .. | .. |
|---|
| 7746 | 8323 | return nfs4_proc_bind_one_conn_to_session(clnt, xprt, p->clp, p->cred); |
|---|
| 7747 | 8324 | } |
|---|
| 7748 | 8325 | |
|---|
| 7749 | | -int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred) |
|---|
| 8326 | +int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, const struct cred *cred) |
|---|
| 7750 | 8327 | { |
|---|
| 7751 | 8328 | struct rpc_bind_conn_calldata data = { |
|---|
| 7752 | 8329 | .clp = clp, |
|---|
| .. | .. |
|---|
| 7912 | 8489 | * Wrapper for EXCHANGE_ID operation. |
|---|
| 7913 | 8490 | */ |
|---|
| 7914 | 8491 | static struct rpc_task * |
|---|
| 7915 | | -nfs4_run_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, |
|---|
| 8492 | +nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred, |
|---|
| 7916 | 8493 | u32 sp4_how, struct rpc_xprt *xprt) |
|---|
| 7917 | 8494 | { |
|---|
| 7918 | 8495 | struct rpc_message msg = { |
|---|
| .. | .. |
|---|
| 7923 | 8500 | .rpc_client = clp->cl_rpcclient, |
|---|
| 7924 | 8501 | .callback_ops = &nfs4_exchange_id_call_ops, |
|---|
| 7925 | 8502 | .rpc_message = &msg, |
|---|
| 7926 | | - .flags = RPC_TASK_TIMEOUT, |
|---|
| 8503 | + .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN, |
|---|
| 7927 | 8504 | }; |
|---|
| 7928 | 8505 | struct nfs41_exchange_id_data *calldata; |
|---|
| 7929 | 8506 | int status; |
|---|
| .. | .. |
|---|
| 8008 | 8585 | * |
|---|
| 8009 | 8586 | * Wrapper for EXCHANGE_ID operation. |
|---|
| 8010 | 8587 | */ |
|---|
| 8011 | | -static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, |
|---|
| 8588 | +static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred, |
|---|
| 8012 | 8589 | u32 sp4_how) |
|---|
| 8013 | 8590 | { |
|---|
| 8014 | 8591 | struct rpc_task *task; |
|---|
| 8015 | 8592 | struct nfs41_exchange_id_args *argp; |
|---|
| 8016 | 8593 | struct nfs41_exchange_id_res *resp; |
|---|
| 8594 | + unsigned long now = jiffies; |
|---|
| 8017 | 8595 | int status; |
|---|
| 8018 | 8596 | |
|---|
| 8019 | 8597 | task = nfs4_run_exchange_id(clp, cred, sp4_how, NULL); |
|---|
| .. | .. |
|---|
| 8034 | 8612 | status = nfs4_sp4_select_mode(clp, &resp->state_protect); |
|---|
| 8035 | 8613 | if (status != 0) |
|---|
| 8036 | 8614 | goto out; |
|---|
| 8615 | + |
|---|
| 8616 | + do_renew_lease(clp, now); |
|---|
| 8037 | 8617 | |
|---|
| 8038 | 8618 | clp->cl_clientid = resp->clientid; |
|---|
| 8039 | 8619 | clp->cl_exchange_flags = resp->flags; |
|---|
| .. | .. |
|---|
| 8076 | 8656 | * |
|---|
| 8077 | 8657 | * Will attempt to negotiate SP4_MACH_CRED if krb5i / krb5p auth is used. |
|---|
| 8078 | 8658 | */ |
|---|
| 8079 | | -int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) |
|---|
| 8659 | +int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred) |
|---|
| 8080 | 8660 | { |
|---|
| 8081 | 8661 | rpc_authflavor_t authflavor = clp->cl_rpcclient->cl_auth->au_flavor; |
|---|
| 8082 | 8662 | int status; |
|---|
| .. | .. |
|---|
| 8108 | 8688 | * @xprt: the rpc_xprt to test |
|---|
| 8109 | 8689 | * @data: call data for _nfs4_proc_exchange_id. |
|---|
| 8110 | 8690 | */ |
|---|
| 8111 | | -int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt, |
|---|
| 8691 | +void nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt, |
|---|
| 8112 | 8692 | void *data) |
|---|
| 8113 | 8693 | { |
|---|
| 8114 | 8694 | struct nfs4_add_xprt_data *adata = (struct nfs4_add_xprt_data *)data; |
|---|
| .. | .. |
|---|
| 8125 | 8705 | /* Test connection for session trunking. Async exchange_id call */ |
|---|
| 8126 | 8706 | task = nfs4_run_exchange_id(adata->clp, adata->cred, sp4_how, xprt); |
|---|
| 8127 | 8707 | if (IS_ERR(task)) |
|---|
| 8128 | | - return PTR_ERR(task); |
|---|
| 8708 | + return; |
|---|
| 8129 | 8709 | |
|---|
| 8130 | 8710 | status = task->tk_status; |
|---|
| 8131 | 8711 | if (status == 0) |
|---|
| 8132 | 8712 | status = nfs4_detect_session_trunking(adata->clp, |
|---|
| 8133 | 8713 | task->tk_msg.rpc_resp, xprt); |
|---|
| 8134 | 8714 | |
|---|
| 8715 | + if (status == 0) |
|---|
| 8716 | + rpc_clnt_xprt_switch_add_xprt(clnt, xprt); |
|---|
| 8717 | + |
|---|
| 8135 | 8718 | rpc_put_task(task); |
|---|
| 8136 | | - return status; |
|---|
| 8137 | 8719 | } |
|---|
| 8138 | 8720 | EXPORT_SYMBOL_GPL(nfs4_test_session_trunk); |
|---|
| 8139 | 8721 | |
|---|
| 8140 | 8722 | static int _nfs4_proc_destroy_clientid(struct nfs_client *clp, |
|---|
| 8141 | | - struct rpc_cred *cred) |
|---|
| 8723 | + const struct cred *cred) |
|---|
| 8142 | 8724 | { |
|---|
| 8143 | 8725 | struct rpc_message msg = { |
|---|
| 8144 | 8726 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_CLIENTID], |
|---|
| .. | .. |
|---|
| 8147 | 8729 | }; |
|---|
| 8148 | 8730 | int status; |
|---|
| 8149 | 8731 | |
|---|
| 8150 | | - status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); |
|---|
| 8732 | + status = rpc_call_sync(clp->cl_rpcclient, &msg, |
|---|
| 8733 | + RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN); |
|---|
| 8151 | 8734 | trace_nfs4_destroy_clientid(clp, status); |
|---|
| 8152 | 8735 | if (status) |
|---|
| 8153 | 8736 | dprintk("NFS: Got error %d from the server %s on " |
|---|
| .. | .. |
|---|
| 8156 | 8739 | } |
|---|
| 8157 | 8740 | |
|---|
| 8158 | 8741 | static int nfs4_proc_destroy_clientid(struct nfs_client *clp, |
|---|
| 8159 | | - struct rpc_cred *cred) |
|---|
| 8742 | + const struct cred *cred) |
|---|
| 8160 | 8743 | { |
|---|
| 8161 | 8744 | unsigned int loop; |
|---|
| 8162 | 8745 | int ret; |
|---|
| .. | .. |
|---|
| 8177 | 8760 | |
|---|
| 8178 | 8761 | int nfs4_destroy_clientid(struct nfs_client *clp) |
|---|
| 8179 | 8762 | { |
|---|
| 8180 | | - struct rpc_cred *cred; |
|---|
| 8763 | + const struct cred *cred; |
|---|
| 8181 | 8764 | int ret = 0; |
|---|
| 8182 | 8765 | |
|---|
| 8183 | 8766 | if (clp->cl_mvops->minor_version < 1) |
|---|
| .. | .. |
|---|
| 8188 | 8771 | goto out; |
|---|
| 8189 | 8772 | cred = nfs4_get_clid_cred(clp); |
|---|
| 8190 | 8773 | ret = nfs4_proc_destroy_clientid(clp, cred); |
|---|
| 8191 | | - if (cred) |
|---|
| 8192 | | - put_rpccred(cred); |
|---|
| 8774 | + put_cred(cred); |
|---|
| 8193 | 8775 | switch (ret) { |
|---|
| 8194 | 8776 | case 0: |
|---|
| 8195 | 8777 | case -NFS4ERR_STALE_CLIENTID: |
|---|
| .. | .. |
|---|
| 8198 | 8780 | out: |
|---|
| 8199 | 8781 | return ret; |
|---|
| 8200 | 8782 | } |
|---|
| 8783 | + |
|---|
| 8784 | +#endif /* CONFIG_NFS_V4_1 */ |
|---|
| 8201 | 8785 | |
|---|
| 8202 | 8786 | struct nfs4_get_lease_time_data { |
|---|
| 8203 | 8787 | struct nfs4_get_lease_time_args *args; |
|---|
| .. | .. |
|---|
| 8231 | 8815 | (struct nfs4_get_lease_time_data *)calldata; |
|---|
| 8232 | 8816 | |
|---|
| 8233 | 8817 | dprintk("--> %s\n", __func__); |
|---|
| 8234 | | - if (!nfs41_sequence_done(task, &data->res->lr_seq_res)) |
|---|
| 8818 | + if (!nfs4_sequence_done(task, &data->res->lr_seq_res)) |
|---|
| 8235 | 8819 | return; |
|---|
| 8236 | 8820 | switch (task->tk_status) { |
|---|
| 8237 | 8821 | case -NFS4ERR_DELAY: |
|---|
| .. | .. |
|---|
| 8239 | 8823 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); |
|---|
| 8240 | 8824 | rpc_delay(task, NFS4_POLL_RETRY_MIN); |
|---|
| 8241 | 8825 | task->tk_status = 0; |
|---|
| 8242 | | - /* fall through */ |
|---|
| 8826 | + fallthrough; |
|---|
| 8243 | 8827 | case -NFS4ERR_RETRY_UNCACHED_REP: |
|---|
| 8244 | 8828 | rpc_restart_call_prepare(task); |
|---|
| 8245 | 8829 | return; |
|---|
| .. | .. |
|---|
| 8254 | 8838 | |
|---|
| 8255 | 8839 | int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo) |
|---|
| 8256 | 8840 | { |
|---|
| 8257 | | - struct rpc_task *task; |
|---|
| 8258 | 8841 | struct nfs4_get_lease_time_args args; |
|---|
| 8259 | 8842 | struct nfs4_get_lease_time_res res = { |
|---|
| 8260 | 8843 | .lr_fsinfo = fsinfo, |
|---|
| .. | .. |
|---|
| 8276 | 8859 | .callback_data = &data, |
|---|
| 8277 | 8860 | .flags = RPC_TASK_TIMEOUT, |
|---|
| 8278 | 8861 | }; |
|---|
| 8279 | | - int status; |
|---|
| 8280 | 8862 | |
|---|
| 8281 | 8863 | nfs4_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0, 1); |
|---|
| 8282 | | - task = rpc_run_task(&task_setup); |
|---|
| 8283 | | - |
|---|
| 8284 | | - if (IS_ERR(task)) |
|---|
| 8285 | | - return PTR_ERR(task); |
|---|
| 8286 | | - |
|---|
| 8287 | | - status = task->tk_status; |
|---|
| 8288 | | - rpc_put_task(task); |
|---|
| 8289 | | - return status; |
|---|
| 8864 | + return nfs4_call_sync_custom(&task_setup); |
|---|
| 8290 | 8865 | } |
|---|
| 8866 | + |
|---|
| 8867 | +#ifdef CONFIG_NFS_V4_1 |
|---|
| 8291 | 8868 | |
|---|
| 8292 | 8869 | /* |
|---|
| 8293 | 8870 | * Initialize the values to be used by the client in CREATE_SESSION |
|---|
| .. | .. |
|---|
| 8303 | 8880 | { |
|---|
| 8304 | 8881 | unsigned int max_rqst_sz, max_resp_sz; |
|---|
| 8305 | 8882 | unsigned int max_bc_payload = rpc_max_bc_payload(clnt); |
|---|
| 8883 | + unsigned int max_bc_slots = rpc_num_bc_slots(clnt); |
|---|
| 8306 | 8884 | |
|---|
| 8307 | 8885 | max_rqst_sz = NFS_MAX_FILE_IO_SIZE + nfs41_maxwrite_overhead; |
|---|
| 8308 | 8886 | max_resp_sz = NFS_MAX_FILE_IO_SIZE + nfs41_maxread_overhead; |
|---|
| .. | .. |
|---|
| 8325 | 8903 | args->bc_attrs.max_resp_sz_cached = 0; |
|---|
| 8326 | 8904 | args->bc_attrs.max_ops = NFS4_MAX_BACK_CHANNEL_OPS; |
|---|
| 8327 | 8905 | args->bc_attrs.max_reqs = max_t(unsigned short, max_session_cb_slots, 1); |
|---|
| 8906 | + if (args->bc_attrs.max_reqs > max_bc_slots) |
|---|
| 8907 | + args->bc_attrs.max_reqs = max_bc_slots; |
|---|
| 8328 | 8908 | |
|---|
| 8329 | 8909 | dprintk("%s: Back Channel : max_rqst_sz=%u max_resp_sz=%u " |
|---|
| 8330 | 8910 | "max_resp_sz_cached=%u max_ops=%u max_reqs=%u\n", |
|---|
| .. | .. |
|---|
| 8405 | 8985 | } |
|---|
| 8406 | 8986 | |
|---|
| 8407 | 8987 | static int _nfs4_proc_create_session(struct nfs_client *clp, |
|---|
| 8408 | | - struct rpc_cred *cred) |
|---|
| 8988 | + const struct cred *cred) |
|---|
| 8409 | 8989 | { |
|---|
| 8410 | 8990 | struct nfs4_session *session = clp->cl_session; |
|---|
| 8411 | 8991 | struct nfs41_create_session_args args = { |
|---|
| .. | .. |
|---|
| 8427 | 9007 | nfs4_init_channel_attrs(&args, clp->cl_rpcclient); |
|---|
| 8428 | 9008 | args.flags = (SESSION4_PERSIST | SESSION4_BACK_CHAN); |
|---|
| 8429 | 9009 | |
|---|
| 8430 | | - status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); |
|---|
| 9010 | + status = rpc_call_sync(session->clp->cl_rpcclient, &msg, |
|---|
| 9011 | + RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN); |
|---|
| 8431 | 9012 | trace_nfs4_create_session(clp, status); |
|---|
| 8432 | 9013 | |
|---|
| 8433 | 9014 | switch (status) { |
|---|
| .. | .. |
|---|
| 8437 | 9018 | case -EACCES: |
|---|
| 8438 | 9019 | case -EAGAIN: |
|---|
| 8439 | 9020 | goto out; |
|---|
| 8440 | | - }; |
|---|
| 9021 | + } |
|---|
| 8441 | 9022 | |
|---|
| 8442 | 9023 | clp->cl_seqid++; |
|---|
| 8443 | 9024 | if (!status) { |
|---|
| .. | .. |
|---|
| 8457 | 9038 | * It is the responsibility of the caller to verify the session is |
|---|
| 8458 | 9039 | * expired before calling this routine. |
|---|
| 8459 | 9040 | */ |
|---|
| 8460 | | -int nfs4_proc_create_session(struct nfs_client *clp, struct rpc_cred *cred) |
|---|
| 9041 | +int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred) |
|---|
| 8461 | 9042 | { |
|---|
| 8462 | 9043 | int status; |
|---|
| 8463 | 9044 | unsigned *ptr; |
|---|
| .. | .. |
|---|
| 8488 | 9069 | * The caller must serialize access to this routine. |
|---|
| 8489 | 9070 | */ |
|---|
| 8490 | 9071 | int nfs4_proc_destroy_session(struct nfs4_session *session, |
|---|
| 8491 | | - struct rpc_cred *cred) |
|---|
| 9072 | + const struct cred *cred) |
|---|
| 8492 | 9073 | { |
|---|
| 8493 | 9074 | struct rpc_message msg = { |
|---|
| 8494 | 9075 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION], |
|---|
| .. | .. |
|---|
| 8503 | 9084 | if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state)) |
|---|
| 8504 | 9085 | return 0; |
|---|
| 8505 | 9086 | |
|---|
| 8506 | | - status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); |
|---|
| 9087 | + status = rpc_call_sync(session->clp->cl_rpcclient, &msg, |
|---|
| 9088 | + RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN); |
|---|
| 8507 | 9089 | trace_nfs4_destroy_session(session->clp, status); |
|---|
| 8508 | 9090 | |
|---|
| 8509 | 9091 | if (status) |
|---|
| .. | .. |
|---|
| 8590 | 9172 | }; |
|---|
| 8591 | 9173 | |
|---|
| 8592 | 9174 | static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, |
|---|
| 8593 | | - struct rpc_cred *cred, |
|---|
| 9175 | + const struct cred *cred, |
|---|
| 8594 | 9176 | struct nfs4_slot *slot, |
|---|
| 8595 | 9177 | bool is_privileged) |
|---|
| 8596 | 9178 | { |
|---|
| .. | .. |
|---|
| 8633 | 9215 | return ret; |
|---|
| 8634 | 9216 | } |
|---|
| 8635 | 9217 | |
|---|
| 8636 | | -static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) |
|---|
| 9218 | +static int nfs41_proc_async_sequence(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags) |
|---|
| 8637 | 9219 | { |
|---|
| 8638 | 9220 | struct rpc_task *task; |
|---|
| 8639 | 9221 | int ret = 0; |
|---|
| .. | .. |
|---|
| 8649 | 9231 | return ret; |
|---|
| 8650 | 9232 | } |
|---|
| 8651 | 9233 | |
|---|
| 8652 | | -static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred) |
|---|
| 9234 | +static int nfs4_proc_sequence(struct nfs_client *clp, const struct cred *cred) |
|---|
| 8653 | 9235 | { |
|---|
| 8654 | 9236 | struct rpc_task *task; |
|---|
| 8655 | 9237 | int ret; |
|---|
| .. | .. |
|---|
| 8689 | 9271 | switch(task->tk_status) { |
|---|
| 8690 | 9272 | case 0: |
|---|
| 8691 | 9273 | wake_up_all(&clp->cl_lock_waitq); |
|---|
| 8692 | | - /* Fallthrough */ |
|---|
| 9274 | + fallthrough; |
|---|
| 8693 | 9275 | case -NFS4ERR_COMPLETE_ALREADY: |
|---|
| 8694 | 9276 | case -NFS4ERR_WRONG_CRED: /* What to do here? */ |
|---|
| 8695 | 9277 | break; |
|---|
| 8696 | 9278 | case -NFS4ERR_DELAY: |
|---|
| 8697 | 9279 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
|---|
| 8698 | | - /* fall through */ |
|---|
| 9280 | + fallthrough; |
|---|
| 8699 | 9281 | case -NFS4ERR_RETRY_UNCACHED_REP: |
|---|
| 9282 | + case -EACCES: |
|---|
| 9283 | + dprintk("%s: failed to reclaim complete error %d for server %s, retrying\n", |
|---|
| 9284 | + __func__, task->tk_status, clp->cl_hostname); |
|---|
| 8700 | 9285 | return -EAGAIN; |
|---|
| 8701 | 9286 | case -NFS4ERR_BADSESSION: |
|---|
| 8702 | 9287 | case -NFS4ERR_DEADSESSION: |
|---|
| 8703 | 9288 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
|---|
| 8704 | | - nfs4_schedule_session_recovery(clp->cl_session, |
|---|
| 8705 | | - task->tk_status); |
|---|
| 8706 | 9289 | break; |
|---|
| 8707 | 9290 | default: |
|---|
| 8708 | 9291 | nfs4_schedule_lease_recovery(clp); |
|---|
| .. | .. |
|---|
| 8745 | 9328 | * Issue a global reclaim complete. |
|---|
| 8746 | 9329 | */ |
|---|
| 8747 | 9330 | static int nfs41_proc_reclaim_complete(struct nfs_client *clp, |
|---|
| 8748 | | - struct rpc_cred *cred) |
|---|
| 9331 | + const struct cred *cred) |
|---|
| 8749 | 9332 | { |
|---|
| 8750 | 9333 | struct nfs4_reclaim_complete_data *calldata; |
|---|
| 8751 | | - struct rpc_task *task; |
|---|
| 8752 | 9334 | struct rpc_message msg = { |
|---|
| 8753 | 9335 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RECLAIM_COMPLETE], |
|---|
| 8754 | 9336 | .rpc_cred = cred, |
|---|
| .. | .. |
|---|
| 8757 | 9339 | .rpc_client = clp->cl_rpcclient, |
|---|
| 8758 | 9340 | .rpc_message = &msg, |
|---|
| 8759 | 9341 | .callback_ops = &nfs4_reclaim_complete_call_ops, |
|---|
| 8760 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 9342 | + .flags = RPC_TASK_NO_ROUND_ROBIN, |
|---|
| 8761 | 9343 | }; |
|---|
| 8762 | 9344 | int status = -ENOMEM; |
|---|
| 8763 | 9345 | |
|---|
| .. | .. |
|---|
| 8772 | 9354 | msg.rpc_argp = &calldata->arg; |
|---|
| 8773 | 9355 | msg.rpc_resp = &calldata->res; |
|---|
| 8774 | 9356 | task_setup_data.callback_data = calldata; |
|---|
| 8775 | | - task = rpc_run_task(&task_setup_data); |
|---|
| 8776 | | - if (IS_ERR(task)) { |
|---|
| 8777 | | - status = PTR_ERR(task); |
|---|
| 8778 | | - goto out; |
|---|
| 8779 | | - } |
|---|
| 8780 | | - status = rpc_wait_for_completion_task(task); |
|---|
| 8781 | | - if (status == 0) |
|---|
| 8782 | | - status = task->tk_status; |
|---|
| 8783 | | - rpc_put_task(task); |
|---|
| 9357 | + status = nfs4_call_sync_custom(&task_setup_data); |
|---|
| 8784 | 9358 | out: |
|---|
| 8785 | 9359 | dprintk("<-- %s status=%d\n", __func__, status); |
|---|
| 8786 | 9360 | return status; |
|---|
| .. | .. |
|---|
| 8937 | 9511 | .rpc_message = &msg, |
|---|
| 8938 | 9512 | .callback_ops = &nfs4_layoutget_call_ops, |
|---|
| 8939 | 9513 | .callback_data = lgp, |
|---|
| 8940 | | - .flags = RPC_TASK_ASYNC, |
|---|
| 9514 | + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, |
|---|
| 8941 | 9515 | }; |
|---|
| 8942 | 9516 | struct pnfs_layout_segment *lseg = NULL; |
|---|
| 8943 | 9517 | struct nfs4_exception exception = { |
|---|
| .. | .. |
|---|
| 8954 | 9528 | nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0, 0); |
|---|
| 8955 | 9529 | |
|---|
| 8956 | 9530 | task = rpc_run_task(&task_setup_data); |
|---|
| 8957 | | - if (IS_ERR(task)) |
|---|
| 8958 | | - return ERR_CAST(task); |
|---|
| 9531 | + |
|---|
| 8959 | 9532 | status = rpc_wait_for_completion_task(task); |
|---|
| 8960 | 9533 | if (status != 0) |
|---|
| 8961 | 9534 | goto out; |
|---|
| 8962 | 9535 | |
|---|
| 8963 | | - /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */ |
|---|
| 8964 | | - if (task->tk_status < 0 || lgp->res.layoutp->len == 0) { |
|---|
| 9536 | + if (task->tk_status < 0) { |
|---|
| 8965 | 9537 | status = nfs4_layoutget_handle_exception(task, lgp, &exception); |
|---|
| 8966 | 9538 | *timeout = exception.timeout; |
|---|
| 9539 | + } else if (lgp->res.layoutp->len == 0) { |
|---|
| 9540 | + status = -EAGAIN; |
|---|
| 9541 | + *timeout = nfs4_update_delay(&exception.timeout); |
|---|
| 8967 | 9542 | } else |
|---|
| 8968 | 9543 | lseg = pnfs_layout_process(lgp); |
|---|
| 8969 | 9544 | out: |
|---|
| .. | .. |
|---|
| 9004 | 9579 | if (!nfs41_sequence_process(task, &lrp->res.seq_res)) |
|---|
| 9005 | 9580 | return; |
|---|
| 9006 | 9581 | |
|---|
| 9582 | + /* |
|---|
| 9583 | + * Was there an RPC level error? Assume the call succeeded, |
|---|
| 9584 | + * and that we need to release the layout |
|---|
| 9585 | + */ |
|---|
| 9586 | + if (task->tk_rpc_status != 0 && RPC_WAS_SENT(task)) { |
|---|
| 9587 | + lrp->res.lrs_present = 0; |
|---|
| 9588 | + return; |
|---|
| 9589 | + } |
|---|
| 9590 | + |
|---|
| 9007 | 9591 | server = NFS_SERVER(lrp->args.inode); |
|---|
| 9008 | 9592 | switch (task->tk_status) { |
|---|
| 9009 | 9593 | case -NFS4ERR_OLD_STATEID: |
|---|
| 9010 | | - if (nfs4_layoutreturn_refresh_stateid(&lrp->args.stateid, |
|---|
| 9594 | + if (nfs4_layout_refresh_old_stateid(&lrp->args.stateid, |
|---|
| 9011 | 9595 | &lrp->args.range, |
|---|
| 9012 | 9596 | lrp->args.inode)) |
|---|
| 9013 | 9597 | goto out_restart; |
|---|
| 9014 | | - /* Fallthrough */ |
|---|
| 9598 | + fallthrough; |
|---|
| 9015 | 9599 | default: |
|---|
| 9016 | 9600 | task->tk_status = 0; |
|---|
| 9017 | | - /* Fallthrough */ |
|---|
| 9601 | + fallthrough; |
|---|
| 9018 | 9602 | case 0: |
|---|
| 9019 | 9603 | break; |
|---|
| 9020 | 9604 | case -NFS4ERR_DELAY: |
|---|
| .. | .. |
|---|
| 9043 | 9627 | lrp->ld_private.ops->free(&lrp->ld_private); |
|---|
| 9044 | 9628 | pnfs_put_layout_hdr(lrp->args.layout); |
|---|
| 9045 | 9629 | nfs_iput_and_deactive(lrp->inode); |
|---|
| 9630 | + put_cred(lrp->cred); |
|---|
| 9046 | 9631 | kfree(calldata); |
|---|
| 9047 | 9632 | dprintk("<-- %s\n", __func__); |
|---|
| 9048 | 9633 | } |
|---|
| .. | .. |
|---|
| 9103 | 9688 | static int |
|---|
| 9104 | 9689 | _nfs4_proc_getdeviceinfo(struct nfs_server *server, |
|---|
| 9105 | 9690 | struct pnfs_device *pdev, |
|---|
| 9106 | | - struct rpc_cred *cred) |
|---|
| 9691 | + const struct cred *cred) |
|---|
| 9107 | 9692 | { |
|---|
| 9108 | 9693 | struct nfs4_getdeviceinfo_args args = { |
|---|
| 9109 | 9694 | .pdev = pdev, |
|---|
| .. | .. |
|---|
| 9135 | 9720 | |
|---|
| 9136 | 9721 | int nfs4_proc_getdeviceinfo(struct nfs_server *server, |
|---|
| 9137 | 9722 | struct pnfs_device *pdev, |
|---|
| 9138 | | - struct rpc_cred *cred) |
|---|
| 9723 | + const struct cred *cred) |
|---|
| 9139 | 9724 | { |
|---|
| 9140 | 9725 | struct nfs4_exception exception = { }; |
|---|
| 9141 | 9726 | int err; |
|---|
| .. | .. |
|---|
| 9192 | 9777 | pnfs_cleanup_layoutcommit(data); |
|---|
| 9193 | 9778 | nfs_post_op_update_inode_force_wcc(data->args.inode, |
|---|
| 9194 | 9779 | data->res.fattr); |
|---|
| 9195 | | - put_rpccred(data->cred); |
|---|
| 9780 | + put_cred(data->cred); |
|---|
| 9196 | 9781 | nfs_iput_and_deactive(data->inode); |
|---|
| 9197 | 9782 | kfree(data); |
|---|
| 9198 | 9783 | } |
|---|
| .. | .. |
|---|
| 9247 | 9832 | return status; |
|---|
| 9248 | 9833 | } |
|---|
| 9249 | 9834 | |
|---|
| 9250 | | -/** |
|---|
| 9835 | +/* |
|---|
| 9251 | 9836 | * Use the state managment nfs_client cl_rpcclient, which uses krb5i (if |
|---|
| 9252 | 9837 | * possible) as per RFC3530bis and RFC5661 Security Considerations sections |
|---|
| 9253 | 9838 | */ |
|---|
| .. | .. |
|---|
| 9267 | 9852 | .rpc_argp = &args, |
|---|
| 9268 | 9853 | .rpc_resp = &res, |
|---|
| 9269 | 9854 | }; |
|---|
| 9270 | | - struct rpc_clnt *clnt = server->client; |
|---|
| 9271 | | - struct rpc_cred *cred = NULL; |
|---|
| 9855 | + struct nfs4_call_sync_data data = { |
|---|
| 9856 | + .seq_server = server, |
|---|
| 9857 | + .seq_args = &args.seq_args, |
|---|
| 9858 | + .seq_res = &res.seq_res, |
|---|
| 9859 | + }; |
|---|
| 9860 | + struct rpc_task_setup task_setup = { |
|---|
| 9861 | + .rpc_client = server->client, |
|---|
| 9862 | + .rpc_message = &msg, |
|---|
| 9863 | + .callback_ops = server->nfs_client->cl_mvops->call_sync_ops, |
|---|
| 9864 | + .callback_data = &data, |
|---|
| 9865 | + .flags = RPC_TASK_NO_ROUND_ROBIN, |
|---|
| 9866 | + }; |
|---|
| 9867 | + const struct cred *cred = NULL; |
|---|
| 9272 | 9868 | int status; |
|---|
| 9273 | 9869 | |
|---|
| 9274 | 9870 | if (use_integrity) { |
|---|
| 9275 | | - clnt = server->nfs_client->cl_rpcclient; |
|---|
| 9871 | + task_setup.rpc_client = server->nfs_client->cl_rpcclient; |
|---|
| 9872 | + |
|---|
| 9276 | 9873 | cred = nfs4_get_clid_cred(server->nfs_client); |
|---|
| 9277 | 9874 | msg.rpc_cred = cred; |
|---|
| 9278 | 9875 | } |
|---|
| 9279 | 9876 | |
|---|
| 9280 | 9877 | dprintk("--> %s\n", __func__); |
|---|
| 9281 | | - status = nfs4_call_sync(clnt, server, &msg, &args.seq_args, |
|---|
| 9282 | | - &res.seq_res, 0); |
|---|
| 9878 | + nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0); |
|---|
| 9879 | + status = nfs4_call_sync_custom(&task_setup); |
|---|
| 9283 | 9880 | dprintk("<-- %s status=%d\n", __func__, status); |
|---|
| 9284 | 9881 | |
|---|
| 9285 | | - if (cred) |
|---|
| 9286 | | - put_rpccred(cred); |
|---|
| 9882 | + put_cred(cred); |
|---|
| 9287 | 9883 | |
|---|
| 9288 | 9884 | return status; |
|---|
| 9289 | 9885 | } |
|---|
| .. | .. |
|---|
| 9292 | 9888 | nfs41_proc_secinfo_no_name(struct nfs_server *server, struct nfs_fh *fhandle, |
|---|
| 9293 | 9889 | struct nfs_fsinfo *info, struct nfs4_secinfo_flavors *flavors) |
|---|
| 9294 | 9890 | { |
|---|
| 9295 | | - struct nfs4_exception exception = { }; |
|---|
| 9891 | + struct nfs4_exception exception = { |
|---|
| 9892 | + .interruptible = true, |
|---|
| 9893 | + }; |
|---|
| 9296 | 9894 | int err; |
|---|
| 9297 | 9895 | do { |
|---|
| 9298 | 9896 | /* first try using integrity protection */ |
|---|
| .. | .. |
|---|
| 9396 | 9994 | |
|---|
| 9397 | 9995 | static int _nfs41_test_stateid(struct nfs_server *server, |
|---|
| 9398 | 9996 | nfs4_stateid *stateid, |
|---|
| 9399 | | - struct rpc_cred *cred) |
|---|
| 9997 | + const struct cred *cred) |
|---|
| 9400 | 9998 | { |
|---|
| 9401 | 9999 | int status; |
|---|
| 9402 | 10000 | struct nfs41_test_stateid_args args = { |
|---|
| .. | .. |
|---|
| 9457 | 10055 | */ |
|---|
| 9458 | 10056 | static int nfs41_test_stateid(struct nfs_server *server, |
|---|
| 9459 | 10057 | nfs4_stateid *stateid, |
|---|
| 9460 | | - struct rpc_cred *cred) |
|---|
| 10058 | + const struct cred *cred) |
|---|
| 9461 | 10059 | { |
|---|
| 9462 | | - struct nfs4_exception exception = { }; |
|---|
| 10060 | + struct nfs4_exception exception = { |
|---|
| 10061 | + .interruptible = true, |
|---|
| 10062 | + }; |
|---|
| 9463 | 10063 | int err; |
|---|
| 9464 | 10064 | do { |
|---|
| 9465 | 10065 | err = _nfs41_test_stateid(server, stateid, cred); |
|---|
| .. | .. |
|---|
| 9513 | 10113 | * @server: server / transport on which to perform the operation |
|---|
| 9514 | 10114 | * @stateid: state ID to release |
|---|
| 9515 | 10115 | * @cred: credential |
|---|
| 9516 | | - * @is_recovery: set to true if this call needs to be privileged |
|---|
| 10116 | + * @privileged: set to true if this call needs to be privileged |
|---|
| 9517 | 10117 | * |
|---|
| 9518 | 10118 | * Note: this function is always asynchronous. |
|---|
| 9519 | 10119 | */ |
|---|
| 9520 | 10120 | static int nfs41_free_stateid(struct nfs_server *server, |
|---|
| 9521 | 10121 | const nfs4_stateid *stateid, |
|---|
| 9522 | | - struct rpc_cred *cred, |
|---|
| 10122 | + const struct cred *cred, |
|---|
| 9523 | 10123 | bool privileged) |
|---|
| 9524 | 10124 | { |
|---|
| 9525 | 10125 | struct rpc_message msg = { |
|---|
| .. | .. |
|---|
| 9560 | 10160 | static void |
|---|
| 9561 | 10161 | nfs41_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp) |
|---|
| 9562 | 10162 | { |
|---|
| 9563 | | - struct rpc_cred *cred = lsp->ls_state->owner->so_cred; |
|---|
| 10163 | + const struct cred *cred = lsp->ls_state->owner->so_cred; |
|---|
| 9564 | 10164 | |
|---|
| 9565 | 10165 | nfs41_free_stateid(server, &lsp->ls_stateid, cred, false); |
|---|
| 9566 | 10166 | nfs4_free_lock_state(server, lsp); |
|---|
| .. | .. |
|---|
| 9631 | 10231 | |
|---|
| 9632 | 10232 | static const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = { |
|---|
| 9633 | 10233 | .sched_state_renewal = nfs4_proc_async_renew, |
|---|
| 9634 | | - .get_state_renewal_cred_locked = nfs4_get_renew_cred_locked, |
|---|
| 10234 | + .get_state_renewal_cred = nfs4_get_renew_cred, |
|---|
| 9635 | 10235 | .renew_lease = nfs4_proc_renew, |
|---|
| 9636 | 10236 | }; |
|---|
| 9637 | 10237 | |
|---|
| 9638 | 10238 | #if defined(CONFIG_NFS_V4_1) |
|---|
| 9639 | 10239 | static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = { |
|---|
| 9640 | 10240 | .sched_state_renewal = nfs41_proc_async_sequence, |
|---|
| 9641 | | - .get_state_renewal_cred_locked = nfs4_get_machine_cred_locked, |
|---|
| 10241 | + .get_state_renewal_cred = nfs4_get_machine_cred, |
|---|
| 9642 | 10242 | .renew_lease = nfs4_proc_sequence, |
|---|
| 9643 | 10243 | }; |
|---|
| 9644 | 10244 | #endif |
|---|
| .. | .. |
|---|
| 9717 | 10317 | | NFS_CAP_ALLOCATE |
|---|
| 9718 | 10318 | | NFS_CAP_COPY |
|---|
| 9719 | 10319 | | NFS_CAP_OFFLOAD_CANCEL |
|---|
| 10320 | + | NFS_CAP_COPY_NOTIFY |
|---|
| 9720 | 10321 | | NFS_CAP_DEALLOCATE |
|---|
| 9721 | 10322 | | NFS_CAP_SEEK |
|---|
| 9722 | 10323 | | NFS_CAP_LAYOUTSTATS |
|---|
| 9723 | | - | NFS_CAP_CLONE, |
|---|
| 10324 | + | NFS_CAP_CLONE |
|---|
| 10325 | + | NFS_CAP_LAYOUTERROR |
|---|
| 10326 | + | NFS_CAP_READ_PLUS, |
|---|
| 9724 | 10327 | .init_client = nfs41_init_client, |
|---|
| 9725 | 10328 | .shutdown_client = nfs41_shutdown_client, |
|---|
| 9726 | 10329 | .match_stateid = nfs41_match_stateid, |
|---|
| .. | .. |
|---|
| 9749 | 10352 | |
|---|
| 9750 | 10353 | static ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size) |
|---|
| 9751 | 10354 | { |
|---|
| 9752 | | - ssize_t error, error2; |
|---|
| 10355 | + ssize_t error, error2, error3; |
|---|
| 9753 | 10356 | |
|---|
| 9754 | 10357 | error = generic_listxattr(dentry, list, size); |
|---|
| 9755 | 10358 | if (error < 0) |
|---|
| .. | .. |
|---|
| 9762 | 10365 | error2 = nfs4_listxattr_nfs4_label(d_inode(dentry), list, size); |
|---|
| 9763 | 10366 | if (error2 < 0) |
|---|
| 9764 | 10367 | return error2; |
|---|
| 9765 | | - return error + error2; |
|---|
| 10368 | + |
|---|
| 10369 | + if (list) { |
|---|
| 10370 | + list += error2; |
|---|
| 10371 | + size -= error2; |
|---|
| 10372 | + } |
|---|
| 10373 | + |
|---|
| 10374 | + error3 = nfs4_listxattr_nfs4_user(d_inode(dentry), list, size); |
|---|
| 10375 | + if (error3 < 0) |
|---|
| 10376 | + return error3; |
|---|
| 10377 | + |
|---|
| 10378 | + return error + error2 + error3; |
|---|
| 9766 | 10379 | } |
|---|
| 9767 | 10380 | |
|---|
| 9768 | 10381 | static const struct inode_operations nfs4_dir_inode_operations = { |
|---|
| .. | .. |
|---|
| 9797 | 10410 | .file_ops = &nfs4_file_operations, |
|---|
| 9798 | 10411 | .getroot = nfs4_proc_get_root, |
|---|
| 9799 | 10412 | .submount = nfs4_submount, |
|---|
| 9800 | | - .try_mount = nfs4_try_mount, |
|---|
| 10413 | + .try_get_tree = nfs4_try_get_tree, |
|---|
| 9801 | 10414 | .getattr = nfs4_proc_getattr, |
|---|
| 9802 | 10415 | .setattr = nfs4_proc_setattr, |
|---|
| 9803 | 10416 | .lookup = nfs4_proc_lookup, |
|---|
| .. | .. |
|---|
| 9850 | 10463 | .set = nfs4_xattr_set_nfs4_acl, |
|---|
| 9851 | 10464 | }; |
|---|
| 9852 | 10465 | |
|---|
| 10466 | +#ifdef CONFIG_NFS_V4_2 |
|---|
| 10467 | +static const struct xattr_handler nfs4_xattr_nfs4_user_handler = { |
|---|
| 10468 | + .prefix = XATTR_USER_PREFIX, |
|---|
| 10469 | + .get = nfs4_xattr_get_nfs4_user, |
|---|
| 10470 | + .set = nfs4_xattr_set_nfs4_user, |
|---|
| 10471 | +}; |
|---|
| 10472 | +#endif |
|---|
| 10473 | + |
|---|
| 9853 | 10474 | const struct xattr_handler *nfs4_xattr_handlers[] = { |
|---|
| 9854 | 10475 | &nfs4_xattr_nfs4_acl_handler, |
|---|
| 9855 | 10476 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
|---|
| 9856 | 10477 | &nfs4_xattr_nfs4_label_handler, |
|---|
| 9857 | 10478 | #endif |
|---|
| 10479 | +#ifdef CONFIG_NFS_V4_2 |
|---|
| 10480 | + &nfs4_xattr_nfs4_user_handler, |
|---|
| 10481 | +#endif |
|---|
| 9858 | 10482 | NULL |
|---|
| 9859 | 10483 | }; |
|---|
| 9860 | 10484 | |
|---|