Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* -*- mode: c; c-basic-offset: 8; -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * vim: noexpandtab sw=8 ts=8 sts=0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * stackglue.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Code which implements an OCFS2 specific interface to underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * cluster stacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Copyright (C) 2007, 2009 Oracle.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/kmod.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/kobject.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/sysctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "ocfs2_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "stackglue.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define OCFS2_STACK_PLUGIN_O2CB		"o2cb"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define OCFS2_STACK_PLUGIN_USER		"user"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define OCFS2_MAX_HB_CTL_PATH		256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static struct ocfs2_protocol_version locking_max_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static DEFINE_SPINLOCK(ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static LIST_HEAD(ocfs2_stack_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * The stack currently in use.  If not null, active_stack->sp_count > 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * the module is pinned, and the locking protocol cannot be changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) static struct ocfs2_stack_plugin *active_stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct ocfs2_stack_plugin *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	assert_spin_locked(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		if (!strcmp(p->sp_name, name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static int ocfs2_stack_driver_request(const char *stack_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				      const char *plugin_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct ocfs2_stack_plugin *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 * If the stack passed by the filesystem isn't the selected one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	 * we can't continue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (strcmp(stack_name, cluster_stack_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		rc = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (active_stack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		 * If the active stack isn't the one we want, it cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		 * be selected right now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		if (!strcmp(active_stack->sp_name, plugin_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			rc = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	p = ocfs2_stack_lookup(plugin_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (!p || !try_module_get(p->sp_owner)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		rc = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	active_stack = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* If we found it, pin it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		active_stack->sp_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * This function looks up the appropriate stack and makes it active.  If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * there is no stack, it tries to load it.  It will fail if the stack still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * cannot be found.  It will also fail if a different stack is in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static int ocfs2_stack_driver_get(const char *stack_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	char *plugin_name = OCFS2_STACK_PLUGIN_O2CB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	 * Classic stack does not pass in a stack name.  This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	 * compatible with older tools as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (!stack_name || !*stack_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		stack_name = OCFS2_STACK_PLUGIN_O2CB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (strlen(stack_name) != OCFS2_STACK_LABEL_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		       "ocfs2 passed an invalid cluster stack label: \"%s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		       stack_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/* Anything that isn't the classic stack is a user stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (strcmp(stack_name, OCFS2_STACK_PLUGIN_O2CB))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		plugin_name = OCFS2_STACK_PLUGIN_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	rc = ocfs2_stack_driver_request(stack_name, plugin_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (rc == -ENOENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		request_module("ocfs2_stack_%s", plugin_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		rc = ocfs2_stack_driver_request(stack_name, plugin_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (rc == -ENOENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		       "ocfs2: Cluster stack driver \"%s\" cannot be found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		       plugin_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	} else if (rc == -EBUSY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		       "ocfs2: A different cluster stack is in use\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static void ocfs2_stack_driver_put(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	BUG_ON(active_stack == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	BUG_ON(active_stack->sp_count == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	active_stack->sp_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (!active_stack->sp_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		module_put(active_stack->sp_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		active_stack = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (!ocfs2_stack_lookup(plugin->sp_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		plugin->sp_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		plugin->sp_max_proto = locking_max_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		list_add(&plugin->sp_list, &ocfs2_stack_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		printk(KERN_INFO "ocfs2: Registered cluster interface %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		       plugin->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		printk(KERN_ERR "ocfs2: Stack \"%s\" already registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		       plugin->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		rc = -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) EXPORT_SYMBOL_GPL(ocfs2_stack_glue_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct ocfs2_stack_plugin *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	p = ocfs2_stack_lookup(plugin->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		BUG_ON(p != plugin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		BUG_ON(plugin == active_stack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		BUG_ON(plugin->sp_count != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		list_del_init(&plugin->sp_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		printk(KERN_INFO "ocfs2: Unregistered cluster interface %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		       plugin->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		printk(KERN_ERR "Stack \"%s\" is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		       plugin->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) EXPORT_SYMBOL_GPL(ocfs2_stack_glue_unregister);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	struct ocfs2_stack_plugin *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (memcmp(max_proto, &locking_max_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		   sizeof(struct ocfs2_protocol_version))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		BUG_ON(locking_max_version.pv_major != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		locking_max_version = *max_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			p->sp_max_proto = locking_max_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) EXPORT_SYMBOL_GPL(ocfs2_stack_glue_set_max_proto_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  * The ocfs2_dlm_lock() and ocfs2_dlm_unlock() functions take no argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * for the ast and bast functions.  They will pass the lksb to the ast
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * and bast.  The caller can wrap the lksb with their own structure to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * get more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		   int mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		   struct ocfs2_dlm_lksb *lksb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		   u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		   void *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		   unsigned int namelen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (!lksb->lksb_conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		lksb->lksb_conn = conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		BUG_ON(lksb->lksb_conn != conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	return active_stack->sp_ops->dlm_lock(conn, mode, lksb, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 					      name, namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) EXPORT_SYMBOL_GPL(ocfs2_dlm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		     struct ocfs2_dlm_lksb *lksb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		     u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	BUG_ON(lksb->lksb_conn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	return active_stack->sp_ops->dlm_unlock(conn, lksb, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) EXPORT_SYMBOL_GPL(ocfs2_dlm_unlock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	return active_stack->sp_ops->lock_status(lksb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) EXPORT_SYMBOL_GPL(ocfs2_dlm_lock_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	return active_stack->sp_ops->lvb_valid(lksb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb_valid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	return active_stack->sp_ops->lock_lvb(lksb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	active_stack->sp_ops->dump_lksb(lksb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) EXPORT_SYMBOL_GPL(ocfs2_dlm_dump_lksb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) int ocfs2_stack_supports_plocks(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	return active_stack && active_stack->sp_ops->plock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) EXPORT_SYMBOL_GPL(ocfs2_stack_supports_plocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  * ocfs2_plock() can only be safely called if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  * ocfs2_stack_supports_plocks() returned true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		struct file *file, int cmd, struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	WARN_ON_ONCE(active_stack->sp_ops->plock == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (active_stack->sp_ops->plock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		return active_stack->sp_ops->plock(conn, ino, file, cmd, fl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) EXPORT_SYMBOL_GPL(ocfs2_plock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int ocfs2_cluster_connect(const char *stack_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			  const char *cluster_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			  int cluster_name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			  const char *group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			  int grouplen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			  struct ocfs2_locking_protocol *lproto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			  void (*recovery_handler)(int node_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 						   void *recovery_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			  void *recovery_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			  struct ocfs2_cluster_connection **conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	struct ocfs2_cluster_connection *new_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	BUG_ON(group == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	BUG_ON(conn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	BUG_ON(recovery_handler == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	if (grouplen > GROUP_NAME_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	if (memcmp(&lproto->lp_max_version, &locking_max_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		   sizeof(struct ocfs2_protocol_version))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 			   GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (!new_conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	strlcpy(new_conn->cc_name, group, GROUP_NAME_MAX + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	new_conn->cc_namelen = grouplen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	if (cluster_name_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		strlcpy(new_conn->cc_cluster_name, cluster_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 			CLUSTER_NAME_MAX + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	new_conn->cc_cluster_name_len = cluster_name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	new_conn->cc_recovery_handler = recovery_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	new_conn->cc_recovery_data = recovery_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	new_conn->cc_proto = lproto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	/* Start the new connection at our maximum compatibility level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	new_conn->cc_version = lproto->lp_max_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	/* This will pin the stack driver if successful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	rc = ocfs2_stack_driver_get(stack_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	rc = active_stack->sp_ops->connect(new_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		ocfs2_stack_driver_put();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	*conn = new_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		kfree(new_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) EXPORT_SYMBOL_GPL(ocfs2_cluster_connect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* The caller will ensure all nodes have the same cluster stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int ocfs2_cluster_connect_agnostic(const char *group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 				   int grouplen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				   struct ocfs2_locking_protocol *lproto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 				   void (*recovery_handler)(int node_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 							    void *recovery_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 				   void *recovery_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 				   struct ocfs2_cluster_connection **conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	char *stack_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	if (cluster_stack_name[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		stack_name = cluster_stack_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	return ocfs2_cluster_connect(stack_name, NULL, 0, group, grouplen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 				     lproto, recovery_handler, recovery_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 				     conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) EXPORT_SYMBOL_GPL(ocfs2_cluster_connect_agnostic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /* If hangup_pending is 0, the stack driver will be dropped */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			     int hangup_pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	BUG_ON(conn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	ret = active_stack->sp_ops->disconnect(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	/* XXX Should we free it anyway? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		kfree(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		if (!hangup_pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			ocfs2_stack_driver_put();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)  * Leave the group for this filesystem.  This is executed by a userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)  * program (stored in ocfs2_hb_ctl_path).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static void ocfs2_leave_group(const char *group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	char *argv[5], *envp[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	argv[0] = ocfs2_hb_ctl_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	argv[1] = "-K";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	argv[2] = "-u";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	argv[3] = (char *)group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	argv[4] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	/* minimal command environment taken from cpu_run_sbin_hotplug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	envp[0] = "HOME=/";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	envp[2] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		       "ocfs2: Error %d running user helper "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		       "\"%s %s %s %s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		       ret, argv[0], argv[1], argv[2], argv[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  * Hangup is a required post-umount.  ocfs2-tools software expects the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  * filesystem to call "ocfs2_hb_ctl" during unmount.  This happens
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  * regardless of whether the DLM got started, so we can't do it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  * in ocfs2_cluster_disconnect().  The ocfs2_leave_group() function does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)  * the actual work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) void ocfs2_cluster_hangup(const char *group, int grouplen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	BUG_ON(group == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	BUG_ON(group[grouplen] != '\0');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	ocfs2_leave_group(group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	/* cluster_disconnect() was called with hangup_pending==1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	ocfs2_stack_driver_put();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) EXPORT_SYMBOL_GPL(ocfs2_cluster_hangup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 			    unsigned int *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	return active_stack->sp_ops->this_node(conn, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) EXPORT_SYMBOL_GPL(ocfs2_cluster_this_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  * Sysfs bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static ssize_t ocfs2_max_locking_protocol_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 					       struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 					       char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	ssize_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	if (locking_max_version.pv_major)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		ret = snprintf(buf, PAGE_SIZE, "%u.%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			       locking_max_version.pv_major,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			       locking_max_version.pv_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static struct kobj_attribute ocfs2_attr_max_locking_protocol =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	__ATTR(max_locking_protocol, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	       ocfs2_max_locking_protocol_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 						 struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 						 char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	ssize_t ret = 0, total = 0, remain = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	struct ocfs2_stack_plugin *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		ret = snprintf(buf, remain, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 			       p->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		if (ret >= remain) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 			/* snprintf() didn't fit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 			total = -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		total += ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		remain -= ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	return total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) static struct kobj_attribute ocfs2_attr_loaded_cluster_plugins =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	__ATTR(loaded_cluster_plugins, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	       ocfs2_loaded_cluster_plugins_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 						struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 						char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	ssize_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	if (active_stack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 		ret = snprintf(buf, PAGE_SIZE, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			       active_stack->sp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		if (ret >= PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 			ret = -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) static struct kobj_attribute ocfs2_attr_active_cluster_plugin =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	__ATTR(active_cluster_plugin, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	       ocfs2_active_cluster_plugin_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) static ssize_t ocfs2_cluster_stack_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 					struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 					char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	ret = snprintf(buf, PAGE_SIZE, "%s\n", cluster_stack_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) static ssize_t ocfs2_cluster_stack_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 					 struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 					 const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	size_t len = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	if (len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	if (buf[len - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	if ((len != OCFS2_STACK_LABEL_LEN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	    (strnlen(buf, len) != len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	spin_lock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	if (active_stack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		if (!strncmp(buf, cluster_stack_name, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 			ret = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 			ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		memcpy(cluster_stack_name, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		ret = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	spin_unlock(&ocfs2_stack_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) static struct kobj_attribute ocfs2_attr_cluster_stack =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	__ATTR(cluster_stack, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	       ocfs2_cluster_stack_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	       ocfs2_cluster_stack_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) static ssize_t ocfs2_dlm_recover_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 					struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 					char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	return snprintf(buf, PAGE_SIZE, "1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) static struct kobj_attribute ocfs2_attr_dlm_recover_support =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	__ATTR(dlm_recover_callback_support, S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	       ocfs2_dlm_recover_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) static struct attribute *ocfs2_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	&ocfs2_attr_max_locking_protocol.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	&ocfs2_attr_loaded_cluster_plugins.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	&ocfs2_attr_active_cluster_plugin.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	&ocfs2_attr_cluster_stack.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	&ocfs2_attr_dlm_recover_support.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) static const struct attribute_group ocfs2_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	.attrs = ocfs2_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) struct kset *ocfs2_kset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) EXPORT_SYMBOL_GPL(ocfs2_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) static void ocfs2_sysfs_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	kset_unregister(ocfs2_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) static int ocfs2_sysfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	ocfs2_kset = kset_create_and_add("ocfs2", NULL, fs_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	if (!ocfs2_kset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	ret = sysfs_create_group(&ocfs2_kset->kobj, &ocfs2_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	kset_unregister(ocfs2_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)  * Sysctl bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)  * The sysctl lives at /proc/sys/fs/ocfs2/nm/hb_ctl_path.  The 'nm' doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)  * make as much sense in a multiple cluster stack world, but it's safer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)  * and easier to preserve the name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) static struct ctl_table ocfs2_nm_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		.procname	= "hb_ctl_path",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 		.data		= ocfs2_hb_ctl_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 		.maxlen		= OCFS2_MAX_HB_CTL_PATH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 		.proc_handler	= proc_dostring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) static struct ctl_table ocfs2_mod_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 		.procname	= "nm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 		.data		= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		.maxlen		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		.mode		= 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		.child		= ocfs2_nm_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) static struct ctl_table ocfs2_kern_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		.procname	= "ocfs2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		.data		= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		.maxlen		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 		.mode		= 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		.child		= ocfs2_mod_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) static struct ctl_table ocfs2_root_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 		.procname	= "fs",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 		.data		= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 		.maxlen		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 		.mode		= 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 		.child		= ocfs2_kern_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) static struct ctl_table_header *ocfs2_table_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)  * Initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) static int __init ocfs2_stack_glue_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 	strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 	ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	if (!ocfs2_table_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 		printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 		       "ocfs2 stack glue: unable to register sysctl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 		return -ENOMEM; /* or something. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	return ocfs2_sysfs_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) static void __exit ocfs2_stack_glue_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	memset(&locking_max_version, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	       sizeof(struct ocfs2_protocol_version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	ocfs2_sysfs_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 	if (ocfs2_table_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 		unregister_sysctl_table(ocfs2_table_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) MODULE_AUTHOR("Oracle");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) MODULE_DESCRIPTION("ocfs2 cluter stack glue layer");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) module_init(ocfs2_stack_glue_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) module_exit(ocfs2_stack_glue_exit);