diff options
| author | Bob Peterson <rpeterso@redhat.com> | 2017-07-18 13:36:01 -0400 |
|---|---|---|
| committer | Bob Peterson <rpeterso@redhat.com> | 2017-08-09 10:36:38 -0400 |
| commit | 240c6235dfe4fe46f2fd0f2b3c15b3a22100a75e (patch) | |
| tree | d619273688a72fd0a28badeb5912e35a84566a29 /fs | |
| parent | 9c1b28081f43c0f14ccbcad02a6e0f227c072da2 (diff) | |
GFS2: Clear gl_object when deleting an inode in gfs2_delete_inode
This patch adds some calls to clear gl_object in function
gfs2_delete_inode. Since we are deleting the inode, and the glock
typically outlives the inode in core, we must clear gl_object
so subsequent use of the glock (e.g. for a new inode in its place)
will not have the old pointer sitting there. In error cases we
need to tidy up after ourselves. In non-error cases, we need to
clear gl_object before we set the block free in the bitmap so
residules aren't left for potential inode creators.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/gfs2/super.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 5fdc54158ff6..87271a859a8d 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
| @@ -1547,6 +1547,7 @@ static void gfs2_evict_inode(struct inode *inode) | |||
| 1547 | /* Must not read inode block until block type has been verified */ | 1547 | /* Must not read inode block until block type has been verified */ |
| 1548 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh); | 1548 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh); |
| 1549 | if (unlikely(error)) { | 1549 | if (unlikely(error)) { |
| 1550 | glock_clear_object(ip->i_iopen_gh.gh_gl, ip); | ||
| 1550 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | 1551 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; |
| 1551 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); | 1552 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); |
| 1552 | goto out; | 1553 | goto out; |
| @@ -1595,6 +1596,11 @@ alloc_failed: | |||
| 1595 | goto out_unlock; | 1596 | goto out_unlock; |
| 1596 | } | 1597 | } |
| 1597 | 1598 | ||
| 1599 | /* We're about to clear the bitmap for the dinode, but as soon as we | ||
| 1600 | do, gfs2_create_inode can create another inode at the same block | ||
| 1601 | location and try to set gl_object again. We clear gl_object here so | ||
| 1602 | that subsequent inode creates don't see an old gl_object. */ | ||
| 1603 | glock_clear_object(ip->i_gl, ip); | ||
| 1598 | error = gfs2_dinode_dealloc(ip); | 1604 | error = gfs2_dinode_dealloc(ip); |
| 1599 | goto out_unlock; | 1605 | goto out_unlock; |
| 1600 | 1606 | ||
| @@ -1623,14 +1629,17 @@ out_unlock: | |||
| 1623 | gfs2_rs_deltree(&ip->i_res); | 1629 | gfs2_rs_deltree(&ip->i_res); |
| 1624 | 1630 | ||
| 1625 | if (gfs2_holder_initialized(&ip->i_iopen_gh)) { | 1631 | if (gfs2_holder_initialized(&ip->i_iopen_gh)) { |
| 1632 | glock_clear_object(ip->i_iopen_gh.gh_gl, ip); | ||
| 1626 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { | 1633 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { |
| 1627 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | 1634 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; |
| 1628 | gfs2_glock_dq(&ip->i_iopen_gh); | 1635 | gfs2_glock_dq(&ip->i_iopen_gh); |
| 1629 | } | 1636 | } |
| 1630 | gfs2_holder_uninit(&ip->i_iopen_gh); | 1637 | gfs2_holder_uninit(&ip->i_iopen_gh); |
| 1631 | } | 1638 | } |
| 1632 | if (gfs2_holder_initialized(&gh)) | 1639 | if (gfs2_holder_initialized(&gh)) { |
| 1640 | glock_clear_object(ip->i_gl, ip); | ||
| 1633 | gfs2_glock_dq_uninit(&gh); | 1641 | gfs2_glock_dq_uninit(&gh); |
| 1642 | } | ||
| 1634 | if (error && error != GLR_TRYFAILED && error != -EROFS) | 1643 | if (error && error != GLR_TRYFAILED && error != -EROFS) |
| 1635 | fs_warn(sdp, "gfs2_evict_inode: %d\n", error); | 1644 | fs_warn(sdp, "gfs2_evict_inode: %d\n", error); |
| 1636 | out: | 1645 | out: |
