Skip to content

Commit ad9a19d

Browse files
committed
Merge tag 'nfsd-4.14' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "More RDMA work and some op-structure constification from Chuck Lever, and a small cleanup to our xdr encoding" * tag 'nfsd-4.14' of git://linux-nfs.org/~bfields/linux: svcrdma: Estimate Send Queue depth properly rdma core: Add rdma_rw_mr_payload() svcrdma: Limit RQ depth svcrdma: Populate tail iovec when receiving nfsd: Incoming xdr_bufs may have content in tail buffer svcrdma: Clean up svc_rdma_build_read_chunk() sunrpc: Const-ify struct sv_serv_ops nfsd: Const-ify NFSv4 encoding and decoding ops arrays sunrpc: Const-ify instances of struct svc_xprt_ops nfsd4: individual encoders no longer see error cases nfsd4: skip encoder in trivial error cases nfsd4: define ->op_release for compound ops nfsd4: opdesc will be useful outside nfs4proc.c nfsd4: move some nfsd4 op definitions to xdr4.h
2 parents 66ba772 + 26fb225 commit ad9a19d

File tree

14 files changed

+323
-401
lines changed

14 files changed

+323
-401
lines changed

drivers/infiniband/core/rw.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,30 @@ void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
643643
}
644644
EXPORT_SYMBOL(rdma_rw_ctx_destroy_signature);
645645

646+
/**
647+
* rdma_rw_mr_factor - return number of MRs required for a payload
648+
* @device: device handling the connection
649+
* @port_num: port num to which the connection is bound
650+
* @maxpages: maximum payload pages per rdma_rw_ctx
651+
*
652+
* Returns the number of MRs the device requires to move @maxpayload
653+
* bytes. The returned value is used during transport creation to
654+
* compute max_rdma_ctxts and the size of the transport's Send and
655+
* Send Completion Queues.
656+
*/
657+
unsigned int rdma_rw_mr_factor(struct ib_device *device, u8 port_num,
658+
unsigned int maxpages)
659+
{
660+
unsigned int mr_pages;
661+
662+
if (rdma_rw_can_use_mr(device, port_num))
663+
mr_pages = rdma_rw_fr_page_list_len(device);
664+
else
665+
mr_pages = device->attrs.max_sge_rd;
666+
return DIV_ROUND_UP(maxpages, mr_pages);
667+
}
668+
EXPORT_SYMBOL(rdma_rw_mr_factor);
669+
646670
void rdma_rw_init_qp(struct ib_device *dev, struct ib_qp_init_attr *attr)
647671
{
648672
u32 factor;

fs/lockd/svc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int lockd_start_svc(struct svc_serv *serv)
396396
return error;
397397
}
398398

399-
static struct svc_serv_ops lockd_sv_ops = {
399+
static const struct svc_serv_ops lockd_sv_ops = {
400400
.svo_shutdown = svc_rpcb_cleanup,
401401
.svo_enqueue_xprt = svc_xprt_do_enqueue,
402402
};

fs/nfs/callback.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,26 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
226226
return ret;
227227
}
228228

