diff options
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r-- | fs/gfs2/glock.c | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1ed81f40da0d..e6c2fd53cab2 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -186,20 +186,6 @@ static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl) | |||
186 | } | 186 | } |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * __gfs2_glock_schedule_for_reclaim - Add a glock to the reclaim list | ||
190 | * @gl: the glock | ||
191 | * | ||
192 | * If the glock is demotable, then we add it (or move it) to the end | ||
193 | * of the glock LRU list. | ||
194 | */ | ||
195 | |||
196 | static void __gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl) | ||
197 | { | ||
198 | if (demote_ok(gl)) | ||
199 | gfs2_glock_add_to_lru(gl); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * gfs2_glock_put_nolock() - Decrement reference count on glock | 189 | * gfs2_glock_put_nolock() - Decrement reference count on glock |
204 | * @gl: The glock to put | 190 | * @gl: The glock to put |
205 | * | 191 | * |
@@ -883,7 +869,14 @@ static int gfs2_glock_demote_wait(void *word) | |||
883 | return 0; | 869 | return 0; |
884 | } | 870 | } |
885 | 871 | ||
886 | static void wait_on_holder(struct gfs2_holder *gh) | 872 | /** |
873 | * gfs2_glock_wait - wait on a glock acquisition | ||
874 | * @gh: the glock holder | ||
875 | * | ||
876 | * Returns: 0 on success | ||
877 | */ | ||
878 | |||
879 | int gfs2_glock_wait(struct gfs2_holder *gh) | ||
887 | { | 880 | { |
888 | unsigned long time1 = jiffies; | 881 | unsigned long time1 = jiffies; |
889 | 882 | ||
@@ -894,12 +887,7 @@ static void wait_on_holder(struct gfs2_holder *gh) | |||
894 | gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time + | 887 | gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time + |
895 | GL_GLOCK_HOLD_INCR, | 888 | GL_GLOCK_HOLD_INCR, |
896 | GL_GLOCK_MAX_HOLD); | 889 | GL_GLOCK_MAX_HOLD); |
897 | } | 890 | return gh->gh_error; |
898 | |||
899 | static void wait_on_demote(struct gfs2_glock *gl) | ||
900 | { | ||
901 | might_sleep(); | ||
902 | wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait, TASK_UNINTERRUPTIBLE); | ||
903 | } | 891 | } |
904 | 892 | ||
905 | /** | 893 | /** |
@@ -929,19 +917,6 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state, | |||
929 | trace_gfs2_demote_rq(gl); | 917 | trace_gfs2_demote_rq(gl); |
930 | } | 918 | } |
931 | 919 | ||
932 | /** | ||
933 | * gfs2_glock_wait - wait on a glock acquisition | ||
934 | * @gh: the glock holder | ||
935 | * | ||
936 | * Returns: 0 on success | ||
937 | */ | ||
938 | |||
939 | int gfs2_glock_wait(struct gfs2_holder *gh) | ||
940 | { | ||
941 | wait_on_holder(gh); | ||
942 | return gh->gh_error; | ||
943 | } | ||
944 | |||
945 | void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...) | 920 | void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...) |
946 | { | 921 | { |
947 | struct va_format vaf; | 922 | struct va_format vaf; |
@@ -979,7 +954,7 @@ __acquires(&gl->gl_spin) | |||
979 | struct gfs2_sbd *sdp = gl->gl_sbd; | 954 | struct gfs2_sbd *sdp = gl->gl_sbd; |
980 | struct list_head *insert_pt = NULL; | 955 | struct list_head *insert_pt = NULL; |
981 | struct gfs2_holder *gh2; | 956 | struct gfs2_holder *gh2; |
982 | int try_lock = 0; | 957 | int try_futile = 0; |
983 | 958 | ||
984 | BUG_ON(gh->gh_owner_pid == NULL); | 959 | BUG_ON(gh->gh_owner_pid == NULL); |
985 | if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) | 960 | if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) |
@@ -987,7 +962,7 @@ __acquires(&gl->gl_spin) | |||
987 | 962 | ||
988 | if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { | 963 | if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { |
989 | if (test_bit(GLF_LOCK, &gl->gl_flags)) | 964 | if (test_bit(GLF_LOCK, &gl->gl_flags)) |
990 | try_lock = 1; | 965 | try_futile = !may_grant(gl, gh); |
991 | if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) | 966 | if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) |
992 | goto fail; | 967 | goto fail; |
993 | } | 968 | } |
@@ -996,9 +971,8 @@ __acquires(&gl->gl_spin) | |||
996 | if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && | 971 | if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && |
997 | (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) | 972 | (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) |
998 | goto trap_recursive; | 973 | goto trap_recursive; |
999 | if (try_lock && | 974 | if (try_futile && |
1000 | !(gh2->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) && | 975 | !(gh2->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) { |
1001 | !may_grant(gl, gh)) { | ||
1002 | fail: | 976 | fail: |
1003 | gh->gh_error = GLR_TRYFAILED; | 977 | gh->gh_error = GLR_TRYFAILED; |
1004 | gfs2_holder_wake(gh); | 978 | gfs2_holder_wake(gh); |
@@ -1121,8 +1095,9 @@ void gfs2_glock_dq(struct gfs2_holder *gh) | |||
1121 | !test_bit(GLF_DEMOTE, &gl->gl_flags)) | 1095 | !test_bit(GLF_DEMOTE, &gl->gl_flags)) |
1122 | fast_path = 1; | 1096 | fast_path = 1; |
1123 | } | 1097 | } |
1124 | if (!test_bit(GLF_LFLUSH, &gl->gl_flags)) | 1098 | if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl)) |
1125 | __gfs2_glock_schedule_for_reclaim(gl); | 1099 | gfs2_glock_add_to_lru(gl); |
1100 | |||
1126 | trace_gfs2_glock_queue(gh, 0); | 1101 | trace_gfs2_glock_queue(gh, 0); |
1127 | spin_unlock(&gl->gl_spin); | 1102 | spin_unlock(&gl->gl_spin); |
1128 | if (likely(fast_path)) | 1103 | if (likely(fast_path)) |
@@ -1141,7 +1116,8 @@ void gfs2_glock_dq_wait(struct gfs2_holder *gh) | |||
1141 | { | 1116 | { |
1142 | struct gfs2_glock *gl = gh->gh_gl; | 1117 | struct gfs2_glock *gl = gh->gh_gl; |
1143 | gfs2_glock_dq(gh); | 1118 | gfs2_glock_dq(gh); |
1144 | wait_on_demote(gl); | 1119 | might_sleep(); |
1120 | wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait, TASK_UNINTERRUPTIBLE); | ||
1145 | } | 1121 | } |
1146 | 1122 | ||
1147 | /** | 1123 | /** |