GFS2: Fix debugfs glock file iterator
authorSteven Whitehouse <swhiteho@redhat.com>
Tue, 22 Jul 2008 21:58:03 +0000 (22:58 +0100)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 13 Aug 2008 08:59:10 +0000 (09:59 +0100)
Due to an incorrect iterator, some glocks were being missed from the
glock dumps obtained via debugfs. This patch fixes the problem and
ensures that we don't miss any glocks in future.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/glock.c

index 13391e546616ce47a9b413dde1ac73ad396d808d..4cbb6957a0d4f3cd513e18583815d7e37cef7f91 100644 (file)
@@ -1816,15 +1816,17 @@ restart:
        if (gl) {
                gi->gl = hlist_entry(gl->gl_list.next,
                                     struct gfs2_glock, gl_list);
-               if (gi->gl)
-                       gfs2_glock_hold(gi->gl);
+       } else {
+               gi->gl = hlist_entry(gl_hash_table[gi->hash].hb_list.first,
+                                    struct gfs2_glock, gl_list);
        }
+       if (gi->gl)
+               gfs2_glock_hold(gi->gl);
        read_unlock(gl_lock_addr(gi->hash));
        if (gl)
                gfs2_glock_put(gl);
-       if (gl && gi->gl == NULL)
-               gi->hash++;
        while (gi->gl == NULL) {
+               gi->hash++;
                if (gi->hash >= GFS2_GL_HASH_SIZE)
                        return 1;
                read_lock(gl_lock_addr(gi->hash));
@@ -1833,7 +1835,6 @@ restart:
                if (gi->gl)
                        gfs2_glock_hold(gi->gl);
                read_unlock(gl_lock_addr(gi->hash));
-               gi->hash++;
        }
 
        if (gi->sdp != gi->gl->gl_sbd)