Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: atheik <atteh.mailbox@gmail.com>
To: linux-cifs@vger.kernel.org
Cc: atheik <atteh.mailbox@gmail.com>
Subject: [PATCH v2 3/3] ksmbd-tools: inform ksmbd of stale share config
Date: Tue,  9 Aug 2022 01:02:16 +0300	[thread overview]
Message-ID: <20220808220216.17235-3-atteh.mailbox@gmail.com> (raw)
In-Reply-To: <20220808220216.17235-1-atteh.mailbox@gmail.com>

When initializing a share from a group, flag the share with
KSMBD_SHARE_FLAG_UPDATE if the group callback mode denotes that the
config file was reloaded. If the share was flagged, then later when
handling a tree connect request, flag the connection with
KSMBD_TREE_CONN_FLAG_UPDATE to inform ksmbd that its cached share
config is stale. If there are no failures when handling the request,
remove the share flag.

Signed-off-by: Atte Heikkilä <atteh.mailbox@gmail.com>
---
 include/linux/ksmbd_server.h | 2 ++
 lib/management/share.c       | 3 +++
 lib/management/tree_conn.c   | 8 +++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/ksmbd_server.h b/include/linux/ksmbd_server.h
index 6705dac..7e86d5d 100644
--- a/include/linux/ksmbd_server.h
+++ b/include/linux/ksmbd_server.h
@@ -235,6 +235,7 @@ enum KSMBD_TREE_CONN_STATUS {
 #define KSMBD_SHARE_FLAG_STREAMS		(1 << 11)
 #define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS	(1 << 12)
 #define KSMBD_SHARE_FLAG_ACL_XATTR		(1 << 13)
+#define KSMBD_SHARE_FLAG_UPDATE 		(1 << 14)
 
 /*
  * Tree connect request flags.
@@ -250,6 +251,7 @@ enum KSMBD_TREE_CONN_STATUS {
 #define KSMBD_TREE_CONN_FLAG_READ_ONLY		(1 << 1)
 #define KSMBD_TREE_CONN_FLAG_WRITABLE		(1 << 2)
 #define KSMBD_TREE_CONN_FLAG_ADMIN_ACCOUNT	(1 << 3)
+#define KSMBD_TREE_CONN_FLAG_UPDATE		(1 << 4)
 
 /*
  * RPC over IPC.
diff --git a/lib/management/share.c b/lib/management/share.c
index acd6d3f..e9492b5 100644
--- a/lib/management/share.c
+++ b/lib/management/share.c
@@ -605,6 +605,9 @@ static void init_share_from_group(struct ksmbd_share *share,
 	if (!g_ascii_strcasecmp(share->name, "ipc$"))
 		set_share_flag(share, KSMBD_SHARE_FLAG_PIPE);
 
+	if (group->cb_mode == GROUPS_CALLBACK_REINIT)
+		set_share_flag(share, KSMBD_SHARE_FLAG_UPDATE);
+
 	g_hash_table_foreach(group->kv, process_group_kv, share);
 
 	fixup_missing_fields(share);
diff --git a/lib/management/tree_conn.c b/lib/management/tree_conn.c
index 10304d1..f5c5749 100644
--- a/lib/management/tree_conn.c
+++ b/lib/management/tree_conn.c
@@ -73,6 +73,8 @@ int tcm_handle_tree_connect(struct ksmbd_tree_connect_request *req,
 		set_conn_flag(conn, KSMBD_TREE_CONN_FLAG_WRITABLE);
 	if (test_share_flag(share, KSMBD_SHARE_FLAG_READONLY))
 		set_conn_flag(conn, KSMBD_TREE_CONN_FLAG_READ_ONLY);
+	if (test_share_flag(share, KSMBD_SHARE_FLAG_UPDATE))
+		set_conn_flag(conn, KSMBD_TREE_CONN_FLAG_UPDATE);
 
 	if (shm_open_connection(share)) {
 		resp->status = KSMBD_TREE_CONN_STATUS_TOO_MANY_CONNS;
@@ -207,8 +209,12 @@ bind:
 		tcm_tree_conn_free(conn);
 		put_ksmbd_user(user);
 	}
+
+	g_rw_lock_writer_lock(&share->update_lock);
+	clear_share_flag(share, KSMBD_SHARE_FLAG_UPDATE);
+	g_rw_lock_writer_unlock(&share->update_lock);
+
 	return 0;
-
 out_error:
 	tcm_tree_conn_free(conn);
 	shm_close_connection(share);
-- 
2.37.1


  parent reply	other threads:[~2022-08-08 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 22:02 [PATCH v2 1/3] ksmbd: request update to stale share config atheik
2022-08-08 22:02 ` [PATCH v2 2/3] ksmbd-tools: cleanup config group handling atheik
2022-08-08 22:02 ` atheik [this message]
2022-08-10  8:06   ` [PATCH v2 3/3] ksmbd-tools: inform ksmbd of stale share config Namjae Jeon
2022-08-09  0:38 ` [PATCH v2 1/3] ksmbd: request update to " Namjae Jeon

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=20220808220216.17235-3-atteh.mailbox@gmail.com \
    --to=atteh.mailbox@gmail.com \
    --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