public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Cabrero <scabrero@suse.de>
To: linux-cifs@vger.kernel.org
Cc: Samuel Cabrero <scabrero@suse.de>
Subject: [PATCH v2 08/11] cifs: Send witness register messages to userspace daemon in echo task
Date: Tue, 27 Oct 2020 11:08:04 +0100	[thread overview]
Message-ID: <20201027100807.21510-9-scabrero@suse.de> (raw)
In-Reply-To: <20201027100807.21510-1-scabrero@suse.de>

If the daemon starts after mounting a share, or if it crashes, this
provides a mechanism to register again.

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
---
 fs/cifs/cifs_swn.c | 15 +++++++++++++++
 fs/cifs/cifs_swn.h |  2 ++
 fs/cifs/connect.c  |  5 +++++
 3 files changed, 22 insertions(+)

diff --git a/fs/cifs/cifs_swn.c b/fs/cifs/cifs_swn.c
index 4396e21ef228..93e31e4a9d99 100644
--- a/fs/cifs/cifs_swn.c
+++ b/fs/cifs/cifs_swn.c
@@ -536,3 +536,18 @@ void cifs_swn_dump(struct seq_file *m)
 	mutex_unlock(&cifs_swnreg_idr_mutex);
 	seq_puts(m, "\n");
 }
+
+void cifs_swn_check(void)
+{
+	struct cifs_swn_reg *swnreg;
+	int id;
+	int ret;
+
+	mutex_lock(&cifs_swnreg_idr_mutex);
+	idr_for_each_entry(&cifs_swnreg_idr, swnreg, id) {
+		ret = cifs_swn_send_register_message(swnreg);
+		if (ret < 0)
+			cifs_dbg(FYI, "%s: Failed to send register message: %d\n", __func__, ret);
+	}
+	mutex_unlock(&cifs_swnreg_idr_mutex);
+}
diff --git a/fs/cifs/cifs_swn.h b/fs/cifs/cifs_swn.h
index 13b25cdc9295..236ecd4959d5 100644
--- a/fs/cifs/cifs_swn.h
+++ b/fs/cifs/cifs_swn.h
@@ -20,4 +20,6 @@ extern int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
 
 extern void cifs_swn_dump(struct seq_file *m);
 
+extern void cifs_swn_check(void);
+
 #endif /* _CIFS_SWN_H */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 0e3a88932560..cb9ca4238ae9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -613,6 +613,11 @@ cifs_echo_request(struct work_struct *work)
 		cifs_dbg(FYI, "Unable to send echo request to server: %s\n",
 			 server->hostname);
 
+#ifdef CONFIG_CIFS_SWN_UPCALL
+	/* Check witness registrations */
+	cifs_swn_check();
+#endif
+
 requeue_echo:
 	queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
 }
-- 
2.29.0


  parent reply	other threads:[~2020-10-27 10:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 10:07 [PATCH v2 00/11] Witness protocol support for transparent failover Samuel Cabrero
2020-10-27 10:07 ` [PATCH v2 01/11] cifs: Make extract_hostname function public Samuel Cabrero
2020-10-27 10:07 ` [PATCH v2 02/11] cifs: Make extract_sharename " Samuel Cabrero
2020-10-27 10:07 ` [PATCH v2 03/11] cifs: Register generic netlink family Samuel Cabrero
2020-10-27 11:49   ` kernel test robot
2020-10-27 10:08 ` [PATCH v2 04/11] cifs: add witness mount option and data structs Samuel Cabrero
2020-10-27 10:08 ` [PATCH v2 05/11] cifs: Send witness register and unregister commands to userspace daemon Samuel Cabrero
2020-10-27 10:08 ` [PATCH v2 06/11] cifs: Set witness notification handler for messages from " Samuel Cabrero
2020-10-27 10:08 ` [PATCH v2 07/11] cifs: Add witness information to debug data dump Samuel Cabrero
2020-10-27 10:08 ` Samuel Cabrero [this message]
2020-10-27 10:08 ` [PATCH v2 09/11] cifs: Simplify reconnect code when dfs upcall is enabled Samuel Cabrero
2020-10-27 10:08 ` [PATCH v2 10/11] cifs: Handle witness client move notification Samuel Cabrero
2020-10-27 10:08 ` [PATCH v2 11/11] cifs: Handle witness share moved notification Samuel Cabrero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201027100807.21510-9-scabrero@suse.de \
    --to=scabrero@suse.de \
    --cc=linux-cifs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox