Skip to contentSkip to conversation

dlm: net-namespace functionality

PATCH In review Alexander Aring 3 participants 17 messages Sep 30, 2024 – Oct 11, 2024

Subsystems (9)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

v2 cover dlm: net-namespace functionality

Hi,

this patch-series is huge but brings a lot of basic "fun" net-namespace functionality to DLM. Currently you need a couple of Linux kernel instances running in e.g. Virtual Machines. With this patch-series I want to break out of this virtual machine world dealing with multiple kernels need to boot them all individually, etc. Now you can use DLM in only one Linux kernel instance and each "node" (previously represented by a virtual machine) is separate by a net-namespace. Why net-namespaces? It just fits to the DLM design for now, you need to have them anyway because the internal DLM socket handling on a per node basis. What we do additionally is to separate the DLM lockspaces (the lockspace that is being registered) by net-namespaces as this represents a "network entity" (node). There might be reasons to introduce a complete new kind of namespaces (locking namespace?) but I don't want to do this step now and as I said net-namespaces are required anyway for the DLM sockets.

You need some new user space tooling as a new netlink net-namespace aware UAPI is introduced (but can co-exist with configfs that operates on init_net only). See [0] for more steps, there is a copr repo for the new tooling and can be enabled by:

$ dnf copr enable aring/nldlm
$ dnf install nldlm

or compile it yourself.

Then there is currently a very simple script [1] to show a 3 nodes cluster using gfs2 on a multiple loop block devices on a shared loop block device image (sounds weird but I do something like that). There are currently some user space synchronization issues that I solve by simple sleeps, but they are only user space problems.

To test it I recommend some virtual machine "but only one" and run the
[1] script. Afterwards you have in your executed net-namespace the 3 mountpoints /cluster/node1, /cluster/node2/ and /cluster/node3. Any vfs operations on those mountpoints acts as a per node entity operation.

We can use it for testing, development and also scale testing to have a large number of nodes joining a lockspace (which seems to be a problem right now). Instead of running 1000 vms, we can run 1000 net-namespaces in a more resource limited environment. For me it seems gfs2 can handle several mounts and still separate the resource according their global variables. Their data structures e.g. glock hash seems to have in their key a separation for that (fsid?). However this is still an experimental feature we might run into issues that requires more separation related to net-namespaces. However basic testing seems to run just fine.

Limitations

I disable any functionality for the DLM character device that allow plock handling or do DLM locking from user space. Just don't use any plock locking in gfs2 for now. But basic vfs operations should work. You can even sniff DLM traffic on the created "dlmsw" virtual bridge.

- Alex

[0] https://gitlab.com/netcoder/nldlm
[1] https://gitlab.com/netcoder/gfs2ns-examples/-/blob/main/three_nodes

changes since v2:
- move to ynl and introduce and use netlink yaml spec
- put the nldlm.h DLM netlink header under UAPI directory
- fix build issues building with CONFIG_NET disabled
- fix possible nullpointer deference if lookup of lockspace failed

Alexander Aring (12):
dlm: introduce dlm_find_lockspace_name()
dlm: disallow different configs nodeid storages
dlm: add struct net to dlm_new_lockspace()
dlm: handle port as __be16 network byte order
dlm: use dlm_config as only cluster configuration
dlm: dlm_config_info config fields to unsigned int
dlm: rename config to configfs
kobject: add kset_type_create_and_add() helper
kobject: export generic helper ops
dlm: separate dlm lockspaces per net-namespace
dlm: add nldlm net-namespace aware UAPI
gfs2: separate mount context by net-namespaces

 Documentation/netlink/specs/nldlm.yaml |  438 ++++++++
 drivers/md/md-cluster.c                |    3 +-
 fs/dlm/Makefile                        |    3 +
 fs/dlm/config.c                        | 1291 +++++++++--------------
 fs/dlm/config.h                        |  215 +++-
 fs/dlm/configfs.c                      |  882 ++++++++++++++++
 fs/dlm/configfs.h                      |   19 +
 fs/dlm/debug_fs.c                      |   24 +-
 fs/dlm/dir.c                           |    4 +-
 fs/dlm/dlm_internal.h                  |   24 +-
 fs/dlm/lock.c                          |   64 +-
 fs/dlm/lock.h                          |    3 +-
 fs/dlm/lockspace.c                     |  220 ++--
 fs/dlm/lockspace.h                     |   12 +-
 fs/dlm/lowcomms.c                      |  525 +++++-----
 fs/dlm/lowcomms.h                      |   29 +-
 fs/dlm/main.c                          |    5 -
 fs/dlm/member.c                        |   36 +-
 fs/dlm/midcomms.c                      |  287 ++---
 fs/dlm/midcomms.h                      |   31 +-
 fs/dlm/netlink2.c                      | 1330 ++++++++++++++++++++++++
 fs/dlm/nldlm-kernel.c                  |  290 ++++++
 fs/dlm/nldlm-kernel.h                  |   50 +
 fs/dlm/nldlm.c                         |  847 +++++++++++++++
 fs/dlm/plock.c                         |    2 +-
 fs/dlm/rcom.c                          |   16 +-
 fs/dlm/rcom.h                          |    3 +-
 fs/dlm/recover.c                       |   17 +-
 fs/dlm/user.c                          |   63 +-
 fs/dlm/user.h                          |    2 +-
 fs/gfs2/glock.c                        |    8 +
 fs/gfs2/incore.h                       |    2 +
 fs/gfs2/lock_dlm.c                     |    6 +-
 fs/gfs2/ops_fstype.c                   |    5 +
 fs/gfs2/sys.c                          |   35 +-
 fs/ocfs2/stack_user.c                  |    2 +-
 include/linux/dlm.h                    |    9 +-
 include/linux/kobject.h                |   10 +-
 include/uapi/linux/nldlm.h             |  153 +++
 lib/kobject.c                          |   65 +-
 40 files changed, 5566 insertions(+), 1464 deletions(-)
 create mode 100644 Documentation/netlink/specs/nldlm.yaml
 create mode 100644 fs/dlm/configfs.c
 create mode 100644 fs/dlm/configfs.h
 create mode 100644 fs/dlm/netlink2.c
 create mode 100644 fs/dlm/nldlm-kernel.c
 create mode 100644 fs/dlm/nldlm-kernel.h
 create mode 100644 fs/dlm/nldlm.c
 create mode 100644 include/uapi/linux/nldlm.h
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/12 dlm: introduce dlm_find_lockspace_name()

A DLM lockspace can be either identified by it's unique id or name. Later patches will introduce a new netlink api that is using a unique lockspace name to identify a lockspace in the lslist. This is mostly required for sysfs functionality that is currently solved by a per lockspace kobject allocation. The new netlink api cannot simple lookup the lockspace by a container_of() call to do whatever sysfs is providing so we introduce dlm_find_lockspace_name() to offer such functionality.

---
 fs/dlm/lockspace.c | 18 ++++++++++++++++++
 fs/dlm/lockspace.h |  1 +
 2 files changed, 19 insertions(+)
fs/dlm/lockspace.c +18 -0
index 8afac6e2dff0..00d37125bc44 100644
@@ -238,6 +238,24 @@ void dlm_lockspace_exit(void)
 	kset_unregister(dlm_kset);
 }
 
