Skip to content

Commit 0ae93b9

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
SUNRPC: Simplify the SVC dispatch code path
Micro-optimization: The last user of the generic SVC dispatch code path has been removed, so svc_process_common() can be simplified. This declutters the hot path so that the by-far most common case (a dispatch function exists) is made the /only/ path. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 35940a5 commit 0ae93b9

File tree

2 files changed

+3
-53
lines changed

2 files changed

+3
-53
lines changed

include/linux/sunrpc/svc.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,7 @@ struct svc_version {
443443
/* Need xprt with congestion control */
444444
bool vs_need_cong_ctrl;
445445

446-
/* Override dispatch function (e.g. when caching replies).
447-
* A return value of 0 means drop the request.
448-
* vs_dispatch == NULL means use default dispatcher.
449-
*/
446+
/* Dispatch function */
450447
int (*vs_dispatch)(struct svc_rqst *, __be32 *);
451448
};
452449

net/sunrpc/svc.c

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,45 +1186,6 @@ void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
11861186
static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {}
11871187
#endif
11881188

1189-
static int
1190-
svc_generic_dispatch(struct svc_rqst *rqstp, __be32 *statp)
1191-
{
1192-
struct kvec *argv = &rqstp->rq_arg.head[0];
1193-
struct kvec *resv = &rqstp->rq_res.head[0];
1194-
const struct svc_procedure *procp = rqstp->rq_procinfo;
1195-
1196-
/*
1197-
* Decode arguments
1198-
* XXX: why do we ignore the return value?
1199-
*/
1200-
if (procp->pc_decode &&
1201-
!procp->pc_decode(rqstp, argv->iov_base)) {
1202-
*statp = rpc_garbage_args;
1203-
return 1;
1204-
}
1205-
1206-
*statp = procp->pc_func(rqstp);
1207-
1208-
if (*statp == rpc_drop_reply ||
1209-
test_bit(RQ_DROPME, &rqstp->rq_flags))
1210-
return 0;
1211-
1212-
if (rqstp->rq_auth_stat != rpc_auth_ok)
1213-
return 1;
1214-
1215-
if (*statp != rpc_success)
1216-
return 1;
1217-
1218-
/* Encode reply */
1219-
if (procp->pc_encode &&
1220-
!procp->pc_encode(rqstp, resv->iov_base + resv->iov_len)) {
1221-
dprintk("svc: failed to encode reply\n");
1222-
/* serv->sv_stats->rpcsystemerr++; */
1223-
*statp = rpc_system_err;
1224-
}
1225-
return 1;
1226-
}
1227-
12281189
__be32
12291190
svc_generic_init_request(struct svc_rqst *rqstp,
12301191
const struct svc_program *progp,
@@ -1392,16 +1353,8 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
13921353
svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
13931354

13941355
/* Call the function that processes the request. */
1395-
if (!process.dispatch) {
1396-
if (!svc_generic_dispatch(rqstp, statp))
1397-
goto release_dropit;
1398-
if (*statp == rpc_garbage_args)
1399-
goto err_garbage;
1400-
} else {
1401-
dprintk("svc: calling dispatcher\n");
1402-
if (!process.dispatch(rqstp, statp))
1403-
goto release_dropit; /* Release reply info */
1404-
}
1356+
if (!process.dispatch(rqstp, statp))
1357+
goto release_dropit;
14051358

14061359
if (rqstp->rq_auth_stat != rpc_auth_ok)
14071360
goto err_release_bad_auth;

0 commit comments

Comments
 (0)