229-
static struct svc_serv_ops nfs40_cb_sv_ops = {
229+
static const struct svc_serv_ops nfs40_cb_sv_ops = {
230230
.svo_function = nfs4_callback_svc,
231231
.svo_enqueue_xprt = svc_xprt_do_enqueue,
232232
.svo_setup = svc_set_num_threads_sync,
233233
.svo_module = THIS_MODULE,
234234
};
235235
#if defined(CONFIG_NFS_V4_1)
236-
static struct svc_serv_ops nfs41_cb_sv_ops = {
236+
static const struct svc_serv_ops nfs41_cb_sv_ops = {
237237
.svo_function = nfs41_callback_svc,
238238
.svo_enqueue_xprt = svc_xprt_do_enqueue,
239239
.svo_setup = svc_set_num_threads_sync,
240240
.svo_module = THIS_MODULE,
241241
};
242242

243-
static struct svc_serv_ops *nfs4_cb_sv_ops[] = {
243+
static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
244244
[0] = &nfs40_cb_sv_ops,
245245
[1] = &nfs41_cb_sv_ops,
246246
};
247247
#else
248-
static struct svc_serv_ops *nfs4_cb_sv_ops[] = {
248+
static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
249249
[0] = &nfs40_cb_sv_ops,
250250
[1] = NULL,
251251
};
@@ -254,8 +254,8 @@ static struct svc_serv_ops *nfs4_cb_sv_ops[] = {
254254
static struct svc_serv *nfs_callback_create_svc(int minorversion)
255255
{
256256
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
257+
const struct svc_serv_ops *sv_ops;
257258
struct svc_serv *serv;
258-
struct svc_serv_ops *sv_ops;
259259

260260
/*
261261
* Check whether we're already up and running.

fs/nfsd/nfs4proc.c

Lines changed: 50 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,14 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
784784
return status;
785785
}
786786

787+
788+
static void
789+
nfsd4_read_release(union nfsd4_op_u *u)
790+
{
791+
if (u->read.rd_filp)
792+
fput(u->read.rd_filp);
793+
}
794+
787795
static __be32
788796
nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
789797
union nfsd4_op_u *u)
@@ -912,6 +920,13 @@ nfsd4_secinfo_no_name(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstat
912920
return nfs_ok;
913921
}
914922

923+
static void
924+
nfsd4_secinfo_release(union nfsd4_op_u *u)
925+
{
926+
if (u->secinfo.si_exp)
927+
exp_put(u->secinfo.si_exp);
928+
}
929+
915930
static __be32
916931
nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
917932
union nfsd4_op_u *u)
@@ -1335,6 +1350,12 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
13351350
return nfserr;
13361351
}
13371352

1353+
static void
1354+
nfsd4_getdeviceinfo_release(union nfsd4_op_u *u)
1355+
{
1356+
kfree(u->getdeviceinfo.gd_device);
1357+
}
1358+
13381359
static __be32
13391360
nfsd4_layoutget(struct svc_rqst *rqstp,
13401361
struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
@@ -1415,6 +1436,12 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
14151436
return nfserr;
14161437
}
14171438

1439+
static void
1440+
nfsd4_layoutget_release(union nfsd4_op_u *u)
1441+
{
1442+
kfree(u->layoutget.lg_content);
1443+
}
1444+
14181445
static __be32
14191446
nfsd4_layoutcommit(struct svc_rqst *rqstp,
14201447
struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
@@ -1541,49 +1568,6 @@ static inline void nfsd4_increment_op_stats(u32 opnum)
15411568
nfsdstats.nfs4_opcount[opnum]++;
15421569
}
15431570

1544-
enum nfsd4_op_flags {
1545-
ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */
1546-
ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */
1547-
ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */
1548-
/* For rfc 5661 section 2.6.3.1.1: */
1549-
OP_HANDLES_WRONGSEC = 1 << 3,
1550-
OP_IS_PUTFH_LIKE = 1 << 4,
1551-
/*
1552-
* These are the ops whose result size we estimate before
1553-
* encoding, to avoid performing an op then not being able to
1554-
* respond or cache a response. This includes writes and setattrs
1555-
* as well as the operations usually called "nonidempotent":
1556-
*/
1557-
OP_MODIFIES_SOMETHING = 1 << 5,
1558-
/*
1559-
* Cache compounds containing these ops in the xid-based drc:
1560-
* We use the DRC for compounds containing non-idempotent
1561-
* operations, *except* those that are 4.1-specific (since
1562-
* sessions provide their own EOS), and except for stateful
1563-
* operations other than setclientid and setclientid_confirm
1564-
* (since sequence numbers provide EOS for open, lock, etc in
1565-
* the v4.0 case).
1566-
*/
1567-
OP_CACHEME = 1 << 6,
1568-
/*
1569-
* These are ops which clear current state id.
1570-
*/
1571-
OP_CLEAR_STATEID = 1 << 7,
1572-
};
1573-
1574-
struct nfsd4_operation {
1575-
__be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
1576-
union nfsd4_op_u *);
1577-
u32 op_flags;
1578-
char *op_name;
1579-
/* Try to get response size before operation */
1580-
u32 (*op_rsize_bop)(struct svc_rqst *, struct nfsd4_op *);
1581-
void (*op_get_currentstateid)(struct nfsd4_compound_state *,
1582-
union nfsd4_op_u *);
1583-
void (*op_set_currentstateid)(struct nfsd4_compound_state *,
1584-
union nfsd4_op_u *);
1585-
};
1586-
15871571
static const struct nfsd4_operation nfsd4_ops[];
15881572

15891573
static const char *nfsd4_op_name(unsigned opnum);
@@ -1621,7 +1605,7 @@ static __be32 nfs41_check_op_ordering(struct nfsd4_compoundargs *args)
16211605
return nfs_ok;
16221606
}
16231607

1624-
static inline const struct nfsd4_operation *OPDESC(struct nfsd4_op *op)
1608+
const struct nfsd4_operation *OPDESC(struct nfsd4_op *op)
16251609
{
16261610
return &nfsd4_ops[op->opnum];
16271611
}
@@ -1694,7 +1678,6 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
16941678
struct nfsd4_compoundargs *args = rqstp->rq_argp;
16951679
struct nfsd4_compoundres *resp = rqstp->rq_resp;
16961680
struct nfsd4_op *op;
1697-
const struct nfsd4_operation *opdesc;
16981681
struct nfsd4_compound_state *cstate = &resp->cstate;
16991682
struct svc_fh *current_fh = &cstate->current_fh;
17001683
struct svc_fh *save_fh = &cstate->save_fh;
@@ -1747,28 +1730,26 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
17471730
goto encode_op;
17481731
}
17491732

1750-
opdesc = OPDESC(op);
1751-
17521733
if (!current_fh->fh_dentry) {
1753-
if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
1734+
if (!(op->opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
17541735
op->status = nfserr_nofilehandle;
17551736
goto encode_op;
17561737
}
17571738
} else if (current_fh->fh_export->ex_fslocs.migrated &&
1758-
!(opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) {
1739+
!(op->opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) {
17591740
op->status = nfserr_moved;
17601741
goto encode_op;
17611742
}
17621743

17631744
fh_clear_wcc(current_fh);
17641745

17651746
/* If op is non-idempotent */
1766-
if (opdesc->op_flags & OP_MODIFIES_SOMETHING) {
1747+
if (op->opdesc->op_flags & OP_MODIFIES_SOMETHING) {
17671748
/*
17681749
* Don't execute this op if we couldn't encode a
17691750
* succesful reply:
17701751
*/
1771-
u32 plen = opdesc->op_rsize_bop(rqstp, op);
1752+
u32 plen = op->opdesc->op_rsize_bop(rqstp, op);
17721753
/*
17731754
* Plus if there's another operation, make sure
17741755
* we'll have space to at least encode an error:
@@ -1781,9 +1762,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
17811762
if (op->status)
17821763
goto encode_op;
17831764

1784-
if (opdesc->op_get_currentstateid)
1785-
opdesc->op_get_currentstateid(cstate, &op->u);
1786-
op->status = opdesc->op_func(rqstp, cstate, &op->u);
1765+
if (op->opdesc->op_get_currentstateid)
1766+
op->opdesc->op_get_currentstateid(cstate, &op->u);
1767+
op->status = op->opdesc->op_func(rqstp, cstate, &op->u);
17871768

17881769
/* Only from SEQUENCE */
17891770
if (cstate->status == nfserr_replay_cache) {
@@ -1792,10 +1773,10 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
17921773
goto out;
17931774
}
17941775
if (!op->status) {
1795-
if (opdesc->op_set_currentstateid)
1796-
opdesc->op_set_currentstateid(cstate, &op->u);
1776+
if (op->opdesc->op_set_currentstateid)
1777+
op->opdesc->op_set_currentstateid(cstate, &op->u);
17971778

1798-
if (opdesc->op_flags & OP_CLEAR_STATEID)
1779+
if (op->opdesc->op_flags & OP_CLEAR_STATEID)
17991780
clear_current_stateid(cstate);
18001781

18011782
if (need_wrongsec_check(rqstp))
@@ -2160,13 +2141,15 @@ static const struct nfsd4_operation nfsd4_ops[] = {
21602141
},
21612142
[OP_LOCK] = {
21622143
.op_func = nfsd4_lock,
2163-
.op_flags = OP_MODIFIES_SOMETHING,
2144+
.op_flags = OP_MODIFIES_SOMETHING |
2145+
OP_NONTRIVIAL_ERROR_ENCODE,
21642146
.op_name = "OP_LOCK",
21652147
.op_rsize_bop = nfsd4_lock_rsize,
21662148
.op_set_currentstateid = nfsd4_set_lockstateid,
21672149
},
21682150
[OP_LOCKT] = {
21692151
.op_func = nfsd4_lockt,
2152+
.op_flags = OP_NONTRIVIAL_ERROR_ENCODE,
21702153
.op_name = "OP_LOCKT",
21712154
.op_rsize_bop = nfsd4_lock_rsize,
21722155
},
@@ -2238,6 +2221,7 @@ static const struct nfsd4_operation nfsd4_ops[] = {
22382221
},
22392222
[OP_READ] = {
22402223
.op_func = nfsd4_read,
2224+
.op_release = nfsd4_read_release,
22412225
.op_name = "OP_READ",
22422226
.op_rsize_bop = nfsd4_read_rsize,
22432227
.op_get_currentstateid = nfsd4_get_readstateid,
@@ -2287,21 +2271,24 @@ static const struct nfsd4_operation nfsd4_ops[] = {
22872271
},
22882272
[OP_SECINFO] = {
22892273
.op_func = nfsd4_secinfo,
2274+
.op_release = nfsd4_secinfo_release,
22902275
.op_flags = OP_HANDLES_WRONGSEC,
22912276
.op_name = "OP_SECINFO",
22922277
.op_rsize_bop = nfsd4_secinfo_rsize,
22932278
},
22942279
[OP_SETATTR] = {
22952280
.op_func = nfsd4_setattr,
22962281
.op_name = "OP_SETATTR",
2297-
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
2282+
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME
2283+
| OP_NONTRIVIAL_ERROR_ENCODE,
22982284
.op_rsize_bop = nfsd4_setattr_rsize,
22992285
.op_get_currentstateid = nfsd4_get_setattrstateid,
23002286
},
23012287
[OP_SETCLIENTID] = {
23022288
.op_func = nfsd4_setclientid,
23032289
.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
2304-
| OP_MODIFIES_SOMETHING | OP_CACHEME,
2290+
| OP_MODIFIES_SOMETHING | OP_CACHEME
2291+
| OP_NONTRIVIAL_ERROR_ENCODE,
23052292
.op_name = "OP_SETCLIENTID",
23062293
.op_rsize_bop = nfsd4_setclientid_rsize,
23072294
},
@@ -2388,6 +2375,7 @@ static const struct nfsd4_operation nfsd4_ops[] = {
23882375
},
23892376
[OP_SECINFO_NO_NAME] = {
23902377
.op_func = nfsd4_secinfo_no_name,
2378+
.op_release = nfsd4_secinfo_release,
23912379
.op_flags = OP_HANDLES_WRONGSEC,
23922380
.op_name = "OP_SECINFO_NO_NAME",
23932381
.op_rsize_bop = nfsd4_secinfo_rsize,
@@ -2408,12 +2396,14 @@ static const struct nfsd4_operation nfsd4_ops[] = {
24082396
#ifdef CONFIG_NFSD_PNFS
24092397
[OP_GETDEVICEINFO] = {
24102398
.op_func = nfsd4_getdeviceinfo,
2399+
.op_release = nfsd4_getdeviceinfo_release,
24112400
.op_flags = ALLOWED_WITHOUT_FH,
24122401
.op_name = "OP_GETDEVICEINFO",
24132402
.op_rsize_bop = nfsd4_getdeviceinfo_rsize,
24142403
},
24152404
[OP_LAYOUTGET] = {
24162405
.op_func = nfsd4_layoutget,
2406+
.op_release = nfsd4_layoutget_release,
24172407
.op_flags = OP_MODIFIES_SOMETHING,
24182408
.op_name = "OP_LAYOUTGET",
24192409
.op_rsize_bop = nfsd4_layoutget_rsize,

0 commit comments

Comments
 (0)