+struct dlm_ls *dlm_find_lockspace_name(const char *lsname)
+{
+	struct dlm_ls *ls;
+
+	spin_lock_bh(&lslist_lock);
+
+	list_for_each_entry(ls, &lslist, ls_list) {
+		if (!strncmp(ls->ls_name, lsname, DLM_LOCKSPACE_LEN)) {
+			atomic_inc(&ls->ls_count);
+			goto out;
+		}
+	}
+	ls = NULL;
+ out:
+	spin_unlock_bh(&lslist_lock);
+	return ls;
+}
+
 struct dlm_ls *dlm_find_lockspace_global(uint32_t id)
 {
 	struct dlm_ls *ls;
fs/dlm/lockspace.h +1 -0
index 47ebd4411926..7898a906aab9 100644
@@ -22,6 +22,7 @@
 
 int dlm_lockspace_init(void);
 void dlm_lockspace_exit(void);
+struct dlm_ls *dlm_find_lockspace_name(const char *lsname);
 struct dlm_ls *dlm_find_lockspace_global(uint32_t id);
 struct dlm_ls *dlm_find_lockspace_local(void *id);
 struct dlm_ls *dlm_find_lockspace_device(int minor);
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/12 dlm: disallow different configs nodeid storages

In reply to Alexander Aring

The DLM configfs path has usually a nodeid in it's directory path and again a file to store the nodeid again in a separate storage. It is forced that the user space will set both (the directory name and nodeid file) storage to the same value if it doesn't do that we run in some kind of broken state.

This patch will simply represent the file storage to it's upper directory nodeid name. It will force the user now to use a valid unsigned int as nodeid directory name and will ignore all nodeid writes in the nodeid file storage as this will now always represent the upper nodeid directory name.

---
 fs/dlm/config.c | 53 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 18 deletions(-)
fs/dlm/config.c +35 -18
index eac96f1c1d74..1b213b5beb19 100644
@@ -24,9 +24,9 @@
 #include "lowcomms.h"
 
 /*
- * /config/dlm/<cluster>/spaces/<space>/nodes/<node>/nodeid
+ * /config/dlm/<cluster>/spaces/<space>/nodes/<node>/nodeid (refers to <node>)
  * /config/dlm/<cluster>/spaces/<space>/nodes/<node>/weight
- * /config/dlm/<cluster>/comms/<comm>/nodeid
+ * /config/dlm/<cluster>/comms/<comm>/nodeid (refers to <comm>)
  * /config/dlm/<cluster>/comms/<comm>/local
  * /config/dlm/<cluster>/comms/<comm>/addr      (write only)
  * /config/dlm/<cluster>/comms/<comm>/addr_list (read only)
@@ -517,6 +517,12 @@ static void release_space(struct config_item *i)
 static struct config_item *make_comm(struct config_group *g, const char *name)
 {
 	struct dlm_comm *cm;
+	unsigned int nodeid;
+	int rv;
+
+	rv = kstrtouint(name, 0, &nodeid);
+	if (rv)
+		return ERR_PTR(rv);
 
 	cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS);
 	if (!cm)
@@ -528,7 +534,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
 	if (!cm->seq)
 		cm->seq = dlm_comm_count++;
 
-	cm->nodeid = -1;
+	cm->nodeid = nodeid;
 	cm->local = 0;
 	cm->addr_count = 0;
 	cm->mark = 0;
@@ -555,16 +561,25 @@ static void release_comm(struct config_item *i)
 static struct config_item *make_node(struct config_group *g, const char *name)
 {
 	struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
+	unsigned int nodeid;
 	struct dlm_node *nd;
+	uint32_t seq = 0;
+	int rv;
+
+	rv = kstrtouint(name, 0, &nodeid);
+	if (rv)
+		return ERR_PTR(rv);
 
 	nd = kzalloc(sizeof(struct dlm_node), GFP_NOFS);
 	if (!nd)
 		return ERR_PTR(-ENOMEM);
 
 	config_item_init_type_name(&nd->item, name, &node_type);
-	nd->nodeid = -1;
+	nd->nodeid = nodeid;
 	nd->weight = 1;  /* default weight of 1 if none is set */
 	nd->new = 1;     /* set to 0 once it's been read by dlm_nodeid_list() */
+	dlm_comm_seq(nodeid, &seq);
+	nd->comm_seq = seq;
 
 	mutex_lock(&sp->members_lock);
 	list_add(&nd->list, &sp->members);
@@ -622,16 +637,19 @@ void dlm_config_exit(void)
 
 static ssize_t comm_nodeid_show(struct config_item *item, char *buf)
 {
-	return sprintf(buf, "%d\n", config_item_to_comm(item)->nodeid);
+	unsigned int nodeid;
+	int rv;
+
+	rv = kstrtouint(config_item_name(item), 0, &nodeid);
+	if (WARN_ON(rv))
+		return rv;
+
+	return sprintf(buf, "%u\n", nodeid);
 }
 
 static ssize_t comm_nodeid_store(struct config_item *item, const char *buf,
 				 size_t len)
 {
-	int rc = kstrtoint(buf, 0, &config_item_to_comm(item)->nodeid);
-
-	if (rc)
-		return rc;
 	return len;
 }
 
@@ -772,20 +790,19 @@ static struct configfs_attribute *comm_attrs[] = {
 
 static ssize_t node_nodeid_show(struct config_item *item, char *buf)
 {
-	return sprintf(buf, "%d\n", config_item_to_node(item)->nodeid);
+	unsigned int nodeid;
+	int rv;
+
+	rv = kstrtouint(config_item_name(item), 0, &nodeid);
+	if (WARN_ON(rv))
+		return rv;
+
+	return sprintf(buf, "%u\n", nodeid);
 }
 
 static ssize_t node_nodeid_store(struct config_item *item, const char *buf,
 				 size_t len)
 {
-	struct dlm_node *nd = config_item_to_node(item);
-	uint32_t seq = 0;
-	int rc = kstrtoint(buf, 0, &nd->nodeid);
-
-	if (rc)
-		return rc;
-	dlm_comm_seq(nd->nodeid, &seq);
-	nd->comm_seq = seq;
 	return len;
 }
 
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v2 3/12 dlm: add struct net to dlm_new_lockspace()

In reply to Alexander Aring

To prepare a namespace separation for each DLM lockspaces context we add a struct net parameter that the user tells us in which net-namespace the lockspace should be created. We are using net-namespace here because a DLM lockspaces context acts like a per cluster node separation and the created per node sockets need to be separated by their net-namespaces anyway. It just fits that the DLM lockspaces are also separated by a per "network entity".

This patch only prepares for such parameter for a functionality that does not exist yet. It does not have any effect. If there will be support for such handling the DLM user need to activate it anyway as the applied parameter for now is the "&init_net" instance that is the default namespace which we are currently using.

---
 drivers/md/md-cluster.c | 3 ++-
 fs/dlm/lockspace.c      | 5 +++--
 fs/gfs2/lock_dlm.c      | 6 +++---
 fs/ocfs2/stack_user.c   | 2 +-
 include/linux/dlm.h     | 9 +++++++--
 5 files changed, 16 insertions(+), 9 deletions(-)
drivers/md/md-cluster.c +2 -1
index 6595f89becdb..a79c3833af96 100644
@@ -897,7 +897,8 @@ static int join(struct mddev *mddev, int nodes)
 
 	memset(str, 0, 64);
 	sprintf(str, "%pU", mddev->uuid);
-	ret = dlm_new_lockspace(str, mddev->bitmap_info.cluster_name,
+	ret = dlm_new_lockspace(&init_net, str,
+				mddev->bitmap_info.cluster_name,
 				DLM_LSFL_SOFTIRQ, LVB_SIZE, &md_ls_ops, mddev,
 				&ops_rv, &cinfo->lockspace);
 	if (ret)
fs/dlm/lockspace.c +3 -2
index 00d37125bc44..2dd37a2e718d 100644
@@ -663,8 +663,9 @@ static int __dlm_new_lockspace(const char *name, const char *cluster,
 	return error;
 }
 
-int dlm_new_lockspace(const char *name, const char *cluster, uint32_t flags,
-		      int lvblen, const struct dlm_lockspace_ops *ops,
+int dlm_new_lockspace(struct net *net, const char *name, const char *cluster,
+		      uint32_t flags, int lvblen,
+		      const struct dlm_lockspace_ops *ops,
 		      void *ops_arg, int *ops_result,
 		      dlm_lockspace_t **lockspace)
 {
fs/gfs2/lock_dlm.c +3 -3
index fa5134df985f..6c5dce57a2ee 100644
@@ -1328,9 +1328,9 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)
 	 * create/join lockspace
 	 */
 
-	error = dlm_new_lockspace(fsname, cluster, flags, GDLM_LVB_SIZE,
-				  &gdlm_lockspace_ops, sdp, &ops_result,
-				  &ls->ls_dlm);
+	error = dlm_new_lockspace(&init_net, fsname, cluster, flags,
+				  GDLM_LVB_SIZE, &gdlm_lockspace_ops, sdp,
+				  &ops_result, &ls->ls_dlm);
 	if (error) {
 		fs_err(sdp, "dlm_new_lockspace error %d\n", error);
 		goto fail_free;
fs/ocfs2/stack_user.c +1 -1
index 77edcd70f72c..23611eba58ef 100644
@@ -984,7 +984,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 	conn->cc_private = lc;
 	lc->oc_type = NO_CONTROLD;
 
-	rc = dlm_new_lockspace(conn->cc_name, conn->cc_cluster_name,
+	rc = dlm_new_lockspace(&init_net, conn->cc_name, conn->cc_cluster_name,
 			       DLM_LSFL_NEWEXCL, DLM_LVB_LEN,
 			       &ocfs2_ls_ops, conn, &ops_rv, &fsdlm);
 	if (rc) {
include/linux/dlm.h +7 -2
index bacda9898f2b..ecab5c197a7f 100644
@@ -11,9 +11,9 @@
 #ifndef __DLM_DOT_H__
 #define __DLM_DOT_H__
 
+#include <net/net_namespace.h>
 #include <uapi/linux/dlm.h>
 
-
 struct dlm_slot {
 	int nodeid; /* 1 to MAX_INT */
 	int slot;   /* 1 to MAX_INT */
@@ -43,6 +43,11 @@ struct dlm_lockspace_ops {
  *
  * Create/join a lockspace.
  *
+ * net: the net namespace context pointer where the lockspace belongs to.
+ * DLM lockspaces can be separated according to net namespaces. As DLM
+ * requires networking communication this net namespace can be used to
+ * have a own DLM lockspace on each network entity e.g. a DLM node.
+ *
  * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not
  *   including terminating null).
  *
@@ -82,7 +87,7 @@ struct dlm_lockspace_ops {
  * lockspace: handle for dlm functions
  */
 
-int dlm_new_lockspace(const char *name, const char *cluster,
+int dlm_new_lockspace(struct net *net, const char *name, const char *cluster,
 		      uint32_t flags, int lvblen,
 		      const struct dlm_lockspace_ops *ops, void *ops_arg,
 		      int *ops_result, dlm_lockspace_t **lockspace);
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH v2 4/12 dlm: handle port as __be16 network byte order

In reply to Alexander Aring

This patch handles the DLM listen port setting internally as byte order as it is a value that is used as network byte on the wire. The user space still sets this value as host byte order for configfs as we don't break UAPI here.

---
 fs/dlm/config.c   | 55 +++++++++++++++++++++++++++++++++++------------
 fs/dlm/config.h   |  2 +-
 fs/dlm/lowcomms.c |  8 +++----
 3 files changed, 46 insertions(+), 19 deletions(-)
fs/dlm/config.c +41 -14
index 1b213b5beb19..77a86c180d0e 100644
@@ -73,7 +73,7 @@ const struct rhashtable_params dlm_rhash_rsb_params = {
 
 struct dlm_cluster {
 	struct config_group group;
-	unsigned int cl_tcp_port;
+	__be16 cl_tcp_port;
 	unsigned int cl_buffer_size;
 	unsigned int cl_rsbtbl_size;
 	unsigned int cl_recover_timer;
@@ -132,6 +132,45 @@ static ssize_t cluster_cluster_name_store(struct config_item *item,
 
 CONFIGFS_ATTR(cluster_, cluster_name);
 
+static ssize_t cluster_tcp_port_show(struct config_item *item, char *buf)
+{
+	return sprintf(buf, "%u\n", be16_to_cpu(dlm_config.ci_tcp_port));
+}
+
+static int dlm_check_zero_and_dlm_running(unsigned int x)
+{
+	if (!x)
+		return -EINVAL;
+
+	if (dlm_lowcomms_is_running())
+		return -EBUSY;
+
+	return 0;
+}
+
+static ssize_t cluster_tcp_port_store(struct config_item *item,
+				      const char *buf, size_t len)
+{
+	int rc;
+	u16 x;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	rc = kstrtou16(buf, 0, &x);
+	if (rc)
+		return rc;
+
+	rc = dlm_check_zero_and_dlm_running(x);
+	if (rc)
+		return rc;
+
+	dlm_config.ci_tcp_port = cpu_to_be16(x);
+	return len;
+}
+
+CONFIGFS_ATTR(cluster_, tcp_port);
+
 static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
 			   int *info_field, int (*check_cb)(unsigned int x),
 			   const char *buf, size_t len)
@@ -191,17 +230,6 @@ static int dlm_check_protocol_and_dlm_running(unsigned int x)
 	return 0;
 }
 
-static int dlm_check_zero_and_dlm_running(unsigned int x)
-{
-	if (!x)
-		return -EINVAL;
-
-	if (dlm_lowcomms_is_running())
-		return -EBUSY;
-
-	return 0;
-}
-
 static int dlm_check_zero(unsigned int x)
 {
 	if (!x)
@@ -218,7 +246,6 @@ static int dlm_check_buffer_size(unsigned int x)
 	return 0;
 }
 
-CLUSTER_ATTR(tcp_port, dlm_check_zero_and_dlm_running);
 CLUSTER_ATTR(buffer_size, dlm_check_buffer_size);
 CLUSTER_ATTR(rsbtbl_size, dlm_check_zero);
 CLUSTER_ATTR(recover_timer, dlm_check_zero);
@@ -974,7 +1001,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
 #define DEFAULT_CLUSTER_NAME      ""
 
 struct dlm_config_info dlm_config = {
-	.ci_tcp_port = DEFAULT_TCP_PORT,
+	.ci_tcp_port = cpu_to_be16(DEFAULT_TCP_PORT),
 	.ci_buffer_size = DLM_MAX_SOCKET_BUFSIZE,
 	.ci_rsbtbl_size = DEFAULT_RSBTBL_SIZE,
 	.ci_recover_timer = DEFAULT_RECOVER_TIMER,
fs/dlm/config.h +1 -1
index ed237d910208..9cb4300cce7c 100644
@@ -29,7 +29,7 @@ extern const struct rhashtable_params dlm_rhash_rsb_params;
 #define DLM_PROTO_SCTP	1
 
 struct dlm_config_info {
-	int ci_tcp_port;
+	__be16 ci_tcp_port;
 	int ci_buffer_size;
 	int ci_rsbtbl_size;
 	int ci_recover_timer;
fs/dlm/lowcomms.c +4 -4
index cb3a10b041c2..df40c3fd1070 100644
@@ -660,18 +660,18 @@ static void add_sock(struct socket *sock, struct connection *con)
 
 /* Add the port number to an IPv6 or 4 sockaddr and return the address
    length */
-static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
+static void make_sockaddr(struct sockaddr_storage *saddr, __be16 port,
 			  int *addr_len)
 {
 	saddr->ss_family =  dlm_local_addr[0].ss_family;
 	if (saddr->ss_family == AF_INET) {
 		struct sockaddr_in *in4_addr = (struct sockaddr_in *)saddr;
-		in4_addr->sin_port = cpu_to_be16(port);
+		in4_addr->sin_port = port;
 		*addr_len = sizeof(struct sockaddr_in);
 		memset(&in4_addr->sin_zero, 0, sizeof(in4_addr->sin_zero));
 	} else {
 		struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
-		in6_addr->sin6_port = cpu_to_be16(port);
+		in6_addr->sin6_port = port;
 		*addr_len = sizeof(struct sockaddr_in6);
 	}
 	memset((char *)saddr + *addr_len, 0, sizeof(struct sockaddr_storage) - *addr_len);
@@ -1121,7 +1121,7 @@ static void writequeue_entry_complete(struct writequeue_entry *e, int completed)
 /*
  * sctp_bind_addrs - bind a SCTP socket to all our addresses
  */
-static int sctp_bind_addrs(struct socket *sock, uint16_t port)
+static int sctp_bind_addrs(struct socket *sock, __be16 port)
 {
 	struct sockaddr_storage localaddr;
 	struct sockaddr *addr = (struct sockaddr *)&localaddr;
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v2 5/12 dlm: use dlm_config as only cluster configuration

In reply to Alexander Aring

This patch removes the configfs storage fields from the dlm_cluster structure to store per cluster values. Those fields also exists for the dlm_config global variable and get stored in both when setting configfs values. To read values it will always be read out from the dlm_cluster configfs structure but this patch changes it to only use the global dlm_config variable. Storing them in two places makes no sense as both are able to be changed under certain conditions during DLM runtime.

---
 fs/dlm/config.c | 47 +++++------------------------------------------
 1 file changed, 5 insertions(+), 42 deletions(-)
fs/dlm/config.c +5 -42
index 77a86c180d0e..d9cde614ddd4 100644
@@ -73,20 +73,6 @@ const struct rhashtable_params dlm_rhash_rsb_params = {
 
 struct dlm_cluster {
 	struct config_group group;
-	__be16 cl_tcp_port;
-	unsigned int cl_buffer_size;
-	unsigned int cl_rsbtbl_size;
-	unsigned int cl_recover_timer;
-	unsigned int cl_toss_secs;
-	unsigned int cl_scan_secs;
-	unsigned int cl_log_debug;
-	unsigned int cl_log_info;
-	unsigned int cl_protocol;
-	unsigned int cl_mark;
-	unsigned int cl_new_rsb_count;
-	unsigned int cl_recover_callbacks;
-	char cl_cluster_name[DLM_LOCKSPACE_LEN];
-
 	struct dlm_spaces *sps;
 	struct dlm_comms *cms;
 };
@@ -115,18 +101,14 @@ enum {
 
 static ssize_t cluster_cluster_name_show(struct config_item *item, char *buf)
 {
-	struct dlm_cluster *cl = config_item_to_cluster(item);
-	return sprintf(buf, "%s\n", cl->cl_cluster_name);
+	return sprintf(buf, "%s\n", dlm_config.ci_cluster_name);
 }
 
 static ssize_t cluster_cluster_name_store(struct config_item *item,
 					  const char *buf, size_t len)
 {
-	struct dlm_cluster *cl = config_item_to_cluster(item);
-
 	strscpy(dlm_config.ci_cluster_name, buf,
-				sizeof(dlm_config.ci_cluster_name));
-	strscpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name));
+		sizeof(dlm_config.ci_cluster_name));
 	return len;
 }
 
@@ -171,8 +153,7 @@ static ssize_t cluster_tcp_port_store(struct config_item *item,
 
 CONFIGFS_ATTR(cluster_, tcp_port);
 
-static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
-			   int *info_field, int (*check_cb)(unsigned int x),
+static ssize_t cluster_set(int *info_field, int (*check_cb)(unsigned int x),
 			   const char *buf, size_t len)
 {
 	unsigned int x;
@@ -190,7 +171,6 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
 			return rc;
 	}
 
-	*cl_field = x;
 	*info_field = x;
 
 	return len;
@@ -200,14 +180,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
 static ssize_t cluster_##name##_store(struct config_item *item, \
 		const char *buf, size_t len) \
 {                                                                             \
-	struct dlm_cluster *cl = config_item_to_cluster(item);		      \
-	return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name,         \
-			   check_cb, buf, len);                               \
+	return cluster_set(&dlm_config.ci_##name, check_cb, buf, len);        \
 }                                                                             \
 static ssize_t cluster_##name##_show(struct config_item *item, char *buf)     \
 {                                                                             \
-	struct dlm_cluster *cl = config_item_to_cluster(item);		      \
-	return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name);               \
+	return snprintf(buf, PAGE_SIZE, "%u\n", dlm_config.ci_##name);        \
 }                                                                             \
 CONFIGFS_ATTR(cluster_, name);
 
@@ -450,20 +427,6 @@ static struct config_group *make_cluster(struct config_group *g,
 	configfs_add_default_group(&sps->ss_group, &cl->group);
 	configfs_add_default_group(&cms->cs_group, &cl->group);
 
-	cl->cl_tcp_port = dlm_config.ci_tcp_port;
-	cl->cl_buffer_size = dlm_config.ci_buffer_size;
-	cl->cl_rsbtbl_size = dlm_config.ci_rsbtbl_size;
-	cl->cl_recover_timer = dlm_config.ci_recover_timer;
-	cl->cl_toss_secs = dlm_config.ci_toss_secs;
-	cl->cl_scan_secs = dlm_config.ci_scan_secs;
-	cl->cl_log_debug = dlm_config.ci_log_debug;
-	cl->cl_log_info = dlm_config.ci_log_info;
-	cl->cl_protocol = dlm_config.ci_protocol;
-	cl->cl_new_rsb_count = dlm_config.ci_new_rsb_count;
-	cl->cl_recover_callbacks = dlm_config.ci_recover_callbacks;
-	memcpy(cl->cl_cluster_name, dlm_config.ci_cluster_name,
-	       DLM_LOCKSPACE_LEN);
-
 	space_list = &sps->ss_group;
 	comm_list = &cms->cs_group;
 	return &cl->group;
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v2 6/12 dlm: dlm_config_info config fields to unsigned int

In reply to Alexander Aring

We are using kstrtouint() to parse common integer fields. This patch will switch to use unsigned int instead of int as we are parsing unsigned integer values.

---
 fs/dlm/config.c |  3 ++-
 fs/dlm/config.h | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/dlm/config.c +2 -1
index d9cde614ddd4..a98f0e746e9e 100644
@@ -153,7 +153,8 @@ static ssize_t cluster_tcp_port_store(struct config_item *item,
 
 CONFIGFS_ATTR(cluster_, tcp_port);
 
-static ssize_t cluster_set(int *info_field, int (*check_cb)(unsigned int x),
+static ssize_t cluster_set(unsigned int *info_field,
+			   int (*check_cb)(unsigned int x),
 			   const char *buf, size_t len)
 {
 	unsigned int x;
fs/dlm/config.h +11 -11
index 9cb4300cce7c..9abe71453c5e 100644
@@ -30,17 +30,17 @@ extern const struct rhashtable_params dlm_rhash_rsb_params;
 
 struct dlm_config_info {
 	__be16 ci_tcp_port;
-	int ci_buffer_size;
-	int ci_rsbtbl_size;
-	int ci_recover_timer;
-	int ci_toss_secs;
-	int ci_scan_secs;
-	int ci_log_debug;
-	int ci_log_info;
-	int ci_protocol;
-	int ci_mark;
-	int ci_new_rsb_count;
-	int ci_recover_callbacks;
+	unsigned int ci_buffer_size;
+	unsigned int ci_rsbtbl_size;
+	unsigned int ci_recover_timer;
+	unsigned int ci_toss_secs;
+	unsigned int ci_scan_secs;
+	unsigned int ci_log_debug;
+	unsigned int ci_log_info;
+	unsigned int ci_protocol;
+	unsigned int ci_mark;
+	unsigned int ci_new_rsb_count;
+	unsigned int ci_recover_callbacks;
 	char ci_cluster_name[DLM_LOCKSPACE_LEN];
 };
 
Signature · 1 line
2.43.0
author maintainer
#7 lore raw

PATCH v2 7/12 dlm: rename config to configfs

In reply to Alexander Aring

This patch will rename the config.c implementation file to configfs.c as in further patches we will introduce a configuration layer to allow different UAPI mechanism operate on current configfs configurations. We need a different UAPI mechanism as we want to separate our configuration on a per net-namespaces basis. The new file "configfs.c" only contains functionality to maintain configfs handling.

---
 fs/dlm/Makefile                 | 2 +-
 fs/dlm/{config.c => configfs.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename fs/dlm/{config.c => configfs.c} (100%)
fs/dlm/Makefile +1 -1
index 5a471af1d1fe..48959179fc78 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DLM) +=		dlm.o
 dlm-y :=			ast.o \
-				config.o \
+				configfs.o \
 				dir.o \
 				lock.o \
 				lockspace.o \
fs/dlm/configfs.c renamed from fs/dlm/config.c +0 -0
similarity index 100%
rename from fs/dlm/config.c
rename to fs/dlm/configfs.c
Signature · 1 line
2.43.0
author maintainer
#8 lore raw

PATCH v2 8/12 kobject: add kset_type_create_and_add() helper

In reply to Alexander Aring

Currently there exists the kset_create_and_add() helper that does not allow to have a different ktype for the created kset kobject. To allow a different ktype this patch will introduce the function kset_type_create_and_add() that allows to set a different ktype instead of using the global default kset_ktype variable.

In my example I need to separate the created kobject inside the kset by net-namespaces. This patch allows me to do that by providing a user defined kobj_type structure that implements the necessary namespace functionality.

---
 include/linux/kobject.h |  8 ++++--
 lib/kobject.c           | 59 ++++++++++++++++++++++++++++++-----------
 2 files changed, 50 insertions(+), 17 deletions(-)
include/linux/kobject.h +6 -2
index c8219505a79f..7504b7547ed2 100644
@@ -175,8 +175,12 @@ struct kset {
 void kset_init(struct kset *kset);
 int __must_check kset_register(struct kset *kset);
 void kset_unregister(struct kset *kset);
-struct kset * __must_check kset_create_and_add(const char *name, const struct kset_uevent_ops *u,
-					       struct kobject *parent_kobj);
+struct kset * __must_check
+kset_type_create_and_add(const char *name, const struct kset_uevent_ops *u,
+			 struct kobject *parent_kobj, const struct kobj_type *ktype);
+struct kset * __must_check
+kset_create_and_add(const char *name, const struct kset_uevent_ops *u,
+		    struct kobject *parent_kobj);
 
 static inline struct kset *to_kset(struct kobject *kobj)
 {
lib/kobject.c +44 -15

102 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#9 lore raw

PATCH v2 9/12 kobject: export generic helper ops

In reply to Alexander Aring

This patch exports generic helpers like kset_release() and kset_get_ownership() so users can use them in their own struct kobj_type implementation instead of implementing their own functions that do the same.

---
 include/linux/kobject.h | 2 ++
 lib/kobject.c           | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/kobject.h +2 -0
index 7504b7547ed2..5fbc358e2be6 100644
@@ -181,6 +181,8 @@ kset_type_create_and_add(const char *name, const struct kset_uevent_ops *u,
 struct kset * __must_check
 kset_create_and_add(const char *name, const struct kset_uevent_ops *u,
 		    struct kobject *parent_kobj);
+void kset_release(struct kobject *kobj);
+void kset_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
 
 static inline struct kset *to_kset(struct kobject *kobj)
 {
lib/kobject.c +4 -2
index 09dd3d4c7f56..ccd2f6282c81 100644
@@ -920,19 +920,21 @@ struct kobject *kset_find_obj(struct kset *kset, const char *name)
 }
 EXPORT_SYMBOL_GPL(kset_find_obj);
 
-static void kset_release(struct kobject *kobj)
+void kset_release(struct kobject *kobj)
 {
 	struct kset *kset = container_of(kobj, struct kset, kobj);
 	pr_debug("'%s' (%p): %s\n",
 		 kobject_name(kobj), kobj, __func__);
 	kfree(kset);
 }
+EXPORT_SYMBOL_GPL(kset_release);
 
-static void kset_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid)
+void kset_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid)
 {
 	if (kobj->parent)
 		kobject_get_ownership(kobj->parent, uid, gid);
 }
+EXPORT_SYMBOL_GPL(kset_get_ownership);
 
 static const struct kobj_type kset_ktype = {
 	.sysfs_ops	= &kobj_sysfs_ops,
Signature · 1 line
2.43.0
author maintainer
#10 lore raw

PATCH v2 10/12 dlm: separate dlm lockspaces per net-namespace

In reply to Alexander Aring

This patch separates the internal DLM lockspace handling on a per net-namespace basis. The current handling of DLM offers that all lockspaces are created on a local machine without separation and the machine is part of a cluster with several nodes as other machines. This patch allows us to create a cluster without running several machines on one Linux kernel. We do that by separating all current global variables on a per net-namespace basis, in this patch it is "struct dlm_net". This patch "simply" convert mostly all global variables on a per net-namespace basis and offer a new config layer to operate on this. The configfs UAPI mechanism is using this config layer, as configfs isn't net-namespace aware it only operates on "init_net" namespace. Further new UAPIs that are namespace aware can operate on the config layer on a net-namespace basis. The DLM config layer is implemented in "config.c" the current configfs UAPI mechanism to access the config layer is implemented in "configfs.c". The config layer uses a per net-namespace mutex lock to avoid mutual access of configuration variables as this layer can be accessed in future from multiple UAPI sources.

Character device access that is used for dlm locking calls from user space are only accessible from init_net namespace, any open() on those character devices will currently end in an -EOPNOTSUPP. To support such a functionality may a different mechanism will be introduced.

This patch will separate the DLM sysfs handling by net-namespace by using kset_type_create_and_add() and implementing the necessary callbacks to reference to the right "struct net" that is part of the per lockspace kobject.

Note as this patch series should have no effect as all users still apply &init_net to dlm_new_lockspace() except that users of the DLM character device don't open() those devices under &init_net will be rejected now.

---
 fs/dlm/Makefile       |   1 +
 fs/dlm/config.c       | 699 ++++++++++++++++++++++++++++++++++++++++++
 fs/dlm/config.h       | 197 ++++++++++--
 fs/dlm/configfs.c     | 614 ++++++++++++++++---------------------
 fs/dlm/configfs.h     |  19 ++
 fs/dlm/debug_fs.c     |  24 +-
 fs/dlm/dir.c          |   4 +-
 fs/dlm/dlm_internal.h |  20 +-
 fs/dlm/lock.c         |  64 ++--
 fs/dlm/lock.h         |   3 +-
 fs/dlm/lockspace.c    | 192 +++++++-----
 fs/dlm/lockspace.h    |  13 +-
 fs/dlm/lowcomms.c     | 521 ++++++++++++++++---------------
 fs/dlm/lowcomms.h     |  29 +-
 fs/dlm/main.c         |   5 -
 fs/dlm/member.c       |  36 +--
 fs/dlm/midcomms.c     | 287 ++++++++---------
 fs/dlm/midcomms.h     |  31 +-
 fs/dlm/plock.c        |   2 +-
 fs/dlm/rcom.c         |  16 +-
 fs/dlm/rcom.h         |   3 +-
 fs/dlm/recover.c      |  17 +-
 fs/dlm/user.c         |  63 ++--
 fs/dlm/user.h         |   2 +-
 24 files changed, 1855 insertions(+), 1007 deletions(-)
 create mode 100644 fs/dlm/config.c
 create mode 100644 fs/dlm/configfs.h
fs/dlm/Makefile +1 -0
index 48959179fc78..c37f9fc361c6 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DLM) +=		dlm.o
 dlm-y :=			ast.o \
+				config.o \
 				configfs.o \
 				dir.o \
 				lock.o \
fs/dlm/config.c new file +699 -0

699 lines not on this page · raw message

fs/dlm/config.h +171 -26

228 lines not on this page · raw message

fs/dlm/configfs.c +257 -357

868 lines not on this page · raw message

fs/dlm/configfs.h new file +19 -0
new file mode 100644
index 000000000000..b8027c0db8b5
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/******************************************************************************
+ ******************************************************************************
+ **
+ **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
+ **  Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
+ **
+ **
+ ******************************************************************************
+ ******************************************************************************/
+
+#ifndef __CONFIGFS_DOT_H__
+#define __CONFIGFS_DOT_H__
+
+int dlm_configfs_init(void);
+void dlm_configfs_exit(void);
+
+#endif				/* __CONFIGFS_DOT_H__ */
+
fs/dlm/debug_fs.c +19 -5
index 700a0cbb2f14..e60c1b5a7475 100644
@@ -331,9 +331,10 @@ static void print_format3(struct dlm_rsb *r, struct seq_file *s)
 	unlock_rsb(r);
 }
 
-static void print_format4(struct dlm_rsb *r, struct seq_file *s)
+static void print_format4(struct dlm_ls *ls, struct dlm_rsb *r,
+			  struct seq_file *s)
 {
-	int our_nodeid = dlm_our_nodeid();
+	int our_nodeid = dlm_our_nodeid(ls->ls_dn);
 	int print_name = 1;
 	int i;
 
@@ -381,6 +382,7 @@ static const struct seq_operations format4_seq_ops;
 static int table_seq_show(struct seq_file *seq, void *iter_ptr)
 {
 	struct dlm_rsb *rsb = list_entry(iter_ptr, struct dlm_rsb, res_slow_list);
+	struct dlm_ls *ls = seq->private;
 
 	if (seq->op == &format1_seq_ops)
 		print_format1(rsb, seq);
@@ -389,7 +391,7 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
 	else if (seq->op == &format3_seq_ops)
 		print_format3(rsb, seq);
 	else if (seq->op == &format4_seq_ops)
-		print_format4(rsb, seq);
+		print_format4(ls, rsb, seq);
 
 	return 0;
 }
@@ -735,11 +737,15 @@ static const struct file_operations dlm_rawmsg_fops = {
 	.write	= dlm_rawmsg_write,
 };
 
-void *dlm_create_debug_comms_file(int nodeid, void *data)
+void *dlm_create_debug_comms_file(struct dlm_net *dn, int nodeid, void *data)
 {
 	struct dentry *d_node;
 	char name[256];
 
+	/* debugfs only supported for init_net */
+	if (!net_eq(read_pnet(&dn->net), &init_net))
+		return NULL;
+
 	memset(name, 0, sizeof(name));
 	snprintf(name, 256, "%d", nodeid);
 
@@ -754,8 +760,12 @@ void *dlm_create_debug_comms_file(int nodeid, void *data)
 	return d_node;
 }
 
-void dlm_delete_debug_comms_file(void *ctx)
+void dlm_delete_debug_comms_file(struct dlm_net *dn, void *ctx)
 {
+	/* debugfs only supported for init_net */
+	if (!net_eq(read_pnet(&dn->net), &init_net))
+		return;
+
 	debugfs_remove(ctx);
 }
 
@@ -764,6 +774,10 @@ void dlm_create_debug_file(struct dlm_ls *ls)
 	/* Reserve enough space for the longest file name */
 	char name[DLM_LOCKSPACE_LEN + sizeof("_queued_asts")];
 
+	/* debugfs only supported for init_net */
+	if (!net_eq(read_pnet(&ls->ls_dn->net), &init_net))
+		return;
+
 	/* format 1 */
 
 	ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name,
fs/dlm/dir.c +2 -2
index b1ab0adbd9d0..2fa0afd5c57b 100644
@@ -35,7 +35,7 @@ int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash)
 	uint32_t node;
 
 	if (ls->ls_num_nodes == 1)
-		return dlm_our_nodeid();
+		return dlm_our_nodeid(ls->ls_dn);
 	else {
 		node = (hash >> 16) % ls->ls_total_weight;
 		return ls->ls_node_array[node];
@@ -74,7 +74,7 @@ int dlm_recover_directory(struct dlm_ls *ls, uint64_t seq)
 		goto out;
 
 	list_for_each_entry(memb, &ls->ls_nodes, list) {
-		if (memb->nodeid == dlm_our_nodeid())
+		if (memb->nodeid == dlm_our_nodeid(ls->ls_dn))
 			continue;
 
 		memset(last_name, 0, DLM_RESNAME_MAXLEN);
fs/dlm/dlm_internal.h +12 -8
index d534a4bc162b..10fe3b59bd70 100644
@@ -64,24 +64,24 @@ struct dlm_msg;
 
 #define log_rinfo(ls, fmt, args...) \
 do { \
-	if (dlm_config.ci_log_info) \
+	if (ls->ls_dn->config.ci_log_info) \
 		printk(KERN_INFO "dlm: %s: " fmt "\n", \
 			(ls)->ls_name, ##args); \
-	else if (dlm_config.ci_log_debug) \
+	else if (ls->ls_dn->config.ci_log_debug) \
 		printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
 		       (ls)->ls_name , ##args); \
 } while (0)
 
 #define log_debug(ls, fmt, args...) \
 do { \
-	if (dlm_config.ci_log_debug) \
+	if (ls->ls_dn->config.ci_log_debug) \
 		printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
 		       (ls)->ls_name , ##args); \
 } while (0)
 
 #define log_limit(ls, fmt, args...) \
 do { \
-	if (dlm_config.ci_log_debug) \
+	if (ls->ls_dn->config.ci_log_debug) \
 		printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \
 			(ls)->ls_name , ##args); \
 } while (0)
@@ -561,6 +561,8 @@ struct rcom_lock {
 
 struct dlm_ls {
 	struct list_head	ls_list;	/* list of lockspaces */
+	struct dlm_net		*ls_dn;
+	netns_tracker		ls_tracker;
 	uint32_t		ls_global_id;	/* global unique lockspace ID */
 	uint32_t		ls_generation;
 	uint32_t		ls_exflags;
@@ -816,15 +818,17 @@ void dlm_register_debugfs(void);
 void dlm_unregister_debugfs(void);
 void dlm_create_debug_file(struct dlm_ls *ls);
 void dlm_delete_debug_file(struct dlm_ls *ls);
-void *dlm_create_debug_comms_file(int nodeid, void *data);
-void dlm_delete_debug_comms_file(void *ctx);
+void *dlm_create_debug_comms_file(struct dlm_net *dn, int nodeid, void *data);
+void dlm_delete_debug_comms_file(struct dlm_net *dn, void *ctx);
 #else
 static inline void dlm_register_debugfs(void) { }
 static inline void dlm_unregister_debugfs(void) { }
 static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
 static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
-static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
-static inline void dlm_delete_debug_comms_file(void *ctx) { }
+static inline void *dlm_create_debug_comms_file(struct dlm_net *dn, int nodeid,
+						void *data) { return NULL; }
+static inline void dlm_delete_debug_comms_file(struct dlm_net *dn,
+					       void *ctx) { }
 #endif
 
 #endif				/* __DLM_INTERNAL_DOT_H__ */
fs/dlm/lock.c +32 -32

202 lines not on this page · raw message

fs/dlm/lock.h +2 -1
index b23d7b854ed4..dc374fc80c9a 100644
@@ -16,7 +16,8 @@ void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len);
 void dlm_print_lkb(struct dlm_lkb *lkb);
 void dlm_receive_message_saved(struct dlm_ls *ls, const struct dlm_message *ms,
 			       uint32_t saved_seq);
-void dlm_receive_buffer(const union dlm_packet *p, int nodeid);
+void dlm_receive_buffer(struct dlm_net *dn, const union dlm_packet *p,
+			int nodeid);
 int dlm_modes_compat(int mode1, int mode2);
 void free_inactive_rsb(struct dlm_rsb *r);
 void dlm_put_rsb(struct dlm_rsb *r);
fs/dlm/lockspace.c +112 -80

461 lines not on this page · raw message

fs/dlm/lockspace.h +7 -6
index 7898a906aab9..9d50fc44dc0b 100644
@@ -22,14 +22,15 @@
 
 int dlm_lockspace_init(void);
 void dlm_lockspace_exit(void);
-struct dlm_ls *dlm_find_lockspace_name(const char *lsname);
-struct dlm_ls *dlm_find_lockspace_global(uint32_t id);
+void dlm_lockspace_net_init(struct dlm_net *dn);
+struct dlm_ls *dlm_find_lockspace_name(struct dlm_net *dn, const char *lsname);
+struct dlm_ls *dlm_find_lockspace_global(struct dlm_net *dn, uint32_t id);
 struct dlm_ls *dlm_find_lockspace_local(void *id);
-struct dlm_ls *dlm_find_lockspace_device(int minor);
+struct dlm_ls *dlm_find_lockspace_device(struct dlm_net *dn, int minor);
 void dlm_put_lockspace(struct dlm_ls *ls);
-void dlm_stop_lockspaces(void);
-int dlm_new_user_lockspace(const char *name, const char *cluster,
-			   uint32_t flags, int lvblen,
+void dlm_stop_lockspaces(struct dlm_net *dn);
+int dlm_new_user_lockspace(struct dlm_net *dn, const char *name,
+			   const char *cluster, uint32_t flags, int lvblen,
 			   const struct dlm_lockspace_ops *ops,
 			   void *ops_arg, int *ops_result,
 			   dlm_lockspace_t **lockspace);
fs/dlm/lowcomms.c +259 -262

347 lines not on this page · raw message

fs/dlm/lowcomms.h +15 -14
index fd0df604eb93..f19c061c9dde 100644

Lines of this file are not shown. View the raw message.

fs/dlm/main.c +0 -5
index 4887c8a05318..01ba63ab3822 100644

Lines of this file are not shown. View the raw message.

fs/dlm/member.c +18 -18
index c9661906568a..ed5f4139d712 100644

Lines of this file are not shown. View the raw message.

fs/dlm/midcomms.c +146 -141

287 lines not on this page · raw message

fs/dlm/midcomms.h +18 -13
index 7fad1d170bba..4abb8c4bb9fb 100644

Lines of this file are not shown. View the raw message.

fs/dlm/plock.c +1 -1
index 9ca83ef70ed1..b16d5277bb1e 100644

Lines of this file are not shown. View the raw message.

fs/dlm/rcom.c +9 -7
index be1a71a6303a..3b7c44375f23 100644

Lines of this file are not shown. View the raw message.

fs/dlm/rcom.h +2 -1
index 765926ae0020..8b1d7418b335 100644

Lines of this file are not shown. View the raw message.

fs/dlm/recover.c +9 -8
index 2e1169c81c6e..9c5849556bff 100644

Lines of this file are not shown. View the raw message.

fs/dlm/user.c +44 -19

63 lines not on this page · raw message

fs/dlm/user.h +1 -1
index 2caf8e6e24d5..eac33bbe99b1 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

author maintainer
#12 lore raw

PATCH v2 11/12 dlm: add nldlm net-namespace aware UAPI

In reply to Alexander Aring

Recent patches introduced support to separate DLM lockspaces on a per net-namespace basis. Currently the file based configfs mechanism is used to configure parts of DLM. Due the lack of namespace awareness (and it's probably complicated to add support for this) in configfs we introduce a socket based UAPI using "netlink". As the DLM subsystem offers now a config layer it can simultaneously being used with configfs, just that nldlm is net-namespace aware.

Most of the current configfs functionality that is necessary to configure DLM is being adapted for now. The nldlm netlink interface offers also a multicast group for lockspace events NLDLM_MCGRP_EVENT. This event group can be used as alternative to the already existing udev event behaviour just it only contains DLM related subsystem events.

Attributes e.g. nodeid, port, IP addresses are expected from the user space to fill those numbers as they appear on the wire. In case of DLM fields it is using little endian byte order.

The dumps are being designed to scale in future with high numbers of members in a lockspace. E.g. dump members require an unique lockspace identifier (currently only the name) and nldlm is using a netlink dump behaviour to be prepared if all entries may not fit into one netlink message.

---
 Documentation/netlink/specs/nldlm.yaml |  438 ++++++++
 fs/dlm/Makefile                        |    2 +
 fs/dlm/config.c                        |   20 +-
 fs/dlm/dlm_internal.h                  |    4 +
 fs/dlm/lockspace.c                     |   13 +-
 fs/dlm/netlink2.c                      | 1330 ++++++++++++++++++++++++
 fs/dlm/nldlm-kernel.c                  |  290 ++++++
 fs/dlm/nldlm-kernel.h                  |   50 +
 fs/dlm/nldlm.c                         |  847 +++++++++++++++
 include/uapi/linux/nldlm.h             |  153 +++
 10 files changed, 3141 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/netlink/specs/nldlm.yaml
 create mode 100644 fs/dlm/netlink2.c
 create mode 100644 fs/dlm/nldlm-kernel.c
 create mode 100644 fs/dlm/nldlm-kernel.h
 create mode 100644 fs/dlm/nldlm.c
 create mode 100644 include/uapi/linux/nldlm.h
Documentation/netlink/specs/nldlm.yaml new file +438 -0
new file mode 100644
index 000000000000..8c32815c0391
@@ -0,0 +1,438 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+
+name: nldlm
+protocol: genetlink
+doc: DLM subsystem.
+
+definitions:
+  -
+    type: enum
+    name: protocol
+    doc: |
+      The transport layer protocol that DLM will use.
+    entries:
+      -
+        name: TCP
+      -
+        name: SCTP
+  -
+    type: enum
+    name: log-level
+    doc: |
+      The internal DLM logger log-level.
+    entries:
+      -
+        name: NONE
+        doc: disable all DLM logging
+      -
+        name: INFO
+        doc: enable INFO log-level only
+      -
+        name: DEBUG
+        doc: enable INFO and DEBUG log-level
+  -
+    type: enum
+    name: ls-ctrl-action
+    doc: |
+      The lockspace control actions. Use in combination with
+      ls-add-member and ls-del-member. First stop lockspace
+      then update the members, then start the lockspace to
+      trigger recovery with new membership updates.
+    entries:
+      -
+        name: STOP
+        doc: stopping the lockspace
+      -
+        name: START
+        doc: starting the lockspace
+  -
+    type: enum
+    name: ls-event-result
+    doc: |
+      The result op of the lockspace event ntf-new-ls and
+      ntf-release-ls. The kernel is waiting for this reply
+      when those events occur.
+    entries:
+      -
+        name: SUCCESS
+        doc: the DLM kernel lockspace event action was successful
+      -
+        name: FAILURE
+        doc: the DLM kernel lockspace event action failed
+
+attribute-sets:
+  -
+    name: cfg
+    attributes:
+      -
+        name: our-nodeid
+        type: u32
+        byte-order: little-endian
+      -
+        name: cluster-name
+        type: string
+      -
+        name: protocol
+        type: u32
+      -
+        name: port
+        type: u16
+        byte-order: big-endian
+      -
+        name: recover-timeout
+        type: u32
+      -
+        name: inactive-timeout
+        type: u32
+      -
+        name: log-level
+        type: u32
+      -
+        name: default-mark
+        type: u32
+      -
+        name: recover-callbacks
+        type: flag
+  -
+    name: ls
+    attributes:
+      -
+        name: name
+        type: string
+  -
+    name: ls-member
+    attributes:
+      -
+        name: ls-name
+        type: string
+      -
+        name: nodeid
+        type: u32
+        byte-order: little-endian
+      -
+        name: weight
+        type: u32
+  -
+    name: ls-ctrl
+    attributes:
+      -
+        name: ls-name
+        type: string
+      -
+        name: action
+        type: u32
+  -
+    name: ls-event-result
+    attributes:
+      -
+        name: ls-name
+        type: string
+      -
+        name: ls-global-id
+        type: u32
+        byte-order: little-endian
+      -
+        name: result
+        type: u32
+  -
+    name: node
+    attributes:
+      -
+        name: id
+        type: u32
+        byte-order: little-endian
+      -
+        name: mark
+        type: u32
+      -
+        name: addrs
+        type: nest
+        nested-attributes: addr
+        multi-attr: true
+  -
+    name: addr
+    attributes:
+      -
+        name: family
+        type: u16
+      -
+        name: addr4
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+      -
+        name: addr6
+        type: binary
+        display-hint: ipv6
+        checks:
+          exact-len: 16
+
+operations:
+  list:
+    -
+      name: get-node
+      doc: |
+        get DLM node information from the kernel configuration.
+      attribute-set: node
+      do:
+        request:
+          attributes:
+            - id
+        reply:
+          attributes:
+            - id
+            - mark
+            - addrs
+      dump:
+        reply:
+          attributes:
+            - id
+            - mark
+            - addrs
+    -
+      name: add-node
+      doc: |
+        add a new DLM node to the kernel configuration.
+      attribute-set: node
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - id
+            - mark
+            - addrs
+    -
+      name: del-node
+      doc: |
+        delete a DLM node from the kernel configuration.
+      attribute-set: node
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - id
+    -
+      name: get-ls
+      doc: |
+        get registered DLM lockspace information.
+      attribute-set: ls
+      do:
+        request:
+          attributes:
+            - name
+        reply:
+          attributes:
+            - name
+      dump:
+        reply:
+          attributes:
+            - name
+    -
+      name: get-ls-member
+      doc: |
+        get members information from a registered DLM lockspace.
+      attribute-set: ls-member
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - ls-name
+            - nodeid
+        reply:
+          attributes:
+            - ls-name
+            - nodeid
+            - weight
+      dump:
+        request:
+          attributes:
+            - ls-name
+        reply:
+          attributes:
+            - ls-name
+            - nodeid
+            - weight
+    -
+      name: ls-add-member
+      doc: |
+        add a member to a specific registered lockspace. Should be used
+        when the lockspaces is stopped.
+      attribute-set: ls-member
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - ls-name
+            - nodeid
+            - weight
+    -
+      name: ls-del-member
+      doc: |
+        delete a member to a specific registered lockspace. Should be used
+        when the lockspaces is stopped.
+      attribute-set: ls-member
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - ls-name
+            - nodeid
+    -
+      name: ls-ctrl
+      doc: |
+        do lockspace control actions like stop and start lockspace for
+        membership updates.
+      attribute-set: ls-ctrl
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - ls-name
+            - action
+    -
+      name: ntf-new-ls
+      doc: |
+        notify that the kernel is creating a new lockspace and the user
+        space need to ackknowledge and set a cluster-wide global-id with
+        ls-event-done.
+      notify: get-ls
+      mcgrp: ls-event
+    -
+      name: ntf-release-ls
+      doc: |
+        notify that the kernel is releasing registered lockspace.
+      notify: get-ls
+      mcgrp: ls-event
+    -
+      name: ls-event-done
+      doc: |
+        send back the result from the user space of the ntf-new-ls or
+        ntf-release-ls ls-event. The user space can decide to accept
+        or reject the lockspace creation. Sending the result back requires
+        to tell the DLM lockspace the cluster-wide unique global-id.
+      attribute-set: ls-event-result
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - ls-name
+            - ls-global-id
+            - result
+    -
+      name: get-cfg
+      doc: |
+        get the current DLM kernel configuration attributes.
+      attribute-set: cfg
+      do:
+        reply:
+          attributes:
+            - our-nodeid
+            - cluster-name
+            - protocol
+            - port
+            - recover-timeout
+            - inactive-timeout
+            - log-level
+            - default-mark
+            - recover-callbacks
+    -
+      name: set-our-nodeid
+      doc: |
+        set our nodeid. The node need to be part of the DLM registered
+        nodes.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - our-nodeid
+    -
+      name: set-cluster-name
+      doc: |
+        set the DLM cluster name.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - cluster-name
+    -
+      name: set-protocol
+      doc: |
+        set the DLM used transportation protocol.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - protocol
+    -
+      name: set-port
+      doc: |
+        set the DLM port to listen for the used transportation protocol.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - port
+    -
+      name: set-recover-timeout
+      doc: |
+        The DLM recovery has some wait events that requires other nodes
+        to answer in a time. This is the timeout value how long DLM
+        should wait until giving up in the DLM recovery routines.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - recover-timeout
+    -
+      name: set-inactive-timeout
+      doc: |
+        DLM lock resources are keeping in memory if not being used inside
+        the lockspace anymore to fast reactivate them if they get used after
+        a certain timeout that can be specified here.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - inactive-timeout
+    -
+      name: set-log-level
+      doc: |
+        set the DLM kernel logging level.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - log-level
+    -
+      name: set-default-mark
+      doc: |
+        set the default skb mark value for DLM sockets.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - default-mark
+    -
+      name: set-recover-callbacks
+      doc: |
+        set feature for recover callbacks that is required for some kernel
+        DLM users.
+      attribute-set: cfg
+      flags: [ admin-perm ]
+      do:
+        request:
+          attributes:
+            - recover-callbacks
+
+mcast-groups:
+  list:
+    -
+      name: ls-event
fs/dlm/Makefile +2 -0
index c37f9fc361c6..05cd2fca2b1e 100644
@@ -11,6 +11,8 @@ dlm-y :=			ast.o \
 				memory.o \
 				midcomms.o \
 				lowcomms.o \
+				nldlm.o \
+				nldlm-kernel.o \
 				plock.o \
 				rcom.o \
 				recover.o \
fs/dlm/config.c +16 -4
index 93d10b9e7483..bb7e2f9b6db8 100644
@@ -91,11 +91,21 @@ int __init dlm_config_init(void)
 	if (rv)
 		return rv;
 
+	rv = dlm_nldlm_init();
+	if (rv)
+		goto err;
+
 	rv = dlm_configfs_init();
-	if (rv) {
-		unregister_pernet_subsys(&dlm_net_ops);
-		dlm_net_id = 0;
-	}
+	if (rv)
+		goto err_nldlm;
+
+	return rv;
+
+err_nldlm:
+	dlm_nldlm_exit();
+err:
+	unregister_pernet_subsys(&dlm_net_ops);
+	dlm_net_id = 0;
 
 	return rv;
 }
@@ -103,6 +113,8 @@ int __init dlm_config_init(void)
 void dlm_config_exit(void)
 {
 	dlm_configfs_exit();
+	dlm_nldlm_exit();
+
 	unregister_pernet_subsys(&dlm_net_ops);
 	dlm_net_id = 0;
 }
fs/dlm/dlm_internal.h +4 -0
index 10fe3b59bd70..c1f85c9a6e77 100644
@@ -813,6 +813,10 @@ extern struct workqueue_struct *dlm_wq;
 int dlm_plock_init(void);
 void dlm_plock_exit(void);
 
+int nldlm_ls_event(const struct dlm_ls *ls, uint32_t cmd);
+int __init dlm_nldlm_init(void);
+void dlm_nldlm_exit(void);
+
 #ifdef CONFIG_DLM_DEBUG
 void dlm_register_debugfs(void);
 void dlm_unregister_debugfs(void);
fs/dlm/lockspace.c +11 -2
index e5eeb3957b89..862d32774100 100644
@@ -9,6 +9,7 @@
 *******************************************************************************
 ******************************************************************************/
 
+#include <uapi/linux/nldlm.h>
 #include <linux/netdevice.h>
 #include <linux/module.h>
 
@@ -205,10 +206,18 @@ static const struct kobj_type dlm_kset_ktype = {
 
 static int do_uevent(struct dlm_ls *ls, int in)
 {
-	if (in)
+	int rv;
+
+	if (in) {
 		kobject_uevent(&ls->ls_kobj, KOBJ_ONLINE);
-	else
+		rv = nldlm_ls_event(ls, NLDLM_CMD_NTF_NEW_LS);
+	} else {
 		kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE);
+		rv = nldlm_ls_event(ls, NLDLM_CMD_NTF_RELEASE_LS);
+	}
+
+	/* ignore if nldlm_ls_event() has no subscribers */
+	WARN_ON(rv && rv != -ESRCH);
 
 	log_rinfo(ls, "%s the lockspace group...", in ? "joining" : "leaving");
 
fs/dlm/netlink2.c new file +1330 -0

1,330 lines not on this page · raw message

fs/dlm/nldlm-kernel.c new file +290 -0

290 lines not on this page · raw message

fs/dlm/nldlm-kernel.h new file +50 -0

50 lines not on this page · raw message

fs/dlm/nldlm.c new file +847 -0

814 lines not on this page · raw message

include/uapi/linux/nldlm.h new file +153 -0

153 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

author maintainer
#14 lore raw

PATCH v2 12/12 gfs2: separate mount context by net-namespaces

In reply to Alexander Aring

This patch changes gfs2 to be the first user of the recently introduced net-namespace feature of DLM. It uses the current net-namespace context of the get_tree() callback of "struct fs_context_operations" that is e.g. being called by syscalls of the coreutils mount process.

Debugfs is being disabled for non "init_net" net-namespaces as debugfs is not net-namespace aware. Otherwise we would see kernel log error messages about existing debugfs entries. There might be in future another ways to get similar information with an UAPI mechanism that is namespace aware.

With this patch you can setup a cluster in one machine without using multiple Linux kernel instances. The idea is to use this for developing/testing as a first use-case. Especially scale testing, a gfs2 file system with a lot of members can be setup without running a large set of virtual machines.

There is a small example script how it works:

https://gitlab.com/netcoder/gfs2ns-examples/-/blob/main/three_nodes

it uses multiple loop block devices references to the same file to provide a kind of shared block device (an alternative could be using dm linear mapping, but loop block device also works). After setting up multiple net-namespaces with a virtual bridge interface DLM can be configured by using nldlmd that is using the recently introduced net-namespace aware nldlm netlink API. Over a shell command like:

ip netns exec node1 sh -c "mount /dev/loop1 /cluster/node1" ip netns exec node2 sh -c "mount /dev/loop2 /cluster/node2"
...

every cluster "node" (hereby identifier with a "node#" string in the iproute2 namespace management mechanism) can mount the shared block device e.g. /dev/loop1, /dev/loop# that references to the same block image on a different file system. Note that the caller in the script will be unmount the file system if the last user left the namespace. I currently workaround this use case by mountbind each block device again in a kind of "default" namespace (usually it should be where "init_net" references to).

Then each mountpoint of "/cluster/node#" acts like being a cluster node access to the gfs2 file system with DLM locking enabled. This offers us new possibilities to write testcases as we operate on a single machine and can "easier" synchronize vfs syscalls in our testcase as no "remote machine" kind network communication is being involved.

The mount sysfs directory for gfs2 needs to be separated by net-namespace as our mount call is from namespace view separated and be treated as per "node" (machine) call. Otherwise we would run into conflicts on files/directories that already exists as the cluster wide unique identifiers are already being in use.

The gfs2 file system has some global variables and it seems it is not necessary to separate them by net-namespace as they store a unique per mount identifier. I didn't had problems yet and it seems it is currently okay to do that, otherwise there might be issues with "things" that are not net-namespace aware in gfs2 yet. However we only should find issues only when we using net-namespaces. If a user only uses "init_net" as this is the current default, there should not be any problems.

---
 fs/gfs2/glock.c      |  8 ++++++++
 fs/gfs2/incore.h     |  2 ++
 fs/gfs2/lock_dlm.c   |  2 +-
 fs/gfs2/ops_fstype.c |  5 +++++
 fs/gfs2/sys.c        | 35 ++++++++++++++++++++++++++++++++++-
 5 files changed, 50 insertions(+), 2 deletions(-)
fs/gfs2/glock.c +8 -0
index 269c3bc7fced..8c2d715485ef 100644
@@ -2901,6 +2901,10 @@ DEFINE_SEQ_ATTRIBUTE(gfs2_sbstats);
 
 void gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
 {
+	/* debugfs is only available for init_net users */
+	if (!net_eq(read_pnet(&sdp->net), &init_net))
+		return;
+
 	sdp->debugfs_dir = debugfs_create_dir(sdp->sd_table_name, gfs2_root);
 
 	debugfs_create_file("glocks", S_IFREG | S_IRUGO, sdp->debugfs_dir, sdp,
@@ -2918,6 +2922,10 @@ void gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
 
 void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp)
 {
+	/* debugfs is only available for init_net users */
+	if (!net_eq(read_pnet(&sdp->net), &init_net))
+		return;
+
 	debugfs_remove_recursive(sdp->debugfs_dir);
 	sdp->debugfs_dir = NULL;
 }
fs/gfs2/incore.h +2 -0
index aa4ef67a34e0..1273ef3dbef5 100644
@@ -710,6 +710,8 @@ struct gfs2_sbd {
 
 	/* Lock Stuff */
 
+	possible_net_t net;
+	netns_tracker tracker;	/* keep track of net references */
 	struct lm_lockstruct sd_lockstruct;
 	struct gfs2_holder sd_live_gh;
 	struct gfs2_glock *sd_rename_gl;
fs/gfs2/lock_dlm.c +1 -1
index 6c5dce57a2ee..d8e1bb99dac2 100644
@@ -1328,7 +1328,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)
 	 * create/join lockspace
 	 */
 
-	error = dlm_new_lockspace(&init_net, fsname, cluster, flags,
+	error = dlm_new_lockspace(read_pnet(&sdp->net), fsname, cluster, flags,
 				  GDLM_LVB_SIZE, &gdlm_lockspace_ops, sdp,
 				  &ops_result, &ls->ls_dlm);
 	if (error) {
fs/gfs2/ops_fstype.c +5 -0
index e83d293c3614..62555fd33210 100644
@@ -64,6 +64,8 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
 
 void free_sbd(struct gfs2_sbd *sdp)
 {
+	put_net_track(read_pnet(&sdp->net), &sdp->tracker);
+
 	if (sdp->sd_lkstats)
 		free_percpu(sdp->sd_lkstats);
 	kfree(sdp);
@@ -71,6 +73,7 @@ void free_sbd(struct gfs2_sbd *sdp)
 
 static struct gfs2_sbd *init_sbd(struct super_block *sb)
 {
+	struct net *net = current->nsproxy->net_ns;
 	struct gfs2_sbd *sdp;
 	struct address_space *mapping;
 
@@ -78,6 +81,8 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 	if (!sdp)
 		return NULL;
 
+	/* store the net-namespace the sdp is created into */
+	write_pnet(&sdp->net, get_net_track(net, &sdp->tracker, GFP_KERNEL));
 	sdp->sd_vfs = sb;
 	sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);
 	if (!sdp->sd_lkstats)
fs/gfs2/sys.c +34 -1
index ecc699f8d9fc..20d1d1fed189 100644
@@ -16,6 +16,7 @@
 #include <linux/uaccess.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/blkdev.h>
+#include <linux/netdevice.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -57,6 +58,24 @@ static const struct sysfs_ops gfs2_attr_ops = {
 
 static struct kset *gfs2_kset;
 
+#if IS_ENABLED(CONFIG_NET)
+/* gfs2 sysfs is separated by net-namespaces */
+static const struct kobj_ns_type_operations *
+gfs2_sysfs_object_child_ns_type(const struct kobject *kobj)
+{
+	return &net_ns_type_operations;
+}
+#endif
+
+static const struct kobj_type gfs2_kset_ktype = {
+	.sysfs_ops      = &kobj_sysfs_ops,
+	.release	= kset_release,
+	.get_ownership  = kset_get_ownership,
+#if IS_ENABLED(CONFIG_NET)
+	.child_ns_type  = gfs2_sysfs_object_child_ns_type,
+#endif
+};
+
 static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
 {
 	return snprintf(buf, PAGE_SIZE, "%u:%u\n",
@@ -383,10 +402,23 @@ static void gfs2_sbd_release(struct kobject *kobj)
 	complete(&sdp->sd_kobj_unregister);
 }
 
+#if IS_ENABLED(CONFIG_NET)
+/* return the net-namespace the kobj belonging to */
+static const void *gfs2_kobj_namespace(const struct kobject *kobj)
+{
+	struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
+
+	return read_pnet(&sdp->net);
+}
+#endif
+
 static struct kobj_type gfs2_ktype = {
 	.release = gfs2_sbd_release,
 	.default_groups = gfs2_groups,
 	.sysfs_ops     = &gfs2_attr_ops,
+#if IS_ENABLED(CONFIG_NET)
+	.namespace = gfs2_kobj_namespace,
+#endif
 };
 
 
@@ -797,7 +829,8 @@ static const struct kset_uevent_ops gfs2_uevent_ops = {
 
 int gfs2_sys_init(void)
 {
-	gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj);
+	gfs2_kset = kset_type_create_and_add("gfs2", &gfs2_uevent_ops,
+					     fs_kobj, &gfs2_kset_ktype);
 	if (!gfs2_kset)
 		return -ENOMEM;
 	return 0;
Signature · 1 line
2.43.0
author maintainer
#13 lore raw

Re: [PATCHv2 dlm/next 11/12] dlm: add nldlm net-namespace aware UAPI

In reply to Alexander Aring

Hi,

Quoted 25 lines · Alexander Aring

Recent patches introduced support to separate DLM lockspaces on a per net-namespace basis. Currently the file based configfs mechanism is used to configure parts of DLM. Due the lack of namespace awareness (and it's probably complicated to add support for this) in configfs we introduce a socket based UAPI using "netlink". As the DLM subsystem offers now a config layer it can simultaneously being used with configfs, just that nldlm is net-namespace aware.

Most of the current configfs functionality that is necessary to configure DLM is being adapted for now. The nldlm netlink interface offers also a multicast group for lockspace events NLDLM_MCGRP_EVENT. This event group can be used as alternative to the already existing udev event behaviour just it only contains DLM related subsystem events.

Attributes e.g. nodeid, port, IP addresses are expected from the user space to fill those numbers as they appear on the wire. In case of DLM fields it is using little endian byte order.

The dumps are being designed to scale in future with high numbers of members in a lockspace. E.g. dump members require an unique lockspace identifier (currently only the name) and nldlm is using a netlink dump behaviour to be prepared if all entries may not fit into one netlink message.

Quoted 8 lines
---
 Documentation/netlink/specs/nldlm.yaml |  438 ++++++++
 fs/dlm/Makefile                        |    2 +
 fs/dlm/config.c                        |   20 +-
 fs/dlm/dlm_internal.h                  |    4 +
 fs/dlm/lockspace.c                     |   13 +-
 fs/dlm/netlink2.c                      | 1330 ++++++++++++++++++++++++

and this file shouldn't be there anymore. Will be dropped in v3.

- Alex

#15 lore raw
In reply to Alexander Aring
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Alexander" == Alexander Aring <[email protected]> writes:

Hi,
this patch-series is huge but brings a lot of basic "fun" net-namespace functionality to DLM. Currently you need a couple of Linux kernel

Please spell out TLAs like DLM the first time you use them. In this case I'm suer you mean Distributed Lock Manager, right?

Quoted 5 lines

instances running in e.g. Virtual Machines. With this patch-series I want to break out of this virtual machine world dealing with multiple kernels need to boot them all individually, etc. Now you can use DLM in only one Linux kernel instance and each "node" (previously represented by a virtual machine) is separate by a net-namespace. Why

Quoted 8 lines

net-namespaces? It just fits to the DLM design for now, you need to have them anyway because the internal DLM socket handling on a per node basis. What we do additionally is to separate the DLM lockspaces (the lockspace that is being registered) by net-namespaces as this represents a "network entity" (node). There might be reasons to introduce a complete new kind of namespaces (locking namespace?) but I don't want to do this step now and as I said net-namespaces are required anyway for the DLM sockets.

This section needs to be re-written to more clearly explain what you're trying to accomplish here, and how this is different or better than what went before. I realize you probably have this knowledge all internalized, but spelling it out in a clear and simple manner would be helpful to everyone.

Quoted 4 lines

You need some new user space tooling as a new netlink net-namespace aware UAPI is introduced (but can co-exist with configfs that operates on init_net only). See [0] for more steps, there is a copr repo for the new tooling and can be enabled by:

What the heck is a 'copr'?

Quoted 4 lines
$ dnf copr enable aring/nldlm
$ dnf install nldlm

or compile it yourself.

These steps really entirely ignore the _why_ you would do this. And assume RedHad based systems.

Quoted 1 line

Then there is currently a very simple script [1] to show a 3 nodes cluster

nit: 3 node cluster

Quoted 4 lines

using gfs2 on a multiple loop block devices on a shared loop block device image (sounds weird but I do something like that). There are currently some user space synchronization issues that I solve by simple sleeps, but they are only user space problems.

Can you give the example on how to do this setup? Ideally in another patch which updates the Documentation/??? file to in the kernel tree.

Quoted 1 line

To test it I recommend some virtual machine "but only one" and run the

I'm having a hard time parsing this, please be more careful with singular or plural usage. English is hard! :-)

Quoted 3 lines

[1] script. Afterwards you have in your executed net-namespace the 3 mountpoints /cluster/node1, /cluster/node2/ and /cluster/node3. Any vfs operations on those mountpoints acts as a per node entity operation.

Which means what? So if I write to /cluster/node1/foo, it shows up in the other two mount points? Or do I need to create a filesystem on top?

Quoted 9 lines

We can use it for testing, development and also scale testing to have a large number of nodes joining a lockspace (which seems to be a problem right now). Instead of running 1000 vms, we can run 1000 net-namespaces in a more resource limited environment. For me it seems gfs2 can handle several mounts and still separate the resource according their global variables. Their data structures e.g. glock hash seems to have in their key a separation for that (fsid?). However this is still an experimental feature we might run into issues that requires more separation related to net-namespaces. However basic testing seems to run just fine.

So is this all just to make testing and development easier so you don't need 10 or 1000 nodes to do stress testing? Would anyone use this in real life?

Quoted 6 lines

Limitations

I disable any functionality for the DLM character device that allow plock handling or do DLM locking from user space. Just don't use any plock locking in gfs2 for now. But basic vfs operations should work. You can even sniff DLM traffic on the created "dlmsw" virtual bridge.

So... what functionality is exposed by this patchset? And Maybe add in an "Advantages" section to explain why this is so good.

Thanks!
John

Quoted 77 lines

- Alex

[0] https://gitlab.com/netcoder/nldlm
[1] https://gitlab.com/netcoder/gfs2ns-examples/-/blob/main/three_nodes

changes since v2:
- move to ynl and introduce and use netlink yaml spec
- put the nldlm.h DLM netlink header under UAPI directory
- fix build issues building with CONFIG_NET disabled
- fix possible nullpointer deference if lookup of lockspace failed

Alexander Aring (12):
dlm: introduce dlm_find_lockspace_name()
dlm: disallow different configs nodeid storages
dlm: add struct net to dlm_new_lockspace()
dlm: handle port as __be16 network byte order
dlm: use dlm_config as only cluster configuration
dlm: dlm_config_info config fields to unsigned int
dlm: rename config to configfs
kobject: add kset_type_create_and_add() helper
kobject: export generic helper ops
dlm: separate dlm lockspaces per net-namespace
dlm: add nldlm net-namespace aware UAPI
gfs2: separate mount context by net-namespaces

 Documentation/netlink/specs/nldlm.yaml |  438 ++++++++
 drivers/md/md-cluster.c                |    3 +-
 fs/dlm/Makefile                        |    3 +
 fs/dlm/config.c                        | 1291 +++++++++--------------
 fs/dlm/config.h                        |  215 +++-
 fs/dlm/configfs.c                      |  882 ++++++++++++++++
 fs/dlm/configfs.h                      |   19 +
 fs/dlm/debug_fs.c                      |   24 +-
 fs/dlm/dir.c                           |    4 +-
 fs/dlm/dlm_internal.h                  |   24 +-
 fs/dlm/lock.c                          |   64 +-
 fs/dlm/lock.h                          |    3 +-
 fs/dlm/lockspace.c                     |  220 ++--
 fs/dlm/lockspace.h                     |   12 +-
 fs/dlm/lowcomms.c                      |  525 +++++-----
 fs/dlm/lowcomms.h                      |   29 +-
 fs/dlm/main.c                          |    5 -
 fs/dlm/member.c                        |   36 +-
 fs/dlm/midcomms.c                      |  287 ++---
 fs/dlm/midcomms.h                      |   31 +-
 fs/dlm/netlink2.c                      | 1330 ++++++++++++++++++++++++
 fs/dlm/nldlm-kernel.c                  |  290 ++++++
 fs/dlm/nldlm-kernel.h                  |   50 +
 fs/dlm/nldlm.c                         |  847 +++++++++++++++
 fs/dlm/plock.c                         |    2 +-
 fs/dlm/rcom.c                          |   16 +-
 fs/dlm/rcom.h                          |    3 +-
 fs/dlm/recover.c                       |   17 +-
 fs/dlm/user.c                          |   63 +-
 fs/dlm/user.h                          |    2 +-
 fs/gfs2/glock.c                        |    8 +
 fs/gfs2/incore.h                       |    2 +
 fs/gfs2/lock_dlm.c                     |    6 +-
 fs/gfs2/ops_fstype.c                   |    5 +
 fs/gfs2/sys.c                          |   35 +-
 fs/ocfs2/stack_user.c                  |    2 +-
 include/linux/dlm.h                    |    9 +-
 include/linux/kobject.h                |   10 +-
 include/uapi/linux/nldlm.h             |  153 +++
 lib/kobject.c                          |   65 +-
 40 files changed, 5566 insertions(+), 1464 deletions(-)
 create mode 100644 Documentation/netlink/specs/nldlm.yaml
 create mode 100644 fs/dlm/configfs.c
 create mode 100644 fs/dlm/configfs.h
 create mode 100644 fs/dlm/netlink2.c
 create mode 100644 fs/dlm/nldlm-kernel.c
 create mode 100644 fs/dlm/nldlm-kernel.h
 create mode 100644 fs/dlm/nldlm.c
 create mode 100644 include/uapi/linux/nldlm.h
Signature · 1 line
2.43.0
author maintainer
#16 lore raw

Hi,

Quoted 10 lines · John Stoffel
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Alexander" == Alexander Aring <[email protected]> writes:

Hi,
this patch-series is huge but brings a lot of basic "fun" net-namespace functionality to DLM. Currently you need a couple of Linux kernel

Please spell out TLAs like DLM the first time you use them. In this case I'm suer you mean Distributed Lock Manager, right?

Yes, DLM stands for Distributed Lock Manager that lives currently in "fs/dlm".

Quoted 14 lines
Quoted 5 lines

instances running in e.g. Virtual Machines. With this patch-series I want to break out of this virtual machine world dealing with multiple kernels need to boot them all individually, etc. Now you can use DLM in only one Linux kernel instance and each "node" (previously represented by a virtual machine) is separate by a net-namespace. Why

Quoted 8 lines

net-namespaces? It just fits to the DLM design for now, you need to have them anyway because the internal DLM socket handling on a per node basis. What we do additionally is to separate the DLM lockspaces (the lockspace that is being registered) by net-namespaces as this represents a "network entity" (node). There might be reasons to introduce a complete new kind of namespaces (locking namespace?) but I don't want to do this step now and as I said net-namespaces are required anyway for the DLM sockets.

Quoted 6 lines

This section needs to be re-written to more clearly explain what you're trying to accomplish here, and how this is different or better than what went before. I realize you probably have this knowledge all internalized, but spelling it out in a clear and simple manner would be helpful to everyone.

Okay, I'll try my best next time.

Usually lockspaces are separated by a per node instance as a different "network entity" with net-namespaces. I separate them instead of building a different "network entity" as a virtual machine that runs a different Linux kernel instance.

There might be a question if DLM lockspaces should be separated by net-namespace or yet another "locking" namespace can be introduced? I don't want to go this step yet as lockspaces are separated by a "network entity" anyway.

Quoted 7 lines
Quoted 4 lines

You need some new user space tooling as a new netlink net-namespace aware UAPI is introduced (but can co-exist with configfs that operates on init_net only). See [0] for more steps, there is a copr repo for the new tooling and can be enabled by:

What the heck is a 'copr'?

That is just a binary repo for rpm packages. Some users may find it handy.

Quoted 9 lines
Quoted 5 lines
$ dnf copr enable aring/nldlm
$ dnf install nldlm

or compile it yourself.

These steps really entirely ignore the _why_ you would do this. And assume RedHad based systems.

That is correct. I will mention that those steps are only for those specific systems.

Quoted 4 lines
Quoted 1 line

Then there is currently a very simple script [1] to show a 3 nodes cluster

nit: 3 node cluster

Quoted 8 lines
Quoted 4 lines

using gfs2 on a multiple loop block devices on a shared loop block device image (sounds weird but I do something like that). There are currently some user space synchronization issues that I solve by simple sleeps, but they are only user space problems.

Can you give the example on how to do this setup? Ideally in another patch which updates the Documentation/??? file to in the kernel tree.

https://gitlab.com/netcoder/gfs2ns-examples/-/blob/main/three_nodes

As I quote with [1]. Okay, I will move them away from my separate repository and add them in Documentation/

Quoted 5 lines
Quoted 1 line

To test it I recommend some virtual machine "but only one" and run the

I'm having a hard time parsing this, please be more careful with singular or plural usage. English is hard! :-)

Quoted 8 lines
Quoted 3 lines

[1] script. Afterwards you have in your executed net-namespace the 3 mountpoints /cluster/node1, /cluster/node2/ and /cluster/node3. Any vfs operations on those mountpoints acts as a per node entity operation.

Which means what? So if I write to /cluster/node1/foo, it shows up in the other two mount points? Or do I need to create a filesystem on top?

Now we are at a point where I think nobody does it in such a way before. I create a "fake" shared block device with 3 block devices:
/dev/loop1, /dev/loop2, /dev/loop3 and they all point to the same filesystem image. Then create only once the gfs2 filesystem on it. Afterwards you can call mount with each process context in the previously mentioned "network entity" for each block device in their "imagined" assigned network entity. The example script does a mount from each net-namespace in the executed net-namespace and you can access each per "network entity" mountpoint per /cluster/node1, /cluster/node2, /cluster/node3 on the executed net-namespace context.

Yes when you call touch /cluster/node1/foo it should show up in the other mountpoints.

Quoted 10 lines
Quoted 9 lines

We can use it for testing, development and also scale testing to have a large number of nodes joining a lockspace (which seems to be a problem right now). Instead of running 1000 vms, we can run 1000 net-namespaces in a more resource limited environment. For me it seems gfs2 can handle several mounts and still separate the resource according their global variables. Their data structures e.g. glock hash seems to have in their key a separation for that (fsid?). However this is still an experimental feature we might run into issues that requires more separation related to net-namespaces. However basic testing seems to run just fine.

Quoted 4 lines

So is this all just to make testing and development easier so you don't need 10 or 1000 nodes to do stress testing? Would anyone use this in real life?

Stress testing maybe, development easier for sure. There are scaling issues with the recovery handling and handling about ~100 nodes related that DLM will stop all lockspace activity when nodes join/leave, that is something I want to look at when I hopefully have this patch series upstream.

Another example is the DLM lock verifier [0], and I need to be careful with the name lock verifier. It verifies that only compatible lock modes can be in use at the same time on a per "network entity" basis. This is the fundamental mechanism of DLM, if this does not work DLM is broken. We can do that now because we know the whole cluster information. We can confirm on any payload that DLM works correctly. For me, this alone is worth having this feature.

For example, we can introduce a new sort of cluster file system xfstests, touch /cluster/node1/foo and check if the file shows up in /cluster/node2/foo. That is an easy example, sometimes we need to synchronize vfs operations and check them on the other "network entity". With this feature we don't need to synchronize our "testing script" over the network anymore with other processes running on other "network entities".

In real life there is maybe not an example yet. Maybe when people start to use DLM for user space locking on a container basis, but this requires net-namespace user space locking functionality that is a future step.

Quoted 10 lines
Quoted 6 lines

Limitations

I disable any functionality for the DLM character device that allow plock handling or do DLM locking from user space. Just don't use any plock locking in gfs2 for now. But basic vfs operations should work. You can even sniff DLM traffic on the created "dlmsw" virtual bridge.

So... what functionality is exposed by this patchset? And Maybe add in an "Advantages" section to explain why this is so good.

Sure, it is important to mention that this net-namespace functionality is experimental. If you use DLM without changing the net-namespace process context it should work as before, in this case there are no limitations.

- Alex

[0] https://lore.kernel.org/gfs2/[email protected]/T/#t

#11 lore raw

Re: [PATCHv2 dlm/next 10/12] dlm: separate dlm lockspaces per net-namespace

In reply to Alexander Aring
kernel test robot noticed "fs/dlm/midcomms.c:#RCU-list_traversed_in_non-reader_section" on:

Hello,

kernel test robot noticed "fs/dlm/midcomms.c:#RCU-list_traversed_in_non-reader_section" on:

commit: e89c4c2902364b7dda0fda243da1b7e84a1faae5 ("[PATCHv2 dlm/next 10/12] dlm: separate dlm lockspaces per net-namespace")
url: https://github.com/intel-lab-lkp/linux/commits/Alexander-Aring/dlm-introduce-dlm_find_lockspace_name/20241001-041944
base: https://git.kernel.org/cgit/linux/kernel/git/gregkh/driver-core.git ad46e8f95e931e113cb98253daf6d443ac244cde patch link: https://lore.kernel.org/all/[email protected]/
patch subject: [PATCHv2 dlm/next 10/12] dlm: separate dlm lockspaces per net-namespace

in testcase: trinity
version:
with following parameters:

	runtime: 300s
	group: group-00
	nr_groups: 5

compiler: clang-18
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

(please refer to attached dmesg/kmsg for entire log/backtrace)

+-------------------------------------------------------------------------+------------+------------+
|                                                                         | 7bd2eb99b7 | e89c4c2902 |
+-------------------------------------------------------------------------+------------+------------+
| fs/dlm/midcomms.c:#RCU-list_traversed_in_non-reader_section             | 0          | 12         |
| fs/dlm/lowcomms.c:#RCU-list_traversed_in_non-reader_section             | 0          | 12         |
+-------------------------------------------------------------------------+------------+------------+

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-lkp/[email protected]

[   35.412526][  T331] WARNING: suspicious RCU usage
[   35.412943][  T331] 6.11.0-11738-ge89c4c290236 #1 Not tainted
[   35.413404][  T331] -----------------------------
[   35.413801][  T331] fs/dlm/midcomms.c:1170 RCU-list traversed in non-reader section!!
[   35.414429][  T331]
[   35.414429][  T331] other info that might help us debug this:
[   35.414429][  T331]
[   35.415231][  T331]
[   35.415231][  T331] rcu_scheduler_active = 2, debug_locks = 1
[   35.415867][  T331] 4 locks held by kworker/u8:1/331:
[ 35.416277][ T331] #0: 83de38c4 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:?) 
[ 35.417037][ T331] #1: ed2b9f04 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:?) 
[ 35.417746][ T331] #2: 82eec22c (pernet_ops_rwsem){++++}-{3:3}, at: cleanup_net (net/core/net_namespace.c:583) 
[ 35.418427][ T331] #3: eaba3c70 (&dn->nodes_srcu){.+.+}-{0:0}, at: srcu_lock_acquire (include/linux/srcu.h:150) 
[   35.419124][  T331]
[   35.419124][  T331] stack backtrace:
[   35.419618][  T331] CPU: 0 UID: 0 PID: 331 Comm: kworker/u8:1 Not tainted 6.11.0-11738-ge89c4c290236 #1
[   35.420349][  T331] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   35.421318][  T331] Workqueue: netns cleanup_net
[   35.422067][  T331] Call Trace:
[ 35.422612][ T331] dump_stack_lvl (lib/dump_stack.c:122) 
[ 35.423303][ T331] dump_stack (lib/dump_stack.c:129) 
[ 35.423991][ T331] lockdep_rcu_suspicious (kernel/locking/lockdep.c:6803) 
[ 35.424808][ T331] dlm_midcomms_exit (fs/dlm/midcomms.c:?) 
[ 35.425565][ T331] dlm_net_exit (fs/dlm/config.c:70) 
[ 35.426219][ T331] cleanup_net (net/core/net_namespace.c:174 net/core/net_namespace.c:626) 
[ 35.426927][ T331] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) 
[ 35.427809][ T331] process_one_work (kernel/workqueue.c:3234) 
[ 35.428581][ T331] worker_thread (kernel/workqueue.c:3304 kernel/workqueue.c:3391) 
[ 35.429358][ T331] kthread (kernel/kthread.c:391) 
[ 35.430046][ T331] ? pr_cont_work (kernel/workqueue.c:3337) 
[ 35.430782][ T331] ? kthread_blkcg (kernel/kthread.c:342) 
[ 35.431480][ T331] ? kthread_blkcg (kernel/kthread.c:342) 
[ 35.432219][ T331] ret_from_fork (arch/x86/kernel/process.c:153) 
[ 35.432972][ T331] ret_from_fork_asm (??:?) 
[ 35.433732][ T331] entry_INT80_32 (init_task.c:?) 
[   35.434945][  T331]
[   35.435452][  T331] =============================
[   35.436245][  T331] WARNING: suspicious RCU usage
[   35.437033][  T331] 6.11.0-11738-ge89c4c290236 #1 Not tainted
[   35.440279][  T331] -----------------------------
[   35.442812][  T331] fs/dlm/lowcomms.c:1961 RCU-list traversed in non-reader section!!
[   35.446360][  T331]
[   35.446360][  T331] other info that might help us debug this:
[   35.446360][  T331]
[   35.450959][  T331]
[   35.450959][  T331] rcu_scheduler_active = 2, debug_locks = 1
[   35.454214][  T331] 4 locks held by kworker/u8:1/331:
[ 35.456221][ T331] #0: 83de38c4 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:?) 
[ 35.459107][ T331] #1: ed2b9f04 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:?) 
[ 35.461940][ T331] #2: 82eec22c (pernet_ops_rwsem){++++}-{3:3}, at: cleanup_net (net/core/net_namespace.c:583) 
[ 35.464777][ T331] #3: eaba3afc (&dn->connections_srcu){.+.+}-{0:0}, at: srcu_lock_acquire (include/linux/srcu.h:150) 
[   35.472495][  T331]
[   35.472495][  T331] stack backtrace:
[   35.473301][  T331] CPU: 0 UID: 0 PID: 331 Comm: kworker/u8:1 Not tainted 6.11.0-11738-ge89c4c290236 #1
[   35.474444][  T331] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   35.475498][  T331] Workqueue: netns cleanup_net
[   35.475954][  T331] Call Trace:
[ 35.476282][ T331] dump_stack_lvl (lib/dump_stack.c:122) 
[ 35.476700][ T331] dump_stack (lib/dump_stack.c:129) 
[ 35.477272][ T331] lockdep_rcu_suspicious (kernel/locking/lockdep.c:6803) 
[ 35.478275][ T331] dlm_lowcomms_exit (fs/dlm/lowcomms.c:?) 
[ 35.479318][ T331] dlm_midcomms_exit (fs/dlm/midcomms.c:1186) 
[ 35.480266][ T331] dlm_net_exit (fs/dlm/config.c:70) 
[ 35.481123][ T331] cleanup_net (net/core/net_namespace.c:174 net/core/net_namespace.c:626) 
[ 35.481942][ T331] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) 
[ 35.482925][ T331] process_one_work (kernel/workqueue.c:3234) 
[ 35.483825][ T331] worker_thread (kernel/workqueue.c:3304 kernel/workqueue.c:3391) 
[ 35.484571][ T331] kthread (kernel/kthread.c:391) 
[ 35.485382][ T331] ? pr_cont_work (kernel/workqueue.c:3337) 
[ 35.486288][ T331] ? kthread_blkcg (kernel/kthread.c:342) 
[ 35.487171][ T331] ? kthread_blkcg (kernel/kthread.c:342) 
[ 35.488014][ T331] ret_from_fork (arch/x86/kernel/process.c:153) 
[ 35.488786][ T331] ret_from_fork_asm (??:?) 
[ 35.489648][ T331] entry_INT80_32 (init_task.c:?) 

The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20241011/[email protected]

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki