btrfs: deal with errors when adding inode reference during log replay
commit 52db77791f upstream.
At __inode_add_ref(), we treating any error returned from
btrfs_lookup_dir_item() or from btrfs_lookup_dir_index_item() as meaning
that there is no existing directory entry in the fs/subvolume tree.
This is not correct since we can get errors such as, for example, -EIO
when reading extent buffers while searching the fs/subvolume's btree.
So fix that and return the error to the caller when it is not -ENOENT.
CC: stable@vger.kernel.org # 4.14+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
95d3aba5fe
commit
4ed68471bc
1 changed files with 7 additions and 2 deletions
|
|
@ -1137,7 +1137,10 @@ next:
|
|||
/* look for a conflicting sequence number */
|
||||
di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir),
|
||||
ref_index, name, namelen, 0);
|
||||
if (di && !IS_ERR(di)) {
|
||||
if (IS_ERR(di)) {
|
||||
if (PTR_ERR(di) != -ENOENT)
|
||||
return PTR_ERR(di);
|
||||
} else if (di) {
|
||||
ret = drop_one_dir_item(trans, root, path, dir, di);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -1147,7 +1150,9 @@ next:
|
|||
/* look for a conflicting name */
|
||||
di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir),
|
||||
name, namelen, 0);
|
||||
if (di && !IS_ERR(di)) {
|
||||
if (IS_ERR(di)) {
|
||||
return PTR_ERR(di);
|
||||
} else if (di) {
|
||||
ret = drop_one_dir_item(trans, root, path, dir, di);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue