Skip to content

Commit

Permalink
[GFS2] Remove lm.[ch] and distribute content
Browse files Browse the repository at this point in the history
The functions in lm.c were just wrappers which were mostly
only used in one other file. By moving the functions to
the files where they are being used, they can be marked
static and also this will usually result in them being inlined
since they are often only used from one point in the code.

A couple of really trivial functions have been inlined by hand
into the function which called them as it makes the code clearer
to do that.

We also gain from one fewer function call in the glock lock and
unlock paths.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Steven Whitehouse committed Mar 31, 2008
1 parent ab0d756 commit da755fd
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 263 deletions.
2 changes: 1 addition & 1 deletion fs/gfs2/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
obj-$(CONFIG_GFS2_FS) += gfs2.o
gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \
glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \
glops.o inode.o log.o lops.o locking.o main.o meta_io.o \
mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \
ops_fstype.o ops_inode.o ops_super.o quota.o \
recovery.o rgrp.o super.o sys.o trans.o util.o
Expand Down
51 changes: 47 additions & 4 deletions fs/gfs2/glock.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "glock.h"
#include "glops.h"
#include "inode.h"
#include "lm.h"
#include "lops.h"
#include "meta_io.h"
#include "quota.h"
Expand Down Expand Up @@ -183,7 +182,8 @@ static void glock_free(struct gfs2_glock *gl)
struct gfs2_sbd *sdp = gl->gl_sbd;
struct inode *aspace = gl->gl_aspace;

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

if (aspace)
gfs2_aspace_put(aspace);
Expand Down Expand Up @@ -293,6 +293,16 @@ static void glock_work_func(struct work_struct *work)
gfs2_glock_put(gl);
}

static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
void **lockp)
{
int error = -EIO;
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);
return error;
}

/**
* gfs2_glock_get() - Get a glock, or create one if one doesn't exist
* @sdp: The GFS2 superblock
Expand Down Expand Up @@ -882,6 +892,17 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
gfs2_holder_wake(gh);
}

static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock,
unsigned int cur_state, unsigned int req_state,
unsigned int flags)
{
int ret = 0;
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state,
req_state, flags);
return ret;
}

/**
* gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock
* @gl: The glock in question
Expand Down Expand Up @@ -922,6 +943,15 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh)
xmote_bh(gl, lck_ret);
}

static unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock,
unsigned int cur_state)
{
int ret = 0;
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state);
return ret;
}

/**
* gfs2_glock_drop_th - call into the lock module to unlock a lock
* @gl: the glock
Expand Down Expand Up @@ -964,6 +994,7 @@ static void gfs2_glock_drop_th(struct gfs2_glock *gl)
static void do_cancels(struct gfs2_holder *gh)
{
struct gfs2_glock *gl = gh->gh_gl;
struct gfs2_sbd *sdp = gl->gl_sbd;

spin_lock(&gl->gl_spin);

Expand All @@ -972,7 +1003,8 @@ static void do_cancels(struct gfs2_holder *gh)
!list_empty(&gh->gh_list)) {
if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) {
spin_unlock(&gl->gl_spin);
gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock);
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
msleep(100);
spin_lock(&gl->gl_spin);
} else {
Expand Down Expand Up @@ -1426,6 +1458,14 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs)
gfs2_glock_dq_uninit(&ghs[x]);
}

static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp)
{
int error = -EIO;
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp);
return error;
}

/**
* gfs2_lvb_hold - attach a LVB from a glock
* @gl: The glock in question
Expand Down Expand Up @@ -1461,12 +1501,15 @@ int gfs2_lvb_hold(struct gfs2_glock *gl)

void gfs2_lvb_unhold(struct gfs2_glock *gl)
{
struct gfs2_sbd *sdp = gl->gl_sbd;

gfs2_glock_hold(gl);
gfs2_glmutex_lock(gl);

gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0);
if (atomic_dec_and_test(&gl->gl_lvb_count)) {
gfs2_lm_unhold_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb);
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb);
gl->gl_lvb = NULL;
gfs2_glock_put(gl);
}
Expand Down
2 changes: 2 additions & 0 deletions fs/gfs2/incore.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ struct gfs2_glock {
struct delayed_work gl_work;
};

#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */

struct gfs2_alloc {
/* Quota stuff */

Expand Down
210 changes: 0 additions & 210 deletions fs/gfs2/lm.c

This file was deleted.

42 changes: 0 additions & 42 deletions fs/gfs2/lm.h

This file was deleted.

Loading

0 comments on commit da755fd

Please sign in to comment.