From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: ocfs2-devel@oss.oracle.com, Joel Becker <joel.becker@oracle.com>
Subject: [PATCH 25/62] ocfs2: Add the 'cluster_stack' sysfs file.
Date: Wed, 2 Apr 2008 13:14:35 -0700 [thread overview]
Message-ID: <12071673701937-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <12071673681650-git-send-email-mfasheh@suse.com>
From: Joel Becker <joel.becker@oracle.com>
Userspace can now query and specify the cluster stack in use via the
/sys/fs/ocfs2/cluster_stack file. By default, it is 'o2cb', which is
the classic stack. Thus, old tools that do not know how to modify this
file will work just fine. The stack cannot be modified if there is a
live filesystem.
ocfs2_cluster_connect() now takes the expected cluster stack as an
argument. This way, the filesystem and the stack glue ensure they are
speaking to the same backend.
If the stack is 'o2cb', the o2cb stack plugin is used. For any other
value, the fsdlm stack plugin is selected.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
fs/ocfs2/dlmglue.c | 3 +-
fs/ocfs2/stackglue.c | 111 +++++++++++++++++++++++++++++++++++++++++++++-----
fs/ocfs2/stackglue.h | 3 +-
3 files changed, 104 insertions(+), 13 deletions(-)
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index f62a9e4..394d25a 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2627,7 +2627,8 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
}
/* for now, uuid == domain */
- status = ocfs2_cluster_connect(osb->uuid_str,
+ status = ocfs2_cluster_connect(osb->osb_cluster_stack,
+ osb->uuid_str,
strlen(osb->uuid_str),
ocfs2_do_node_down, osb,
&conn);
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 76ae4fc..bf45d9b 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -27,11 +27,17 @@
#include <linux/kobject.h>
#include <linux/sysfs.h>
+#include "ocfs2_fs.h"
+
#include "stackglue.h"
+#define OCFS2_STACK_PLUGIN_O2CB "o2cb"
+#define OCFS2_STACK_PLUGIN_USER "user"
+
static struct ocfs2_locking_protocol *lproto;
static DEFINE_SPINLOCK(ocfs2_stack_lock);
static LIST_HEAD(ocfs2_stack_list);
+static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1];
/*
* The stack currently in use. If not null, active_stack->sp_count > 0,
@@ -53,26 +59,36 @@ static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name)
return NULL;
}
-static int ocfs2_stack_driver_request(const char *name)
+static int ocfs2_stack_driver_request(const char *stack_name,
+ const char *plugin_name)
{
int rc;
struct ocfs2_stack_plugin *p;
spin_lock(&ocfs2_stack_lock);
+ /*
+ * If the stack passed by the filesystem isn't the selected one,
+ * we can't continue.
+ */
+ if (strcmp(stack_name, cluster_stack_name)) {
+ rc = -EBUSY;
+ goto out;
+ }
+
if (active_stack) {
/*
* If the active stack isn't the one we want, it cannot
* be selected right now.
*/
- if (!strcmp(active_stack->sp_name, name))
+ if (!strcmp(active_stack->sp_name, plugin_name))
rc = 0;
else
rc = -EBUSY;
goto out;
}
- p = ocfs2_stack_lookup(name);
+ p = ocfs2_stack_lookup(plugin_name);
if (!p || !try_module_get(p->sp_owner)) {
rc = -ENOENT;
goto out;
@@ -94,23 +110,42 @@ out:
* there is no stack, it tries to load it. It will fail if the stack still
* cannot be found. It will also fail if a different stack is in use.
*/
-static int ocfs2_stack_driver_get(const char *name)
+static int ocfs2_stack_driver_get(const char *stack_name)
{
int rc;
+ char *plugin_name = OCFS2_STACK_PLUGIN_O2CB;
+
+ /*
+ * Classic stack does not pass in a stack name. This is
+ * compatible with older tools as well.
+ */
+ if (!stack_name || !*stack_name)
+ stack_name = OCFS2_STACK_PLUGIN_O2CB;
+
+ if (strlen(stack_name) != OCFS2_STACK_LABEL_LEN) {
+ printk(KERN_ERR
+ "ocfs2 passed an invalid cluster stack label: \"%s\"\n",
+ stack_name);
+ return -EINVAL;
+ }
- rc = ocfs2_stack_driver_request(name);
+ /* Anything that isn't the classic stack is a user stack */
+ if (strcmp(stack_name, OCFS2_STACK_PLUGIN_O2CB))
+ plugin_name = OCFS2_STACK_PLUGIN_USER;
+
+ rc = ocfs2_stack_driver_request(stack_name, plugin_name);
if (rc == -ENOENT) {
- request_module("ocfs2_stack_%s", name);
- rc = ocfs2_stack_driver_request(name);
+ request_module("ocfs2_stack_%s", plugin_name);
+ rc = ocfs2_stack_driver_request(stack_name, plugin_name);
}
if (rc == -ENOENT) {
printk(KERN_ERR
"ocfs2: Cluster stack driver \"%s\" cannot be found\n",
- name);
+ plugin_name);
} else if (rc == -EBUSY) {
printk(KERN_ERR
- "ocfs2: A different cluster stack driver is in use\n");
+ "ocfs2: A different cluster stack is in use\n");
}
return rc;
@@ -242,7 +277,8 @@ void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb)
}
EXPORT_SYMBOL_GPL(ocfs2_dlm_dump_lksb);
-int ocfs2_cluster_connect(const char *group,
+int ocfs2_cluster_connect(const char *stack_name,
+ const char *group,
int grouplen,
void (*recovery_handler)(int node_num,
void *recovery_data),
@@ -277,7 +313,7 @@ int ocfs2_cluster_connect(const char *group,
new_conn->cc_version = lproto->lp_max_version;
/* This will pin the stack driver if successful */
- rc = ocfs2_stack_driver_get("o2cb");
+ rc = ocfs2_stack_driver_get(stack_name);
if (rc)
goto out_free;
@@ -416,10 +452,61 @@ static struct kobj_attribute ocfs2_attr_active_cluster_plugin =
__ATTR(active_cluster_plugin, S_IFREG | S_IRUGO,
ocfs2_active_cluster_plugin_show, NULL);
+static ssize_t ocfs2_cluster_stack_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+ ssize_t ret;
+ spin_lock(&ocfs2_stack_lock);
+ ret = snprintf(buf, PAGE_SIZE, "%s\n", cluster_stack_name);
+ spin_unlock(&ocfs2_stack_lock);
+
+ return ret;
+}
+
+static ssize_t ocfs2_cluster_stack_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
+{
+ size_t len = count;
+ ssize_t ret;
+
+ if (len == 0)
+ return len;
+
+ if (buf[len - 1] == '\n')
+ len--;
+
+ if ((len != OCFS2_STACK_LABEL_LEN) ||
+ (strnlen(buf, len) != len))
+ return -EINVAL;
+
+ spin_lock(&ocfs2_stack_lock);
+ if (active_stack) {
+ if (!strncmp(buf, cluster_stack_name, len))
+ ret = count;
+ else
+ ret = -EBUSY;
+ } else {
+ memcpy(cluster_stack_name, buf, len);
+ ret = count;
+ }
+ spin_unlock(&ocfs2_stack_lock);
+
+ return ret;
+}
+
+
+static struct kobj_attribute ocfs2_attr_cluster_stack =
+ __ATTR(cluster_stack, S_IFREG | S_IRUGO | S_IWUSR,
+ ocfs2_cluster_stack_show,
+ ocfs2_cluster_stack_store);
+
static struct attribute *ocfs2_attrs[] = {
&ocfs2_attr_max_locking_protocol.attr,
&ocfs2_attr_loaded_cluster_plugins.attr,
&ocfs2_attr_active_cluster_plugin.attr,
+ &ocfs2_attr_cluster_stack.attr,
NULL,
};
@@ -455,6 +542,8 @@ error:
static int __init ocfs2_stack_glue_init(void)
{
+ strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
+
return ocfs2_sysfs_init();
}
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index c96c8bb..d88bc65 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -209,7 +209,8 @@ struct ocfs2_stack_plugin {
/* Used by the filesystem */
-int ocfs2_cluster_connect(const char *group,
+int ocfs2_cluster_connect(const char *stack_name,
+ const char *group,
int grouplen,
void (*recovery_handler)(int node_num,
void *recovery_data),
--
1.5.4.1
next prev parent reply other threads:[~2008-04-02 20:26 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 20:14 [PATCH 0/62] Ocfs2 updates for 2.6.26-rc1 Mark Fasheh
2008-04-02 20:14 ` [PATCH 01/62] ocfs2: Move slot map access into slot_map.c Mark Fasheh
2008-04-02 20:14 ` [PATCH 02/62] ocfs2: Make ocfs2_slot_info private Mark Fasheh
2008-04-02 20:14 ` [PATCH 03/62] ocfs2: Change the recovery map to an array of node numbers Mark Fasheh
2008-04-02 20:14 ` [PATCH 04/62] ocfs2: slot_map I/O based on max_slots Mark Fasheh
2008-04-02 20:14 ` [PATCH 05/62] ocfs2: De-magic the in-memory slot map Mark Fasheh
2008-04-02 20:14 ` [PATCH 06/62] ocfs2: Define the contents of the slot_map file Mark Fasheh
2008-04-02 20:14 ` [PATCH 07/62] ocfs2: New slot map format Mark Fasheh
2008-04-02 20:14 ` [PATCH 08/62] ocfs2: Separate out dlm lock functions Mark Fasheh
2008-04-02 20:14 ` [PATCH 09/62] ocfs2: Use global DLM_ constants in generic code Mark Fasheh
2008-04-02 20:14 ` [PATCH 10/62] ocfs2: Use -errno instead of dlm_status for ocfs2_dlm_lock/unlock() API Mark Fasheh
2008-04-02 20:14 ` [PATCH 11/62] ocfs2: Create the lock status block union Mark Fasheh
2008-04-02 20:14 ` [PATCH 12/62] ocfs2: Introduce the new ocfs2_cluster_connect/disconnect() API Mark Fasheh
2008-04-02 20:14 ` [PATCH 13/62] ocfs2: Abstract out node number queries Mark Fasheh
2008-04-02 20:14 ` [PATCH 14/62] ocfs2: Move o2hb functionality into the stack glue Mark Fasheh
2008-04-02 20:14 ` [PATCH 15/62] ocfs2: Fill node number during cluster stack init Mark Fasheh
2008-04-02 20:14 ` [PATCH 16/62] ocfs2: Remove CANCELGRANT from the view of dlmglue Mark Fasheh
2008-04-02 20:14 ` [PATCH 17/62] ocfs2: handle async EAGAIN from NOQUEUE request Mark Fasheh
2008-04-02 20:14 ` [PATCH 18/62] ocfs2: Abstract out a debugging function for underlying dlms Mark Fasheh
2008-04-02 20:14 ` [PATCH 19/62] ocfs2: Clean up stackglue initialization Mark Fasheh
2008-04-02 20:14 ` [PATCH 20/62] ocfs2: Split o2cb code from generic stack functions Mark Fasheh
2008-04-02 20:14 ` [PATCH 21/62] ocfs2: Create ocfs2_stack_operations and split out the o2cb stack Mark Fasheh
2008-04-02 20:14 ` [PATCH 22/62] ocfs2: Break out stackglue into modules Mark Fasheh
2008-04-02 20:14 ` [PATCH 23/62] ocfs2: Create stack glue sysfs files Mark Fasheh
2008-04-02 20:14 ` [PATCH 24/62] ocfs2: Add the USERSPACE_STACK incompat bit Mark Fasheh
2008-04-02 20:14 ` Mark Fasheh [this message]
2008-04-02 20:14 ` [PATCH 26/62] ocfs2: Add the user stack module Mark Fasheh
2008-04-02 20:14 ` [PATCH 27/62] ocfs2: Add the ocfs2_control misc device Mark Fasheh
2008-04-02 20:14 ` [PATCH 28/62] ocfs2: Start the ocfs2_control handshake Mark Fasheh
2008-04-02 20:14 ` [PATCH 29/62] ocfs2: Introduce the DOWN message to ocfs2_control Mark Fasheh
2008-04-02 20:14 ` [PATCH 30/62] ocfs2: Add the local node id to the handshake Mark Fasheh
2008-04-02 20:14 ` [PATCH 31/62] ocfs2: Add the 'set version' message to the ocfs2_control device Mark Fasheh
2008-04-02 20:14 ` [PATCH 32/62] ocfs2: add fsdlm to stackglue Mark Fasheh
2008-04-02 20:14 ` [PATCH 33/62] ocfs2: Change mlog_bug_on to BUG_ON in ocfs2_lockid.h Mark Fasheh
2008-04-02 20:14 ` [PATCH 34/62] ocfs2: Add kbuild for ocfs2_stack_user.ko Mark Fasheh
2008-04-02 20:14 ` [PATCH 35/62] ocfs2: Allow selection of cluster plug-ins Mark Fasheh
2008-04-02 20:14 ` [PATCH 36/62] ocfs2: Document /sys/fs/ocfs2 Mark Fasheh
2008-04-02 20:14 ` [PATCH 37/62] ocfs2/dlm: Rename slabcache dlm_mle_cache to o2dlm_mle Mark Fasheh
2008-04-02 20:14 ` [PATCH 38/62] ocfs2/dlm: Create slabcaches for lock and lockres Mark Fasheh
2008-04-02 20:14 ` [PATCH 39/62] ocfs2/dlm: Link all lockres' to a tracking list Mark Fasheh
2008-04-02 20:14 ` [PATCH 40/62] ocfs2/dlm: Create debugfs dirs Mark Fasheh
2008-04-02 20:14 ` [PATCH 41/62] ocfs2/dlm: Dump the dlm state in a debugfs file Mark Fasheh
2008-04-02 20:14 ` [PATCH 42/62] ocfs2/dlm: Dumps the lockres' into " Mark Fasheh
2008-04-02 20:14 ` [PATCH 43/62] ocfs2/dlm: Move struct dlm_master_list_entry to dlmcommon.h Mark Fasheh
2008-04-02 20:14 ` [PATCH 44/62] ocfs2/dlm: Dumps the mles into a debugfs file Mark Fasheh
2008-04-02 20:14 ` [PATCH 45/62] ocfs2/dlm: Dumps the purgelist " Mark Fasheh
2008-04-02 20:14 ` [PATCH 46/62] ocfs2/dlm: Move dlm_print_one_mle() from dlmmaster.c to dlmdebug.c Mark Fasheh
2008-04-02 20:14 ` [PATCH 47/62] ocfs2/dlm: Fix lockname in lockres print function Mark Fasheh
2008-04-02 20:14 ` [PATCH 48/62] ocfs2/dlm: Cleanup lockres print Mark Fasheh
2008-04-02 20:14 ` [PATCH 49/62] ocfs2: Reconnect after idle time out Mark Fasheh
2008-04-02 20:15 ` [PATCH 50/62] sysfs: Allow removal of symlinks in the sysfs root Mark Fasheh
2008-04-02 20:15 ` [PATCH 51/62] ocfs2: Move /sys/o2cb to /sys/fs/o2cb Mark Fasheh
2008-04-02 20:15 ` [PATCH 52/62] ocfs2: Add support for cross extent block Mark Fasheh
2008-04-02 20:15 ` [PATCH 53/62] ocfs2: Enable cross extent block merge Mark Fasheh
2008-04-02 20:15 ` [PATCH 54/62] ocfs2: Add a new parameter for ocfs2_reserve_suballoc_bits Mark Fasheh
2008-04-02 20:15 ` [PATCH 55/62] ocfs2: Add ac_alloc_slot in ocfs2_alloc_context Mark Fasheh
2008-04-02 20:15 ` [PATCH 56/62] ocfs2: Add inode stealing for ocfs2_reserve_new_inode Mark Fasheh
2008-04-02 20:15 ` [PATCH 57/62] fs/ocfs2/aops.c: test for IS_ERR rather than 0 Mark Fasheh
2008-04-02 20:15 ` [PATCH 58/62] ocfs2: Improve rename locking Mark Fasheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12071673701937-git-send-email-mfasheh@suse.com \
--to=mfasheh@suse.com \
--cc=joel.becker@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®