From f472c0bc87b388c20300a05b0691bf7cd1d61da7 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 9 Jan 2019 16:43:45 -0800 Subject: [PATCH] scoutfs: add scoutfs_net_response_node() Today all responses can only be sent down the connection that sent the response while the request is being processed. We'll be adding subsystems that need to send responses asynchronously after initial request processing. Give them a call to send a response to a node id instead of to a node's connection. Signed-off-by: Zach Brown --- kmod/src/net.c | 15 +++++++++++++++ kmod/src/net.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/kmod/src/net.c b/kmod/src/net.c index a217e19c..14c763a9 100644 --- a/kmod/src/net.c +++ b/kmod/src/net.c @@ -1353,6 +1353,21 @@ int scoutfs_net_response(struct super_block *sb, NULL, NULL, NULL); } +int scoutfs_net_response_node(struct super_block *sb, + struct scoutfs_net_connection *conn, + u64 node_id, u8 cmd, u64 id, int error, + void *resp, u16 resp_len) +{ + if (error) { + resp = NULL; + resp_len = 0; + } + + return submit_send(sb, conn, node_id, cmd, SCOUTFS_NET_FLAG_RESPONSE, + id, net_err_from_host(sb, error), resp, resp_len, + NULL, NULL, NULL); +} + /* * The response function that was submitted with the request is not * called if the request is canceled here. diff --git a/kmod/src/net.h b/kmod/src/net.h index cbbd29bc..b59db537 100644 --- a/kmod/src/net.h +++ b/kmod/src/net.h @@ -58,6 +58,10 @@ int scoutfs_net_sync_request(struct super_block *sb, int scoutfs_net_response(struct super_block *sb, struct scoutfs_net_connection *conn, u8 cmd, u64 id, int error, void *resp, u16 resp_len); +int scoutfs_net_response_node(struct super_block *sb, + struct scoutfs_net_connection *conn, + u64 node_id, u8 cmd, u64 id, int error, + void *resp, u16 resp_len); void scoutfs_net_shutdown(struct super_block *sb, struct scoutfs_net_connection *conn); void scoutfs_net_free_conn(struct super_block *sb,