diff options
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r-- | fs/gfs2/glock.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index a8387e0b5068..611f84d22573 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "glock.h" | 35 | #include "glock.h" |
36 | #include "glops.h" | 36 | #include "glops.h" |
37 | #include "inode.h" | 37 | #include "inode.h" |
38 | #include "lm.h" | ||
39 | #include "lops.h" | 38 | #include "lops.h" |
40 | #include "meta_io.h" | 39 | #include "meta_io.h" |
41 | #include "quota.h" | 40 | #include "quota.h" |
@@ -183,7 +182,8 @@ static void glock_free(struct gfs2_glock *gl) | |||
183 | struct gfs2_sbd *sdp = gl->gl_sbd; | 182 | struct gfs2_sbd *sdp = gl->gl_sbd; |
184 | struct inode *aspace = gl->gl_aspace; | 183 | struct inode *aspace = gl->gl_aspace; |
185 | 184 | ||
186 | gfs2_lm_put_lock(sdp, gl->gl_lock); | 185 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
186 | sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock); | ||
187 | 187 | ||
188 | if (aspace) | 188 | if (aspace) |
189 | gfs2_aspace_put(aspace); | 189 | gfs2_aspace_put(aspace); |
@@ -293,6 +293,16 @@ static void glock_work_func(struct work_struct *work) | |||
293 | gfs2_glock_put(gl); | 293 | gfs2_glock_put(gl); |
294 | } | 294 | } |
295 | 295 | ||
296 | static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
297 | void **lockp) | ||
298 | { | ||
299 | int error = -EIO; | ||
300 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
301 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( | ||
302 | sdp->sd_lockstruct.ls_lockspace, name, lockp); | ||
303 | return error; | ||
304 | } | ||
305 | |||
296 | /** | 306 | /** |
297 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist | 307 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist |
298 | * @sdp: The GFS2 superblock | 308 | * @sdp: The GFS2 superblock |
@@ -882,6 +892,17 @@ out: | |||
882 | gfs2_holder_wake(gh); | 892 | gfs2_holder_wake(gh); |
883 | } | 893 | } |
884 | 894 | ||
895 | static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | ||
896 | unsigned int cur_state, unsigned int req_state, | ||
897 | unsigned int flags) | ||
898 | { | ||
899 | int ret = 0; | ||
900 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
901 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, | ||
902 | req_state, flags); | ||
903 | return ret; | ||
904 | } | ||
905 | |||
885 | /** | 906 | /** |
886 | * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock | 907 | * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock |
887 | * @gl: The glock in question | 908 | * @gl: The glock in question |
@@ -922,6 +943,15 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh) | |||
922 | xmote_bh(gl, lck_ret); | 943 | xmote_bh(gl, lck_ret); |
923 | } | 944 | } |
924 | 945 | ||
946 | static unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, | ||
947 | unsigned int cur_state) | ||
948 | { | ||
949 | int ret = 0; | ||
950 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
951 | ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); | ||
952 | return ret; | ||
953 | } | ||
954 | |||
925 | /** | 955 | /** |
926 | * gfs2_glock_drop_th - call into the lock module to unlock a lock | 956 | * gfs2_glock_drop_th - call into the lock module to unlock a lock |
927 | * @gl: the glock | 957 | * @gl: the glock |
@@ -964,6 +994,7 @@ static void gfs2_glock_drop_th(struct gfs2_glock *gl) | |||
964 | static void do_cancels(struct gfs2_holder *gh) | 994 | static void do_cancels(struct gfs2_holder *gh) |
965 | { | 995 | { |
966 | struct gfs2_glock *gl = gh->gh_gl; | 996 | struct gfs2_glock *gl = gh->gh_gl; |
997 | struct gfs2_sbd *sdp = gl->gl_sbd; | ||
967 | 998 | ||
968 | spin_lock(&gl->gl_spin); | 999 | spin_lock(&gl->gl_spin); |
969 | 1000 | ||
@@ -972,7 +1003,8 @@ static void do_cancels(struct gfs2_holder *gh) | |||
972 | !list_empty(&gh->gh_list)) { | 1003 | !list_empty(&gh->gh_list)) { |
973 | if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { | 1004 | if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { |
974 | spin_unlock(&gl->gl_spin); | 1005 | spin_unlock(&gl->gl_spin); |
975 | gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); | 1006 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
1007 | sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock); | ||
976 | msleep(100); | 1008 | msleep(100); |
977 | spin_lock(&gl->gl_spin); | 1009 | spin_lock(&gl->gl_spin); |
978 | } else { | 1010 | } else { |
@@ -1426,6 +1458,14 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) | |||
1426 | gfs2_glock_dq_uninit(&ghs[x]); | 1458 | gfs2_glock_dq_uninit(&ghs[x]); |
1427 | } | 1459 | } |
1428 | 1460 | ||
1461 | static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) | ||
1462 | { | ||
1463 | int error = -EIO; | ||
1464 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
1465 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); | ||
1466 | return error; | ||
1467 | } | ||
1468 | |||
1429 | /** | 1469 | /** |
1430 | * gfs2_lvb_hold - attach a LVB from a glock | 1470 | * gfs2_lvb_hold - attach a LVB from a glock |
1431 | * @gl: The glock in question | 1471 | * @gl: The glock in question |
@@ -1461,12 +1501,15 @@ int gfs2_lvb_hold(struct gfs2_glock *gl) | |||
1461 | 1501 | ||
1462 | void gfs2_lvb_unhold(struct gfs2_glock *gl) | 1502 | void gfs2_lvb_unhold(struct gfs2_glock *gl) |
1463 | { | 1503 | { |
1504 | struct gfs2_sbd *sdp = gl->gl_sbd; | ||
1505 | |||
1464 | gfs2_glock_hold(gl); | 1506 | gfs2_glock_hold(gl); |
1465 | gfs2_glmutex_lock(gl); | 1507 | gfs2_glmutex_lock(gl); |
1466 | 1508 | ||
1467 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); | 1509 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); |
1468 | if (atomic_dec_and_test(&gl->gl_lvb_count)) { | 1510 | if (atomic_dec_and_test(&gl->gl_lvb_count)) { |
1469 | gfs2_lm_unhold_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); | 1511 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
1512 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb); | ||
1470 | gl->gl_lvb = NULL; | 1513 | gl->gl_lvb = NULL; |
1471 | gfs2_glock_put(gl); | 1514 | gfs2_glock_put(gl); |
1472 | } | 1515 | } |