Commit f96d4474 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: check error value from btrfs_update_inode in tree log

Error injection testing uncovered a case where we ended up with invalid
link counts on an inode.  This happened because we failed to notice an
error when updating the inode while replaying the tree log, and
committed the transaction with an invalid file system.

Fix this by checking the return value of btrfs_update_inode.  This
resolved the link count errors I was seeing, and we already properly
handle passing up the error values in these paths.

CC: stable@vger.kernel.org # 4.4+
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 011b28ac
...@@ -1574,7 +1574,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -1574,7 +1574,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto out; goto out;
btrfs_update_inode(trans, root, BTRFS_I(inode)); ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
if (ret)
goto out;
} }
ref_ptr = (unsigned long)(ref_ptr + ref_struct_size) + namelen; ref_ptr = (unsigned long)(ref_ptr + ref_struct_size) + namelen;
...@@ -1749,7 +1751,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, ...@@ -1749,7 +1751,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
if (nlink != inode->i_nlink) { if (nlink != inode->i_nlink) {
set_nlink(inode, nlink); set_nlink(inode, nlink);
btrfs_update_inode(trans, root, BTRFS_I(inode)); ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
if (ret)
goto out;
} }
BTRFS_I(inode)->index_cnt = (u64)-1; BTRFS_I(inode)->index_cnt = (u64)-1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment