Skip to content

Commit 4930984

Browse files
pibrochtorvalds
authored andcommitted
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>
1 parent ea45466 commit 4930984

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

‎fs/ocfs2/suballoc.c‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
14221422
int status;
14231423
/* there is a really tiny chance the journal calls could fail,
14241424
* 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;
14261426
struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
14271427
struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
14281428
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,
14371437
(unsigned long long)le64_to_cpu(bg->bg_blkno),
14381438
(unsigned long long)le64_to_cpu(prev_bg->bg_blkno));
14391439

1440-
fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
14411440
bg_ptr = le64_to_cpu(bg->bg_next_group);
14421441
prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group);
14431442

@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
14461445
OCFS2_JOURNAL_ACCESS_WRITE);
14471446
if (status < 0) {
14481447
mlog_errno(status);
1449-
goto out_rollback;
1448+
goto out;
14501449
}
14511450

14521451
prev_bg->bg_next_group = bg->bg_next_group;
@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle,
14561455
bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);
14571456
if (status < 0) {
14581457
mlog_errno(status);
1459-
goto out_rollback;
1458+
goto out_rollback_prev_bg;
14601459
}
14611460

14621461
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,
14661465
fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);
14671466
if (status < 0) {
14681467
mlog_errno(status);
1469-
goto out_rollback;
1468+
goto out_rollback_bg;
14701469
}
14711470

14721471
fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
14731472
ocfs2_journal_dirty(handle, fe_bh);
14741473

1475-
out_rollback:
1476-
if (status < 0) {
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-
}
1474+
out:
1475+
return status;
14811476

1482-
if (status)
1483-
mlog_errno(status);
1477+
out_rollback_bg:
1478+
bg->bg_next_group = cpu_to_le64(bg_ptr);
1479+
out_rollback_prev_bg:
1480+
prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
1481+
1482+
mlog_errno(status);
14841483
return status;
14851484
}
14861485

0 commit comments

Comments
 (0)