diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2008-10-15 04:46:39 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2009-01-05 02:38:49 -0500 |
commit | 1bb7322fd0d5abdce396de51cbc5dbc489523018 (patch) | |
tree | fb602151904bbfaa10dc671a059acce90011eca9 /fs | |
parent | b276058371f5c2ad92f9f27373a72b219ed580ed (diff) |
GFS2: Fix up jdata writepage/delete_inode
There is a bug in writepage and delete_inode which allows jdata files to
invalidate pages from the address space without being in a transaction at
the time. This causes problems in case the pages are in the journal. This
patch fixes that case and prevents the resulting oops.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/ops_address.c | 16 | ||||
-rw-r--r-- | fs/gfs2/ops_super.c | 7 |
2 files changed, 11 insertions, 12 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 15f710f2d4da..574b222feefc 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -210,25 +210,23 @@ static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc | |||
210 | { | 210 | { |
211 | struct inode *inode = page->mapping->host; | 211 | struct inode *inode = page->mapping->host; |
212 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 212 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
213 | int error; | 213 | int ret; |
214 | int done_trans = 0; | 214 | int done_trans = 0; |
215 | 215 | ||
216 | error = gfs2_writepage_common(page, wbc); | ||
217 | if (error <= 0) | ||
218 | return error; | ||
219 | |||
220 | if (PageChecked(page)) { | 216 | if (PageChecked(page)) { |
221 | if (wbc->sync_mode != WB_SYNC_ALL) | 217 | if (wbc->sync_mode != WB_SYNC_ALL) |
222 | goto out_ignore; | 218 | goto out_ignore; |
223 | error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); | 219 | ret = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); |
224 | if (error) | 220 | if (ret) |
225 | goto out_ignore; | 221 | goto out_ignore; |
226 | done_trans = 1; | 222 | done_trans = 1; |
227 | } | 223 | } |
228 | error = __gfs2_jdata_writepage(page, wbc); | 224 | ret = gfs2_writepage_common(page, wbc); |
225 | if (ret > 0) | ||
226 | ret = __gfs2_jdata_writepage(page, wbc); | ||
229 | if (done_trans) | 227 | if (done_trans) |
230 | gfs2_trans_end(sdp); | 228 | gfs2_trans_end(sdp); |
231 | return error; | 229 | return ret; |
232 | 230 | ||
233 | out_ignore: | 231 | out_ignore: |
234 | redirty_page_for_writepage(wbc, page); | 232 | redirty_page_for_writepage(wbc, page); |
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 9c7678db08fb..2cb744ba3b77 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c | |||
@@ -493,7 +493,7 @@ static void gfs2_delete_inode(struct inode *inode) | |||
493 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); | 493 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); |
494 | error = gfs2_glock_nq(&ip->i_iopen_gh); | 494 | error = gfs2_glock_nq(&ip->i_iopen_gh); |
495 | if (error) | 495 | if (error) |
496 | goto out_uninit; | 496 | goto out_truncate; |
497 | 497 | ||
498 | if (S_ISDIR(inode->i_mode) && | 498 | if (S_ISDIR(inode->i_mode) && |
499 | (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { | 499 | (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { |
@@ -518,6 +518,7 @@ static void gfs2_delete_inode(struct inode *inode) | |||
518 | if (error) | 518 | if (error) |
519 | goto out_unlock; | 519 | goto out_unlock; |
520 | 520 | ||
521 | out_truncate: | ||
521 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); | 522 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); |
522 | if (error) | 523 | if (error) |
523 | goto out_unlock; | 524 | goto out_unlock; |
@@ -526,8 +527,8 @@ static void gfs2_delete_inode(struct inode *inode) | |||
526 | gfs2_trans_end(sdp); | 527 | gfs2_trans_end(sdp); |
527 | 528 | ||
528 | out_unlock: | 529 | out_unlock: |
529 | gfs2_glock_dq(&ip->i_iopen_gh); | 530 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) |
530 | out_uninit: | 531 | gfs2_glock_dq(&ip->i_iopen_gh); |
531 | gfs2_holder_uninit(&ip->i_iopen_gh); | 532 | gfs2_holder_uninit(&ip->i_iopen_gh); |
532 | gfs2_glock_dq_uninit(&gh); | 533 | gfs2_glock_dq_uninit(&gh); |
533 | if (error && error != GLR_TRYFAILED) | 534 | if (error && error != GLR_TRYFAILED) |