diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2016-06-17 08:31:27 -0400 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2016-06-27 10:47:09 -0400 |
commit | 6df9f9a253c7dc9f8ed18bf89d762de350a31813 (patch) | |
tree | a048f6fb09f9da9d1616b7f5a9c9254ce6f1d7ab | |
parent | cda9dd4207aeb29d0aa2298085cc2d1ebcb87e04 (diff) |
gfs2: Lock holder cleanup
Make the code more readable by cleaning up the different ways of
initializing lock holders and checking for initialized lock holders:
mark lock holders as uninitialized by setting the holder's glock to NULL
(gfs2_holder_mark_uninitialized) instead of zeroing out the entire
object or using a separate flag. Recognize initialized holders by their
non-NULL glock (gfs2_holder_initialized). Don't zero out holder objects
which are immeditiately initialized via gfs2_holder_init or
gfs2_glock_nq_init.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r-- | fs/gfs2/dentry.c | 2 | ||||
-rw-r--r-- | fs/gfs2/file.c | 2 | ||||
-rw-r--r-- | fs/gfs2/glock.c | 2 | ||||
-rw-r--r-- | fs/gfs2/glock.h | 10 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 33 | ||||
-rw-r--r-- | fs/gfs2/main.c | 2 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 2 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 4 | ||||
-rw-r--r-- | fs/gfs2/super.c | 24 |
9 files changed, 46 insertions, 35 deletions
diff --git a/fs/gfs2/dentry.c b/fs/gfs2/dentry.c index 30822b148f3e..5173b98ca036 100644 --- a/fs/gfs2/dentry.c +++ b/fs/gfs2/dentry.c | |||
@@ -117,7 +117,7 @@ static int gfs2_dentry_delete(const struct dentry *dentry) | |||
117 | return 0; | 117 | return 0; |
118 | 118 | ||
119 | ginode = GFS2_I(d_inode(dentry)); | 119 | ginode = GFS2_I(d_inode(dentry)); |
120 | if (!ginode->i_iopen_gh.gh_gl) | 120 | if (!gfs2_holder_initialized(&ginode->i_iopen_gh)) |
121 | return 0; | 121 | return 0; |
122 | 122 | ||
123 | if (test_bit(GLF_DEMOTE, &ginode->i_iopen_gh.gh_gl->gl_flags)) | 123 | if (test_bit(GLF_DEMOTE, &ginode->i_iopen_gh.gh_gl->gl_flags)) |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index e0f98e483aec..320e65e61938 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -1098,7 +1098,7 @@ static void do_unflock(struct file *file, struct file_lock *fl) | |||
1098 | 1098 | ||
1099 | mutex_lock(&fp->f_fl_mutex); | 1099 | mutex_lock(&fp->f_fl_mutex); |
1100 | locks_lock_file_wait(file, fl); | 1100 | locks_lock_file_wait(file, fl); |
1101 | if (fl_gh->gh_gl) { | 1101 | if (gfs2_holder_initialized(fl_gh)) { |
1102 | gfs2_glock_dq(fl_gh); | 1102 | gfs2_glock_dq(fl_gh); |
1103 | gfs2_holder_uninit(fl_gh); | 1103 | gfs2_holder_uninit(fl_gh); |
1104 | } | 1104 | } |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1138a6131c61..3a90b2b5b9bb 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -801,7 +801,7 @@ void gfs2_holder_uninit(struct gfs2_holder *gh) | |||
801 | { | 801 | { |
802 | put_pid(gh->gh_owner_pid); | 802 | put_pid(gh->gh_owner_pid); |
803 | gfs2_glock_put(gh->gh_gl); | 803 | gfs2_glock_put(gh->gh_gl); |
804 | gh->gh_gl = NULL; | 804 | gfs2_holder_mark_uninitialized(gh); |
805 | gh->gh_ip = 0; | 805 | gh->gh_ip = 0; |
806 | } | 806 | } |
807 | 807 | ||
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 46ab67fc16da..ab1ef322f7a5 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h | |||
@@ -247,4 +247,14 @@ extern void gfs2_unregister_debugfs(void); | |||
247 | 247 | ||
248 | extern const struct lm_lockops gfs2_dlm_ops; | 248 | extern const struct lm_lockops gfs2_dlm_ops; |
249 | 249 | ||
250 | static inline void gfs2_holder_mark_uninitialized(struct gfs2_holder *gh) | ||
251 | { | ||
252 | gh->gh_gl = NULL; | ||
253 | } | ||
254 | |||
255 | static inline bool gfs2_holder_initialized(struct gfs2_holder *gh) | ||
256 | { | ||
257 | return gh->gh_gl; | ||
258 | } | ||
259 | |||
250 | #endif /* __GLOCK_DOT_H__ */ | 260 | #endif /* __GLOCK_DOT_H__ */ |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 481b6496727d..de54d605cd09 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -127,9 +127,9 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, | |||
127 | struct gfs2_inode *ip; | 127 | struct gfs2_inode *ip; |
128 | struct gfs2_glock *io_gl = NULL; | 128 | struct gfs2_glock *io_gl = NULL; |
129 | struct gfs2_holder i_gh; | 129 | struct gfs2_holder i_gh; |
130 | bool unlock = false; | ||
131 | int error; | 130 | int error; |
132 | 131 | ||
132 | gfs2_holder_mark_uninitialized(&i_gh); | ||
133 | inode = gfs2_iget(sb, no_addr); | 133 | inode = gfs2_iget(sb, no_addr); |
134 | if (!inode) | 134 | if (!inode) |
135 | return ERR_PTR(-ENOMEM); | 135 | return ERR_PTR(-ENOMEM); |
@@ -159,7 +159,6 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, | |||
159 | GL_SKIP, &i_gh); | 159 | GL_SKIP, &i_gh); |
160 | if (error) | 160 | if (error) |
161 | goto fail_put; | 161 | goto fail_put; |
162 | unlock = true; | ||
163 | 162 | ||
164 | if (blktype != GFS2_BLKST_FREE) { | 163 | if (blktype != GFS2_BLKST_FREE) { |
165 | error = gfs2_check_blk_type(sdp, no_addr, | 164 | error = gfs2_check_blk_type(sdp, no_addr, |
@@ -191,7 +190,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, | |||
191 | unlock_new_inode(inode); | 190 | unlock_new_inode(inode); |
192 | } | 191 | } |
193 | 192 | ||
194 | if (unlock) | 193 | if (gfs2_holder_initialized(&i_gh)) |
195 | gfs2_glock_dq_uninit(&i_gh); | 194 | gfs2_glock_dq_uninit(&i_gh); |
196 | return inode; | 195 | return inode; |
197 | 196 | ||
@@ -203,7 +202,7 @@ fail_refresh: | |||
203 | fail_put: | 202 | fail_put: |
204 | if (io_gl) | 203 | if (io_gl) |
205 | gfs2_glock_put(io_gl); | 204 | gfs2_glock_put(io_gl); |
206 | if (unlock) | 205 | if (gfs2_holder_initialized(&i_gh)) |
207 | gfs2_glock_dq_uninit(&i_gh); | 206 | gfs2_glock_dq_uninit(&i_gh); |
208 | ip->i_gl->gl_object = NULL; | 207 | ip->i_gl->gl_object = NULL; |
209 | fail: | 208 | fail: |
@@ -281,8 +280,8 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | |||
281 | struct gfs2_holder d_gh; | 280 | struct gfs2_holder d_gh; |
282 | int error = 0; | 281 | int error = 0; |
283 | struct inode *inode = NULL; | 282 | struct inode *inode = NULL; |
284 | int unlock = 0; | ||
285 | 283 | ||
284 | gfs2_holder_mark_uninitialized(&d_gh); | ||
286 | if (!name->len || name->len > GFS2_FNAMESIZE) | 285 | if (!name->len || name->len > GFS2_FNAMESIZE) |
287 | return ERR_PTR(-ENAMETOOLONG); | 286 | return ERR_PTR(-ENAMETOOLONG); |
288 | 287 | ||
@@ -297,7 +296,6 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | |||
297 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); | 296 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); |
298 | if (error) | 297 | if (error) |
299 | return ERR_PTR(error); | 298 | return ERR_PTR(error); |
300 | unlock = 1; | ||
301 | } | 299 | } |
302 | 300 | ||
303 | if (!is_root) { | 301 | if (!is_root) { |
@@ -310,7 +308,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | |||
310 | if (IS_ERR(inode)) | 308 | if (IS_ERR(inode)) |
311 | error = PTR_ERR(inode); | 309 | error = PTR_ERR(inode); |
312 | out: | 310 | out: |
313 | if (unlock) | 311 | if (gfs2_holder_initialized(&d_gh)) |
314 | gfs2_glock_dq_uninit(&d_gh); | 312 | gfs2_glock_dq_uninit(&d_gh); |
315 | if (error == -ENOENT) | 313 | if (error == -ENOENT) |
316 | return NULL; | 314 | return NULL; |
@@ -1354,7 +1352,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
1354 | struct gfs2_inode *ip = GFS2_I(d_inode(odentry)); | 1352 | struct gfs2_inode *ip = GFS2_I(d_inode(odentry)); |
1355 | struct gfs2_inode *nip = NULL; | 1353 | struct gfs2_inode *nip = NULL; |
1356 | struct gfs2_sbd *sdp = GFS2_SB(odir); | 1354 | struct gfs2_sbd *sdp = GFS2_SB(odir); |
1357 | struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, }; | 1355 | struct gfs2_holder ghs[5], r_gh; |
1358 | struct gfs2_rgrpd *nrgd; | 1356 | struct gfs2_rgrpd *nrgd; |
1359 | unsigned int num_gh; | 1357 | unsigned int num_gh; |
1360 | int dir_rename = 0; | 1358 | int dir_rename = 0; |
@@ -1362,6 +1360,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
1362 | unsigned int x; | 1360 | unsigned int x; |
1363 | int error; | 1361 | int error; |
1364 | 1362 | ||
1363 | gfs2_holder_mark_uninitialized(&r_gh); | ||
1365 | if (d_really_is_positive(ndentry)) { | 1364 | if (d_really_is_positive(ndentry)) { |
1366 | nip = GFS2_I(d_inode(ndentry)); | 1365 | nip = GFS2_I(d_inode(ndentry)); |
1367 | if (ip == nip) | 1366 | if (ip == nip) |
@@ -1551,7 +1550,7 @@ out_gunlock: | |||
1551 | gfs2_holder_uninit(ghs + x); | 1550 | gfs2_holder_uninit(ghs + x); |
1552 | } | 1551 | } |
1553 | out_gunlock_r: | 1552 | out_gunlock_r: |
1554 | if (r_gh.gh_gl) | 1553 | if (gfs2_holder_initialized(&r_gh)) |
1555 | gfs2_glock_dq_uninit(&r_gh); | 1554 | gfs2_glock_dq_uninit(&r_gh); |
1556 | out: | 1555 | out: |
1557 | return error; | 1556 | return error; |
@@ -1577,13 +1576,14 @@ static int gfs2_exchange(struct inode *odir, struct dentry *odentry, | |||
1577 | struct gfs2_inode *oip = GFS2_I(odentry->d_inode); | 1576 | struct gfs2_inode *oip = GFS2_I(odentry->d_inode); |
1578 | struct gfs2_inode *nip = GFS2_I(ndentry->d_inode); | 1577 | struct gfs2_inode *nip = GFS2_I(ndentry->d_inode); |
1579 | struct gfs2_sbd *sdp = GFS2_SB(odir); | 1578 | struct gfs2_sbd *sdp = GFS2_SB(odir); |
1580 | struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, }; | 1579 | struct gfs2_holder ghs[5], r_gh; |
1581 | unsigned int num_gh; | 1580 | unsigned int num_gh; |
1582 | unsigned int x; | 1581 | unsigned int x; |
1583 | umode_t old_mode = oip->i_inode.i_mode; | 1582 | umode_t old_mode = oip->i_inode.i_mode; |
1584 | umode_t new_mode = nip->i_inode.i_mode; | 1583 | umode_t new_mode = nip->i_inode.i_mode; |
1585 | int error; | 1584 | int error; |
1586 | 1585 | ||
1586 | gfs2_holder_mark_uninitialized(&r_gh); | ||
1587 | error = gfs2_rindex_update(sdp); | 1587 | error = gfs2_rindex_update(sdp); |
1588 | if (error) | 1588 | if (error) |
1589 | return error; | 1589 | return error; |
@@ -1691,7 +1691,7 @@ out_gunlock: | |||
1691 | gfs2_holder_uninit(ghs + x); | 1691 | gfs2_holder_uninit(ghs + x); |
1692 | } | 1692 | } |
1693 | out_gunlock_r: | 1693 | out_gunlock_r: |
1694 | if (r_gh.gh_gl) | 1694 | if (gfs2_holder_initialized(&r_gh)) |
1695 | gfs2_glock_dq_uninit(&r_gh); | 1695 | gfs2_glock_dq_uninit(&r_gh); |
1696 | out: | 1696 | out: |
1697 | return error; | 1697 | return error; |
@@ -1788,9 +1788,8 @@ int gfs2_permission(struct inode *inode, int mask) | |||
1788 | struct gfs2_inode *ip; | 1788 | struct gfs2_inode *ip; |
1789 | struct gfs2_holder i_gh; | 1789 | struct gfs2_holder i_gh; |
1790 | int error; | 1790 | int error; |
1791 | int unlock = 0; | ||
1792 | |||
1793 | 1791 | ||
1792 | gfs2_holder_mark_uninitialized(&i_gh); | ||
1794 | ip = GFS2_I(inode); | 1793 | ip = GFS2_I(inode); |
1795 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { | 1794 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { |
1796 | if (mask & MAY_NOT_BLOCK) | 1795 | if (mask & MAY_NOT_BLOCK) |
@@ -1798,14 +1797,13 @@ int gfs2_permission(struct inode *inode, int mask) | |||
1798 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); | 1797 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); |
1799 | if (error) | 1798 | if (error) |
1800 | return error; | 1799 | return error; |
1801 | unlock = 1; | ||
1802 | } | 1800 | } |
1803 | 1801 | ||
1804 | if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) | 1802 | if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) |
1805 | error = -EACCES; | 1803 | error = -EACCES; |
1806 | else | 1804 | else |
1807 | error = generic_permission(inode, mask); | 1805 | error = generic_permission(inode, mask); |
1808 | if (unlock) | 1806 | if (gfs2_holder_initialized(&i_gh)) |
1809 | gfs2_glock_dq_uninit(&i_gh); | 1807 | gfs2_glock_dq_uninit(&i_gh); |
1810 | 1808 | ||
1811 | return error; | 1809 | return error; |
@@ -1977,17 +1975,16 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1977 | struct gfs2_inode *ip = GFS2_I(inode); | 1975 | struct gfs2_inode *ip = GFS2_I(inode); |
1978 | struct gfs2_holder gh; | 1976 | struct gfs2_holder gh; |
1979 | int error; | 1977 | int error; |
1980 | int unlock = 0; | ||
1981 | 1978 | ||
1979 | gfs2_holder_mark_uninitialized(&gh); | ||
1982 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { | 1980 | if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) { |
1983 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); | 1981 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); |
1984 | if (error) | 1982 | if (error) |
1985 | return error; | 1983 | return error; |
1986 | unlock = 1; | ||
1987 | } | 1984 | } |
1988 | 1985 | ||
1989 | generic_fillattr(inode, stat); | 1986 | generic_fillattr(inode, stat); |
1990 | if (unlock) | 1987 | if (gfs2_holder_initialized(&gh)) |
1991 | gfs2_glock_dq_uninit(&gh); | 1988 | gfs2_glock_dq_uninit(&gh); |
1992 | 1989 | ||
1993 | return 0; | 1990 | return 0; |
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 615f67581cc2..74fd0139e6c2 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -45,7 +45,7 @@ static void gfs2_init_inode_once(void *foo) | |||
45 | memset(&ip->i_res, 0, sizeof(ip->i_res)); | 45 | memset(&ip->i_res, 0, sizeof(ip->i_res)); |
46 | RB_CLEAR_NODE(&ip->i_res.rs_node); | 46 | RB_CLEAR_NODE(&ip->i_res.rs_node); |
47 | ip->i_hash_cache = NULL; | 47 | ip->i_hash_cache = NULL; |
48 | ip->i_iopen_gh.gh_gl = NULL; | 48 | gfs2_holder_mark_uninitialized(&ip->i_iopen_gh); |
49 | } | 49 | } |
50 | 50 | ||
51 | static void gfs2_init_glock_once(void *foo) | 51 | static void gfs2_init_glock_once(void *foo) |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index ce7d69a2fdc0..6c657b202501 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -883,7 +883,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
883 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), | 883 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), |
884 | &data_blocks, &ind_blocks); | 884 | &data_blocks, &ind_blocks); |
885 | 885 | ||
886 | ghs = kcalloc(num_qd, sizeof(struct gfs2_holder), GFP_NOFS); | 886 | ghs = kmalloc(num_qd * sizeof(struct gfs2_holder), GFP_NOFS); |
887 | if (!ghs) | 887 | if (!ghs) |
888 | return -ENOMEM; | 888 | return -ENOMEM; |
889 | 889 | ||
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 960aaf43d665..fba38ca94135 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -2100,7 +2100,7 @@ void gfs2_inplace_release(struct gfs2_inode *ip) | |||
2100 | { | 2100 | { |
2101 | struct gfs2_blkreserv *rs = &ip->i_res; | 2101 | struct gfs2_blkreserv *rs = &ip->i_res; |
2102 | 2102 | ||
2103 | if (rs->rs_rgd_gh.gh_gl) | 2103 | if (gfs2_holder_initialized(&rs->rs_rgd_gh)) |
2104 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); | 2104 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); |
2105 | } | 2105 | } |
2106 | 2106 | ||
@@ -2600,7 +2600,7 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state) | |||
2600 | { | 2600 | { |
2601 | unsigned int x; | 2601 | unsigned int x; |
2602 | 2602 | ||
2603 | rlist->rl_ghs = kcalloc(rlist->rl_rgrps, sizeof(struct gfs2_holder), | 2603 | rlist->rl_ghs = kmalloc(rlist->rl_rgrps * sizeof(struct gfs2_holder), |
2604 | GFP_NOFS | __GFP_NOFAIL); | 2604 | GFP_NOFS | __GFP_NOFAIL); |
2605 | for (x = 0; x < rlist->rl_rgrps; x++) | 2605 | for (x = 0; x < rlist->rl_rgrps; x++) |
2606 | gfs2_holder_init(rlist->rl_rgd[x]->rd_gl, | 2606 | gfs2_holder_init(rlist->rl_rgd[x]->rd_gl, |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 9b2ff353e45f..3a7e60bb39f8 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -855,7 +855,7 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp) | |||
855 | wait_event(sdp->sd_reserving_log_wait, atomic_read(&sdp->sd_reserving_log) == 0); | 855 | wait_event(sdp->sd_reserving_log_wait, atomic_read(&sdp->sd_reserving_log) == 0); |
856 | gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks); | 856 | gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks); |
857 | 857 | ||
858 | if (freeze_gh.gh_gl) | 858 | if (gfs2_holder_initialized(&freeze_gh)) |
859 | gfs2_glock_dq_uninit(&freeze_gh); | 859 | gfs2_glock_dq_uninit(&freeze_gh); |
860 | 860 | ||
861 | gfs2_quota_cleanup(sdp); | 861 | gfs2_quota_cleanup(sdp); |
@@ -1033,7 +1033,7 @@ static int gfs2_unfreeze(struct super_block *sb) | |||
1033 | 1033 | ||
1034 | mutex_lock(&sdp->sd_freeze_mutex); | 1034 | mutex_lock(&sdp->sd_freeze_mutex); |
1035 | if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || | 1035 | if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || |
1036 | sdp->sd_freeze_gh.gh_gl == NULL) { | 1036 | !gfs2_holder_initialized(&sdp->sd_freeze_gh)) { |
1037 | mutex_unlock(&sdp->sd_freeze_mutex); | 1037 | mutex_unlock(&sdp->sd_freeze_mutex); |
1038 | return 0; | 1038 | return 0; |
1039 | } | 1039 | } |
@@ -1084,9 +1084,11 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host | |||
1084 | int error = 0, err; | 1084 | int error = 0, err; |
1085 | 1085 | ||
1086 | memset(sc, 0, sizeof(struct gfs2_statfs_change_host)); | 1086 | memset(sc, 0, sizeof(struct gfs2_statfs_change_host)); |
1087 | gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL); | 1087 | gha = kmalloc(slots * sizeof(struct gfs2_holder), GFP_KERNEL); |
1088 | if (!gha) | 1088 | if (!gha) |
1089 | return -ENOMEM; | 1089 | return -ENOMEM; |
1090 | for (x = 0; x < slots; x++) | ||
1091 | gfs2_holder_mark_uninitialized(gha + x); | ||
1090 | 1092 | ||
1091 | rgd_next = gfs2_rgrpd_get_first(sdp); | 1093 | rgd_next = gfs2_rgrpd_get_first(sdp); |
1092 | 1094 | ||
@@ -1096,7 +1098,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host | |||
1096 | for (x = 0; x < slots; x++) { | 1098 | for (x = 0; x < slots; x++) { |
1097 | gh = gha + x; | 1099 | gh = gha + x; |
1098 | 1100 | ||
1099 | if (gh->gh_gl && gfs2_glock_poll(gh)) { | 1101 | if (gfs2_holder_initialized(gh) && gfs2_glock_poll(gh)) { |
1100 | err = gfs2_glock_wait(gh); | 1102 | err = gfs2_glock_wait(gh); |
1101 | if (err) { | 1103 | if (err) { |
1102 | gfs2_holder_uninit(gh); | 1104 | gfs2_holder_uninit(gh); |
@@ -1109,7 +1111,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host | |||
1109 | } | 1111 | } |
1110 | } | 1112 | } |
1111 | 1113 | ||
1112 | if (gh->gh_gl) | 1114 | if (gfs2_holder_initialized(gh)) |
1113 | done = 0; | 1115 | done = 0; |
1114 | else if (rgd_next && !error) { | 1116 | else if (rgd_next && !error) { |
1115 | error = gfs2_glock_nq_init(rgd_next->rd_gl, | 1117 | error = gfs2_glock_nq_init(rgd_next->rd_gl, |
@@ -1304,9 +1306,11 @@ static int gfs2_drop_inode(struct inode *inode) | |||
1304 | { | 1306 | { |
1305 | struct gfs2_inode *ip = GFS2_I(inode); | 1307 | struct gfs2_inode *ip = GFS2_I(inode); |
1306 | 1308 | ||
1307 | if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) && inode->i_nlink) { | 1309 | if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) && |
1310 | inode->i_nlink && | ||
1311 | gfs2_holder_initialized(&ip->i_iopen_gh)) { | ||
1308 | struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; | 1312 | struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; |
1309 | if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags)) | 1313 | if (test_bit(GLF_DEMOTE, &gl->gl_flags)) |
1310 | clear_nlink(inode); | 1314 | clear_nlink(inode); |
1311 | } | 1315 | } |
1312 | return generic_drop_inode(inode); | 1316 | return generic_drop_inode(inode); |
@@ -1551,7 +1555,7 @@ static void gfs2_evict_inode(struct inode *inode) | |||
1551 | goto out_truncate; | 1555 | goto out_truncate; |
1552 | } | 1556 | } |
1553 | 1557 | ||
1554 | if (ip->i_iopen_gh.gh_gl && | 1558 | if (gfs2_holder_initialized(&ip->i_iopen_gh) && |
1555 | test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { | 1559 | test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { |
1556 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | 1560 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; |
1557 | gfs2_glock_dq_wait(&ip->i_iopen_gh); | 1561 | gfs2_glock_dq_wait(&ip->i_iopen_gh); |
@@ -1610,7 +1614,7 @@ out_unlock: | |||
1610 | if (gfs2_rs_active(&ip->i_res)) | 1614 | if (gfs2_rs_active(&ip->i_res)) |
1611 | gfs2_rs_deltree(&ip->i_res); | 1615 | gfs2_rs_deltree(&ip->i_res); |
1612 | 1616 | ||
1613 | if (ip->i_iopen_gh.gh_gl) { | 1617 | if (gfs2_holder_initialized(&ip->i_iopen_gh)) { |
1614 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { | 1618 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { |
1615 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | 1619 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; |
1616 | gfs2_glock_dq_wait(&ip->i_iopen_gh); | 1620 | gfs2_glock_dq_wait(&ip->i_iopen_gh); |
@@ -1632,7 +1636,7 @@ out: | |||
1632 | gfs2_glock_add_to_lru(ip->i_gl); | 1636 | gfs2_glock_add_to_lru(ip->i_gl); |
1633 | gfs2_glock_put(ip->i_gl); | 1637 | gfs2_glock_put(ip->i_gl); |
1634 | ip->i_gl = NULL; | 1638 | ip->i_gl = NULL; |
1635 | if (ip->i_iopen_gh.gh_gl) { | 1639 | if (gfs2_holder_initialized(&ip->i_iopen_gh)) { |
1636 | ip->i_iopen_gh.gh_gl->gl_object = NULL; | 1640 | ip->i_iopen_gh.gh_gl->gl_object = NULL; |
1637 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | 1641 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; |
1638 | gfs2_glock_dq_wait(&ip->i_iopen_gh); | 1642 | gfs2_glock_dq_wait(&ip->i_iopen_gh); |