]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: fix lost error handling when looking up extended ref on log replay
authorFilipe Manana <fdmanana@suse.com>
Mon, 1 Aug 2022 13:57:51 +0000 (14:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:18:19 +0000 (11:18 +0200)
commit 1da67fecacc6481f8dfde522739df383f4e7098c upstream.

During log replay, when processing inode references, if we get an error
when looking up for an extended reference at __add_inode_ref(), we ignore
it and proceed, returning success (0) if no other error happens after the
lookup. This is obviously wrong because in case an extended reference
exists and it encodes some name not in the log, we need to unlink it,
otherwise the filesystem state will not match the state it had after the
last fsync.

So just make __add_inode_ref() return an error it gets from the extended
reference lookup.

Fixes: b60c4f34cab4e6 ("btrfs: extended inode refs")
CC: stable@vger.kernel.org # 4.9+
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>
fs/btrfs/tree-log.c

index b7bfecfc2ea33a42fb01922054bf76d3cf560a55..bebd74267bed6a0ca719cd67d89c2cc65bdeba43 100644 (file)
@@ -1100,7 +1100,9 @@ again:
        extref = btrfs_lookup_inode_extref(NULL, root, path, name, namelen,
                                           inode_objectid, parent_objectid, 0,
                                           0);
-       if (!IS_ERR_OR_NULL(extref)) {
+       if (IS_ERR(extref)) {
+               return PTR_ERR(extref);
+       } else if (extref) {
                u32 item_size;
                u32 cur_offset = 0;
                unsigned long base;