summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-09-04 09:49:55 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-09-04 09:49:55 -0400
commit5029996547a9f3988459e11955c13259495308ef (patch)
tree4667c98c19a6f39dc820e4eb648ecfa03b29bce2
parente9fc2aa091ab8fa46e60d4c9d06a89305c441652 (diff)
[GFS2] Tidy up locking code
As per Jan Engelhardt's second email, this removes some unused code, and fixes up indenting in various places. Cc: Jan Engelhardt <jengelh@linux01.gwdg.de> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/glock.c53
-rw-r--r--fs/gfs2/glock.h6
-rw-r--r--fs/gfs2/lm.c62
-rw-r--r--fs/gfs2/lm.h25
-rw-r--r--fs/gfs2/lm_interface.h2
-rw-r--r--fs/gfs2/locking.c10
-rw-r--r--fs/gfs2/main.c2
7 files changed, 47 insertions, 113 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 989f4f78f9be..fac271f390bf 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -300,8 +300,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number,
/* If this glock protects actual on-disk data or metadata blocks,
create a VFS inode to manage the pages/buffers holding them. */
- if (glops == &gfs2_inode_glops ||
- glops == &gfs2_rgrp_glops) {
+ if (glops == &gfs2_inode_glops || glops == &gfs2_rgrp_glops) {
gl->gl_aspace = gfs2_aspace_get(sdp);
if (!gl->gl_aspace) {
error = -ENOMEM;
@@ -820,13 +819,11 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
if (!gh)
gl->gl_stamp = jiffies;
-
else if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) {
spin_lock(&gl->gl_spin);
list_del_init(&gh->gh_list);
gh->gh_error = -EIO;
spin_unlock(&gl->gl_spin);
-
} else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) {
spin_lock(&gl->gl_spin);
list_del_init(&gh->gh_list);
@@ -842,7 +839,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
spin_unlock(&gl->gl_spin);
if (ret & LM_OUT_CANCELED)
- handle_callback(gl, LM_ST_UNLOCKED); /* Lame */
+ handle_callback(gl, LM_ST_UNLOCKED);
} else if (ret & LM_OUT_CANCELED) {
spin_lock(&gl->gl_spin);
@@ -916,11 +913,8 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags)
gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED);
gfs2_assert_warn(sdp, state != gl->gl_state);
- if (gl->gl_state == LM_ST_EXCLUSIVE) {
- if (glops->go_sync)
- glops->go_sync(gl,
- DIO_METADATA | DIO_DATA | DIO_RELEASE);
- }
+ if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
+ glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
gfs2_glock_hold(gl);
gl->gl_req_bh = xmote_bh;
@@ -1006,10 +1000,8 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl)
gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders));
gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED);
- if (gl->gl_state == LM_ST_EXCLUSIVE) {
- if (glops->go_sync)
- glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
- }
+ if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
+ glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
gfs2_glock_hold(gl);
gl->gl_req_bh = drop_bh;
@@ -1041,9 +1033,8 @@ static void do_cancels(struct gfs2_holder *gh)
while (gl->gl_req_gh != gh &&
!test_bit(HIF_HOLDER, &gh->gh_iflags) &&
!list_empty(&gh->gh_list)) {
- if (gl->gl_req_bh &&
- !(gl->gl_req_gh &&
- (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) {
+ if (gl->gl_req_bh && !(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);
msleep(100);
@@ -1323,10 +1314,8 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state,
spin_lock(&gl->gl_spin);
- if (test_bit(GLF_LOCK, &gl->gl_flags) ||
- !list_empty(&gl->gl_holders) ||
- !list_empty(&gl->gl_waiters1) ||
- !list_empty(&gl->gl_waiters2) ||
+ if (test_bit(GLF_LOCK, &gl->gl_flags) || !list_empty(&gl->gl_holders) ||
+ !list_empty(&gl->gl_waiters1) || !list_empty(&gl->gl_waiters2) ||
!list_empty(&gl->gl_waiters3) ||
relaxed_state_ok(gl->gl_state, state, flags)) {
spin_unlock(&gl->gl_spin);
@@ -1690,19 +1679,6 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl)
gfs2_glock_put(gl);
}
-#if 0
-void gfs2_lvb_sync(struct gfs2_glock *gl)
-{
- gfs2_glmutex_lock(gl);
-
- gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count));
- if (!gfs2_assert_warn(gl->gl_sbd, gfs2_glock_is_held_excl(gl)))
- gfs2_lm_sync_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb);
-
- gfs2_glmutex_unlock(gl);
-}
-#endif /* 0 */
-
static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name,
unsigned int state)
{
@@ -1813,8 +1789,7 @@ static int demote_ok(struct gfs2_glock *gl)
if (test_bit(GLF_STICKY, &gl->gl_flags))
demote = 0;
else if (test_bit(GLF_PREFETCH, &gl->gl_flags))
- demote = time_after_eq(jiffies,
- gl->gl_stamp +
+ demote = time_after_eq(jiffies, gl->gl_stamp +
gfs2_tune_get(sdp, gt_prefetch_secs) * HZ);
else if (glops->go_demote_ok)
demote = glops->go_demote_ok(gl);
@@ -1872,8 +1847,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp)
if (gfs2_glmutex_trylock(gl)) {
if (queue_empty(gl, &gl->gl_holders) &&
- gl->gl_state != LM_ST_UNLOCKED &&
- demote_ok(gl))
+ gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl))
handle_callback(gl, LM_ST_UNLOCKED);
gfs2_glmutex_unlock(gl);
}
@@ -2036,8 +2010,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait)
cont = 0;
for (x = 0; x < GFS2_GL_HASH_SIZE; x++)
- if (examine_bucket(clear_glock, sdp,
- &sdp->sd_gl_hash[x]))
+ if (examine_bucket(clear_glock, sdp, &sdp->sd_gl_hash[x]))
cont = 1;
if (!wait || !cont)
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 07a8d02a234d..1a90a1983beb 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -51,17 +51,17 @@ static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl)
static inline int gfs2_glock_is_held_excl(struct gfs2_glock *gl)
{
- return (gl->gl_state == LM_ST_EXCLUSIVE);
+ return gl->gl_state == LM_ST_EXCLUSIVE;
}
static inline int gfs2_glock_is_held_dfrd(struct gfs2_glock *gl)
{
- return (gl->gl_state == LM_ST_DEFERRED);
+ return gl->gl_state == LM_ST_DEFERRED;
}
static inline int gfs2_glock_is_held_shrd(struct gfs2_glock *gl)
{
- return (gl->gl_state == LM_ST_SHARED);
+ return gl->gl_state == LM_ST_SHARED;
}
static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl)
diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c
index 1a9e75da19d1..fb918c7de655 100644
--- a/fs/gfs2/lm.c
+++ b/fs/gfs2/lm.c
@@ -124,10 +124,8 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
lm_lock_t **lockp)
{
- int error;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- error = -EIO;
- else
+ 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;
@@ -143,12 +141,9 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock,
unsigned int cur_state, unsigned int req_state,
unsigned int flags)
{
- int ret;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- ret = 0;
- else
- ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock,
- cur_state,
+ 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;
}
@@ -156,10 +151,8 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock,
unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock,
unsigned int cur_state)
{
- int ret;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- ret = 0;
- else
+ 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;
}
@@ -172,10 +165,8 @@ void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock)
int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp)
{
- int error;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- error = -EIO;
- else
+ 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;
}
@@ -186,50 +177,33 @@ void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb);
}
-#if 0
-void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
-{
- if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb);
-}
-#endif /* 0 */
-
int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name,
struct file *file, struct file_lock *fl)
{
- int error;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- error = -EIO;
- else
+ int error = -EIO;
+ if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = sdp->sd_lockstruct.ls_ops->lm_plock_get(
- sdp->sd_lockstruct.ls_lockspace,
- name, file, fl);
+ sdp->sd_lockstruct.ls_lockspace, name, file, fl);
return error;
}
int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name,
struct file *file, int cmd, struct file_lock *fl)
{
- int error;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- error = -EIO;
- else
+ int error = -EIO;
+ if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = sdp->sd_lockstruct.ls_ops->lm_plock(
- sdp->sd_lockstruct.ls_lockspace,
- name, file, cmd, fl);
+ sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl);
return error;
}
int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name,
struct file *file, struct file_lock *fl)
{
- int error;
- if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
- error = -EIO;
- else
+ int error = -EIO;
+ if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = sdp->sd_lockstruct.ls_ops->lm_punlock(
- sdp->sd_lockstruct.ls_lockspace,
- name, file, fl);
+ sdp->sd_lockstruct.ls_lockspace, name, file, fl);
return error;
}
diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h
index 15839aaa4ca6..dbef88852ef3 100644
--- a/fs/gfs2/lm.h
+++ b/fs/gfs2/lm.h
@@ -16,9 +16,9 @@ int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent);
void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp);
void gfs2_lm_unmount(struct gfs2_sbd *sdp);
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
-__attribute__ ((format(printf, 2, 3)));
-int gfs2_lm_get_lock(struct gfs2_sbd *sdp,
- struct lm_lockname *name, lm_lock_t **lockp);
+ __attribute__ ((format(printf, 2, 3)));
+int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+ lm_lock_t **lockp);
void gfs2_lm_put_lock(struct gfs2_sbd *sdp, lm_lock_t *lock);
unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock,
unsigned int cur_state, unsigned int req_state,
@@ -28,16 +28,13 @@ unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock,
void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock);
int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp);
void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb);
-int gfs2_lm_plock_get(struct gfs2_sbd *sdp,
- struct lm_lockname *name,
- struct file *file, struct file_lock *fl);
-int gfs2_lm_plock(struct gfs2_sbd *sdp,
- struct lm_lockname *name,
- struct file *file, int cmd, struct file_lock *fl);
-int gfs2_lm_punlock(struct gfs2_sbd *sdp,
- struct lm_lockname *name,
- struct file *file, struct file_lock *fl);
-void gfs2_lm_recovery_done(struct gfs2_sbd *sdp,
- unsigned int jid, unsigned int message);
+int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name,
+ struct file *file, struct file_lock *fl);
+int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+ struct file *file, int cmd, struct file_lock *fl);
+int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+ struct file *file, struct file_lock *fl);
+void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid,
+ unsigned int message);
#endif /* __LM_DOT_H__ */
diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h
index e1e89d92a8db..0bf4c276e0fe 100644
--- a/fs/gfs2/lm_interface.h
+++ b/fs/gfs2/lm_interface.h
@@ -260,8 +260,6 @@ struct lm_lockstruct {
int ls_flags;
};
-void __init gfs2_init_lmh(void);
-
/*
* Lock module bottom interface. A lock module makes itself available to GFS
* with these functions.
diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c
index 11c4068105cc..fce2001e5e25 100644
--- a/fs/gfs2/locking.c
+++ b/fs/gfs2/locking.c
@@ -27,8 +27,8 @@ struct lmh_wrapper {
/* 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 struct list_head lmh_list;
-static struct mutex lmh_lock;
+static LIST_HEAD(lmh_list);
+static DEFINE_MUTEX(lmh_lock);
/**
* gfs2_register_lockproto - Register a low-level locking protocol
@@ -180,12 +180,6 @@ void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct)
mutex_unlock(&lmh_lock);
}
-void __init gfs2_init_lmh(void)
-{
- mutex_init(&lmh_lock);
- INIT_LIST_HEAD(&lmh_list);
-}
-
EXPORT_SYMBOL_GPL(gfs2_register_lockproto);
EXPORT_SYMBOL_GPL(gfs2_unregister_lockproto);
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index b46f400705a2..143fda727a9c 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -65,8 +65,6 @@ static int __init init_gfs2_fs(void)
{
int error;
- gfs2_init_lmh();
-
error = gfs2_sys_init();
if (error)
return error;