From b4ede2ac6a52c92fc667d3a9a96d189ad663428b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 6 Jul 2021 15:38:09 -0700 Subject: [PATCH] Allow omap responses to disconnected originators The omap message lifecycle is a little different than the server's usual handling that sends a response from the request handler. The response is sent long after the initial receive handler is pinning the connection to the client. It's fine for the response to be dropped. The main server request handler handled this case but other response senders didn't. Put this error handling in the server response sender itself so that all callers are covered. Signed-off-by: Zach Brown --- kmod/src/omap.c | 4 ---- kmod/src/server.c | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/kmod/src/omap.c b/kmod/src/omap.c index 0bd14dcf..529cfda4 100644 --- a/kmod/src/omap.c +++ b/kmod/src/omap.c @@ -595,10 +595,6 @@ out: free_req(req); } - /* it's fine if we couldn't send to a client that left */ - if (ret == -ENOTCONN) - ret = 0; - return ret; } diff --git a/kmod/src/server.c b/kmod/src/server.c index 0bcabc45..c0be71fd 100644 --- a/kmod/src/server.c +++ b/kmod/src/server.c @@ -2366,15 +2366,27 @@ int scoutfs_server_send_omap_request(struct super_block *sb, u64 rid, open_ino_map_response, NULL, NULL); } -/* The server is sending an omap response to the client */ +/* + * The server is sending an omap response to the client that originated + * the request. These responses are sent long after the incoming + * request has pinned the client connection and guaranteed that we'll be + * able to queue a response. This can race with the client connection + * being torn down and it's OK if we drop the response. Either the + * client is being evicted and we don't care about them anymore or we're + * tearing down in unmount and the client will resend to thee next + * server. + */ int scoutfs_server_send_omap_response(struct super_block *sb, u64 rid, u64 id, struct scoutfs_open_ino_map *map, int err) { struct server_info *server = SCOUTFS_SB(sb)->server_info; + int ret; - return scoutfs_net_response_node(sb, server->conn, rid, - SCOUTFS_NET_CMD_OPEN_INO_MAP, id, err, - map, sizeof(*map)); + ret = scoutfs_net_response_node(sb, server->conn, rid, SCOUTFS_NET_CMD_OPEN_INO_MAP, + id, err, map, sizeof(*map)); + if (ret == -ENOTCONN) + ret = 0; + return ret; } /* The server is receiving an omap request from the client */