btrfs: fix invalid extref key setup when replaying dentry
authorFilipe Manana <fdmanana@suse.com>
Wed, 3 Sep 2025 15:53:21 +0000 (16:53 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Sep 2025 03:25:31 +0000 (05:25 +0200)
The offset for an extref item's key is not the object ID of the parent
dir, otherwise we would not need the extref item and would use plain ref
items. Instead the offset is the result of a hash computation that uses
the object ID of the parent dir and the name associated to the entry.
So fix this by setting the key offset at replay_one_name() to be the
result of calling btrfs_extref_hash().

Fixes: 725af92a6251 ("btrfs: Open-code name_in_log_ref in replay_one_name")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c

index 7d5d90845ca985c940730d76fa7d718915e1216d..7a63afedd01e6e78f942968d203ae5286f1363e8 100644 (file)
@@ -1964,7 +1964,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
 
        search_key.objectid = log_key.objectid;
        search_key.type = BTRFS_INODE_EXTREF_KEY;
-       search_key.offset = key->objectid;
+       search_key.offset = btrfs_extref_hash(key->objectid, name.name, name.len);
        ret = backref_in_log(root->log_root, &search_key, key->objectid, &name);
        if (ret < 0) {
                goto out;