[GFS2] Update copyright, tidy up incore.h
[linux-block.git] / fs / gfs2 / glock.c
index c3dde8560827ec5d2d7613ca453778f6605a7368..989f4f78f9be7432b0b914eb2d6b16d2463986ba 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
+ * of the GNU General Public License version 2.
  */
 
 #include <linux/sched.h>
@@ -83,7 +83,7 @@ static inline int relaxed_state_ok(unsigned int actual, unsigned requested,
  * Returns: The number of the corresponding hash bucket
  */
 
-static unsigned int gl_hash(struct lm_lockname *name)
+static unsigned int gl_hash(const struct lm_lockname *name)
 {
        unsigned int h;
 
@@ -200,7 +200,8 @@ static inline int queue_empty(struct gfs2_glock *gl, struct list_head *head)
  */
 
 static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket,
-                                       struct lm_lockname *name)
+                                       const struct gfs2_sbd *sdp,
+                                       const struct lm_lockname *name)
 {
        struct gfs2_glock *gl;
 
@@ -209,6 +210,8 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket,
                        continue;
                if (!lm_name_equal(&gl->gl_name, name))
                        continue;
+               if (gl->gl_sbd != sdp)
+                       continue;
 
                kref_get(&gl->gl_ref);
 
@@ -227,13 +230,13 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket,
  */
 
 static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp,
-                                         struct lm_lockname *name)
+                                         const struct lm_lockname *name)
 {
        struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(name)];
        struct gfs2_glock *gl;
 
        read_lock(&bucket->hb_lock);
-       gl = search_bucket(bucket, name);
+       gl = search_bucket(bucket, sdp, name);
        read_unlock(&bucket->hb_lock);
 
        return gl;
@@ -266,7 +269,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number,
        bucket = &sdp->sd_gl_hash[gl_hash(&name)];
 
        read_lock(&bucket->hb_lock);
-       gl = search_bucket(bucket, &name);
+       gl = search_bucket(bucket, sdp, &name);
        read_unlock(&bucket->hb_lock);
 
        if (gl || !create) {
@@ -278,31 +281,22 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number,
        if (!gl)
                return -ENOMEM;
 
-       memset(gl, 0, sizeof(struct gfs2_glock));
-
-       INIT_LIST_HEAD(&gl->gl_list);
+       gl->gl_flags = 0;
        gl->gl_name = name;
        kref_init(&gl->gl_ref);
-
-       spin_lock_init(&gl->gl_spin);
-
        gl->gl_state = LM_ST_UNLOCKED;
        gl->gl_owner = NULL;
        gl->gl_ip = 0;
-       INIT_LIST_HEAD(&gl->gl_holders);
-       INIT_LIST_HEAD(&gl->gl_waiters1);
-       INIT_LIST_HEAD(&gl->gl_waiters2);
-       INIT_LIST_HEAD(&gl->gl_waiters3);
-
        gl->gl_ops = glops;
-
+       gl->gl_req_gh = NULL;
+       gl->gl_req_bh = NULL;
+       gl->gl_vn = 0;
+       gl->gl_stamp = jiffies;
+       gl->gl_object = NULL;
        gl->gl_bucket = bucket;
-       INIT_LIST_HEAD(&gl->gl_reclaim);
-
        gl->gl_sbd = sdp;
-
+       gl->gl_aspace = NULL;
        lops_init_le(&gl->gl_le, &gfs2_glock_lops);
-       INIT_LIST_HEAD(&gl->gl_ail_list);
 
        /* If this glock protects actual on-disk data or metadata blocks,
           create a VFS inode to manage the pages/buffers holding them. */
@@ -320,7 +314,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number,
                goto fail_aspace;
 
        write_lock(&bucket->hb_lock);
-       tmp = search_bucket(bucket, &name);
+       tmp = search_bucket(bucket, sdp, &name);
        if (tmp) {
                write_unlock(&bucket->hb_lock);
                glock_free(gl);
@@ -334,13 +328,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number,
 
        return 0;
 
- fail_aspace:
+fail_aspace:
        if (gl->gl_aspace)
                gfs2_aspace_put(gl->gl_aspace);
-
- fail:
+fail:
        kmem_cache_free(gfs2_glock_cachep, gl); 
-
        return error;
 }
 
@@ -495,9 +487,7 @@ static int rq_promote(struct gfs2_holder *gh)
                                gfs2_reclaim_glock(sdp);
                        }
 
-                       glops->go_xmote_th(gl, gh->gh_state,
-                                          gh->gh_flags);
-
+                       glops->go_xmote_th(gl, gh->gh_state, gh->gh_flags);
                        spin_lock(&gl->gl_spin);
                }
                return 1;
@@ -935,8 +925,7 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags)
        gfs2_glock_hold(gl);
        gl->gl_req_bh = xmote_bh;
 
-       lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state,
-                              lck_flags);
+       lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags);
 
        if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR)))
                return;
@@ -1019,8 +1008,7 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl)
 
        if (gl->gl_state == LM_ST_EXCLUSIVE) {
                if (glops->go_sync)
-                       glops->go_sync(gl,
-                                      DIO_METADATA | DIO_DATA | DIO_RELEASE);
+                       glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE);
        }
 
        gfs2_glock_hold(gl);