From 63a39c764181e60bc7bd8236996cf9abe353d906 Mon Sep 17 00:00:00 2001 From: Shreyas Siravara Date: Fri, 26 Feb 2016 20:59:00 -0800 Subject: nfs: Tear down transports for requests that arrive before the volume is initialized Summary: - Disconnects RPC transports for requests that cannot be serviced because volumes are not ready. - This is a cherry-pick of D2991403 Signed-off-by: Shreyas Siravara Change-Id: I07ff0795b81d25624541ff981b5f2586d078e9a6 BUG: 1428068 Reviewed-on: http://review.gluster.org/16154 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Kevin Vigor CentOS-regression: Gluster Build System Reviewed-on: https://review.gluster.org/16805 Reviewed-by: Amar Tumballi Tested-by: Jeff Darcy Reviewed-by: Jeff Darcy --- xlators/nfs/server/src/nfs3.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'xlators/nfs') diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index cbc69c7af7f..729f811c917 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -413,6 +413,28 @@ out: } +/* + * This macro checks if the volume is started or not. + * If it is not started, it closes the client connection & logs it. + * + * Why do we do this? + * + * There is a "race condition" where gNFSd may start listening for RPC requests + * prior to the volume being started. Presumably, that is why this macro exists + * in the first place. In the NFS kernel client (specifically Linux's NFS + * kernel client), they establish a TCP connection to our endpoint and + * (re-)send requests. If we ignore the request, and return nothing back, + * the NFS kernel client waits forever for our response. If for some reason, + * the TCP connection were to die, and re-establish, the requests are + * retransmitted and everything begins working as expected + * + * Now, this is clearly bad behavior on the client side, + * but in order to make every user's life easier, + * gNFSd should simply disconnect the TCP connection if it sees requests + * before it is ready to accept them. + * + */ + #define nfs3_volume_started_check(nf3stt, vlm, rtval, erlbl) \ do { \ if ((!nfs_subvolume_started (nfs_state (nf3stt->nfsx), vlm))){\ @@ -420,11 +442,32 @@ out: NFS_MSG_VOL_DISABLE, \ "Volume is disabled: %s", \ vlm->name); \ + nfs3_disconnect_transport (req->trans); \ rtval = RPCSVC_ACTOR_IGNORE; \ goto erlbl; \ } \ } while (0) \ +void +nfs3_disconnect_transport (rpc_transport_t *transport) +{ + int ret = 0; + + GF_VALIDATE_OR_GOTO (GF_NFS3, transport, out); + + ret = rpc_transport_disconnect (transport, _gf_false); + if (ret != 0) { + gf_log (GF_NFS3, GF_LOG_WARNING, + "Unable to close client connection to %s.", + transport->peerinfo.identifier); + } else { + gf_log (GF_NFS3, GF_LOG_WARNING, + "Closed client connection to %s.", + transport->peerinfo.identifier); + } +out: + return; +} int nfs3_export_sync_trusted (struct nfs3_state *nfs3, uuid_t exportid) -- cgit