diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-04 09:49:55 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-04 09:49:55 -0400 |
commit | 5029996547a9f3988459e11955c13259495308ef (patch) | |
tree | 4667c98c19a6f39dc820e4eb648ecfa03b29bce2 /fs/gfs2/glock.c | |
parent | e9fc2aa091ab8fa46e60d4c9d06a89305c441652 (diff) |
[GFS2] Tidy up locking code
As per Jan Engelhardt's second email, this removes some unused code,
and fixes up indenting in various places.
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r-- | fs/gfs2/glock.c | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 989f4f78f9be..fac271f390bf 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -300,8 +300,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, | |||
300 | 300 | ||
301 | /* If this glock protects actual on-disk data or metadata blocks, | 301 | /* If this glock protects actual on-disk data or metadata blocks, |
302 | create a VFS inode to manage the pages/buffers holding them. */ | 302 | create a VFS inode to manage the pages/buffers holding them. */ |
303 | if (glops == &gfs2_inode_glops || | 303 | if (glops == &gfs2_inode_glops || glops == &gfs2_rgrp_glops) { |
304 | glops == &gfs2_rgrp_glops) { | ||
305 | gl->gl_aspace = gfs2_aspace_get(sdp); | 304 | gl->gl_aspace = gfs2_aspace_get(sdp); |
306 | if (!gl->gl_aspace) { | 305 | if (!gl->gl_aspace) { |
307 | error = -ENOMEM; | 306 | error = -ENOMEM; |
@@ -820,13 +819,11 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) | |||
820 | 819 | ||
821 | if (!gh) | 820 | if (!gh) |
822 | gl->gl_stamp = jiffies; | 821 | gl->gl_stamp = jiffies; |
823 | |||
824 | else if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { | 822 | else if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { |
825 | spin_lock(&gl->gl_spin); | 823 | spin_lock(&gl->gl_spin); |
826 | list_del_init(&gh->gh_list); | 824 | list_del_init(&gh->gh_list); |
827 | gh->gh_error = -EIO; | 825 | gh->gh_error = -EIO; |
828 | spin_unlock(&gl->gl_spin); | 826 | spin_unlock(&gl->gl_spin); |
829 | |||
830 | } else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) { | 827 | } else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) { |
831 | spin_lock(&gl->gl_spin); | 828 | spin_lock(&gl->gl_spin); |
832 | list_del_init(&gh->gh_list); | 829 | list_del_init(&gh->gh_list); |
@@ -842,7 +839,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) | |||
842 | spin_unlock(&gl->gl_spin); | 839 | spin_unlock(&gl->gl_spin); |
843 | 840 | ||
844 | if (ret & LM_OUT_CANCELED) | 841 | if (ret & LM_OUT_CANCELED) |
845 | handle_callback(gl, LM_ST_UNLOCKED); /* Lame */ | 842 | handle_callback(gl, LM_ST_UNLOCKED); |
846 | 843 | ||
847 | } else if (ret & LM_OUT_CANCELED) { | 844 | } else if (ret & LM_OUT_CANCELED) { |
848 | spin_lock(&gl->gl_spin); | 845 | spin_lock(&gl->gl_spin); |
@@ -916,11 +913,8 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) | |||
916 | gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED); | 913 | gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED); |
917 | gfs2_assert_warn(sdp, state != gl->gl_state); | 914 | gfs2_assert_warn(sdp, state != gl->gl_state); |
918 | 915 | ||
919 | if (gl->gl_state == LM_ST_EXCLUSIVE) { | 916 | if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) |
920 | if (glops->go_sync) | 917 | glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); |
921 | glops->go_sync(gl, | ||
922 | DIO_METADATA | DIO_DATA | DIO_RELEASE); | ||
923 | } | ||
924 | 918 | ||
925 | gfs2_glock_hold(gl); | 919 | gfs2_glock_hold(gl); |
926 | gl->gl_req_bh = xmote_bh; | 920 | gl->gl_req_bh = xmote_bh; |
@@ -1006,10 +1000,8 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl) | |||
1006 | gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); | 1000 | gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); |
1007 | gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED); | 1001 | gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED); |
1008 | 1002 | ||
1009 | if (gl->gl_state == LM_ST_EXCLUSIVE) { | 1003 | if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) |
1010 | if (glops->go_sync) | 1004 | glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); |
1011 | glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); | ||
1012 | } | ||
1013 | 1005 | ||
1014 | gfs2_glock_hold(gl); | 1006 | gfs2_glock_hold(gl); |
1015 | gl->gl_req_bh = drop_bh; | 1007 | gl->gl_req_bh = drop_bh; |
@@ -1041,9 +1033,8 @@ static void do_cancels(struct gfs2_holder *gh) | |||
1041 | while (gl->gl_req_gh != gh && | 1033 | while (gl->gl_req_gh != gh && |
1042 | !test_bit(HIF_HOLDER, &gh->gh_iflags) && | 1034 | !test_bit(HIF_HOLDER, &gh->gh_iflags) && |
1043 | !list_empty(&gh->gh_list)) { | 1035 | !list_empty(&gh->gh_list)) { |
1044 | if (gl->gl_req_bh && | 1036 | if (gl->gl_req_bh && !(gl->gl_req_gh && |
1045 | !(gl->gl_req_gh && | 1037 | (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { |
1046 | (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { | ||
1047 | spin_unlock(&gl->gl_spin); | 1038 | spin_unlock(&gl->gl_spin); |
1048 | gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); | 1039 | gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); |
1049 | msleep(100); | 1040 | msleep(100); |
@@ -1323,10 +1314,8 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, | |||
1323 | 1314 | ||
1324 | spin_lock(&gl->gl_spin); | 1315 | spin_lock(&gl->gl_spin); |
1325 | 1316 | ||
1326 | if (test_bit(GLF_LOCK, &gl->gl_flags) || | 1317 | if (test_bit(GLF_LOCK, &gl->gl_flags) || !list_empty(&gl->gl_holders) || |
1327 | !list_empty(&gl->gl_holders) || | 1318 | !list_empty(&gl->gl_waiters1) || !list_empty(&gl->gl_waiters2) || |
1328 | !list_empty(&gl->gl_waiters1) || | ||
1329 | !list_empty(&gl->gl_waiters2) || | ||
1330 | !list_empty(&gl->gl_waiters3) || | 1319 | !list_empty(&gl->gl_waiters3) || |
1331 | relaxed_state_ok(gl->gl_state, state, flags)) { | 1320 | relaxed_state_ok(gl->gl_state, state, flags)) { |
1332 | spin_unlock(&gl->gl_spin); | 1321 | spin_unlock(&gl->gl_spin); |
@@ -1690,19 +1679,6 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl) | |||
1690 | gfs2_glock_put(gl); | 1679 | gfs2_glock_put(gl); |
1691 | } | 1680 | } |
1692 | 1681 | ||
1693 | #if 0 | ||
1694 | void gfs2_lvb_sync(struct gfs2_glock *gl) | ||
1695 | { | ||
1696 | gfs2_glmutex_lock(gl); | ||
1697 | |||
1698 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count)); | ||
1699 | if (!gfs2_assert_warn(gl->gl_sbd, gfs2_glock_is_held_excl(gl))) | ||
1700 | gfs2_lm_sync_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); | ||
1701 | |||
1702 | gfs2_glmutex_unlock(gl); | ||
1703 | } | ||
1704 | #endif /* 0 */ | ||
1705 | |||
1706 | static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, | 1682 | static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, |
1707 | unsigned int state) | 1683 | unsigned int state) |
1708 | { | 1684 | { |
@@ -1813,8 +1789,7 @@ static int demote_ok(struct gfs2_glock *gl) | |||
1813 | if (test_bit(GLF_STICKY, &gl->gl_flags)) | 1789 | if (test_bit(GLF_STICKY, &gl->gl_flags)) |
1814 | demote = 0; | 1790 | demote = 0; |
1815 | else if (test_bit(GLF_PREFETCH, &gl->gl_flags)) | 1791 | else if (test_bit(GLF_PREFETCH, &gl->gl_flags)) |
1816 | demote = time_after_eq(jiffies, | 1792 | demote = time_after_eq(jiffies, gl->gl_stamp + |
1817 | gl->gl_stamp + | ||
1818 | gfs2_tune_get(sdp, gt_prefetch_secs) * HZ); | 1793 | gfs2_tune_get(sdp, gt_prefetch_secs) * HZ); |
1819 | else if (glops->go_demote_ok) | 1794 | else if (glops->go_demote_ok) |
1820 | demote = glops->go_demote_ok(gl); | 1795 | demote = glops->go_demote_ok(gl); |
@@ -1872,8 +1847,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) | |||
1872 | 1847 | ||
1873 | if (gfs2_glmutex_trylock(gl)) { | 1848 | if (gfs2_glmutex_trylock(gl)) { |
1874 | if (queue_empty(gl, &gl->gl_holders) && | 1849 | if (queue_empty(gl, &gl->gl_holders) && |
1875 | gl->gl_state != LM_ST_UNLOCKED && | 1850 | gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) |
1876 | demote_ok(gl)) | ||
1877 | handle_callback(gl, LM_ST_UNLOCKED); | 1851 | handle_callback(gl, LM_ST_UNLOCKED); |
1878 | gfs2_glmutex_unlock(gl); | 1852 | gfs2_glmutex_unlock(gl); |
1879 | } | 1853 | } |
@@ -2036,8 +2010,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) | |||
2036 | cont = 0; | 2010 | cont = 0; |
2037 | 2011 | ||
2038 | for (x = 0; x < GFS2_GL_HASH_SIZE; x++) | 2012 | for (x = 0; x < GFS2_GL_HASH_SIZE; x++) |
2039 | if (examine_bucket(clear_glock, sdp, | 2013 | if (examine_bucket(clear_glock, sdp, &sdp->sd_gl_hash[x])) |
2040 | &sdp->sd_gl_hash[x])) | ||
2041 | cont = 1; | 2014 | cont = 1; |
2042 | 2015 | ||
2043 | if (!wait || !cont) | 2016 | if (!wait || !cont) |