Btrfs: Update and fix mount -o nodatacow

To check whether a given file extent is referenced by multiple snapshots, the
checker walks down the fs tree through dead root and checks all tree blocks in
the path.

We can easily detect whether a given tree block is directly referenced by other
snapshot. We can also detect any indirect reference from other snapshot by
checking reference's generation. The checker can always detect multiple
references, but can't reliably detect cases of single reference. So btrfs may
do file data cow even there is only one reference.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Yan Zheng
2008-07-30 09:26:11 -04:00
committed by Chris Mason
parent 3bf1041867
commit f321e49103
5 changed files with 148 additions and 102 deletions

View File

@@ -249,11 +249,8 @@ again:
if (bytenr == 0)
goto not_found;
if (btrfs_count_snapshots_in_path(root, path, inode->i_ino,
bytenr) != 1) {
if (btrfs_cross_ref_exists(root, &found_key, bytenr))
goto not_found;
}
/*
* we may be called by the resizer, make sure we're inside
* the limits of the FS
@@ -277,6 +274,7 @@ loop:
goto again;
not_found:
btrfs_release_path(root, path);
cow_file_range(inode, start, end);
start = end + 1;
goto loop;