Skip to content

Commit 52db777

Browse files
fdmananakdave
authored andcommitted
btrfs: deal with errors when adding inode reference during log replay
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: [email protected] # 4.14+ Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e15ac64 commit 52db777

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/btrfs/tree-log.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,10 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
11901190
/* look for a conflicting sequence number */
11911191
di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir),
11921192
ref_index, name, namelen, 0);
1193-
if (di && !IS_ERR(di)) {
1193+
if (IS_ERR(di)) {
1194+
if (PTR_ERR(di) != -ENOENT)
1195+
return PTR_ERR(di);
1196+
} else if (di) {
11941197
ret = drop_one_dir_item(trans, root, path, dir, di);
11951198
if (ret)
11961199
return ret;
@@ -1200,7 +1203,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
12001203
/* look for a conflicting name */
12011204
di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir),
12021205
name, namelen, 0);
1203-
if (di && !IS_ERR(di)) {
1206+
if (IS_ERR(di)) {
1207+
return PTR_ERR(di);
1208+
} else if (di) {
12041209
ret = drop_one_dir_item(trans, root, path, dir, di);
12051210
if (ret)
12061211
return ret;

0 commit comments

Comments
 (0)