Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-4.2' of git://linux-nfs.org/~bfields/linux

Pull nfsd updates from Bruce Fields:
"A relatively quiet cycle, with a mix of cleanup and smaller bugfixes"

* 'for-4.2' of git://linux-nfs.org/~bfields/linux: (24 commits)
sunrpc: use sg_init_one() in krb5_rc4_setup_enc/seq_key()
nfsd: wrap too long lines in nfsd4_encode_read
nfsd: fput rd_file from XDR encode context
nfsd: take struct file setup fully into nfs4_preprocess_stateid_op
nfsd: refactor nfs4_preprocess_stateid_op
nfsd: clean up raparams handling
nfsd: use swap() in sort_pacl_range()
rpcrdma: Merge svcrdma and xprtrdma modules into one
svcrdma: Add a separate "max data segs macro for svcrdma
svcrdma: Replace GFP_KERNEL in a loop with GFP_NOFAIL
svcrdma: Keep rpcrdma_msg fields in network byte-order
svcrdma: Fix byte-swapping in svc_rdma_sendto.c
nfsd: Update callback sequnce id only CB_SEQUENCE success
nfsd: Reset cb_status in nfsd4_cb_prepare() at retrying
svcrdma: Remove svc_rdma_xdr_decode_deferred_req()
SUNRPC: Move EXPORT_SYMBOL for svc_process
uapi/nfs: Add NFSv4.1 ACL definitions
nfsd: Remove dead declarations
nfsd: work around a gcc-5.1 warning
nfsd: Checking for acl support does not require fetching any acls
...

