aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJie Liu <jeff.liu@oracle.com>2013-07-03 18:00:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:24 -0400
commit493098413bdb45f223ff0552e2f734849491dbbe (patch)
tree9555b2e11687d8321ba1c233c61da1feeb02fcd1 /fs
parentea45466aec98b68faaf354901c42e281e58af50a (diff)
ocfs2: rework transaction rollback in ocfs2_relink_block_group()
In ocfs2_relink_block_group(), we roll back all those changes if notify intent to modify buffers for metadata update failed even if the relevant buffer has not yet been modified/got dirty at that point, that are not quite right because of: - None buffer has been modified/dirty if failed to call ocfs2_journal_access_gd() against the previous block group buffer - Only the previous block group buffer has got dirty if failed to call ocfs2_journal_access_gd() against the block group buffer - There is no need to roll back the change for file entry buffer at all Those problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless bg_ptr variable as well. Signed-off-by: Jie Liu <jeff.liu@oracle.com> Cc: Younger Liu <younger.liu@huawei.com> Cc: Sunil Mushran <sunil.mushran@gmail.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: 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/suballoc.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index b7e74b580c0f..101d16d78162 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
1422 int status; 1422 int status;
1423 /* there is a really tiny chance the journal calls could fail, 1423 /* there is a really tiny chance the journal calls could fail,
1424 * but we wouldn't want inconsistent blocks in *any* case. */ 1424 * but we wouldn't want inconsistent blocks in *any* case. */
1425 u64 fe_ptr, bg_ptr, prev_bg_ptr; 1425 u64 bg_ptr, prev_bg_ptr;
1426 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; 1426 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
1427 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; 1427 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
1428 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data; 1428 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data;
@@ -1437,7 +1437,6 @@ static int ocfs2_relink_block_group(handle_t *handle,
1437 (unsigned long long)le64_to_cpu(bg->bg_blkno), 1437 (unsigned long long)le64_to_cpu(bg->bg_blkno),
1438 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); 1438 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno));
1439 1439
1440 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
1441 bg_ptr = le64_to_cpu(bg->bg_next_group); 1440 bg_ptr = le64_to_cpu(bg->bg_next_group);
1442 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); 1441 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group);
1443 1442
@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
1446 OCFS2_JOURNAL_ACCESS_WRITE); 1445 OCFS2_JOURNAL_ACCESS_WRITE);
1447 if (status < 0) { 1446 if (status < 0) {
1448 mlog_errno(status); 1447 mlog_errno(status);
1449 goto out_rollback; 1448 goto out;
1450 } 1449 }
1451 1450
1452 prev_bg->bg_next_group = bg->bg_next_group; 1451 prev_bg->bg_next_group = bg->bg_next_group;
@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
1456 bg_bh, OCFS2_JOURNAL_ACCESS_WRITE); 1455 bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);
1457 if (status < 0) { 1456 if (status < 0) {
1458 mlog_errno(status); 1457 mlog_errno(status);
1459 goto out_rollback; 1458 goto out_rollback_prev_bg;
1460 } 1459 }
1461 1460
1462 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; 1461 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
@@ -1466,21 +1465,21 @@ static int ocfs2_relink_block_group(handle_t *handle,
1466 fe_bh, OCFS2_JOURNAL_ACCESS_WRITE); 1465 fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);
1467 if (status < 0) { 1466 if (status < 0) {
1468 mlog_errno(status); 1467 mlog_errno(status);
1469 goto out_rollback; 1468 goto out_rollback_bg;
1470 } 1469 }
1471 1470
1472 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; 1471 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
1473 ocfs2_journal_dirty(handle, fe_bh); 1472 ocfs2_journal_dirty(handle, fe_bh);
1474 1473
1475out_rollback: 1474out:
1476 if (status < 0) { 1475 return status;
1477 fe->id2.i_chain.cl_recs[chain].c_blkno = cpu_to_le64(fe_ptr);
1478 bg->bg_next_group = cpu_to_le64(bg_ptr);
1479 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
1480 }
1481 1476
1482 if (status) 1477out_rollback_bg:
1483 mlog_errno(status); 1478 bg->bg_next_group = cpu_to_le64(bg_ptr);
1479out_rollback_prev_bg:
1480 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
1481
1482 mlog_errno(status);
1484 return status; 1483 return status;
1485} 1484}
1486 1485