Skip to contentSkip to conversation

dlm: configuration

PATCH In review David Teigland 2 participants 4 messages Apr 25, 2005 – Apr 26, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 4/7 dlm: configuration

Per-lockspace configuration happens through files under:
/sys/kernel/dlm/<lockspace_name>/. This includes telling each lockspace which nodes are using the lockspace and suspending locking in a lockspace.

Lockspace-independent configuration involves telling the dlm communication layer the IP address of each node ID that's being used. These addresses are set using an ioctl on a misc device.

---

 drivers/dlm/config.c       |   42 +++++
 drivers/dlm/config.h       |   31 ++++
 drivers/dlm/member_sysfs.c |  321 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/dlm/member_sysfs.h |   21 ++
 drivers/dlm/node_ioctl.c   |  126 +++++++++++++++++
 include/linux/dlm_node.h   |   43 ++++++
 6 files changed, 584 insertions(+)
include/linux/dlm_node.h +43 -0
@@ -0,0 +1,43 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+**
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#ifndef __DLM_NODE_DOT_H__
+#define __DLM_NODE_DOT_H__
+
+#define DLM_ADDR_LEN			(256)
+#define DLM_MAX_ADDR_COUNT		(3)
+#define DLM_NODE_MISC_NAME		("dlm-node")
+
+#define DLM_NODE_VERSION_MAJOR		(1)
+#define DLM_NODE_VERSION_MINOR		(0)
+#define DLM_NODE_VERSION_PATCH		(0)
+
+struct dlm_node_ioctl {
+	__u32	version[3];
+	int	nodeid;
+	int	weight;
+	char	addr[DLM_ADDR_LEN];
+};
+
+enum {
+	DLM_NODE_VERSION_CMD = 0,
+	DLM_SET_NODE_CMD,
+	DLM_SET_LOCAL_CMD,
+};
+
+#define DLM_IOCTL			(0xd1)
+
+#define DLM_NODE_VERSION _IOWR(DLM_IOCTL, DLM_NODE_VERSION_CMD, struct dlm_node_ioctl)
+#define DLM_SET_NODE     _IOWR(DLM_IOCTL, DLM_SET_NODE_CMD, struct dlm_node_ioctl)
+#define DLM_SET_LOCAL    _IOWR(DLM_IOCTL, DLM_SET_LOCAL_CMD, struct dlm_node_ioctl)
+
+#endif
drivers/dlm/config.c +42 -0

42 lines not on this page · raw message

drivers/dlm/config.h +31 -0
@@ -0,0 +1,31 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
+**  Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+**  
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#ifndef __CONFIG_DOT_H__
+#define __CONFIG_DOT_H__
+
+struct dlm_config_info {
+	int tcp_port;
+	int buffer_size;
+	int rsbtbl_size;
+	int lkbtbl_size;
+	int dirtbl_size;
+	int recover_timer;
+};
+
+extern struct dlm_config_info dlm_config;
+
+extern int dlm_config_init(void);
+extern void dlm_config_exit(void);
+
+#endif				/* __CONFIG_DOT_H__ */
drivers/dlm/member_sysfs.c +321 -0

321 lines not on this page · raw message

drivers/dlm/member_sysfs.h +21 -0
@@ -0,0 +1,21 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+**  
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#ifndef __MEMBER_SYSFS_DOT_H__
+#define __MEMBER_SYSFS_DOT_H__
+
+int dlm_member_sysfs_init(void);
+void dlm_member_sysfs_exit(void);
+int dlm_kobject_setup(struct dlm_ls *ls);
+
+#endif                          /* __MEMBER_SYSFS_DOT_H__ */
+
drivers/dlm/node_ioctl.c +126 -0

126 lines not on this page · raw message

#1 lore raw
Quoted 12 lines · David Teigland

Per-lockspace configuration happens through files under:
/sys/kernel/dlm/<lockspace_name>/. This includes telling each lockspace which nodes are using the lockspace and suspending locking in a lockspace.

Lockspace-independent configuration involves telling the dlm communication layer the IP address of each node ID that's being used. These addresses are set using an ioctl on a misc device.

[...]

Quoted 5 lines
drivers/dlm/member_sysfs.c +5 -0
+static ssize_t dlm_finish_store(struct dlm_ls *ls, const char *buf, size_t len)
+{
+	dlm_ls_finish(ls, simple_strtol(buf, NULL, 0));
+	return len;
+}

[...]

drivers/dlm/member_sysfs.c line 132

Quoted 5 lines
drivers/dlm/member_sysfs.c +5 -0
+static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
+{
+	ls->ls_global_id = simple_strtol(buf, NULL, 0);
+	return len;
+}

[...]

What's the point of `len' in these two functions?
You pass in len, don't use it at all, then return the value. I fail to see the usefulness. Why not just have the function return void and omit the `len' parameter?

Signature · 1 line
Jesper Juhl
#2 lore raw
Quoted 12 lines · Jesper Juhl

drivers/dlm/member_sysfs.c line 132

Quoted 5 lines · David Teigland
drivers/dlm/member_sysfs.c +5 -0
+static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
+{
+	ls->ls_global_id = simple_strtol(buf, NULL, 0);
+	return len;
+}

What's the point of `len' in these two functions?
You pass in len, don't use it at all, then return the value. I fail to see the usefulness. Why not just have the function return void and omit the `len' parameter?

Do I have a choice? Aren't these stipulated by sysfs?

static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t len)

{
        struct dlm_ls *ls  = container_of(kobj, struct dlm_ls, ls_kobj);
        struct dlm_attr *a = container_of(attr, struct dlm_attr, attr);
        return a->store ? a->store(ls, buf, len) : len;
}

static struct sysfs_ops dlm_attr_ops = {
.show = dlm_attr_show,
.store = dlm_attr_store,
};

Dave

#3 lore raw
Quoted 20 lines · David Teigland

Date: Tue, 26 Apr 2005 14:49:40 +0800
From: David Teigland <[email protected]>
To: Jesper Juhl <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH 4/7] dlm: configuration

Quoted 12 lines · Jesper Juhl

drivers/dlm/member_sysfs.c line 132

Quoted 5 lines · David Teigland
drivers/dlm/member_sysfs.c +5 -0
+static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
+{
+	ls->ls_global_id = simple_strtol(buf, NULL, 0);
+	return len;
+}

What's the point of `len' in these two functions?
You pass in len, don't use it at all, then return the value. I fail to see the usefulness. Why not just have the function return void and omit the `len' parameter?

Quoted 2 lines

Do I have a choice? Aren't these stipulated by sysfs?

Hmm, right you are. I simply did a quick scan through the code and commented on everything that seemed odd, I didn't look into it in too much detail (too much code, too little time), so I may also have flagged a few other things that are perfectly OK but just seemed odd on a quick pass.

Signature · 1 line
Jesper Juhl