Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101149
b: refs/heads/master
c: 048bca2
h: refs/heads/master
i:
  101147: 5ffbdaa
v: v3
  • Loading branch information
Steven Whitehouse committed Jun 27, 2008
1 parent 43f482f commit 032463d
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 267 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f3c9d38a26be32abf9b8897e9e0afc7166c712dd
refs/heads/master: 048bca223739368aa5b9ce7cfb1d576c32d66cc7
18 changes: 3 additions & 15 deletions trunk/fs/gfs2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion trunk/fs/gfs2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

15 changes: 12 additions & 3 deletions trunk/fs/gfs2/glock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -910,7 +916,8 @@ static inline void add_to_queue(struct gfs2_holder *gh)
gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
if (!(gh->gh_flags & LM_FLAG_PRIORITY)) {
spin_unlock(&gl->gl_spin);
sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
if (sdp->sd_lockstruct.ls_ops->lm_cancel)
sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
spin_lock(&gl->gl_spin);
}
return;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
52 changes: 50 additions & 2 deletions trunk/fs/gfs2/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand All @@ -139,7 +185,8 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
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);
Expand All @@ -158,7 +205,8 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
{
mutex_lock(&lmh_lock);
lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
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);
mutex_unlock(&lmh_lock);
Expand Down
3 changes: 0 additions & 3 deletions trunk/fs/gfs2/locking/nolock/Makefile

This file was deleted.

Loading

0 comments on commit 032463d

Please sign in to comment.