aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorYounger Liu <younger.liu@huawei.com>2013-11-12 18:07:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:01 -0500
commiteedd40e1cad4217c9b7e2577debcdd0c48732cc3 (patch)
tree7392d157fe0a7d306e3b63e457529c3846497c41 /fs
parent728b98059a2f19393f906ba4febc0f2d1d15f280 (diff)
ocfs2: rollback transaction in ocfs2_group_add()
If ocfs2_journal_access_di() fails, group->bg_next_group should rollback. Otherwise, there would be a inconsistency between group_bh and main_bm_bh. Signed-off-by: Younger Liu <younger.liu@huawei.com> Cc: Mark Fasheh <mfasheh@suse.com> Acked-by: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/resize.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index ec55add7604a..376750f7883e 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -469,6 +469,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
469 struct ocfs2_chain_list *cl; 469 struct ocfs2_chain_list *cl;
470 struct ocfs2_chain_rec *cr; 470 struct ocfs2_chain_rec *cr;
471 u16 cl_bpc; 471 u16 cl_bpc;
472 u64 bg_ptr;
472 473
473 if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) 474 if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
474 return -EROFS; 475 return -EROFS;
@@ -538,12 +539,14 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
538 } 539 }
539 540
540 group = (struct ocfs2_group_desc *)group_bh->b_data; 541 group = (struct ocfs2_group_desc *)group_bh->b_data;
542 bg_ptr = le64_to_cpu(group->bg_next_group);
541 group->bg_next_group = cr->c_blkno; 543 group->bg_next_group = cr->c_blkno;
542 ocfs2_journal_dirty(handle, group_bh); 544 ocfs2_journal_dirty(handle, group_bh);
543 545
544 ret = ocfs2_journal_access_di(handle, INODE_CACHE(main_bm_inode), 546 ret = ocfs2_journal_access_di(handle, INODE_CACHE(main_bm_inode),
545 main_bm_bh, OCFS2_JOURNAL_ACCESS_WRITE); 547 main_bm_bh, OCFS2_JOURNAL_ACCESS_WRITE);
546 if (ret < 0) { 548 if (ret < 0) {
549 group->bg_next_group = cpu_to_le64(bg_ptr);
547 mlog_errno(ret); 550 mlog_errno(ret);
548 goto out_commit; 551 goto out_commit;
549 } 552 }