Skip to content

Commit a289ce5

Browse files
vaverinJ. Bruce Fields
authored andcommitted
sunrpc: replace svc_serv->sv_bc_xprt by boolean flag
svc_serv-> sv_bc_xprt is netns-unsafe and cannot be used as pointer. To prevent its misuse in future it is replaced by new boolean flag. Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent d4b09ac commit a289ce5

5 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎fs/nfs/callback.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
206206
goto err_bind;
207207
}
208208

209-
ret = -EPROTONOSUPPORT;
209+
ret = 0;
210210
if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0)
211211
ret = nfs4_callback_up_net(serv, net);
212-
else if (xprt->ops->bc_up)
213-
ret = xprt->ops->bc_up(serv, net);
212+
else if (xprt->ops->bc_setup)
213+
serv->sv_bc_enabled = true;
214+
else
215+
ret = -EPROTONOSUPPORT;
214216

215217
if (ret < 0) {
216218
printk(KERN_ERR "NFS: callback service start failed\n");

‎include/linux/sunrpc/bc_xprt.h‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ void xprt_free_bc_rqst(struct rpc_rqst *req);
4747
/*
4848
* Determine if a shared backchannel is in use
4949
*/
50-
static inline int svc_is_backchannel(const struct svc_rqst *rqstp)
50+
static inline bool svc_is_backchannel(const struct svc_rqst *rqstp)
5151
{
52-
if (rqstp->rq_server->sv_bc_xprt)
53-
return 1;
54-
return 0;
52+
return rqstp->rq_server->sv_bc_enabled;
5553
}
5654
#else /* CONFIG_SUNRPC_BACKCHANNEL */
5755
static inline int xprt_setup_backchannel(struct rpc_xprt *xprt,
@@ -60,9 +58,9 @@ static inline int xprt_setup_backchannel(struct rpc_xprt *xprt,
6058
return 0;
6159
}
6260

63-
static inline int svc_is_backchannel(const struct svc_rqst *rqstp)
61+
static inline bool svc_is_backchannel(const struct svc_rqst *rqstp)
6462
{
65-
return 0;
63+
return false;
6664
}
6765

6866
static inline void xprt_free_bc_request(struct rpc_rqst *req)

‎include/linux/sunrpc/svc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct svc_serv {
109109
spinlock_t sv_cb_lock; /* protects the svc_cb_list */
110110
wait_queue_head_t sv_cb_waitq; /* sleep here if there are no
111111
* entries in the svc_cb_list */
112-
struct svc_xprt *sv_bc_xprt; /* callback on fore channel */
112+
bool sv_bc_enabled; /* service uses backchannel */
113113
#endif /* CONFIG_SUNRPC_BACKCHANNEL */
114114
};
115115

‎net/sunrpc/svcsock.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,8 +1623,6 @@ static struct svc_xprt *svc_bc_create_socket(struct svc_serv *serv,
16231623
svc_xprt_init(net, &svc_tcp_bc_class, xprt, serv);
16241624
set_bit(XPT_CONG_CTRL, &svsk->sk_xprt.xpt_flags);
16251625

1626-
serv->sv_bc_xprt = xprt;
1627-
16281626
return xprt;
16291627
}
16301628

‎net/sunrpc/xprtrdma/svc_rdma_transport.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ static struct svc_xprt *svc_rdma_bc_create(struct svc_serv *serv,
136136

137137
svc_xprt_init(net, &svc_rdma_bc_class, xprt, serv);
138138
set_bit(XPT_CONG_CTRL, &xprt->xpt_flags);
139-
serv->sv_bc_xprt = xprt;
140139

141140
dprintk("svcrdma: %s(%p)\n", __func__, xprt);
142141
return xprt;

0 commit comments

Comments
 (0)