ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
From: Jie Liu <[email protected]>
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.
--- fs/ocfs2/suballoc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
fs/ocfs2/suballoc.c +12 -13
@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);
@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;
@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out: +return status; -if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);return status; }
Signature · 1 line
1.7.9.5
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
Quoted 13 lines · Jeff Liu
From: Jie Liu <[email protected]>
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 callocfs2_journal_access_gd()against the block group buffer
- There is no need to roll back the change for file entry buffer at all
Quoted 5 lines
Those problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless
bg_ptrvariable as well.Signed-off-by Jie Liu <[email protected]>Cc Younger Liu <[email protected]>
Fine.
Quoted 75 lines
--- fs/ocfs2/suballoc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)fs/ocfs2/suballoc.c +12
-13@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out: +return status; -if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);return status; }
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
In reply to Jeff LiuQuoted 73 lines · On Thu, 20 Jun 2013 13:29:33 +0800 Jeff Liu <[email protected]> wrote:
From: Jie Liu <[email protected]>
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 callocfs2_journal_access_gd()against the block group buffer
- There is no need to roll back the change for file entry buffer at allThose problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless
bg_ptrvariable as well....
fs/ocfs2/suballoc.c +5
-11@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out:
fs/ocfs2/suballoc.c static int ocfs2_relink_block_group(handle_t *handle, · line 1482
Quoted 10 lines
fs/ocfs2/suballoc.c +7
-2+return status; -if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);
We already called mlog_errno() for this status in all cases.
How does this look?
fs/ocfs2/suballoc.c renamed from fs/ocfs2/suballoc.c~ocfs2-rework-transaction-rollback-in-ocfs2_relink_block_group-fix +6 -12
@@ -1443,44 +1443,38 @@ static int ocfs2_relink_block_group(hand status =ocfs2_journal_access_gd (handle,INODE_CACHE (alloc_inode), prev_bg_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out; - } prev_bg->bg_next_group = bg->bg_next_group;ocfs2_journal_dirty (handle, prev_bg_bh); status =ocfs2_journal_access_gd (handle,INODE_CACHE (alloc_inode), bg_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out_rollback_prev_bg; - } bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;ocfs2_journal_dirty (handle, bg_bh); status =ocfs2_journal_access_di (handle,INODE_CACHE (alloc_inode), fe_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out_rollback_bg; - } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); out: +if (status <0 ) +mlog_errno (status);return status; out_rollback_bg: bg->bg_next_group =cpu_to_le64 (bg_ptr); out_rollback_prev_bg: prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - -mlog_errno (status); -return status; + goto out; }
btw, the ocfs2 source and executable cold be made about half the size if mlog_errno() were to immediately return if status>=0.
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
Quoted 77 lines · Andrew Morton
Quoted 75 lines · On Thu, 20 Jun 2013 13:29:33 +0800 Jeff Liu <[email protected]> wrote:
From: Jie Liu <[email protected]>
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 callocfs2_journal_access_gd()against the block group buffer
- There is no need to roll back the change for file entry buffer at allThose problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless
bg_ptrvariable as well....
fs/ocfs2/suballoc.c +6
-11@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out: +return status;
Quoted 10 lines
fs/ocfs2/suballoc.c static int ocfs2_relink_block_group(handle_t *handle, · line 1482
Quoted 8 lines
fs/ocfs2/suballoc.c +6
-2-if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);We already called
mlog_errno()for this status in all cases.
Yep.
Quoted 2 lines
How does this look?
Looks fine :-P
Quoted 54 lines
fs/ocfs2/suballoc.c renamed from fs/ocfs2/suballoc.c~ocfs2-rework-transaction-rollback-in-ocfs2_relink_block_group-fix +6
-12@@ -1443,44 +1443,38 @@ static int ocfs2_relink_block_group(hand status =ocfs2_journal_access_gd (handle,INODE_CACHE (alloc_inode), prev_bg_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out; - } prev_bg->bg_next_group = bg->bg_next_group;ocfs2_journal_dirty (handle, prev_bg_bh); status =ocfs2_journal_access_gd (handle,INODE_CACHE (alloc_inode), bg_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out_rollback_prev_bg; - } bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;ocfs2_journal_dirty (handle, bg_bh); status =ocfs2_journal_access_di (handle,INODE_CACHE (alloc_inode), fe_bh,OCFS2_JOURNAL_ACCESS_WRITE ); -if (status <0 ) { -mlog_errno (status); +if (status <0 ) goto out_rollback_bg; - } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); out: +if (status <0 ) +mlog_errno (status);return status; out_rollback_bg: bg->bg_next_group =cpu_to_le64 (bg_ptr); out_rollback_prev_bg: prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - -mlog_errno (status); -return status; + goto out; }
Quoted 2 lines
btw, the ocfs2 source and executable cold be made about half the size if
mlog_errno()were to immediately return if status>=0.
I'm going to deal with it, thanks for pointing this out!
-Jeff
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
In reply to Jeff Liuit looks good , but it is better that if moving the following two sentence to before 'ocfs2_journal_dirty(handle, fe_bh);' sentence. 1.ocfs2_journal_dirty(handle, prev_bg_bh);
2.ocfs2_journal_dirty(handle, bg_bh);
because if it fail, it maybe commit by jbd2 journal.
Thanks,
Jensen
Quoted 92 lines · Jeff Liu
From: Jie Liu <[email protected]>
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 callocfs2_journal_access_gd()against the block group buffer
- There is no need to roll back the change for file entry buffer at allThose problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless
bg_ptrvariable as well.Signed-off-by Jie Liu <[email protected]>Cc Younger Liu <[email protected]>--- fs/ocfs2/suballoc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)fs/ocfs2/suballoc.c +12
-13@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out: +return status; -if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);return status; }
PATCH v2 1/1 ocfs2: Rework transaction rollback in ocfs2_relink_block_group()
Quoted 3 lines · Jensen
it looks good , but it is better that if moving the following two sentence to before '
ocfs2_journal_dirty(handle, fe_bh);' sentence. 1.ocfs2_journal_dirty(handle,prev_bg_bh);
2.ocfs2_journal_dirty(handle,bg_bh);
Thanks for your review, but are you sure you gone over the code?
-Jeff
Quoted 103 lines
because if it fail, it maybe commit by jbd2 journal.
Thanks,
JensenQuoted 92 lines · Jeff Liu
From: Jie Liu <[email protected]>
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 callocfs2_journal_access_gd()against the block group buffer
- There is no need to roll back the change for file entry buffer at allThose problems will not cause anything wrong but unnecessary. This patch fix them and kill the useless
bg_ptrvariable as well.Signed-off-by Jie Liu <[email protected]>Cc Younger Liu <[email protected]>--- fs/ocfs2/suballoc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)fs/ocfs2/suballoc.c +12
-13@@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle,int status;/* there is a really tiny chance the journal calls could fail, * but we wouldn't want inconsistent blocks in *any* case. */ -u64 fe_ptr, bg_ptr, prev_bg_ptr; +u64 bg_ptr, prev_bg_ptr;struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;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, (unsigned long long )le64_to_cpu (bg->bg_blkno), (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); - fe_ptr =le64_to_cpu (fe->id2.i_chain.cl_recs[chain].c_blkno); bg_ptr =le64_to_cpu (bg->bg_next_group); prev_bg_ptr =le64_to_cpu (prev_bg->bg_next_group);@@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out; } prev_bg->bg_next_group = bg->bg_next_group;@@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, bg_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_prev_bg; } 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, fe_bh, OCFS2_JOURNAL_ACCESS_WRITE);if (status <0 ) {mlog_errno (status); - goto out_rollback; + goto out_rollback_bg; } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;ocfs2_journal_dirty (handle, fe_bh); -out_rollback: -if (status <0 ) { - fe->id2.i_chain.cl_recs[chain].c_blkno =cpu_to_le64 (fe_ptr); - bg->bg_next_group =cpu_to_le64 (bg_ptr); - prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); - } +out: +return status; -if (status) -mlog_errno (status); +out_rollback_bg: + bg->bg_next_group =cpu_to_le64 (bg_ptr); +out_rollback_prev_bg: + prev_bg->bg_next_group =cpu_to_le64 (prev_bg_ptr); + +mlog_errno (status);return status; }