]> git.karo-electronics.de Git - linux-beck.git/commitdiff
GFS2: Make "try" lock not try quite so hard
authorSteven Whitehouse <swhiteho@redhat.com>
Fri, 23 Jul 2010 13:05:51 +0000 (14:05 +0100)
committerSteven Whitehouse <swhiteho@redhat.com>
Thu, 29 Jul 2010 08:37:38 +0000 (09:37 +0100)
This looks like a big change, but in reality its only a single line of actual
code change, the rest is just moving a function to before its new caller.
The "try" flag for glocks is a rather subtle and delicate setting since it
requires that the state machine tries just hard enough to ensure that it has
a good chance of getting the requested lock, but no so hard that the
request can land up blocked behind another.

The patch adds in an additional check which will fail any queued try
locks if there is another request blocking the try lock request which
is not granted and compatible, nor in progress already. The check is made
only after all pending locks which may be granted have been granted.

I've checked this with the reproducer for the reported flock bug which
this is intended to fix, and it now passes.

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

index 0898f3ec8212e5599df8c547d7d106aeb15d6c86..717531d1b2a8777a727622df2831695baebb3dbf 100644 (file)
@@ -327,6 +327,30 @@ static void gfs2_holder_wake(struct gfs2_holder *gh)
        wake_up_bit(&gh->gh_iflags, HIF_WAIT);
 }
 
+/**
+ * do_error - Something unexpected has happened during a lock request
+ *
+ */
+
+static inline void do_error(struct gfs2_glock *gl, const int ret)
+{
+       struct gfs2_holder *gh, *tmp;
+
+       list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
+               if (test_bit(HIF_HOLDER, &gh->gh_iflags))
+                       continue;
+               if (ret & LM_OUT_ERROR)
+                       gh->gh_error = -EIO;
+               else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
+                       gh->gh_error = GLR_TRYFAILED;
+               else
+                       continue;
+               list_del_init(&gh->gh_list);
+               trace_gfs2_glock_queue(gh, 0);
+               gfs2_holder_wake(gh);
+       }
+}
+
 /**
  * do_promote - promote as many requests as possible on the current queue
  * @gl: The glock
@@ -375,35 +399,12 @@ restart:
                }
                if (gh->gh_list.prev == &gl->gl_holders)
                        return 1;
+               do_error(gl, 0);
                break;
        }
        return 0;
 }
 
-/**
- * do_error - Something unexpected has happened during a lock request
- *
- */
-
-static inline void do_error(struct gfs2_glock *gl, const int ret)
-{
-       struct gfs2_holder *gh, *tmp;
-
-       list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
-               if (test_bit(HIF_HOLDER, &gh->gh_iflags))
-                       continue;
-               if (ret & LM_OUT_ERROR)
-                       gh->gh_error = -EIO;
-               else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
-                       gh->gh_error = GLR_TRYFAILED;
-               else
-                       continue;
-               list_del_init(&gh->gh_list);
-               trace_gfs2_glock_queue(gh, 0);
-               gfs2_holder_wake(gh);
-       }
-}
-
 /**
  * find_first_waiter - find the first gh that's waiting for the glock
  * @gl: the glock