All of lore.kernel.org
 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 1/3] ksmbd: request update to stale share config
Date: Mon,  8 Aug 2022 05:43:39 +0300	[thread overview]
Message-ID: <20220808024341.63913-1-atteh.mailbox@gmail.com> (raw)

ksmbd_share_config_get() retrieves the cached share config as long
as there is at least one connection to the share. This is an issue when
the user space utilities are used to update share configs. In that case
there is a need to inform ksmbd that it should not use the cached share
config for a new connection to the share. With these changes the tree
connection flag KSMBD_TREE_CONN_FLAG_UPDATE indicates this. When this
flag is set, ksmbd removes the share config from the shares hash table
meaning that ksmbd_share_config_get() ends up requesting a share config
from user space.

Signed-off-by: Atte Heikkilä <atteh.mailbox@gmail.com>
---
 ksmbd_netlink.h     |  2 ++
 mgmt/share_config.c |  6 +++++-
 mgmt/share_config.h |  1 +
 mgmt/tree_connect.c | 14 ++++++++++++++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/ksmbd_netlink.h b/ksmbd_netlink.h
index 192cb13..5d77b72 100644
--- a/ksmbd_netlink.h
+++ b/ksmbd_netlink.h
@@ -349,6 +349,7 @@ enum KSMBD_TREE_CONN_STATUS {
 #define KSMBD_SHARE_FLAG_STREAMS		BIT(11)
 #define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS	BIT(12)
 #define KSMBD_SHARE_FLAG_ACL_XATTR		BIT(13)
+#define KSMBD_SHARE_FLAG_UPDATE 		BIT(14)
 
 /*
  * Tree connect request flags.
@@ -364,6 +365,7 @@ enum KSMBD_TREE_CONN_STATUS {
 #define KSMBD_TREE_CONN_FLAG_READ_ONLY		BIT(1)
 #define KSMBD_TREE_CONN_FLAG_WRITABLE		BIT(2)
 #define KSMBD_TREE_CONN_FLAG_ADMIN_ACCOUNT	BIT(3)
+#define KSMBD_TREE_CONN_FLAG_UPDATE		BIT(4)
 
 /*
  * RPC over IPC.
diff --git a/mgmt/share_config.c b/mgmt/share_config.c
index 70655af..c9bca1c 100644
--- a/mgmt/share_config.c
+++ b/mgmt/share_config.c
@@ -51,12 +51,16 @@ static void kill_share(struct ksmbd_share_config *share)
 	kfree(share);
 }
 
-void __ksmbd_share_config_put(struct ksmbd_share_config *share)
+void ksmbd_share_config_del(struct ksmbd_share_config *share)
 {
 	down_write(&shares_table_lock);
 	hash_del(&share->hlist);
 	up_write(&shares_table_lock);
+}
 
+void __ksmbd_share_config_put(struct ksmbd_share_config *share)
+{
+	ksmbd_share_config_del(share);
 	kill_share(share);
 }
 
diff --git a/mgmt/share_config.h b/mgmt/share_config.h
index 28bf351..902f2cb 100644
--- a/mgmt/share_config.h
+++ b/mgmt/share_config.h
@@ -64,6 +64,7 @@ static inline int test_share_config_flag(struct ksmbd_share_config *share,
 	return share->flags & flag;
 }
 
+void ksmbd_share_config_del(struct ksmbd_share_config *share);
 void __ksmbd_share_config_put(struct ksmbd_share_config *share);
 
 static inline void ksmbd_share_config_put(struct ksmbd_share_config *share)
diff --git a/mgmt/tree_connect.c b/mgmt/tree_connect.c
index 7d467e1..0cf6265 100644
--- a/mgmt/tree_connect.c
+++ b/mgmt/tree_connect.c
@@ -65,6 +65,20 @@ ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
 	}
 
 	tree_conn->flags = resp->connection_flags;
+	if (test_tree_conn_flag(tree_conn, KSMBD_TREE_CONN_FLAG_UPDATE)) {
+		struct ksmbd_share_config *new_sc;
+
+		ksmbd_share_config_del(sc);
+		new_sc = ksmbd_share_config_get(share_name);
+		if (!new_sc) {
+			pr_err("Failed to update stale share config\n");
+			status.ret = -ESTALE;
+			goto out_error;
+		}
+		ksmbd_share_config_put(sc);
+		sc = new_sc;
+	}
+
 	tree_conn->user = sess->user;
 	tree_conn->share_conf = sc;
 	status.tree_conn = tree_conn;
-- 
2.37.1


             reply	other threads:[~2022-08-08  2:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  2:43 atheik [this message]
2022-08-08  2:43 ` [PATCH 2/3] ksmbd-tools: cleanup config group handling atheik
2022-08-08  5:18   ` Hyunchul Lee
2022-08-08  2:43 ` [PATCH 3/3] ksmbd-tools: inform ksmbd of stale share config atheik
2022-08-08  5:19   ` Hyunchul Lee
2022-08-08  4:57 ` [PATCH 1/3] ksmbd: request update to " Hyunchul Lee
2022-08-08 13:06   ` 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=20220808024341.63913-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.