2008-02-02 06:02:36 +07:00
|
|
|
/* -*- mode: c; c-basic-offset: 8; -*-
|
|
|
|
* vim: noexpandtab sw=8 ts=8 sts=0:
|
|
|
|
*
|
|
|
|
* stack_o2cb.c
|
|
|
|
*
|
|
|
|
* Code which interfaces ocfs2 with the o2cb stack.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Oracle. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2009-08-07 06:07:50 +07:00
|
|
|
#include <linux/kernel.h>
|
2008-02-02 06:02:36 +07:00
|
|
|
#include <linux/crc32.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-02-02 06:03:57 +07:00
|
|
|
#include <linux/module.h>
|
2008-02-02 06:02:36 +07:00
|
|
|
|
|
|
|
/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
|
|
|
|
#include <linux/fs.h>
|
|
|
|
|
|
|
|
#include "cluster/masklog.h"
|
|
|
|
#include "cluster/nodemanager.h"
|
|
|
|
#include "cluster/heartbeat.h"
|
2011-07-25 00:33:54 +07:00
|
|
|
#include "cluster/tcp.h"
|
2008-02-02 06:02:36 +07:00
|
|
|
|
|
|
|
#include "stackglue.h"
|
|
|
|
|
|
|
|
struct o2dlm_private {
|
|
|
|
struct dlm_eviction_cb op_eviction_cb;
|
|
|
|
};
|
|
|
|
|
2008-02-02 06:03:57 +07:00
|
|
|
static struct ocfs2_stack_plugin o2cb_stack;
|
|
|
|
|
2008-02-02 06:02:36 +07:00
|
|
|
/* These should be identical */
|
|
|
|
#if (DLM_LOCK_IV != LKM_IVMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_NL != LKM_NLMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_CR != LKM_CRMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_CW != LKM_CWMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_PR != LKM_PRMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_PW != LKM_PWMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
#if (DLM_LOCK_EX != LKM_EXMODE)
|
|
|
|
# error Lock modes do not match
|
|
|
|
#endif
|
|
|
|
static inline int mode_to_o2dlm(int mode)
|
|
|
|
{
|
|
|
|
BUG_ON(mode > LKM_MAXMODE);
|
|
|
|
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define map_flag(_generic, _o2dlm) \
|
|
|
|
if (flags & (_generic)) { \
|
|
|
|
flags &= ~(_generic); \
|
|
|
|
o2dlm_flags |= (_o2dlm); \
|
|
|
|
}
|
|
|
|
static int flags_to_o2dlm(u32 flags)
|
|
|
|
{
|
|
|
|
int o2dlm_flags = 0;
|
|
|
|
|
|
|
|
map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
|
|
|
|
map_flag(DLM_LKF_CANCEL, LKM_CANCEL);
|
|
|
|
map_flag(DLM_LKF_CONVERT, LKM_CONVERT);
|
|
|
|
map_flag(DLM_LKF_VALBLK, LKM_VALBLK);
|
|
|
|
map_flag(DLM_LKF_IVVALBLK, LKM_INVVALBLK);
|
|
|
|
map_flag(DLM_LKF_ORPHAN, LKM_ORPHAN);
|
|
|
|
map_flag(DLM_LKF_FORCEUNLOCK, LKM_FORCE);
|
|
|
|
map_flag(DLM_LKF_TIMEOUT, LKM_TIMEOUT);
|
|
|
|
map_flag(DLM_LKF_LOCAL, LKM_LOCAL);
|
|
|
|
|
|
|
|
/* map_flag() should have cleared every flag passed in */
|
|
|
|
BUG_ON(flags != 0);
|
|
|
|
|
|
|
|
return o2dlm_flags;
|
|
|
|
}
|
|
|
|
#undef map_flag
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map an o2dlm status to standard errno values.
|
|
|
|
*
|
|
|
|
* o2dlm only uses a handful of these, and returns even fewer to the
|
|
|
|
* caller. Still, we try to assign sane values to each error.
|
|
|
|
*
|
|
|
|
* The following value pairs have special meanings to dlmglue, thus
|
|
|
|
* the right hand side needs to stay unique - never duplicate the
|
|
|
|
* mapping elsewhere in the table!
|
|
|
|
*
|
|
|
|
* DLM_NORMAL: 0
|
|
|
|
* DLM_NOTQUEUED: -EAGAIN
|
|
|
|
* DLM_CANCELGRANT: -EBUSY
|
|
|
|
* DLM_CANCEL: -DLM_ECANCEL
|
|
|
|
*/
|
|
|
|
/* Keep in sync with dlmapi.h */
|
|
|
|
static int status_map[] = {
|
|
|
|
[DLM_NORMAL] = 0, /* Success */
|
|
|
|
[DLM_GRANTED] = -EINVAL,
|
|
|
|
[DLM_DENIED] = -EACCES,
|
|
|
|
[DLM_DENIED_NOLOCKS] = -EACCES,
|
|
|
|
[DLM_WORKING] = -EACCES,
|
|
|
|
[DLM_BLOCKED] = -EINVAL,
|
|
|
|
[DLM_BLOCKED_ORPHAN] = -EINVAL,
|
|
|
|
[DLM_DENIED_GRACE_PERIOD] = -EACCES,
|
|
|
|
[DLM_SYSERR] = -ENOMEM, /* It is what it is */
|
|
|
|
[DLM_NOSUPPORT] = -EPROTO,
|
|
|
|
[DLM_CANCELGRANT] = -EBUSY, /* Cancel after grant */
|
|
|
|
[DLM_IVLOCKID] = -EINVAL,
|
|
|
|
[DLM_SYNC] = -EINVAL,
|
|
|
|
[DLM_BADTYPE] = -EINVAL,
|
|
|
|
[DLM_BADRESOURCE] = -EINVAL,
|
|
|
|
[DLM_MAXHANDLES] = -ENOMEM,
|
|
|
|
[DLM_NOCLINFO] = -EINVAL,
|
|
|
|
[DLM_NOLOCKMGR] = -EINVAL,
|
|
|
|
[DLM_NOPURGED] = -EINVAL,
|
|
|
|
[DLM_BADARGS] = -EINVAL,
|
|
|
|
[DLM_VOID] = -EINVAL,
|
|
|
|
[DLM_NOTQUEUED] = -EAGAIN, /* Trylock failed */
|
|
|
|
[DLM_IVBUFLEN] = -EINVAL,
|
|
|
|
[DLM_CVTUNGRANT] = -EPERM,
|
|
|
|
[DLM_BADPARAM] = -EINVAL,
|
|
|
|
[DLM_VALNOTVALID] = -EINVAL,
|
|
|
|
[DLM_REJECTED] = -EPERM,
|
|
|
|
[DLM_ABORT] = -EINVAL,
|
|
|
|
[DLM_CANCEL] = -DLM_ECANCEL, /* Successful cancel */
|
|
|
|
[DLM_IVRESHANDLE] = -EINVAL,
|
|
|
|
[DLM_DEADLOCK] = -EDEADLK,
|
|
|
|
[DLM_DENIED_NOASTS] = -EINVAL,
|
|
|
|
[DLM_FORWARD] = -EINVAL,
|
|
|
|
[DLM_TIMEOUT] = -ETIMEDOUT,
|
|
|
|
[DLM_IVGROUPID] = -EINVAL,
|
|
|
|
[DLM_VERS_CONFLICT] = -EOPNOTSUPP,
|
|
|
|
[DLM_BAD_DEVICE_PATH] = -ENOENT,
|
|
|
|
[DLM_NO_DEVICE_PERMISSION] = -EPERM,
|
|
|
|
[DLM_NO_CONTROL_DEVICE] = -ENOENT,
|
|
|
|
[DLM_RECOVERING] = -ENOTCONN,
|
|
|
|
[DLM_MIGRATING] = -ERESTART,
|
|
|
|
[DLM_MAXSTATS] = -EINVAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int dlm_status_to_errno(enum dlm_status status)
|
|
|
|
{
|
2009-08-07 06:07:50 +07:00
|
|
|
BUG_ON(status < 0 || status >= ARRAY_SIZE(status_map));
|
2008-02-02 06:02:36 +07:00
|
|
|
|
|
|
|
return status_map[status];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void o2dlm_lock_ast_wrapper(void *astarg)
|
|
|
|
{
|
2010-01-30 05:46:44 +07:00
|
|
|
struct ocfs2_dlm_lksb *lksb = astarg;
|
2010-01-29 10:22:39 +07:00
|
|
|
|
2010-01-30 06:46:23 +07:00
|
|
|
lksb->lksb_conn->cc_proto->lp_lock_ast(lksb);
|
2008-02-02 06:02:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
|
|
|
|
{
|
2010-01-30 05:46:44 +07:00
|
|
|
struct ocfs2_dlm_lksb *lksb = astarg;
|
2010-01-29 10:22:39 +07:00
|
|
|
|
2010-01-30 06:46:23 +07:00
|
|
|
lksb->lksb_conn->cc_proto->lp_blocking_ast(lksb, level);
|
2008-02-02 06:02:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
|
|
|
|
{
|
2010-01-30 05:46:44 +07:00
|
|
|
struct ocfs2_dlm_lksb *lksb = astarg;
|
2008-02-02 06:02:36 +07:00
|
|
|
int error = dlm_status_to_errno(status);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In o2dlm, you can get both the lock_ast() for the lock being
|
|
|
|
* granted and the unlock_ast() for the CANCEL failing. A
|
|
|
|
* successful cancel sends DLM_NORMAL here. If the
|
|
|
|
* lock grant happened before the cancel arrived, you get
|
|
|
|
* DLM_CANCELGRANT.
|
|
|
|
*
|
|
|
|
* There's no need for the double-ast. If we see DLM_CANCELGRANT,
|
|
|
|
* we just ignore it. We expect the lock_ast() to handle the
|
|
|
|
* granted lock.
|
|
|
|
*/
|
|
|
|
if (status == DLM_CANCELGRANT)
|
|
|
|
return;
|
|
|
|
|
2010-01-30 06:46:23 +07:00
|
|
|
lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, error);
|
2008-02-02 06:02:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
|
|
|
|
int mode,
|
2010-01-30 05:46:44 +07:00
|
|
|
struct ocfs2_dlm_lksb *lksb,
|
2008-02-02 06:02:36 +07:00
|
|
|
u32 flags,
|
|
|
|
void *name,
|
2010-01-29 10:22:39 +07:00
|
|
|
unsigned int namelen)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
enum dlm_status status;
|
|
|
|
int o2dlm_mode = mode_to_o2dlm(mode);
|
|
|
|
int o2dlm_flags = flags_to_o2dlm(flags);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
status = dlmlock(conn->cc_lockspace, o2dlm_mode, &lksb->lksb_o2dlm,
|
|
|
|
o2dlm_flags, name, namelen,
|
2010-01-29 10:22:39 +07:00
|
|
|
o2dlm_lock_ast_wrapper, lksb,
|
2008-02-02 06:02:36 +07:00
|
|
|
o2dlm_blocking_ast_wrapper);
|
|
|
|
ret = dlm_status_to_errno(status);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn,
|
2010-01-30 05:46:44 +07:00
|
|
|
struct ocfs2_dlm_lksb *lksb,
|
2010-01-29 10:22:39 +07:00
|
|
|
u32 flags)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
enum dlm_status status;
|
|
|
|
int o2dlm_flags = flags_to_o2dlm(flags);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
status = dlmunlock(conn->cc_lockspace, &lksb->lksb_o2dlm,
|
2010-01-29 10:22:39 +07:00
|
|
|
o2dlm_flags, o2dlm_unlock_ast_wrapper, lksb);
|
2008-02-02 06:02:36 +07:00
|
|
|
ret = dlm_status_to_errno(status);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-01-30 05:46:44 +07:00
|
|
|
static int o2cb_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
return dlm_status_to_errno(lksb->lksb_o2dlm.status);
|
|
|
|
}
|
|
|
|
|
2009-06-20 05:14:13 +07:00
|
|
|
/*
|
|
|
|
* o2dlm aways has a "valid" LVB. If the dlm loses track of the LVB
|
|
|
|
* contents, it will zero out the LVB. Thus the caller can always trust
|
|
|
|
* the contents.
|
|
|
|
*/
|
2010-01-30 05:46:44 +07:00
|
|
|
static int o2cb_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
|
2009-06-20 05:14:13 +07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-01-30 05:46:44 +07:00
|
|
|
static void *o2cb_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
return (void *)(lksb->lksb_o2dlm.lvb);
|
|
|
|
}
|
|
|
|
|
2010-01-30 05:46:44 +07:00
|
|
|
static void o2cb_dump_lksb(struct ocfs2_dlm_lksb *lksb)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
dlm_print_one_lock(lksb->lksb_o2dlm.lockid);
|
|
|
|
}
|
|
|
|
|
2011-07-25 00:33:54 +07:00
|
|
|
/*
|
|
|
|
* Check if this node is heartbeating and is connected to all other
|
|
|
|
* heartbeating nodes.
|
|
|
|
*/
|
|
|
|
static int o2cb_cluster_check(void)
|
|
|
|
{
|
|
|
|
u8 node_num;
|
|
|
|
int i;
|
|
|
|
unsigned long hbmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
|
|
|
|
unsigned long netmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
|
|
|
|
|
|
|
|
node_num = o2nm_this_node();
|
|
|
|
if (node_num == O2NM_MAX_NODES) {
|
|
|
|
printk(KERN_ERR "o2cb: This node has not been configured.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* o2dlm expects o2net sockets to be created. If not, then
|
|
|
|
* dlm_join_domain() fails with a stack of errors which are both cryptic
|
|
|
|
* and incomplete. The idea here is to detect upfront whether we have
|
|
|
|
* managed to connect to all nodes or not. If not, then list the nodes
|
|
|
|
* to allow the user to check the configuration (incorrect IP, firewall,
|
|
|
|
* etc.) Yes, this is racy. But its not the end of the world.
|
|
|
|
*/
|
|
|
|
#define O2CB_MAP_STABILIZE_COUNT 60
|
|
|
|
for (i = 0; i < O2CB_MAP_STABILIZE_COUNT; ++i) {
|
|
|
|
o2hb_fill_node_map(hbmap, sizeof(hbmap));
|
|
|
|
if (!test_bit(node_num, hbmap)) {
|
|
|
|
printk(KERN_ERR "o2cb: %s heartbeat has not been "
|
|
|
|
"started.\n", (o2hb_global_heartbeat_active() ?
|
|
|
|
"Global" : "Local"));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
o2net_fill_node_map(netmap, sizeof(netmap));
|
|
|
|
/* Force set the current node to allow easy compare */
|
|
|
|
set_bit(node_num, netmap);
|
|
|
|
if (!memcmp(hbmap, netmap, sizeof(hbmap)))
|
|
|
|
return 0;
|
|
|
|
if (i < O2CB_MAP_STABILIZE_COUNT)
|
|
|
|
msleep(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_ERR "o2cb: This node could not connect to nodes:");
|
|
|
|
i = -1;
|
|
|
|
while ((i = find_next_bit(hbmap, O2NM_MAX_NODES,
|
|
|
|
i + 1)) < O2NM_MAX_NODES) {
|
|
|
|
if (!test_bit(i, netmap))
|
|
|
|
printk(" %u", i);
|
|
|
|
}
|
|
|
|
printk(".\n");
|
|
|
|
|
|
|
|
return -ENOTCONN;
|
|
|
|
}
|
|
|
|
|
2008-02-02 06:02:36 +07:00
|
|
|
/*
|
|
|
|
* Called from the dlm when it's about to evict a node. This is how the
|
|
|
|
* classic stack signals node death.
|
|
|
|
*/
|
|
|
|
static void o2dlm_eviction_cb(int node_num, void *data)
|
|
|
|
{
|
|
|
|
struct ocfs2_cluster_connection *conn = data;
|
|
|
|
|
2011-07-25 00:24:54 +07:00
|
|
|
printk(KERN_NOTICE "o2cb: o2dlm has evicted node %d from domain %.*s\n",
|
|
|
|
node_num, conn->cc_namelen, conn->cc_name);
|
2008-02-02 06:02:36 +07:00
|
|
|
|
|
|
|
conn->cc_recovery_handler(node_num, conn->cc_recovery_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
u32 dlm_key;
|
|
|
|
struct dlm_ctxt *dlm;
|
|
|
|
struct o2dlm_private *priv;
|
2010-01-22 20:58:04 +07:00
|
|
|
struct dlm_protocol_version fs_version;
|
2008-02-02 06:02:36 +07:00
|
|
|
|
|
|
|
BUG_ON(conn == NULL);
|
2010-01-30 06:46:23 +07:00
|
|
|
BUG_ON(conn->cc_proto == NULL);
|
2008-02-02 06:02:36 +07:00
|
|
|
|
2011-07-25 00:33:54 +07:00
|
|
|
/* Ensure cluster stack is up and all nodes are connected */
|
|
|
|
rc = o2cb_cluster_check();
|
|
|
|
if (rc) {
|
|
|
|
printk(KERN_ERR "o2cb: Cluster check failed. Fix errors "
|
|
|
|
"before retrying.\n");
|
2008-02-02 06:02:36 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = kzalloc(sizeof(struct o2dlm_private), GFP_KERNEL);
|
|
|
|
if (!priv) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This just fills the structure in. It is safe to pass conn. */
|
|
|
|
dlm_setup_eviction_cb(&priv->op_eviction_cb, o2dlm_eviction_cb,
|
|
|
|
conn);
|
|
|
|
|
|
|
|
conn->cc_private = priv;
|
|
|
|
|
|
|
|
/* used by the dlm code to make message headers unique, each
|
|
|
|
* node in this domain must agree on this. */
|
|
|
|
dlm_key = crc32_le(0, conn->cc_name, conn->cc_namelen);
|
2010-01-22 20:58:04 +07:00
|
|
|
fs_version.pv_major = conn->cc_version.pv_major;
|
|
|
|
fs_version.pv_minor = conn->cc_version.pv_minor;
|
2008-02-02 06:02:36 +07:00
|
|
|
|
2010-01-22 20:58:04 +07:00
|
|
|
dlm = dlm_register_domain(conn->cc_name, dlm_key, &fs_version);
|
2008-02-02 06:02:36 +07:00
|
|
|
if (IS_ERR(dlm)) {
|
|
|
|
rc = PTR_ERR(dlm);
|
|
|
|
mlog_errno(rc);
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
2010-01-22 20:58:04 +07:00
|
|
|
conn->cc_version.pv_major = fs_version.pv_major;
|
|
|
|
conn->cc_version.pv_minor = fs_version.pv_minor;
|
2008-02-02 06:02:36 +07:00
|
|
|
conn->cc_lockspace = dlm;
|
|
|
|
|
|
|
|
dlm_register_eviction_cb(dlm, &priv->op_eviction_cb);
|
|
|
|
|
|
|
|
out_free:
|
2013-02-22 07:42:44 +07:00
|
|
|
if (rc)
|
2008-02-02 06:02:36 +07:00
|
|
|
kfree(conn->cc_private);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-05-31 05:58:26 +07:00
|
|
|
static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
struct dlm_ctxt *dlm = conn->cc_lockspace;
|
|
|
|
struct o2dlm_private *priv = conn->cc_private;
|
|
|
|
|
|
|
|
dlm_unregister_eviction_cb(&priv->op_eviction_cb);
|
|
|
|
conn->cc_private = NULL;
|
|
|
|
kfree(priv);
|
|
|
|
|
|
|
|
dlm_unregister_domain(dlm);
|
|
|
|
conn->cc_lockspace = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-22 06:48:24 +07:00
|
|
|
static int o2cb_cluster_this_node(struct ocfs2_cluster_connection *conn,
|
|
|
|
unsigned int *node)
|
2008-02-02 06:02:36 +07:00
|
|
|
{
|
|
|
|
int node_num;
|
|
|
|
|
|
|
|
node_num = o2nm_this_node();
|
|
|
|
if (node_num == O2NM_INVALID_NODE_NUM)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
if (node_num >= O2NM_MAX_NODES)
|
|
|
|
return -EOVERFLOW;
|
|
|
|
|
|
|
|
*node = node_num;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-21 15:49:31 +07:00
|
|
|
static struct ocfs2_stack_operations o2cb_stack_ops = {
|
2008-02-02 06:02:36 +07:00
|
|
|
.connect = o2cb_cluster_connect,
|
|
|
|
.disconnect = o2cb_cluster_disconnect,
|
|
|
|
.this_node = o2cb_cluster_this_node,
|
|
|
|
.dlm_lock = o2cb_dlm_lock,
|
|
|
|
.dlm_unlock = o2cb_dlm_unlock,
|
|
|
|
.lock_status = o2cb_dlm_lock_status,
|
2009-06-20 05:14:13 +07:00
|
|
|
.lvb_valid = o2cb_dlm_lvb_valid,
|
2008-02-02 06:02:36 +07:00
|
|
|
.lock_lvb = o2cb_dlm_lvb,
|
|
|
|
.dump_lksb = o2cb_dump_lksb,
|
|
|
|
};
|
|
|
|
|
2008-02-02 06:03:57 +07:00
|
|
|
static struct ocfs2_stack_plugin o2cb_stack = {
|
|
|
|
.sp_name = "o2cb",
|
|
|
|
.sp_ops = &o2cb_stack_ops,
|
|
|
|
.sp_owner = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init o2cb_stack_init(void)
|
|
|
|
{
|
|
|
|
return ocfs2_stack_glue_register(&o2cb_stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit o2cb_stack_exit(void)
|
|
|
|
{
|
|
|
|
ocfs2_stack_glue_unregister(&o2cb_stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Oracle");
|
|
|
|
MODULE_DESCRIPTION("ocfs2 driver for the classic o2cb stack");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
module_init(o2cb_stack_init);
|
|
|
|
module_exit(o2cb_stack_exit);
|