Skip to content

Commit

Permalink
ocfs2: Break out stackglue into modules.
Browse files Browse the repository at this point in the history
We define the ocfs2_stack_plugin structure to represent a stack driver.
The o2cb stack code is split into stack_o2cb.c.  This becomes the
ocfs2_stack_o2cb.ko module.

The stackglue generic functions are similarly split into the
ocfs2_stackglue.ko module.  This module now provides an interface to
register drivers.  The ocfs2_stack_o2cb driver registers itself.  As
part of this interface, ocfs2_stackglue can load drivers on demand.
This is accomplished in ocfs2_cluster_connect().

ocfs2_cluster_disconnect() is now notified when a _hangup() is pending.
If a hangup is pending, it will not release the driver module and will
let _hangup() do that.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Apr 18, 2008
1 parent e3dad42 commit 286eaa9
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 50 deletions.
7 changes: 4 additions & 3 deletions fs/ocfs2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ EXTRA_CFLAGS += -Ifs/ocfs2

EXTRA_CFLAGS += -DCATCH_BH_JBD_RACES

obj-$(CONFIG_OCFS2_FS) += ocfs2.o
obj-$(CONFIG_OCFS2_FS) += ocfs2.o ocfs2_stackglue.o ocfs2_stack_o2cb.o

ocfs2-objs := \
alloc.o \
Expand All @@ -24,14 +24,15 @@ ocfs2-objs := \
namei.o \
resize.o \
slot_map.o \
stackglue.o \
stack_o2cb.o \
suballoc.o \
super.o \
symlink.o \
sysfile.o \
uptodate.o \
ver.o

ocfs2_stackglue-objs := stackglue.o
ocfs2_stack_o2cb-objs := stack_o2cb.o

obj-$(CONFIG_OCFS2_FS) += cluster/
obj-$(CONFIG_OCFS2_FS) += dlm/
7 changes: 4 additions & 3 deletions fs/ocfs2/dlmglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
mlog_errno(status);
mlog(ML_ERROR,
"could not find this host's node number\n");
ocfs2_cluster_disconnect(conn);
ocfs2_cluster_disconnect(conn, 0);
goto bail;
}

Expand All @@ -2663,7 +2663,8 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
return status;
}

void ocfs2_dlm_shutdown(struct ocfs2_super *osb)
void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
int hangup_pending)
{
mlog_entry_void();

Expand All @@ -2683,7 +2684,7 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb)
ocfs2_lock_res_free(&osb->osb_super_lockres);
ocfs2_lock_res_free(&osb->osb_rename_lockres);

ocfs2_cluster_disconnect(osb->cconn);
ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
osb->cconn = NULL;

ocfs2_dlm_shutdown_debug(osb);
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/dlmglue.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ocfs2_meta_lvb {
#define OCFS2_LOCK_NONBLOCK (0x04)

int ocfs2_dlm_init(struct ocfs2_super *osb);
void ocfs2_dlm_shutdown(struct ocfs2_super *osb);
void ocfs2_dlm_shutdown(struct ocfs2_super *osb, int hangup_pending);
void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res);
void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
enum ocfs2_lock_type type,
Expand Down
41 changes: 33 additions & 8 deletions fs/ocfs2/stack_o2cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include <linux/crc32.h>
#include <linux/kmod.h>
#include <linux/module.h>

/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
#include <linux/fs.h>
Expand All @@ -33,6 +33,8 @@ struct o2dlm_private {
struct dlm_eviction_cb op_eviction_cb;
};

static struct ocfs2_stack_plugin o2cb_stack;

/* These should be identical */
#if (DLM_LOCK_IV != LKM_IVMODE)
# error Lock modes do not match
Expand Down Expand Up @@ -158,23 +160,23 @@ static int dlm_status_to_errno(enum dlm_status status)

static void o2dlm_lock_ast_wrapper(void *astarg)
{
BUG_ON(stack_glue_lproto == NULL);
BUG_ON(o2cb_stack.sp_proto == NULL);

stack_glue_lproto->lp_lock_ast(astarg);
o2cb_stack.sp_proto->lp_lock_ast(astarg);
}

static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
{
BUG_ON(stack_glue_lproto == NULL);
BUG_ON(o2cb_stack.sp_proto == NULL);

stack_glue_lproto->lp_blocking_ast(astarg, level);
o2cb_stack.sp_proto->lp_blocking_ast(astarg, level);
}

static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
{
int error = dlm_status_to_errno(status);

BUG_ON(stack_glue_lproto == NULL);
BUG_ON(o2cb_stack.sp_proto == NULL);

/*
* In o2dlm, you can get both the lock_ast() for the lock being
Expand All @@ -190,7 +192,7 @@ static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
if (status == DLM_CANCELGRANT)
return;

stack_glue_lproto->lp_unlock_ast(astarg, error);
o2cb_stack.sp_proto->lp_unlock_ast(astarg, error);
}

static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
Expand Down Expand Up @@ -267,6 +269,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
struct dlm_protocol_version dlm_version;

BUG_ON(conn == NULL);
BUG_ON(o2cb_stack.sp_proto == NULL);

/* for now we only have one cluster/node, make sure we see it
* in the heartbeat universe */
Expand Down Expand Up @@ -314,7 +317,8 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
return rc;
}

static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn)
static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn,
int hangup_pending)
{
struct dlm_ctxt *dlm = conn->cc_lockspace;
struct o2dlm_private *priv = conn->cc_private;
Expand Down Expand Up @@ -393,3 +397,24 @@ struct ocfs2_stack_operations o2cb_stack_ops = {
.dump_lksb = o2cb_dump_lksb,
};

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);
Loading

0 comments on commit 286eaa9

Please sign in to comment.