Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38853
b: refs/heads/master
c: 16feb9f
h: refs/heads/master
i:
  38851: 4d1cb26
v: v3
  • Loading branch information
Steven Whitehouse committed Sep 13, 2006
1 parent 8cd588d commit d4afd11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 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: 0bc0748dfbefacce9c6b67ab23f2c80133b598f7
refs/heads/master: 16feb9fec0e1f74339bd6992130ceedb3aa9567e
34 changes: 12 additions & 22 deletions trunk/fs/gfs2/glock.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <linux/delay.h>
#include <linux/sort.h>
#include <linux/jhash.h>
#include <linux/kref.h>
#include <linux/kallsyms.h>
#include <linux/gfs2_ondisk.h>
#include <linux/list.h>
Expand Down Expand Up @@ -179,23 +178,7 @@ static void glock_free(struct gfs2_glock *gl)

void gfs2_glock_hold(struct gfs2_glock *gl)
{
kref_get(&gl->gl_ref);
}

/* All work is done after the return from kref_put() so we
can release the write_lock before the free. */

static void kill_glock(struct kref *kref)
{
struct gfs2_glock *gl = container_of(kref, struct gfs2_glock, gl_ref);
struct gfs2_sbd *sdp = gl->gl_sbd;

gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED);
gfs2_assert(sdp, list_empty(&gl->gl_reclaim));
gfs2_assert(sdp, list_empty(&gl->gl_holders));
gfs2_assert(sdp, list_empty(&gl->gl_waiters1));
gfs2_assert(sdp, list_empty(&gl->gl_waiters2));
gfs2_assert(sdp, list_empty(&gl->gl_waiters3));
atomic_inc(&gl->gl_ref);
}

/**
Expand All @@ -207,12 +190,19 @@ static void kill_glock(struct kref *kref)
int gfs2_glock_put(struct gfs2_glock *gl)
{
int rv = 0;
struct gfs2_sbd *sdp = gl->gl_sbd;

write_lock(gl_lock_addr(gl->gl_hash));
if (kref_put(&gl->gl_ref, kill_glock)) {
if (atomic_dec_and_test(&gl->gl_ref)) {
hlist_del(&gl->gl_list);
write_unlock(gl_lock_addr(gl->gl_hash));
BUG_ON(spin_is_locked(&gl->gl_spin));
gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED);
gfs2_assert(sdp, list_empty(&gl->gl_reclaim));
gfs2_assert(sdp, list_empty(&gl->gl_holders));
gfs2_assert(sdp, list_empty(&gl->gl_waiters1));
gfs2_assert(sdp, list_empty(&gl->gl_waiters2));
gfs2_assert(sdp, list_empty(&gl->gl_waiters3));
glock_free(gl);
rv = 1;
goto out;
Expand Down Expand Up @@ -267,7 +257,7 @@ static struct gfs2_glock *search_bucket(unsigned int hash,
if (gl->gl_sbd != sdp)
continue;

kref_get(&gl->gl_ref);
atomic_inc(&gl->gl_ref);

return gl;
}
Expand Down Expand Up @@ -333,7 +323,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,

gl->gl_flags = 0;
gl->gl_name = name;
kref_init(&gl->gl_ref);
atomic_set(&gl->gl_ref, 1);
gl->gl_state = LM_ST_UNLOCKED;
gl->gl_hash = hash;
gl->gl_owner = NULL;
Expand Down Expand Up @@ -2124,7 +2114,7 @@ static int dump_glock(struct gfs2_glock *gl)
printk(" %u", x);
}
printk(" \n");
printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount));
printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref));
printk(KERN_INFO " gl_state = %u\n", gl->gl_state);
printk(KERN_INFO " gl_owner = %s\n", gl->gl_owner->comm);
print_symbol(KERN_INFO " gl_ip = %s\n", gl->gl_ip);
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/gfs2/incore.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct gfs2_glock {
struct hlist_node gl_list;
unsigned long gl_flags; /* GLF_... */
struct lm_lockname gl_name;
struct kref gl_ref;
atomic_t gl_ref;

spinlock_t gl_spin;

Expand Down

0 comments on commit d4afd11

Please sign in to comment.