summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-05-08 16:31:21 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:02 -0400
commitbbaf549e0c3d28399fc5abd68020d4025ae5c3a7 (patch)
tree19443b7e2a18fd04556ab9c5d914de3d29034a0d /fs/btrfs/extent-tree.c
parentc1c4d91c38e6e5b29543b02d4a4fb7f007e44f70 (diff)
downloadop-kernel-dev-bbaf549e0c3d28399fc5abd68020d4025ae5c3a7.zip
op-kernel-dev-bbaf549e0c3d28399fc5abd68020d4025ae5c3a7.tar.gz
Btrfs: A number of nodatacow fixes
Once part of a delalloc request fails the cow checks, just cow the entire range It is possible for the back references to all be from the same root, but still have snapshots against an extent. The checks are now more strict, forcing cow any time there are multiple refs against the data extent. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 30a5094..db996f0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -731,6 +731,7 @@ u32 btrfs_count_snapshots_in_path(struct btrfs_root *root,
u64 found_owner;
u64 root_objectid = root->root_key.objectid;
u32 total_count = 0;
+ u32 extent_refs;
u32 cur_count;
u32 nritems;
int ret;
@@ -767,6 +768,7 @@ again:
}
item = btrfs_item_ptr(l, path->slots[0], struct btrfs_extent_item);
+ extent_refs = btrfs_extent_refs(l, item);
while (1) {
l = path->nodes[0];
nritems = btrfs_header_nritems(l);
@@ -800,10 +802,28 @@ again:
total_count = 2;
goto out;
}
+ /*
+ * nasty. we don't count a reference held by
+ * the running transaction. This allows nodatacow
+ * to avoid cow most of the time
+ */
+ if (found_owner >= BTRFS_FIRST_FREE_OBJECTID &&
+ btrfs_ref_generation(l, ref_item) ==
+ root->fs_info->generation) {
+ extent_refs--;
+ }
}
total_count = 1;
path->slots[0]++;
}
+ /*
+ * if there is more than one reference against a data extent,
+ * we have to assume the other ref is another snapshot
+ */
+ if (level == -1 && extent_refs > 1) {
+ total_count = 2;
+ goto out;
+ }
if (cur_count == 0) {
total_count = 0;
goto out;
OpenPOWER on IntegriCloud