Commit 048bca22 authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

[GFS2] No lock_nolock



This patch merges the lock_nolock module into GFS2 itself. As well as removing
some of the overhead of the module, it also means that its now impossible to
build GFS2 without a lock module (which would be a pointless thing to do
anyway).

We also plan to merge lock_dlm into GFS2 in the future, but that is a more
tricky task, and will therefore be a separate patch.

Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
Cc: David Teigland <teigland@redhat.com>
parent f3c9d38a
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -14,23 +14,11 @@ config GFS2_FS
	  GFS is perfect consistency -- changes made to the filesystem on one
	  machine show up immediately on all other machines in the cluster.

	  To use the GFS2 filesystem, you will need to enable one or more of
	  the below locking modules. Documentation and utilities for GFS2 can
	  To use the GFS2 filesystem in a cluster, you will need to enable
	  the locking module below. Documentation and utilities for GFS2 can
	  be found here: http://sources.redhat.com/cluster

config GFS2_FS_LOCKING_NOLOCK
	tristate "GFS2 \"nolock\" locking module"
	depends on GFS2_FS
	help
	  Single node locking module for GFS2.

	  Use this module if you want to use GFS2 on a single node without
	  its clustering features. You can still take advantage of the
	  large file support, and upgrade to running a full cluster later on
	  if required.

	  If you will only be using GFS2 in cluster mode, you do not need this
	  module.
	  The "nolock" lock module is now built in to GFS2 by default.

config GFS2_FS_LOCKING_DLM
	tristate "GFS2 DLM locking module"
+0 −1
Original line number Diff line number Diff line
@@ -5,6 +5,5 @@ gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \
	ops_fstype.o ops_inode.o ops_super.o quota.o \
	recovery.o rgrp.o super.o sys.o trans.o util.o

obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += locking/nolock/
obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/
+12 −3
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ static void glock_free(struct gfs2_glock *gl)
	struct gfs2_sbd *sdp = gl->gl_sbd;
	struct inode *aspace = gl->gl_aspace;

	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
	if (sdp->sd_lockstruct.ls_ops->lm_put_lock)
		sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock);

	if (aspace)
@@ -488,6 +488,10 @@ static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock,
				 unsigned int flags)
{
	int ret = LM_OUT_ERROR;

	if (!sdp->sd_lockstruct.ls_ops->lm_lock)
		return req_state == LM_ST_UNLOCKED ? 0 : req_state;

	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
		ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state,
							 req_state, flags);
@@ -631,6 +635,8 @@ static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
		     void **lockp)
{
	int error = -EIO;
	if (!sdp->sd_lockstruct.ls_ops->lm_get_lock)
		return 0;
	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
		error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
				sdp->sd_lockstruct.ls_lockspace, name, lockp);
@@ -910,6 +916,7 @@ do_cancel:
	gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
	if (!(gh->gh_flags & LM_FLAG_PRIORITY)) {
		spin_unlock(&gl->gl_spin);
		if (sdp->sd_lockstruct.ls_ops->lm_cancel)
			sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
		spin_lock(&gl->gl_spin);
	}
@@ -1187,6 +1194,8 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs)
static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp)
{
	int error = -EIO;
	if (!sdp->sd_lockstruct.ls_ops->lm_hold_lvb)
		return 0;
	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
		error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp);
	return error;
@@ -1226,7 +1235,7 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl)
	gfs2_glock_hold(gl);
	gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0);
	if (atomic_dec_and_test(&gl->gl_lvb_count)) {
		if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
		if (sdp->sd_lockstruct.ls_ops->lm_unhold_lvb)
			sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb);
		gl->gl_lvb = NULL;
		gfs2_glock_put(gl);
+50 −2
Original line number Diff line number Diff line
@@ -23,12 +23,54 @@ struct lmh_wrapper {
	const struct lm_lockops *lw_ops;
};

static int nolock_mount(char *table_name, char *host_data,
			lm_callback_t cb, void *cb_data,
			unsigned int min_lvb_size, int flags,
			struct lm_lockstruct *lockstruct,
			struct kobject *fskobj);

/* List of registered low-level locking protocols.  A file system selects one
   of them by name at mount time, e.g. lock_nolock, lock_dlm. */

static const struct lm_lockops nolock_ops = {
	.lm_proto_name = "lock_nolock",
	.lm_mount = nolock_mount,
};

static struct lmh_wrapper nolock_proto  = {
	.lw_list = LIST_HEAD_INIT(nolock_proto.lw_list),
	.lw_ops = &nolock_ops,
};

static LIST_HEAD(lmh_list);
static DEFINE_MUTEX(lmh_lock);

static int nolock_mount(char *table_name, char *host_data,
			lm_callback_t cb, void *cb_data,
			unsigned int min_lvb_size, int flags,
			struct lm_lockstruct *lockstruct,
			struct kobject *fskobj)
{
	char *c;
	unsigned int jid;

	c = strstr(host_data, "jid=");
	if (!c)
		jid = 0;
	else {
		c += 4;
		sscanf(c, "%u", &jid);
	}

	lockstruct->ls_jid = jid;
	lockstruct->ls_first = 1;
	lockstruct->ls_lvb_size = min_lvb_size;
	lockstruct->ls_ops = &nolock_ops;
	lockstruct->ls_flags = LM_LSFLAG_LOCAL;

	return 0;
}

/**
 * gfs2_register_lockproto - Register a low-level locking protocol
 * @proto: the protocol definition
@@ -116,9 +158,13 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
	int try = 0;
	int error, found;


retry:
	mutex_lock(&lmh_lock);

	if (list_empty(&nolock_proto.lw_list))
		list_add(&lmh_list, &nolock_proto.lw_list);

	found = 0;
	list_for_each_entry(lw, &lmh_list, lw_list) {
		if (!strcmp(lw->lw_ops->lm_proto_name, proto_name)) {
@@ -139,7 +185,8 @@ retry:
		goto out;
	}

	if (!try_module_get(lw->lw_ops->lm_owner)) {
	if (lw->lw_ops->lm_owner &&
	    !try_module_get(lw->lw_ops->lm_owner)) {
		try = 0;
		mutex_unlock(&lmh_lock);
		msleep(1000);
@@ -158,6 +205,7 @@ out:
void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
{
	mutex_lock(&lmh_lock);
	if (lockstruct->ls_ops->lm_unmount)
		lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
	if (lockstruct->ls_ops->lm_owner)
		module_put(lockstruct->ls_ops->lm_owner);

fs/gfs2/locking/nolock/Makefile

deleted100644 → 0
+0 −3
Original line number Diff line number Diff line
obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += lock_nolock.o
lock_nolock-y := main.o
Loading