diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-13 10:43:37 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-13 10:43:37 -0400 |
commit | 16feb9fec0e1f74339bd6992130ceedb3aa9567e (patch) | |
tree | cc759c3d591fdd2915de4dcd08bc7baf4290f48f /fs/gfs2 | |
parent | 0bc0748dfbefacce9c6b67ab23f2c80133b598f7 (diff) | |
download | op-kernel-dev-16feb9fec0e1f74339bd6992130ceedb3aa9567e.zip op-kernel-dev-16feb9fec0e1f74339bd6992130ceedb3aa9567e.tar.gz |
[GFS2] Use atomic_t rather than kref in glock.c
Use atomic_t as the ref count in glocks rather than a kref.
This is another step towards using RCU for the glock hash.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/glock.c | 34 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 2 |
2 files changed, 13 insertions, 23 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index cf54b0b..2316490 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -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> @@ -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); } /** @@ -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; @@ -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; } @@ -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; @@ -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); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index c68d392..89df68b 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -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; |