summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/gfs2/glock.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index a27dbd3dec01..661350989e98 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -931,6 +931,17 @@ void gfs2_holder_uninit(struct gfs2_holder *gh)
931 gh->gh_ip = 0; 931 gh->gh_ip = 0;
932} 932}
933 933
934static void gfs2_glock_update_hold_time(struct gfs2_glock *gl,
935 unsigned long start_time)
936{
937 /* Have we waited longer that a second? */
938 if (time_after(jiffies, start_time + HZ)) {
939 /* Lengthen the minimum hold time. */
940 gl->gl_hold_time = min(gl->gl_hold_time + GL_GLOCK_HOLD_INCR,
941 GL_GLOCK_MAX_HOLD);
942 }
943}
944
934/** 945/**
935 * gfs2_glock_wait - wait on a glock acquisition 946 * gfs2_glock_wait - wait on a glock acquisition
936 * @gh: the glock holder 947 * @gh: the glock holder
@@ -940,15 +951,11 @@ void gfs2_holder_uninit(struct gfs2_holder *gh)
940 951
941int gfs2_glock_wait(struct gfs2_holder *gh) 952int gfs2_glock_wait(struct gfs2_holder *gh)
942{ 953{
943 unsigned long time1 = jiffies; 954 unsigned long start_time = jiffies;
944 955
945 might_sleep(); 956 might_sleep();
946 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE); 957 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE);
947 if (time_after(jiffies, time1 + HZ)) /* have we waited > a second? */ 958 gfs2_glock_update_hold_time(gh->gh_gl, start_time);
948 /* Lengthen the minimum hold time. */
949 gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time +
950 GL_GLOCK_HOLD_INCR,
951 GL_GLOCK_MAX_HOLD);
952 return gh->gh_error; 959 return gh->gh_error;
953} 960}
954 961