Btrfs: Fix leaf reference cache miss
Due to the optimization for truncate, tree leaves only containing checksum items can be deleted without being COW'ed first. This causes reference cache misses. The way to fix the miss is create cache entries for tree leaves only contain checksum. This patch also fixes a -EEXIST issue in shared reference cache. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
This commit is contained in:
@@ -1151,6 +1151,14 @@ int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
|
||||
}
|
||||
|
||||
ret = btrfs_add_leaf_ref(root, ref, shared);
|
||||
if (ret == -EEXIST && shared) {
|
||||
struct btrfs_leaf_ref *old;
|
||||
old = btrfs_lookup_leaf_ref(root, ref->bytenr);
|
||||
BUG_ON(!old);
|
||||
btrfs_remove_leaf_ref(root, old);
|
||||
btrfs_free_leaf_ref(root, old);
|
||||
ret = btrfs_add_leaf_ref(root, ref, shared);
|
||||
}
|
||||
WARN_ON(ret);
|
||||
btrfs_free_leaf_ref(root, ref);
|
||||
}
|
||||
|
Reference in New Issue
Block a user