Message ID | 73314ceb4a87c4a6fc559834235e63f7aae79570.1621435862.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs_del_csums error handling fixes | expand |
On 2021/5/19 下午10:52, Josef Bacik wrote: > We are unconditionally returning 0 in cleanup_ref_head, despite the fact > that btrfs_del_csums could fail. We need to return the error so the > transaction gets aborted properly, fix this by returning ret from > btrfs_del_csums in cleanup_ref_head. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/extent-tree.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c > index b84bbc24ff57..790de24576ac 100644 > --- a/fs/btrfs/extent-tree.c > +++ b/fs/btrfs/extent-tree.c > @@ -1826,7 +1826,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, > > struct btrfs_fs_info *fs_info = trans->fs_info; > struct btrfs_delayed_ref_root *delayed_refs; > - int ret; > + int ret = 0; > > delayed_refs = &trans->transaction->delayed_refs; > > @@ -1868,7 +1868,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, > trace_run_delayed_ref_head(fs_info, head, 0); > btrfs_delayed_ref_unlock(head); > btrfs_put_delayed_ref_head(head); > - return 0; > + return ret; > } > > static struct btrfs_delayed_ref_head *btrfs_obtain_ref_head( >
On Wed, May 19, 2021 at 10:52:46AM -0400, Josef Bacik wrote: > We are unconditionally returning 0 in cleanup_ref_head, despite the fact > that btrfs_del_csums could fail. We need to return the error so the > transaction gets aborted properly, fix this by returning ret from > btrfs_del_csums in cleanup_ref_head. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> > --- > fs/btrfs/extent-tree.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c > index b84bbc24ff57..790de24576ac 100644 > --- a/fs/btrfs/extent-tree.c > +++ b/fs/btrfs/extent-tree.c > @@ -1826,7 +1826,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, > > struct btrfs_fs_info *fs_info = trans->fs_info; > struct btrfs_delayed_ref_root *delayed_refs; > - int ret; > + int ret = 0; > > delayed_refs = &trans->transaction->delayed_refs; ret is used for a return just after this line ret = run_and_cleanup_extent_op(trans, head); so not necessary to initialize at the declaration > > @@ -1868,7 +1868,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, > trace_run_delayed_ref_head(fs_info, head, 0); > btrfs_delayed_ref_unlock(head); > btrfs_put_delayed_ref_head(head); > - return 0; > + return ret; > } > > static struct btrfs_delayed_ref_head *btrfs_obtain_ref_head( > -- > 2.26.3
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b84bbc24ff57..790de24576ac 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1826,7 +1826,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_delayed_ref_root *delayed_refs; - int ret; + int ret = 0; delayed_refs = &trans->transaction->delayed_refs; @@ -1868,7 +1868,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, trace_run_delayed_ref_head(fs_info, head, 0); btrfs_delayed_ref_unlock(head); btrfs_put_delayed_ref_head(head); - return 0; + return ret; } static struct btrfs_delayed_ref_head *btrfs_obtain_ref_head(
We are unconditionally returning 0 in cleanup_ref_head, despite the fact that btrfs_del_csums could fail. We need to return the error so the transaction gets aborted properly, fix this by returning ret from btrfs_del_csums in cleanup_ref_head. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)