+410 -495
+4 -40
Documentation/filesystems/nfs/knfsd-stats.txt
··· 68 68 rate of change for this counter is zero; significantly non-zero 69 69 values may indicate a performance limitation. 70 70 71 - This can happen either because there are too few nfsd threads in the 72 - thread pool for the NFS workload (the workload is thread-limited), 73 - or because the NFS workload needs more CPU time than is available in 74 - the thread pool (the workload is CPU-limited). In the former case, 75 - configuring more nfsd threads will probably improve the performance 76 - of the NFS workload. In the latter case, the sunrpc server layer is 77 - already choosing not to wake idle nfsd threads because there are too 78 - many nfsd threads which want to run but cannot, so configuring more 79 - nfsd threads will make no difference whatsoever. The overloads-avoided 80 - statistic (see below) can be used to distinguish these cases. 71 + This can happen because there are too few nfsd threads in the thread 72 + pool for the NFS workload (the workload is thread-limited), in which 73 + case configuring more nfsd threads will probably improve the 74 + performance of the NFS workload. 81 75 82 76 threads-woken 83 77 Counts how many times an idle nfsd thread is woken to try to ··· 81 87 network-facing NFS work is being handled quickly, which is a good 82 88 thing. The ideal rate of change for this counter will be close 83 89 to but less than the rate of change of the packets-arrived counter. 84 - 85 - overloads-avoided 86 - Counts how many times the sunrpc server layer chose not to wake an 87 - nfsd thread, despite the presence of idle nfsd threads, because 88 - too many nfsd threads had been recently woken but could not get 89 - enough CPU time to actually run. 90 - 91 - This statistic counts a circumstance where the sunrpc layer 92 - heuristically avoids overloading the CPU scheduler with too many 93 - runnable nfsd threads. The ideal rate of change for this counter 94 - is zero. Significant non-zero values indicate that the workload 95 - is CPU limited. Usually this is associated with heavy CPU usage 96 - on all the CPUs in the nfsd thread pool. 97 - 98 - If a sustained large overloads-avoided rate is detected on a pool, 99 - the top(1) utility should be used to check for the following 100 - pattern of CPU usage on all the CPUs associated with the given 101 - nfsd thread pool. 102 - 103 - - %us ~= 0 (as you're *NOT* running applications on your NFS server) 104 - 105 - - %wa ~= 0 106 - 107 - - %id ~= 0 108 - 109 - - %sy + %hi + %si ~= 100 110 - 111 - If this pattern is seen, configuring more nfsd threads will *not* 112 - improve the performance of the workload. If this patten is not 113 - seen, then something more subtle is wrong. 114 90 115 91 threads-timedout 116 92 Counts how many times an nfsd thread triggered an idle timeout,
+7 -5
fs/nfsd/nfs3xdr.c
··· 805 805 806 806 static __be32 807 807 compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, 808 - const char *name, int namlen) 808 + const char *name, int namlen, u64 ino) 809 809 { 810 810 struct svc_export *exp; 811 811 struct dentry *dparent, *dchild; ··· 830 830 goto out; 831 831 if (d_really_is_negative(dchild)) 832 832 goto out; 833 + if (dchild->d_inode->i_ino != ino) 834 + goto out; 833 835 rv = fh_compose(fhp, exp, dchild, &cd->fh); 834 836 out: 835 837 dput(dchild); 836 838 return rv; 837 839 } 838 840 839 - static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen) 841 + static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen, u64 ino) 840 842 { 841 843 struct svc_fh *fh = &cd->scratch; 842 844 __be32 err; 843 845 844 846 fh_init(fh, NFS3_FHSIZE); 845 - err = compose_entry_fh(cd, fh, name, namlen); 847 + err = compose_entry_fh(cd, fh, name, namlen, ino); 846 848 if (err) { 847 849 *p++ = 0; 848 850 *p++ = 0; ··· 929 927 p = encode_entry_baggage(cd, p, name, namlen, ino); 930 928 931 929 if (plus) 932 - p = encode_entryplus_baggage(cd, p, name, namlen); 930 + p = encode_entryplus_baggage(cd, p, name, namlen, ino); 933 931 num_entry_words = p - cd->buffer; 934 932 } else if (*(page+1) != NULL) { 935 933 /* temporarily encode entry into next page, then move back to ··· 943 941 p1 = encode_entry_baggage(cd, p1, name, namlen, ino); 944 942 945 943 if (plus) 946 - p1 = encode_entryplus_baggage(cd, p1, name, namlen); 944 + p1 = encode_entryplus_baggage(cd, p1, name, namlen, ino); 947 945 948 946 /* determine entry word length and lengths to go in pages */ 949 947 num_entry_words = p1 - tmp;
+2 -16
fs/nfsd/nfs4acl.c
··· 52 52 #define NFS4_ANYONE_MODE (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL | NFS4_ACE_SYNCHRONIZE) 53 53 #define NFS4_OWNER_MODE (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL) 54 54 55 - /* We don't support these bits; insist they be neither allowed nor denied */ 56 - #define NFS4_MASK_UNSUPP (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER \ 57 - | NFS4_ACE_READ_NAMED_ATTRS | NFS4_ACE_WRITE_NAMED_ATTRS) 58 - 59 55 /* flags used to simulate posix default ACLs */ 60 56 #define NFS4_INHERITANCE_FLAGS (NFS4_ACE_FILE_INHERIT_ACE \ 61 57 | NFS4_ACE_DIRECTORY_INHERIT_ACE) ··· 59 63 #define NFS4_SUPPORTED_FLAGS (NFS4_INHERITANCE_FLAGS \ 60 64 | NFS4_ACE_INHERIT_ONLY_ACE \ 61 65 | NFS4_ACE_IDENTIFIER_GROUP) 62 - 63 - #define MASK_EQUAL(mask1, mask2) \ 64 - ( ((mask1) & NFS4_ACE_MASK_ALL) == ((mask2) & NFS4_ACE_MASK_ALL) ) 65 66 66 67 static u32 67 68 mask_from_posix(unsigned short perm, unsigned int flags) ··· 118 125 if ((perm & NFS4_EXECUTE_MODE) == NFS4_EXECUTE_MODE) 119 126 *mode |= ACL_EXECUTE; 120 127 } 121 - 122 - struct ace_container { 123 - struct nfs4_ace *ace; 124 - struct list_head ace_l; 125 - }; 126 128 127 129 static short ace2type(struct nfs4_ace *); 128 130 static void _posix_to_nfsv4_one(struct posix_acl *, struct nfs4_acl *, ··· 372 384 static void 373 385 sort_pacl_range(struct posix_acl *pacl, int start, int end) { 374 386 int sorted = 0, i; 375 - struct posix_acl_entry tmp; 376 387 377 388 /* We just do a bubble sort; easy to do in place, and we're not 378 389 * expecting acl's to be long enough to justify anything more. */ ··· 381 394 if (pace_gt(&pacl->a_entries[i], 382 395 &pacl->a_entries[i+1])) { 383 396 sorted = 0; 384 - tmp = pacl->a_entries[i]; 385 - pacl->a_entries[i] = pacl->a_entries[i+1]; 386 - pacl->a_entries[i+1] = tmp; 397 + swap(pacl->a_entries[i], 398 + pacl->a_entries[i + 1]); 387 399 } 388 400 } 389 401 }
+13 -2
fs/nfsd/nfs4callback.c
··· 455 455 if (unlikely(status || cb->cb_status)) 456 456 return status; 457 457 458 + cb->cb_update_seq_nr = true; 458 459 return decode_cb_sequence4resok(xdr, cb); 459 460 } 460 461 ··· 876 875 u32 minorversion = clp->cl_minorversion; 877 876 878 877 cb->cb_minorversion = minorversion; 878 + cb->cb_update_seq_nr = false; 879 + cb->cb_status = 0; 879 880 if (minorversion) { 880 881 if (!nfsd41_cb_get_slot(clp, task)) 881 882 return; ··· 894 891 clp->cl_minorversion); 895 892 896 893 if (clp->cl_minorversion) { 897 - /* No need for lock, access serialized in nfsd4_cb_prepare */ 898 - if (!task->tk_status) 894 + /* 895 + * No need for lock, access serialized in nfsd4_cb_prepare 896 + * 897 + * RFC5661 20.9.3 898 + * If CB_SEQUENCE returns an error, then the state of the slot 899 + * (sequence ID, cached reply) MUST NOT change. 900 + */ 901 + if (cb->cb_update_seq_nr) 899 902 ++clp->cl_cb_session->se_cb_seq_nr; 903 + 900 904 clear_bit(0, &clp->cl_cb_slot_busy); 901 905 rpc_wake_up_next(&clp->cl_cb_waitq); 902 906 dprintk("%s: freed slot, new seqid=%d\n", __func__, ··· 1100 1090 cb->cb_ops = ops; 1101 1091 INIT_WORK(&cb->cb_work, nfsd4_run_cb_work); 1102 1092 cb->cb_status = 0; 1093 + cb->cb_update_seq_nr = false; 1103 1094 cb->cb_need_restart = false; 1104 1095 } 1105 1096
+15 -28
fs/nfsd/nfs4proc.c
··· 760 760 { 761 761 __be32 status; 762 762 763 - /* no need to check permission - this will be done in nfsd_read() */ 764 - 765 763 read->rd_filp = NULL; 766 764 if (read->rd_offset >= OFFSET_MAX) 767 765 return nfserr_inval; ··· 776 778 clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags); 777 779 778 780 /* check stateid */ 779 - if ((status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), 780 - cstate, &read->rd_stateid, 781 - RD_STATE, &read->rd_filp))) { 781 + status = nfs4_preprocess_stateid_op(rqstp, cstate, &read->rd_stateid, 782 + RD_STATE, &read->rd_filp, &read->rd_tmp_file); 783 + if (status) { 782 784 dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); 783 785 goto out; 784 786 } ··· 922 924 int err; 923 925 924 926 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { 925 - status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), cstate, 926 - &setattr->sa_stateid, WR_STATE, NULL); 927 + status = nfs4_preprocess_stateid_op(rqstp, cstate, 928 + &setattr->sa_stateid, WR_STATE, NULL, NULL); 927 929 if (status) { 928 930 dprintk("NFSD: nfsd4_setattr: couldn't process stateid!\n"); 929 931 return status; ··· 984 986 unsigned long cnt; 985 987 int nvecs; 986 988 987 - /* no need to check permission - this will be done in nfsd_write() */ 988 - 989 989 if (write->wr_offset >= OFFSET_MAX) 990 990 return nfserr_inval; 991 991 992 - status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), 993 - cstate, stateid, WR_STATE, &filp); 992 + status = nfs4_preprocess_stateid_op(rqstp, cstate, stateid, WR_STATE, 993 + &filp, NULL); 994 994 if (status) { 995 995 dprintk("NFSD: nfsd4_write: couldn't process stateid!\n"); 996 996 return status; ··· 1001 1005 nvecs = fill_in_write_vector(rqstp->rq_vec, write); 1002 1006 WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); 1003 1007 1004 - status = nfsd_write(rqstp, &cstate->current_fh, filp, 1005 - write->wr_offset, rqstp->rq_vec, nvecs, 1006 - &cnt, &write->wr_how_written); 1007 - if (filp) 1008 - fput(filp); 1008 + status = nfsd_vfs_write(rqstp, &cstate->current_fh, filp, 1009 + write->wr_offset, rqstp->rq_vec, nvecs, &cnt, 1010 + &write->wr_how_written); 1011 + fput(filp); 1009 1012 1010 1013 write->wr_bytes_written = cnt; 1011 1014 ··· 1018 1023 __be32 status = nfserr_notsupp; 1019 1024 struct file *file; 1020 1025 1021 - status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), cstate, 1026 + status = nfs4_preprocess_stateid_op(rqstp, cstate, 1022 1027 &fallocate->falloc_stateid, 1023 - WR_STATE, &file); 1028 + WR_STATE, &file, NULL); 1024 1029 if (status != nfs_ok) { 1025 1030 dprintk("NFSD: nfsd4_fallocate: couldn't process stateid!\n"); 1026 1031 return status; 1027 1032 } 1028 - if (!file) 1029 - return nfserr_bad_stateid; 1030 1033 1031 1034 status = nfsd4_vfs_fallocate(rqstp, &cstate->current_fh, file, 1032 1035 fallocate->falloc_offset, ··· 1057 1064 __be32 status; 1058 1065 struct file *file; 1059 1066 1060 - status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), cstate, 1067 + status = nfs4_preprocess_stateid_op(rqstp, cstate, 1061 1068 &seek->seek_stateid, 1062 - RD_STATE, &file); 1069 + RD_STATE, &file, NULL); 1063 1070 if (status) { 1064 1071 dprintk("NFSD: nfsd4_seek: couldn't process stateid!\n"); 1065 1072 return status; 1066 1073 } 1067 - if (!file) 1068 - return nfserr_bad_stateid; 1069 1074 1070 1075 switch (seek->seek_whence) { 1071 1076 case NFS4_CONTENT_DATA: ··· 1723 1732 be32_to_cpu(status)); 1724 1733 1725 1734 nfsd4_cstate_clear_replay(cstate); 1726 - /* XXX Ugh, we need to get rid of this kind of special case: */ 1727 - if (op->opnum == OP_READ && op->u.read.rd_filp) 1728 - fput(op->u.read.rd_filp); 1729 - 1730 1735 nfsd4_increment_op_stats(op->opnum); 1731 1736 } 1732 1737
+98 -54
fs/nfsd/nfs4state.c
··· 3861 3861 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open) 3862 3862 { 3863 3863 __be32 status; 3864 - unsigned char old_deny_bmap; 3864 + unsigned char old_deny_bmap = stp->st_deny_bmap; 3865 3865 3866 3866 if (!test_access(open->op_share_access, stp)) 3867 3867 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); ··· 3870 3870 spin_lock(&fp->fi_lock); 3871 3871 status = nfs4_file_check_deny(fp, open->op_share_deny); 3872 3872 if (status == nfs_ok) { 3873 - old_deny_bmap = stp->st_deny_bmap; 3874 3873 set_deny(open->op_share_deny, stp); 3875 3874 fp->fi_share_deny |= 3876 3875 (open->op_share_deny & NFS4_SHARE_DENY_BOTH); ··· 4573 4574 return nfs_ok; 4574 4575 } 4575 4576 4576 - /* 4577 - * Checks for stateid operations 4578 - */ 4579 - __be32 4580 - nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, 4581 - stateid_t *stateid, int flags, struct file **filpp) 4577 + static struct file * 4578 + nfs4_find_file(struct nfs4_stid *s, int flags) 4582 4579 { 4583 - struct nfs4_stid *s; 4584 - struct nfs4_ol_stateid *stp = NULL; 4585 - struct nfs4_delegation *dp = NULL; 4586 - struct svc_fh *current_fh = &cstate->current_fh; 4587 - struct inode *ino = d_inode(current_fh->fh_dentry); 4580 + if (!s) 4581 + return NULL; 4582 + 4583 + switch (s->sc_type) { 4584 + case NFS4_DELEG_STID: 4585 + if (WARN_ON_ONCE(!s->sc_file->fi_deleg_file)) 4586 + return NULL; 4587 + return get_file(s->sc_file->fi_deleg_file); 4588 + case NFS4_OPEN_STID: 4589 + case NFS4_LOCK_STID: 4590 + if (flags & RD_STATE) 4591 + return find_readable_file(s->sc_file); 4592 + else 4593 + return find_writeable_file(s->sc_file); 4594 + break; 4595 + } 4596 + 4597 + return NULL; 4598 + } 4599 + 4600 + static __be32 4601 + nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags) 4602 + { 4603 + __be32 status; 4604 + 4605 + status = nfs4_check_fh(fhp, ols); 4606 + if (status) 4607 + return status; 4608 + status = nfsd4_check_openowner_confirmed(ols); 4609 + if (status) 4610 + return status; 4611 + return nfs4_check_openmode(ols, flags); 4612 + } 4613 + 4614 + static __be32 4615 + nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s, 4616 + struct file **filpp, bool *tmp_file, int flags) 4617 + { 4618 + int acc = (flags & RD_STATE) ? NFSD_MAY_READ : NFSD_MAY_WRITE; 4619 + struct file *file; 4620 + __be32 status; 4621 + 4622 + file = nfs4_find_file(s, flags); 4623 + if (file) { 4624 + status = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, 4625 + acc | NFSD_MAY_OWNER_OVERRIDE); 4626 + if (status) { 4627 + fput(file); 4628 + return status; 4629 + } 4630 + 4631 + *filpp = file; 4632 + } else { 4633 + status = nfsd_open(rqstp, fhp, S_IFREG, acc, filpp); 4634 + if (status) 4635 + return status; 4636 + 4637 + if (tmp_file) 4638 + *tmp_file = true; 4639 + } 4640 + 4641 + return 0; 4642 + } 4643 + 4644 + /* 4645 + * Checks for stateid operations 4646 + */ 4647 + __be32 4648 + nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, 4649 + struct nfsd4_compound_state *cstate, stateid_t *stateid, 4650 + int flags, struct file **filpp, bool *tmp_file) 4651 + { 4652 + struct svc_fh *fhp = &cstate->current_fh; 4653 + struct inode *ino = d_inode(fhp->fh_dentry); 4654 + struct net *net = SVC_NET(rqstp); 4588 4655 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 4589 - struct file *file = NULL; 4656 + struct nfs4_stid *s = NULL; 4590 4657 __be32 status; 4591 4658 4592 4659 if (filpp) 4593 4660 *filpp = NULL; 4661 + if (tmp_file) 4662 + *tmp_file = false; 4594 4663 4595 4664 if (grace_disallows_io(net, ino)) 4596 4665 return nfserr_grace; 4597 4666 4598 - if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) 4599 - return check_special_stateids(net, current_fh, stateid, flags); 4667 + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) { 4668 + status = check_special_stateids(net, fhp, stateid, flags); 4669 + goto done; 4670 + } 4600 4671 4601 4672 status = nfsd4_lookup_stateid(cstate, stateid, 4602 4673 NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, 4603 4674 &s, nn); 4604 4675 if (status) 4605 4676 return status; 4606 - status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate)); 4677 + status = check_stateid_generation(stateid, &s->sc_stateid, 4678 + nfsd4_has_session(cstate)); 4607 4679 if (status) 4608 4680 goto out; 4681 + 4609 4682 switch (s->sc_type) { 4610 4683 case NFS4_DELEG_STID: 4611 - dp = delegstateid(s); 4612 - status = nfs4_check_delegmode(dp, flags); 4613 - if (status) 4614 - goto out; 4615 - if (filpp) { 4616 - file = dp->dl_stid.sc_file->fi_deleg_file; 4617 - if (!file) { 4618 - WARN_ON_ONCE(1); 4619 - status = nfserr_serverfault; 4620 - goto out; 4621 - } 4622 - get_file(file); 4623 - } 4684 + status = nfs4_check_delegmode(delegstateid(s), flags); 4624 4685 break; 4625 4686 case NFS4_OPEN_STID: 4626 4687 case NFS4_LOCK_STID: 4627 - stp = openlockstateid(s); 4628 - status = nfs4_check_fh(current_fh, stp); 4629 - if (status) 4630 - goto out; 4631 - status = nfsd4_check_openowner_confirmed(stp); 4632 - if (status) 4633 - goto out; 4634 - status = nfs4_check_openmode(stp, flags); 4635 - if (status) 4636 - goto out; 4637 - if (filpp) { 4638 - struct nfs4_file *fp = stp->st_stid.sc_file; 4639 - 4640 - if (flags & RD_STATE) 4641 - file = find_readable_file(fp); 4642 - else 4643 - file = find_writeable_file(fp); 4644 - } 4688 + status = nfs4_check_olstateid(fhp, openlockstateid(s), flags); 4645 4689 break; 4646 4690 default: 4647 4691 status = nfserr_bad_stateid; 4648 - goto out; 4692 + break; 4649 4693 } 4650 - status = nfs_ok; 4651 - if (file) 4652 - *filpp = file; 4694 + 4695 + done: 4696 + if (!status && filpp) 4697 + status = nfs4_check_file(rqstp, fhp, s, filpp, tmp_file, flags); 4653 4698 out: 4654 - nfs4_put_stid(s); 4699 + if (s) 4700 + nfs4_put_stid(s); 4655 4701 return status; 4656 4702 } 4657 4703 ··· 5549 5505 __be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file); 5550 5506 if (!err) { 5551 5507 err = nfserrno(vfs_test_lock(file, lock)); 5552 - nfsd_close(file); 5508 + fput(file); 5553 5509 } 5554 5510 return err; 5555 5511 }
+36 -41
fs/nfsd/nfs4xdr.c
··· 33 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 34 */ 35 35 36 + #include <linux/file.h> 36 37 #include <linux/slab.h> 37 38 #include <linux/namei.h> 38 39 #include <linux/statfs.h> ··· 2228 2227 u32 rdattr_err = 0; 2229 2228 __be32 status; 2230 2229 int err; 2231 - int aclsupport = 0; 2232 2230 struct nfs4_acl *acl = NULL; 2233 2231 void *context = NULL; 2234 2232 int contextlen; ··· 2274 2274 goto out; 2275 2275 fhp = tempfh; 2276 2276 } 2277 - if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT 2278 - | FATTR4_WORD0_SUPPORTED_ATTRS)) { 2277 + if (bmval0 & FATTR4_WORD0_ACL) { 2279 2278 err = nfsd4_get_nfs4_acl(rqstp, dentry, &acl); 2280 - aclsupport = (err == 0); 2281 - if (bmval0 & FATTR4_WORD0_ACL) { 2282 - if (err == -EOPNOTSUPP) 2283 - bmval0 &= ~FATTR4_WORD0_ACL; 2284 - else if (err == -EINVAL) { 2285 - status = nfserr_attrnotsupp; 2286 - goto out; 2287 - } else if (err != 0) 2288 - goto out_nfserr; 2289 - } 2279 + if (err == -EOPNOTSUPP) 2280 + bmval0 &= ~FATTR4_WORD0_ACL; 2281 + else if (err == -EINVAL) { 2282 + status = nfserr_attrnotsupp; 2283 + goto out; 2284 + } else if (err != 0) 2285 + goto out_nfserr; 2290 2286 } 2291 2287 2292 2288 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL ··· 2334 2338 u32 word1 = nfsd_suppattrs1(minorversion); 2335 2339 u32 word2 = nfsd_suppattrs2(minorversion); 2336 2340 2337 - if (!aclsupport) 2341 + if (!IS_POSIXACL(dentry->d_inode)) 2338 2342 word0 &= ~FATTR4_WORD0_ACL; 2339 2343 if (!contextsupport) 2340 2344 word2 &= ~FATTR4_WORD2_SECURITY_LABEL; ··· 2482 2486 p = xdr_reserve_space(xdr, 4); 2483 2487 if (!p) 2484 2488 goto out_resource; 2485 - *p++ = cpu_to_be32(aclsupport ? 2489 + *p++ = cpu_to_be32(IS_POSIXACL(dentry->d_inode) ? 2486 2490 ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL : 0); 2487 2491 } 2488 2492 if (bmval0 & FATTR4_WORD0_CANSETTIME) { ··· 3418 3422 unsigned long maxcount; 3419 3423 struct xdr_stream *xdr = &resp->xdr; 3420 3424 struct file *file = read->rd_filp; 3421 - struct svc_fh *fhp = read->rd_fhp; 3422 3425 int starting_len = xdr->buf->len; 3423 - struct raparms *ra; 3426 + struct raparms *ra = NULL; 3424 3427 __be32 *p; 3425 - __be32 err; 3426 3428 3427 3429 if (nfserr) 3428 - return nfserr; 3430 + goto out; 3429 3431 3430 3432 p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */ 3431 3433 if (!p) { 3432 3434 WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)); 3433 - return nfserr_resource; 3435 + nfserr = nfserr_resource; 3436 + goto out; 3434 3437 } 3435 - if (resp->xdr.buf->page_len && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) { 3438 + if (resp->xdr.buf->page_len && 3439 + test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) { 3436 3440 WARN_ON_ONCE(1); 3437 - return nfserr_resource; 3441 + nfserr = nfserr_resource; 3442 + goto out; 3438 3443 } 3439 3444 xdr_commit_encode(xdr); 3440 3445 3441 3446 maxcount = svc_max_payload(resp->rqstp); 3442 - maxcount = min_t(unsigned long, maxcount, (xdr->buf->buflen - xdr->buf->len)); 3447 + maxcount = min_t(unsigned long, maxcount, 3448 + (xdr->buf->buflen - xdr->buf->len)); 3443 3449 maxcount = min_t(unsigned long, maxcount, read->rd_length); 3444 3450 3445 - if (read->rd_filp) 3446 - err = nfsd_permission(resp->rqstp, fhp->fh_export, 3447 - fhp->fh_dentry, 3448 - NFSD_MAY_READ|NFSD_MAY_OWNER_OVERRIDE); 3451 + if (read->rd_tmp_file) 3452 + ra = nfsd_init_raparms(file); 3453 + 3454 + if (file->f_op->splice_read && 3455 + test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) 3456 + nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount); 3449 3457 else 3450 - err = nfsd_get_tmp_read_open(resp->rqstp, read->rd_fhp, 3451 - &file, &ra); 3452 - if (err) 3453 - goto err_truncate; 3458 + nfserr = nfsd4_encode_readv(resp, read, file, maxcount); 3454 3459 3455 - if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) 3456 - err = nfsd4_encode_splice_read(resp, read, file, maxcount); 3457 - else 3458 - err = nfsd4_encode_readv(resp, read, file, maxcount); 3460 + if (ra) 3461 + nfsd_put_raparams(file, ra); 3459 3462 3460 - if (!read->rd_filp) 3461 - nfsd_put_tmp_read_open(file, ra); 3462 - 3463 - err_truncate: 3464 - if (err) 3463 + if (nfserr) 3465 3464 xdr_truncate_encode(xdr, starting_len); 3466 - return err; 3465 + 3466 + out: 3467 + if (file) 3468 + fput(file); 3469 + return nfserr; 3467 3470 } 3468 3471 3469 3472 static __be32
+50 -2
fs/nfsd/nfsproc.c
··· 59 59 nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp, 60 60 struct nfsd_attrstat *resp) 61 61 { 62 + struct iattr *iap = &argp->attrs; 63 + struct svc_fh *fhp; 62 64 __be32 nfserr; 65 + 63 66 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n", 64 67 SVCFH_fmt(&argp->fh), 65 68 argp->attrs.ia_valid, (long) argp->attrs.ia_size); 66 69 67 - fh_copy(&resp->fh, &argp->fh); 68 - nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0); 70 + fhp = fh_copy(&resp->fh, &argp->fh); 71 + 72 + /* 73 + * NFSv2 does not differentiate between "set-[ac]time-to-now" 74 + * which only requires access, and "set-[ac]time-to-X" which 75 + * requires ownership. 76 + * So if it looks like it might be "set both to the same time which 77 + * is close to now", and if inode_change_ok fails, then we 78 + * convert to "set to now" instead of "set to explicit time" 79 + * 80 + * We only call inode_change_ok as the last test as technically 81 + * it is not an interface that we should be using. 82 + */ 83 + #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET) 84 + #define MAX_TOUCH_TIME_ERROR (30*60) 85 + if ((iap->ia_valid & BOTH_TIME_SET) == BOTH_TIME_SET && 86 + iap->ia_mtime.tv_sec == iap->ia_atime.tv_sec) { 87 + /* 88 + * Looks probable. 89 + * 90 + * Now just make sure time is in the right ballpark. 91 + * Solaris, at least, doesn't seem to care what the time 92 + * request is. We require it be within 30 minutes of now. 93 + */ 94 + time_t delta = iap->ia_atime.tv_sec - get_seconds(); 95 + struct inode *inode; 96 + 97 + nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); 98 + if (nfserr) 99 + goto done; 100 + inode = d_inode(fhp->fh_dentry); 101 + 102 + if (delta < 0) 103 + delta = -delta; 104 + if (delta < MAX_TOUCH_TIME_ERROR && 105 + inode_change_ok(inode, iap) != 0) { 106 + /* 107 + * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME. 108 + * This will cause notify_change to set these times 109 + * to "now" 110 + */ 111 + iap->ia_valid &= ~BOTH_TIME_SET; 112 + } 113 + } 114 + 115 + nfserr = nfsd_setattr(rqstp, fhp, iap, 0, (time_t)0); 116 + done: 69 117 return nfsd_return_attrs(nfserr, resp); 70 118 } 71 119
+4 -3
fs/nfsd/state.h
··· 68 68 struct nfsd4_callback_ops *cb_ops; 69 69 struct work_struct cb_work; 70 70 int cb_status; 71 + bool cb_update_seq_nr; 71 72 bool cb_need_restart; 72 73 }; 73 74 ··· 583 582 struct nfsd4_compound_state; 584 583 struct nfsd_net; 585 584 586 - extern __be32 nfs4_preprocess_stateid_op(struct net *net, 587 - struct nfsd4_compound_state *cstate, 588 - stateid_t *stateid, int flags, struct file **filp); 585 + extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, 586 + struct nfsd4_compound_state *cstate, stateid_t *stateid, 587 + int flags, struct file **filp, bool *tmp_file); 589 588 __be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, 590 589 stateid_t *stateid, unsigned char typemask, 591 590 struct nfs4_stid **s, struct nfsd_net *nn);
+29 -99
fs/nfsd/vfs.c
··· 302 302 static void 303 303 nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap) 304 304 { 305 - /* 306 - * NFSv2 does not differentiate between "set-[ac]time-to-now" 307 - * which only requires access, and "set-[ac]time-to-X" which 308 - * requires ownership. 309 - * So if it looks like it might be "set both to the same time which 310 - * is close to now", and if inode_change_ok fails, then we 311 - * convert to "set to now" instead of "set to explicit time" 312 - * 313 - * We only call inode_change_ok as the last test as technically 314 - * it is not an interface that we should be using. 315 - */ 316 - #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET) 317 - #define MAX_TOUCH_TIME_ERROR (30*60) 318 - if ((iap->ia_valid & BOTH_TIME_SET) == BOTH_TIME_SET && 319 - iap->ia_mtime.tv_sec == iap->ia_atime.tv_sec) { 320 - /* 321 - * Looks probable. 322 - * 323 - * Now just make sure time is in the right ballpark. 324 - * Solaris, at least, doesn't seem to care what the time 325 - * request is. We require it be within 30 minutes of now. 326 - */ 327 - time_t delta = iap->ia_atime.tv_sec - get_seconds(); 328 - if (delta < 0) 329 - delta = -delta; 330 - if (delta < MAX_TOUCH_TIME_ERROR && 331 - inode_change_ok(inode, iap) != 0) { 332 - /* 333 - * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME. 334 - * This will cause notify_change to set these times 335 - * to "now" 336 - */ 337 - iap->ia_valid &= ~BOTH_TIME_SET; 338 - } 339 - } 340 - 341 305 /* sanitize the mode change */ 342 306 if (iap->ia_valid & ATTR_MODE) { 343 307 iap->ia_mode &= S_IALLUGO; ··· 502 538 struct file *file, loff_t offset, loff_t len, 503 539 int flags) 504 540 { 505 - __be32 err; 506 541 int error; 507 542 508 543 if (!S_ISREG(file_inode(file)->i_mode)) 509 544 return nfserr_inval; 510 - 511 - err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, NFSD_MAY_WRITE); 512 - if (err) 513 - return err; 514 545 515 546 error = vfs_fallocate(file, flags, offset, len); 516 547 if (!error) ··· 703 744 704 745 host_err = ima_file_check(file, may_flags, 0); 705 746 if (host_err) { 706 - nfsd_close(file); 747 + fput(file); 707 748 goto out_nfserr; 708 749 } 709 750 ··· 720 761 return err; 721 762 } 722 763 723 - /* 724 - * Close a file. 725 - */ 726 - void 727 - nfsd_close(struct file *filp) 764 + struct raparms * 765 + nfsd_init_raparms(struct file *file) 728 766 { 729 - fput(filp); 730 - } 731 - 732 - /* 733 - * Obtain the readahead parameters for the file 734 - * specified by (dev, ino). 735 - */ 736 - 737 - static inline struct raparms * 738 - nfsd_get_raparms(dev_t dev, ino_t ino) 739 - { 767 + struct inode *inode = file_inode(file); 768 + dev_t dev = inode->i_sb->s_dev; 769 + ino_t ino = inode->i_ino; 740 770 struct raparms *ra, **rap, **frap = NULL; 741 771 int depth = 0; 742 772 unsigned int hash; ··· 762 814 ra->p_count++; 763 815 nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++; 764 816 spin_unlock(&rab->pb_lock); 817 + 818 + if (ra->p_set) 819 + file->f_ra = ra->p_ra; 765 820 return ra; 821 + } 822 + 823 + void nfsd_put_raparams(struct file *file, struct raparms *ra) 824 + { 825 + struct raparm_hbucket *rab = &raparm_hash[ra->p_hindex]; 826 + 827 + spin_lock(&rab->pb_lock); 828 + ra->p_ra = file->f_ra; 829 + ra->p_set = 1; 830 + ra->p_count--; 831 + spin_unlock(&rab->pb_lock); 766 832 } 767 833 768 834 /* ··· 907 945 return err; 908 946 } 909 947 910 - static __be32 948 + __be32 911 949 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, 912 950 loff_t offset, struct kvec *vec, int vlen, 913 951 unsigned long *cnt, int *stablep) ··· 971 1009 return err; 972 1010 } 973 1011 974 - __be32 nfsd_get_tmp_read_open(struct svc_rqst *rqstp, struct svc_fh *fhp, 975 - struct file **file, struct raparms **ra) 976 - { 977 - struct inode *inode; 978 - __be32 err; 979 - 980 - err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, file); 981 - if (err) 982 - return err; 983 - 984 - inode = file_inode(*file); 985 - 986 - /* Get readahead parameters */ 987 - *ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino); 988 - 989 - if (*ra && (*ra)->p_set) 990 - (*file)->f_ra = (*ra)->p_ra; 991 - return nfs_ok; 992 - } 993 - 994 - void nfsd_put_tmp_read_open(struct file *file, struct raparms *ra) 995 - { 996 - /* Write back readahead params */ 997 - if (ra) { 998 - struct raparm_hbucket *rab = &raparm_hash[ra->p_hindex]; 999 - spin_lock(&rab->pb_lock); 1000 - ra->p_ra = file->f_ra; 1001 - ra->p_set = 1; 1002 - ra->p_count--; 1003 - spin_unlock(&rab->pb_lock); 1004 - } 1005 - nfsd_close(file); 1006 - } 1007 - 1008 1012 /* 1009 1013 * Read data from a file. count must contain the requested read count 1010 1014 * on entry. On return, *count contains the number of bytes actually read. ··· 983 1055 struct raparms *ra; 984 1056 __be32 err; 985 1057 986 - err = nfsd_get_tmp_read_open(rqstp, fhp, &file, &ra); 1058 + err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file); 987 1059 if (err) 988 1060 return err; 989 1061 1062 + ra = nfsd_init_raparms(file); 990 1063 err = nfsd_vfs_read(rqstp, file, offset, vec, vlen, count); 991 - 992 - nfsd_put_tmp_read_open(file, ra); 1064 + if (ra) 1065 + nfsd_put_raparams(file, ra); 1066 + fput(file); 993 1067 994 1068 return err; 995 1069 } ··· 1023 1093 if (cnt) 1024 1094 err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, 1025 1095 cnt, stablep); 1026 - nfsd_close(file); 1096 + fput(file); 1027 1097 } 1028 1098 out: 1029 1099 return err; ··· 1068 1138 err = nfserr_notsupp; 1069 1139 } 1070 1140 1071 - nfsd_close(file); 1141 + fput(file); 1072 1142 out: 1073 1143 return err; 1074 1144 } ··· 1907 1977 if (err == nfserr_eof || err == nfserr_toosmall) 1908 1978 err = nfs_ok; /* can still be found in ->err */ 1909 1979 out_close: 1910 - nfsd_close(file); 1980 + fput(file); 1911 1981 out: 1912 1982 return err; 1913 1983 }
+7 -4
fs/nfsd/vfs.h
··· 71 71 #endif /* CONFIG_NFSD_V3 */ 72 72 __be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t, 73 73 int, struct file **); 74 - void nfsd_close(struct file *); 75 74 struct raparms; 76 - __be32 nfsd_get_tmp_read_open(struct svc_rqst *, struct svc_fh *, 77 - struct file **, struct raparms **); 78 - void nfsd_put_tmp_read_open(struct file *, struct raparms *); 79 75 __be32 nfsd_splice_read(struct svc_rqst *, 80 76 struct file *, loff_t, unsigned long *); 81 77 __be32 nfsd_readv(struct file *, loff_t, struct kvec *, int, ··· 80 84 loff_t, struct kvec *, int, unsigned long *); 81 85 __be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *, 82 86 loff_t, struct kvec *,int, unsigned long *, int *); 87 + __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, 88 + struct file *file, loff_t offset, 89 + struct kvec *vec, int vlen, unsigned long *cnt, 90 + int *stablep); 83 91 __be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *, 84 92 char *, int *); 85 93 __be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *, ··· 103 103 104 104 __be32 nfsd_permission(struct svc_rqst *, struct svc_export *, 105 105 struct dentry *, int); 106 + 107 + struct raparms *nfsd_init_raparms(struct file *file); 108 + void nfsd_put_raparams(struct file *file, struct raparms *ra); 106 109 107 110 static inline int fh_want_write(struct svc_fh *fh) 108 111 {
+1
fs/nfsd/xdr4.h
··· 273 273 u32 rd_length; /* request */ 274 274 int rd_vlen; 275 275 struct file *rd_filp; 276 + bool rd_tmp_file; 276 277 277 278 struct svc_rqst *rd_rqstp; /* response */ 278 279 struct svc_fh * rd_fhp; /* response */
+8 -3
include/linux/sunrpc/svc_rdma.h
··· 172 172 #define RDMAXPRT_SQ_PENDING 2 173 173 #define RDMAXPRT_CONN_PENDING 3 174 174 175 + #define RPCRDMA_MAX_SVC_SEGS (64) /* server max scatter/gather */ 176 + #if RPCSVC_MAXPAYLOAD < (RPCRDMA_MAX_SVC_SEGS << PAGE_SHIFT) 177 + #define RPCRDMA_MAXPAYLOAD RPCSVC_MAXPAYLOAD 178 + #else 179 + #define RPCRDMA_MAXPAYLOAD (RPCRDMA_MAX_SVC_SEGS << PAGE_SHIFT) 180 + #endif 181 + 175 182 #define RPCRDMA_LISTEN_BACKLOG 10 176 183 /* The default ORD value is based on two outstanding full-size writes with a 177 184 * page size of 4k, or 32k * 2 ops / 4k = 16 outstanding RDMA_READ. */ ··· 189 182 190 183 /* svc_rdma_marshal.c */ 191 184 extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg **, struct svc_rqst *); 192 - extern int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *); 193 185 extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *, 194 186 struct rpcrdma_msg *, 195 - enum rpcrdma_errcode, u32 *); 187 + enum rpcrdma_errcode, __be32 *); 196 188 extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int); 197 189 extern void svc_rdma_xdr_encode_reply_array(struct rpcrdma_write_array *, int); 198 190 extern void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *, int, ··· 218 212 extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *); 219 213 extern void svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *, 220 214 enum rpcrdma_errcode); 221 - struct page *svc_rdma_get_page(void); 222 215 extern int svc_rdma_post_recv(struct svcxprt_rdma *); 223 216 extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *); 224 217 extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
+7
include/uapi/linux/nfs4.h
··· 86 86 #define ACL4_SUPPORT_AUDIT_ACL 0x04 87 87 #define ACL4_SUPPORT_ALARM_ACL 0x08 88 88 89 + #define NFS4_ACL_AUTO_INHERIT 0x00000001 90 + #define NFS4_ACL_PROTECTED 0x00000002 91 + #define NFS4_ACL_DEFAULTED 0x00000004 92 + 89 93 #define NFS4_ACE_FILE_INHERIT_ACE 0x00000001 90 94 #define NFS4_ACE_DIRECTORY_INHERIT_ACE 0x00000002 91 95 #define NFS4_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004 ··· 97 93 #define NFS4_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010 98 94 #define NFS4_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020 99 95 #define NFS4_ACE_IDENTIFIER_GROUP 0x00000040 96 + #define NFS4_ACE_INHERITED_ACE 0x00000080 100 97 101 98 #define NFS4_ACE_READ_DATA 0x00000001 102 99 #define NFS4_ACE_LIST_DIRECTORY 0x00000001 ··· 111 106 #define NFS4_ACE_DELETE_CHILD 0x00000040 112 107 #define NFS4_ACE_READ_ATTRIBUTES 0x00000080 113 108 #define NFS4_ACE_WRITE_ATTRIBUTES 0x00000100 109 + #define NFS4_ACE_WRITE_RETENTION 0x00000200 110 + #define NFS4_ACE_WRITE_RETENTION_HOLD 0x00000400 114 111 #define NFS4_ACE_DELETE 0x00010000 115 112 #define NFS4_ACE_READ_ACL 0x00020000 116 113 #define NFS4_ACE_WRITE_ACL 0x00040000
+8 -20
net/sunrpc/Kconfig
··· 48 48 49 49 If unsure, say Y. 50 50 51 - config SUNRPC_XPRT_RDMA_CLIENT 52 - tristate "RPC over RDMA Client Support" 51 + config SUNRPC_XPRT_RDMA 52 + tristate "RPC-over-RDMA transport" 53 53 depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS 54 54 default SUNRPC && INFINIBAND 55 55 help 56 - This option allows the NFS client to support an RDMA-enabled 57 - transport. 56 + This option allows the NFS client and server to use RDMA 57 + transports (InfiniBand, iWARP, or RoCE). 58 58 59 - To compile RPC client RDMA transport support as a module, 60 - choose M here: the module will be called xprtrdma. 59 + To compile this support as a module, choose M. The module 60 + will be called rpcrdma.ko. 61 61 62 - If unsure, say N. 63 - 64 - config SUNRPC_XPRT_RDMA_SERVER 65 - tristate "RPC over RDMA Server Support" 66 - depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS 67 - default SUNRPC && INFINIBAND 68 - help 69 - This option allows the NFS server to support an RDMA-enabled 70 - transport. 71 - 72 - To compile RPC server RDMA transport support as a module, 73 - choose M here: the module will be called svcrdma. 74 - 75 - If unsure, say N. 62 + If unsure, or you know there is no RDMA capability on your 63 + hardware platform, say N.
+1 -2
net/sunrpc/Makefile
··· 5 5 6 6 obj-$(CONFIG_SUNRPC) += sunrpc.o 7 7 obj-$(CONFIG_SUNRPC_GSS) += auth_gss/ 8 - 9 - obj-y += xprtrdma/ 8 + obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ 10 9 11 10 sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ 12 11 auth.o auth_null.o auth_unix.o auth_generic.o \
+2 -6
net/sunrpc/auth_gss/gss_krb5_crypto.c
··· 881 881 if (err) 882 882 goto out_err; 883 883 884 - sg_init_table(sg, 1); 885 - sg_set_buf(sg, &zeroconstant, 4); 886 - 884 + sg_init_one(sg, &zeroconstant, 4); 887 885 err = crypto_hash_digest(&desc, sg, 4, Kseq); 888 886 if (err) 889 887 goto out_err; ··· 949 951 if (err) 950 952 goto out_err; 951 953 952 - sg_init_table(sg, 1); 953 - sg_set_buf(sg, zeroconstant, 4); 954 - 954 + sg_init_one(sg, zeroconstant, 4); 955 955 err = crypto_hash_digest(&desc, sg, 4, Kcrypt); 956 956 if (err) 957 957 goto out_err;
+1 -1
net/sunrpc/svc.c
··· 1290 1290 svc_putnl(resv, ntohl(rpc_stat)); 1291 1291 goto sendit; 1292 1292 } 1293 - EXPORT_SYMBOL_GPL(svc_process); 1294 1293 1295 1294 /* 1296 1295 * Process the RPC request. ··· 1337 1338 svc_drop(rqstp); 1338 1339 return 0; 1339 1340 } 1341 + EXPORT_SYMBOL_GPL(svc_process); 1340 1342 1341 1343 #if defined(CONFIG_SUNRPC_BACKCHANNEL) 1342 1344 /*
+6 -8
net/sunrpc/xprtrdma/Makefile
··· 1 - obj-$(CONFIG_SUNRPC_XPRT_RDMA_CLIENT) += xprtrdma.o 1 + obj-$(CONFIG_SUNRPC_XPRT_RDMA) += rpcrdma.o 2 2 3 - xprtrdma-y := transport.o rpc_rdma.o verbs.o \ 4 - fmr_ops.o frwr_ops.o physical_ops.o 5 - 6 - obj-$(CONFIG_SUNRPC_XPRT_RDMA_SERVER) += svcrdma.o 7 - 8 - svcrdma-y := svc_rdma.o svc_rdma_transport.o \ 9 - svc_rdma_marshal.o svc_rdma_sendto.o svc_rdma_recvfrom.o 3 + rpcrdma-y := transport.o rpc_rdma.o verbs.o \ 4 + fmr_ops.o frwr_ops.o physical_ops.o \ 5 + svc_rdma.o svc_rdma_transport.o \ 6 + svc_rdma_marshal.o svc_rdma_sendto.o svc_rdma_recvfrom.o \ 7 + module.o
+46
net/sunrpc/xprtrdma/module.c
··· 1 + /* 2 + * Copyright (c) 2015 Oracle. All rights reserved. 3 + */ 4 + 5 + /* rpcrdma.ko module initialization 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/init.h> 10 + #include <linux/sunrpc/svc_rdma.h> 11 + #include "xprt_rdma.h" 12 + 13 + #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 14 + # define RPCDBG_FACILITY RPCDBG_TRANS 15 + #endif 16 + 17 + MODULE_AUTHOR("Open Grid Computing and Network Appliance, Inc."); 18 + MODULE_DESCRIPTION("RPC/RDMA Transport"); 19 + MODULE_LICENSE("Dual BSD/GPL"); 20 + MODULE_ALIAS("svcrdma"); 21 + MODULE_ALIAS("xprtrdma"); 22 + 23 + static void __exit rpc_rdma_cleanup(void) 24 + { 25 + xprt_rdma_cleanup(); 26 + svc_rdma_cleanup(); 27 + } 28 + 29 + static int __init rpc_rdma_init(void) 30 + { 31 + int rc; 32 + 33 + rc = svc_rdma_init(); 34 + if (rc) 35 + goto out; 36 + 37 + rc = xprt_rdma_init(); 38 + if (rc) 39 + svc_rdma_cleanup(); 40 + 41 + out: 42 + return rc; 43 + } 44 + 45 + module_init(rpc_rdma_init); 46 + module_exit(rpc_rdma_cleanup);
+1 -7
net/sunrpc/xprtrdma/svc_rdma.c
··· 38 38 * 39 39 * Author: Tom Tucker <tom@opengridcomputing.com> 40 40 */ 41 - #include <linux/module.h> 42 - #include <linux/init.h> 41 + 43 42 #include <linux/slab.h> 44 43 #include <linux/fs.h> 45 44 #include <linux/sysctl.h> ··· 294 295 destroy_workqueue(svc_rdma_wq); 295 296 return -ENOMEM; 296 297 } 297 - MODULE_AUTHOR("Tom Tucker <tom@opengridcomputing.com>"); 298 - MODULE_DESCRIPTION("SVC RDMA Transport"); 299 - MODULE_LICENSE("Dual BSD/GPL"); 300 - module_init(svc_rdma_init); 301 - module_exit(svc_rdma_cleanup);
+39 -101
net/sunrpc/xprtrdma/svc_rdma_marshal.c
··· 50 50 /* 51 51 * Decodes a read chunk list. The expected format is as follows: 52 52 * descrim : xdr_one 53 - * position : u32 offset into XDR stream 54 - * handle : u32 RKEY 53 + * position : __be32 offset into XDR stream 54 + * handle : __be32 RKEY 55 55 * . . . 56 56 * end-of-list: xdr_zero 57 57 */ 58 - static u32 *decode_read_list(u32 *va, u32 *vaend) 58 + static __be32 *decode_read_list(__be32 *va, __be32 *vaend) 59 59 { 60 60 struct rpcrdma_read_chunk *ch = (struct rpcrdma_read_chunk *)va; 61 61 ··· 67 67 } 68 68 ch++; 69 69 } 70 - return (u32 *)&ch->rc_position; 70 + return &ch->rc_position; 71 71 } 72 72 73 73 /* 74 74 * Decodes a write chunk list. The expected format is as follows: 75 75 * descrim : xdr_one 76 76 * nchunks : <count> 77 - * handle : u32 RKEY ---+ 78 - * length : u32 <len of segment> | 77 + * handle : __be32 RKEY ---+ 78 + * length : __be32 <len of segment> | 79 79 * offset : remove va + <count> 80 80 * . . . | 81 81 * ---+ 82 82 */ 83 - static u32 *decode_write_list(u32 *va, u32 *vaend) 83 + static __be32 *decode_write_list(__be32 *va, __be32 *vaend) 84 84 { 85 85 unsigned long start, end; 86 86 int nchunks; ··· 90 90 91 91 /* Check for not write-array */ 92 92 if (ary->wc_discrim == xdr_zero) 93 - return (u32 *)&ary->wc_nchunks; 93 + return &ary->wc_nchunks; 94 94 95 95 if ((unsigned long)ary + sizeof(struct rpcrdma_write_array) > 96 96 (unsigned long)vaend) { 97 97 dprintk("svcrdma: ary=%p, vaend=%p\n", ary, vaend); 98 98 return NULL; 99 99 } 100 - nchunks = ntohl(ary->wc_nchunks); 100 + nchunks = be32_to_cpu(ary->wc_nchunks); 101 101 102 102 start = (unsigned long)&ary->wc_array[0]; 103 103 end = (unsigned long)vaend; ··· 112 112 * rs_length is the 2nd 4B field in wc_target and taking its 113 113 * address skips the list terminator 114 114 */ 115 - return (u32 *)&ary->wc_array[nchunks].wc_target.rs_length; 115 + return &ary->wc_array[nchunks].wc_target.rs_length; 116 116 } 117 117 118 - static u32 *decode_reply_array(u32 *va, u32 *vaend) 118 + static __be32 *decode_reply_array(__be32 *va, __be32 *vaend) 119 119 { 120 120 unsigned long start, end; 121 121 int nchunks; ··· 124 124 125 125 /* Check for no reply-array */ 126 126 if (ary->wc_discrim == xdr_zero) 127 - return (u32 *)&ary->wc_nchunks; 127 + return &ary->wc_nchunks; 128 128 129 129 if ((unsigned long)ary + sizeof(struct rpcrdma_write_array) > 130 130 (unsigned long)vaend) { 131 131 dprintk("svcrdma: ary=%p, vaend=%p\n", ary, vaend); 132 132 return NULL; 133 133 } 134 - nchunks = ntohl(ary->wc_nchunks); 134 + nchunks = be32_to_cpu(ary->wc_nchunks); 135 135 136 136 start = (unsigned long)&ary->wc_array[0]; 137 137 end = (unsigned long)vaend; ··· 142 142 ary, nchunks, vaend); 143 143 return NULL; 144 144 } 145 - return (u32 *)&ary->wc_array[nchunks]; 145 + return (__be32 *)&ary->wc_array[nchunks]; 146 146 } 147 147 148 148 int svc_rdma_xdr_decode_req(struct rpcrdma_msg **rdma_req, 149 149 struct svc_rqst *rqstp) 150 150 { 151 151 struct rpcrdma_msg *rmsgp = NULL; 152 - u32 *va; 153 - u32 *vaend; 152 + __be32 *va, *vaend; 154 153 u32 hdr_len; 155 154 156 155 rmsgp = (struct rpcrdma_msg *)rqstp->rq_arg.head[0].iov_base; ··· 161 162 return -EINVAL; 162 163 } 163 164 164 - /* Decode the header */ 165 - rmsgp->rm_xid = ntohl(rmsgp->rm_xid); 166 - rmsgp->rm_vers = ntohl(rmsgp->rm_vers); 167 - rmsgp->rm_credit = ntohl(rmsgp->rm_credit); 168 - rmsgp->rm_type = ntohl(rmsgp->rm_type); 169 - 170 - if (rmsgp->rm_vers != RPCRDMA_VERSION) 165 + if (rmsgp->rm_vers != rpcrdma_version) 171 166 return -ENOSYS; 172 167 173 168 /* Pull in the extra for the padded case and bump our pointer */ 174 - if (rmsgp->rm_type == RDMA_MSGP) { 169 + if (rmsgp->rm_type == rdma_msgp) { 175 170 int hdrlen; 171 + 176 172 rmsgp->rm_body.rm_padded.rm_align = 177 - ntohl(rmsgp->rm_body.rm_padded.rm_align); 173 + be32_to_cpu(rmsgp->rm_body.rm_padded.rm_align); 178 174 rmsgp->rm_body.rm_padded.rm_thresh = 179 - ntohl(rmsgp->rm_body.rm_padded.rm_thresh); 175 + be32_to_cpu(rmsgp->rm_body.rm_padded.rm_thresh); 180 176 181 177 va = &rmsgp->rm_body.rm_padded.rm_pempty[4]; 182 178 rqstp->rq_arg.head[0].iov_base = va; ··· 186 192 * chunk list and a reply chunk list. 187 193 */ 188 194 va = &rmsgp->rm_body.rm_chunks[0]; 189 - vaend = (u32 *)((unsigned long)rmsgp + rqstp->rq_arg.len); 195 + vaend = (__be32 *)((unsigned long)rmsgp + rqstp->rq_arg.len); 190 196 va = decode_read_list(va, vaend); 191 197 if (!va) 192 198 return -EINVAL; ··· 205 211 return hdr_len; 206 212 } 207 213 208 - int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *rqstp) 209 - { 210 - struct rpcrdma_msg *rmsgp = NULL; 211 - struct rpcrdma_read_chunk *ch; 212 - struct rpcrdma_write_array *ary; 213 - u32 *va; 214 - u32 hdrlen; 215 - 216 - dprintk("svcrdma: processing deferred RDMA header on rqstp=%p\n", 217 - rqstp); 218 - rmsgp = (struct rpcrdma_msg *)rqstp->rq_arg.head[0].iov_base; 219 - 220 - /* Pull in the extra for the padded case and bump our pointer */ 221 - if (rmsgp->rm_type == RDMA_MSGP) { 222 - va = &rmsgp->rm_body.rm_padded.rm_pempty[4]; 223 - rqstp->rq_arg.head[0].iov_base = va; 224 - hdrlen = (u32)((unsigned long)va - (unsigned long)rmsgp); 225 - rqstp->rq_arg.head[0].iov_len -= hdrlen; 226 - return hdrlen; 227 - } 228 - 229 - /* 230 - * Skip all chunks to find RPC msg. These were previously processed 231 - */ 232 - va = &rmsgp->rm_body.rm_chunks[0]; 233 - 234 - /* Skip read-list */ 235 - for (ch = (struct rpcrdma_read_chunk *)va; 236 - ch->rc_discrim != xdr_zero; ch++); 237 - va = (u32 *)&ch->rc_position; 238 - 239 - /* Skip write-list */ 240 - ary = (struct rpcrdma_write_array *)va; 241 - if (ary->wc_discrim == xdr_zero) 242 - va = (u32 *)&ary->wc_nchunks; 243 - else 244 - /* 245 - * rs_length is the 2nd 4B field in wc_target and taking its 246 - * address skips the list terminator 247 - */ 248 - va = (u32 *)&ary->wc_array[ary->wc_nchunks].wc_target.rs_length; 249 - 250 - /* Skip reply-array */ 251 - ary = (struct rpcrdma_write_array *)va; 252 - if (ary->wc_discrim == xdr_zero) 253 - va = (u32 *)&ary->wc_nchunks; 254 - else 255 - va = (u32 *)&ary->wc_array[ary->wc_nchunks]; 256 - 257 - rqstp->rq_arg.head[0].iov_base = va; 258 - hdrlen = (unsigned long)va - (unsigned long)rmsgp; 259 - rqstp->rq_arg.head[0].iov_len -= hdrlen; 260 - 261 - return hdrlen; 262 - } 263 - 264 214 int svc_rdma_xdr_encode_error(struct svcxprt_rdma *xprt, 265 215 struct rpcrdma_msg *rmsgp, 266 - enum rpcrdma_errcode err, u32 *va) 216 + enum rpcrdma_errcode err, __be32 *va) 267 217 { 268 - u32 *startp = va; 218 + __be32 *startp = va; 269 219 270 - *va++ = htonl(rmsgp->rm_xid); 271 - *va++ = htonl(rmsgp->rm_vers); 272 - *va++ = htonl(xprt->sc_max_requests); 273 - *va++ = htonl(RDMA_ERROR); 274 - *va++ = htonl(err); 220 + *va++ = rmsgp->rm_xid; 221 + *va++ = rmsgp->rm_vers; 222 + *va++ = cpu_to_be32(xprt->sc_max_requests); 223 + *va++ = rdma_error; 224 + *va++ = cpu_to_be32(err); 275 225 if (err == ERR_VERS) { 276 - *va++ = htonl(RPCRDMA_VERSION); 277 - *va++ = htonl(RPCRDMA_VERSION); 226 + *va++ = rpcrdma_version; 227 + *va++ = rpcrdma_version; 278 228 } 279 229 280 230 return (int)((unsigned long)va - (unsigned long)startp); ··· 235 297 &rmsgp->rm_body.rm_chunks[1]; 236 298 if (wr_ary->wc_discrim) 237 299 wr_ary = (struct rpcrdma_write_array *) 238 - &wr_ary->wc_array[ntohl(wr_ary->wc_nchunks)]. 300 + &wr_ary->wc_array[be32_to_cpu(wr_ary->wc_nchunks)]. 239 301 wc_target.rs_length; 240 302 else 241 303 wr_ary = (struct rpcrdma_write_array *) ··· 244 306 /* skip reply array */ 245 307 if (wr_ary->wc_discrim) 246 308 wr_ary = (struct rpcrdma_write_array *) 247 - &wr_ary->wc_array[ntohl(wr_ary->wc_nchunks)]; 309 + &wr_ary->wc_array[be32_to_cpu(wr_ary->wc_nchunks)]; 248 310 else 249 311 wr_ary = (struct rpcrdma_write_array *) 250 312 &wr_ary->wc_nchunks; ··· 263 325 ary = (struct rpcrdma_write_array *) 264 326 &rmsgp->rm_body.rm_chunks[1]; 265 327 ary->wc_discrim = xdr_one; 266 - ary->wc_nchunks = htonl(chunks); 328 + ary->wc_nchunks = cpu_to_be32(chunks); 267 329 268 330 /* write-list terminator */ 269 331 ary->wc_array[chunks].wc_target.rs_handle = xdr_zero; ··· 276 338 int chunks) 277 339 { 278 340 ary->wc_discrim = xdr_one; 279 - ary->wc_nchunks = htonl(chunks); 341 + ary->wc_nchunks = cpu_to_be32(chunks); 280 342 } 281 343 282 344 void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *ary, ··· 288 350 struct rpcrdma_segment *seg = &ary->wc_array[chunk_no].wc_target; 289 351 seg->rs_handle = rs_handle; 290 352 seg->rs_offset = rs_offset; 291 - seg->rs_length = htonl(write_len); 353 + seg->rs_length = cpu_to_be32(write_len); 292 354 } 293 355 294 356 void svc_rdma_xdr_encode_reply_header(struct svcxprt_rdma *xprt, ··· 296 358 struct rpcrdma_msg *rdma_resp, 297 359 enum rpcrdma_proc rdma_type) 298 360 { 299 - rdma_resp->rm_xid = htonl(rdma_argp->rm_xid); 300 - rdma_resp->rm_vers = htonl(rdma_argp->rm_vers); 301 - rdma_resp->rm_credit = htonl(xprt->sc_max_requests); 302 - rdma_resp->rm_type = htonl(rdma_type); 361 + rdma_resp->rm_xid = rdma_argp->rm_xid; 362 + rdma_resp->rm_vers = rdma_argp->rm_vers; 363 + rdma_resp->rm_credit = cpu_to_be32(xprt->sc_max_requests); 364 + rdma_resp->rm_type = cpu_to_be32(rdma_type); 303 365 304 366 /* Encode <nul> chunks lists */ 305 367 rdma_resp->rm_body.rm_chunks[0] = xdr_zero;
+1 -1
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
··· 85 85 86 86 /* RDMA_NOMSG: RDMA READ data should land just after RDMA RECV data */ 87 87 rmsgp = (struct rpcrdma_msg *)rqstp->rq_arg.head[0].iov_base; 88 - if (be32_to_cpu(rmsgp->rm_type) == RDMA_NOMSG) 88 + if (rmsgp->rm_type == rdma_nomsg) 89 89 rqstp->rq_arg.pages = &rqstp->rq_pages[0]; 90 90 else 91 91 rqstp->rq_arg.pages = &rqstp->rq_pages[1];
+9 -7
net/sunrpc/xprtrdma/svc_rdma_sendto.c
··· 240 240 u32 xdr_off; 241 241 int chunk_off; 242 242 int chunk_no; 243 + int nchunks; 243 244 struct rpcrdma_write_array *arg_ary; 244 245 struct rpcrdma_write_array *res_ary; 245 246 int ret; ··· 252 251 &rdma_resp->rm_body.rm_chunks[1]; 253 252 254 253 /* Write chunks start at the pagelist */ 254 + nchunks = be32_to_cpu(arg_ary->wc_nchunks); 255 255 for (xdr_off = rqstp->rq_res.head[0].iov_len, chunk_no = 0; 256 - xfer_len && chunk_no < arg_ary->wc_nchunks; 256 + xfer_len && chunk_no < nchunks; 257 257 chunk_no++) { 258 258 struct rpcrdma_segment *arg_ch; 259 259 u64 rs_offset; 260 260 261 261 arg_ch = &arg_ary->wc_array[chunk_no].wc_target; 262 - write_len = min(xfer_len, ntohl(arg_ch->rs_length)); 262 + write_len = min(xfer_len, be32_to_cpu(arg_ch->rs_length)); 263 263 264 264 /* Prepare the response chunk given the length actually 265 265 * written */ ··· 272 270 chunk_off = 0; 273 271 while (write_len) { 274 272 ret = send_write(xprt, rqstp, 275 - ntohl(arg_ch->rs_handle), 273 + be32_to_cpu(arg_ch->rs_handle), 276 274 rs_offset + chunk_off, 277 275 xdr_off, 278 276 write_len, ··· 320 318 &rdma_resp->rm_body.rm_chunks[2]; 321 319 322 320 /* xdr offset starts at RPC message */ 323 - nchunks = ntohl(arg_ary->wc_nchunks); 321 + nchunks = be32_to_cpu(arg_ary->wc_nchunks); 324 322 for (xdr_off = 0, chunk_no = 0; 325 323 xfer_len && chunk_no < nchunks; 326 324 chunk_no++) { 327 325 u64 rs_offset; 328 326 ch = &arg_ary->wc_array[chunk_no].wc_target; 329 - write_len = min(xfer_len, htonl(ch->rs_length)); 327 + write_len = min(xfer_len, be32_to_cpu(ch->rs_length)); 330 328 331 329 /* Prepare the reply chunk given the length actually 332 330 * written */ ··· 337 335 chunk_off = 0; 338 336 while (write_len) { 339 337 ret = send_write(xprt, rqstp, 340 - ntohl(ch->rs_handle), 338 + be32_to_cpu(ch->rs_handle), 341 339 rs_offset + chunk_off, 342 340 xdr_off, 343 341 write_len, ··· 517 515 inline_bytes = rqstp->rq_res.len; 518 516 519 517 /* Create the RDMA response header */ 520 - res_page = svc_rdma_get_page(); 518 + res_page = alloc_page(GFP_KERNEL | __GFP_NOFAIL); 521 519 rdma_resp = page_address(res_page); 522 520 reply_ary = svc_rdma_get_reply_array(rdma_argp); 523 521 if (reply_ary)
+8 -28
net/sunrpc/xprtrdma/svc_rdma_transport.c
··· 91 91 .xcl_name = "rdma", 92 92 .xcl_owner = THIS_MODULE, 93 93 .xcl_ops = &svc_rdma_ops, 94 - .xcl_max_payload = RPCSVC_MAXPAYLOAD_RDMA, 94 + .xcl_max_payload = RPCRDMA_MAXPAYLOAD, 95 95 .xcl_ident = XPRT_TRANSPORT_RDMA, 96 96 }; 97 97 ··· 99 99 { 100 100 struct svc_rdma_op_ctxt *ctxt; 101 101 102 - while (1) { 103 - ctxt = kmem_cache_alloc(svc_rdma_ctxt_cachep, GFP_KERNEL); 104 - if (ctxt) 105 - break; 106 - schedule_timeout_uninterruptible(msecs_to_jiffies(500)); 107 - } 102 + ctxt = kmem_cache_alloc(svc_rdma_ctxt_cachep, 103 + GFP_KERNEL | __GFP_NOFAIL); 108 104 ctxt->xprt = xprt; 109 105 INIT_LIST_HEAD(&ctxt->dto_q); 110 106 ctxt->count = 0; ··· 152 156 struct svc_rdma_req_map *svc_rdma_get_req_map(void) 153 157 { 154 158 struct svc_rdma_req_map *map; 155 - while (1) { 156 - map = kmem_cache_alloc(svc_rdma_map_cachep, GFP_KERNEL); 157 - if (map) 158 - break; 159 - schedule_timeout_uninterruptible(msecs_to_jiffies(500)); 160 - } 159 + map = kmem_cache_alloc(svc_rdma_map_cachep, 160 + GFP_KERNEL | __GFP_NOFAIL); 161 161 map->count = 0; 162 162 return map; 163 163 } ··· 485 493 return cma_xprt; 486 494 } 487 495 488 - struct page *svc_rdma_get_page(void) 489 - { 490 - struct page *page; 491 - 492 - while ((page = alloc_page(GFP_KERNEL)) == NULL) { 493 - /* If we can't get memory, wait a bit and try again */ 494 - printk(KERN_INFO "svcrdma: out of memory...retrying in 1s\n"); 495 - schedule_timeout_uninterruptible(msecs_to_jiffies(1000)); 496 - } 497 - return page; 498 - } 499 - 500 496 int svc_rdma_post_recv(struct svcxprt_rdma *xprt) 501 497 { 502 498 struct ib_recv_wr recv_wr, *bad_recv_wr; ··· 503 523 pr_err("svcrdma: Too many sges (%d)\n", sge_no); 504 524 goto err_put_ctxt; 505 525 } 506 - page = svc_rdma_get_page(); 526 + page = alloc_page(GFP_KERNEL | __GFP_NOFAIL); 507 527 ctxt->pages[sge_no] = page; 508 528 pa = ib_dma_map_page(xprt->sc_cm_id->device, 509 529 page, 0, PAGE_SIZE, ··· 1298 1318 struct ib_send_wr err_wr; 1299 1319 struct page *p; 1300 1320 struct svc_rdma_op_ctxt *ctxt; 1301 - u32 *va; 1321 + __be32 *va; 1302 1322 int length; 1303 1323 int ret; 1304 1324 1305 - p = svc_rdma_get_page(); 1325 + p = alloc_page(GFP_KERNEL | __GFP_NOFAIL); 1306 1326 va = page_address(p); 1307 1327 1308 1328 /* XDR encode error */
+2 -11
net/sunrpc/xprtrdma/transport.c
··· 48 48 */ 49 49 50 50 #include <linux/module.h> 51 - #include <linux/init.h> 52 51 #include <linux/slab.h> 53 52 #include <linux/seq_file.h> 54 53 #include <linux/sunrpc/addr.h> ··· 57 58 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 58 59 # define RPCDBG_FACILITY RPCDBG_TRANS 59 60 #endif 60 - 61 - MODULE_LICENSE("Dual BSD/GPL"); 62 - 63 - MODULE_DESCRIPTION("RPC/RDMA Transport for Linux kernel NFS"); 64 - MODULE_AUTHOR("Network Appliance, Inc."); 65 61 66 62 /* 67 63 * tunables ··· 705 711 .setup = xprt_setup_rdma, 706 712 }; 707 713 708 - static void __exit xprt_rdma_cleanup(void) 714 + void xprt_rdma_cleanup(void) 709 715 { 710 716 int rc; 711 717 ··· 722 728 __func__, rc); 723 729 } 724 730 725 - static int __init xprt_rdma_init(void) 731 + int xprt_rdma_init(void) 726 732 { 727 733 int rc; 728 734 ··· 747 753 #endif 748 754 return 0; 749 755 } 750 - 751 - module_init(xprt_rdma_init); 752 - module_exit(xprt_rdma_cleanup);
+5 -6
net/sunrpc/xprtrdma/xprt_rdma.h
··· 480 480 */ 481 481 int rpcrdma_marshal_req(struct rpc_rqst *); 482 482 483 + /* RPC/RDMA module init - xprtrdma/transport.c 484 + */ 485 + int xprt_rdma_init(void); 486 + void xprt_rdma_cleanup(void); 487 + 483 488 /* Temporary NFS request map cache. Created in svc_rdma.c */ 484 489 extern struct kmem_cache *svc_rdma_map_cachep; 485 490 /* WR context cache. Created in svc_rdma.c */ 486 491 extern struct kmem_cache *svc_rdma_ctxt_cachep; 487 492 /* Workqueue created in svc_rdma.c */ 488 493 extern struct workqueue_struct *svc_rdma_wq; 489 - 490 - #if RPCSVC_MAXPAYLOAD < (RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT) 491 - #define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD 492 - #else 493 - #define RPCSVC_MAXPAYLOAD_RDMA (RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT) 494 - #endif 495 494 496 495 #endif /* _LINUX_SUNRPC_XPRT_RDMA_H */