diff options
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r-- | fs/gfs2/file.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 26b3f952e6b1..7f4ed3daa38c 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/dlm.h> | 26 | #include <linux/dlm.h> |
27 | #include <linux/dlm_plock.h> | 27 | #include <linux/dlm_plock.h> |
28 | #include <linux/aio.h> | 28 | #include <linux/aio.h> |
29 | #include <linux/delay.h> | ||
29 | 30 | ||
30 | #include "gfs2.h" | 31 | #include "gfs2.h" |
31 | #include "incore.h" | 32 | #include "incore.h" |
@@ -979,9 +980,10 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
979 | unsigned int state; | 980 | unsigned int state; |
980 | int flags; | 981 | int flags; |
981 | int error = 0; | 982 | int error = 0; |
983 | int sleeptime; | ||
982 | 984 | ||
983 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; | 985 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; |
984 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT; | 986 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY_1CB) | GL_EXACT; |
985 | 987 | ||
986 | mutex_lock(&fp->f_fl_mutex); | 988 | mutex_lock(&fp->f_fl_mutex); |
987 | 989 | ||
@@ -1001,7 +1003,14 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
1001 | gfs2_holder_init(gl, state, flags, fl_gh); | 1003 | gfs2_holder_init(gl, state, flags, fl_gh); |
1002 | gfs2_glock_put(gl); | 1004 | gfs2_glock_put(gl); |
1003 | } | 1005 | } |
1004 | error = gfs2_glock_nq(fl_gh); | 1006 | for (sleeptime = 1; sleeptime <= 4; sleeptime <<= 1) { |
1007 | error = gfs2_glock_nq(fl_gh); | ||
1008 | if (error != GLR_TRYFAILED) | ||
1009 | break; | ||
1010 | fl_gh->gh_flags = LM_FLAG_TRY | GL_EXACT; | ||
1011 | fl_gh->gh_error = 0; | ||
1012 | msleep(sleeptime); | ||
1013 | } | ||
1005 | if (error) { | 1014 | if (error) { |
1006 | gfs2_holder_uninit(fl_gh); | 1015 | gfs2_holder_uninit(fl_gh); |
1007 | if (error == GLR_TRYFAILED) | 1016 | if (error == GLR_TRYFAILED) |
@@ -1024,7 +1033,7 @@ static void do_unflock(struct file *file, struct file_lock *fl) | |||
1024 | mutex_lock(&fp->f_fl_mutex); | 1033 | mutex_lock(&fp->f_fl_mutex); |
1025 | flock_lock_file_wait(file, fl); | 1034 | flock_lock_file_wait(file, fl); |
1026 | if (fl_gh->gh_gl) { | 1035 | if (fl_gh->gh_gl) { |
1027 | gfs2_glock_dq_wait(fl_gh); | 1036 | gfs2_glock_dq(fl_gh); |
1028 | gfs2_holder_uninit(fl_gh); | 1037 | gfs2_holder_uninit(fl_gh); |
1029 | } | 1038 | } |
1030 | mutex_unlock(&fp->f_fl_mutex); | 1039 | mutex_unlock(&fp->f_fl_mutex); |