|
@@ -1271,7 +1271,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
|
|
u64 disk_num_bytes;
|
|
u64 disk_num_bytes;
|
|
u64 ram_bytes;
|
|
u64 ram_bytes;
|
|
int extent_type;
|
|
int extent_type;
|
|
- int ret, err;
|
|
|
|
|
|
+ int ret;
|
|
int type;
|
|
int type;
|
|
int nocow;
|
|
int nocow;
|
|
int check_prev = 1;
|
|
int check_prev = 1;
|
|
@@ -1403,11 +1403,8 @@ next_slot:
|
|
* if there are pending snapshots for this root,
|
|
* if there are pending snapshots for this root,
|
|
* we fall into common COW way.
|
|
* we fall into common COW way.
|
|
*/
|
|
*/
|
|
- if (!nolock) {
|
|
|
|
- err = btrfs_start_write_no_snapshotting(root);
|
|
|
|
- if (!err)
|
|
|
|
- goto out_check;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!nolock && atomic_read(&root->snapshot_force_cow))
|
|
|
|
+ goto out_check;
|
|
/*
|
|
/*
|
|
* force cow if csum exists in the range.
|
|
* force cow if csum exists in the range.
|
|
* this ensure that csum for a given extent are
|
|
* this ensure that csum for a given extent are
|
|
@@ -1416,9 +1413,6 @@ next_slot:
|
|
ret = csum_exist_in_range(fs_info, disk_bytenr,
|
|
ret = csum_exist_in_range(fs_info, disk_bytenr,
|
|
num_bytes);
|
|
num_bytes);
|
|
if (ret) {
|
|
if (ret) {
|
|
- if (!nolock)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* ret could be -EIO if the above fails to read
|
|
* ret could be -EIO if the above fails to read
|
|
* metadata.
|
|
* metadata.
|
|
@@ -1431,11 +1425,8 @@ next_slot:
|
|
WARN_ON_ONCE(nolock);
|
|
WARN_ON_ONCE(nolock);
|
|
goto out_check;
|
|
goto out_check;
|
|
}
|
|
}
|
|
- if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr)) {
|
|
|
|
- if (!nolock)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
|
|
+ if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr))
|
|
goto out_check;
|
|
goto out_check;
|
|
- }
|
|
|
|
nocow = 1;
|
|
nocow = 1;
|
|
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
|
|
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
|
|
extent_end = found_key.offset +
|
|
extent_end = found_key.offset +
|
|
@@ -1448,8 +1439,6 @@ next_slot:
|
|
out_check:
|
|
out_check:
|
|
if (extent_end <= start) {
|
|
if (extent_end <= start) {
|
|
path->slots[0]++;
|
|
path->slots[0]++;
|
|
- if (!nolock && nocow)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
if (nocow)
|
|
if (nocow)
|
|
btrfs_dec_nocow_writers(fs_info, disk_bytenr);
|
|
btrfs_dec_nocow_writers(fs_info, disk_bytenr);
|
|
goto next_slot;
|
|
goto next_slot;
|
|
@@ -1471,8 +1460,6 @@ out_check:
|
|
end, page_started, nr_written, 1,
|
|
end, page_started, nr_written, 1,
|
|
NULL);
|
|
NULL);
|
|
if (ret) {
|
|
if (ret) {
|
|
- if (!nolock && nocow)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
if (nocow)
|
|
if (nocow)
|
|
btrfs_dec_nocow_writers(fs_info,
|
|
btrfs_dec_nocow_writers(fs_info,
|
|
disk_bytenr);
|
|
disk_bytenr);
|
|
@@ -1492,8 +1479,6 @@ out_check:
|
|
ram_bytes, BTRFS_COMPRESS_NONE,
|
|
ram_bytes, BTRFS_COMPRESS_NONE,
|
|
BTRFS_ORDERED_PREALLOC);
|
|
BTRFS_ORDERED_PREALLOC);
|
|
if (IS_ERR(em)) {
|
|
if (IS_ERR(em)) {
|
|
- if (!nolock && nocow)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
if (nocow)
|
|
if (nocow)
|
|
btrfs_dec_nocow_writers(fs_info,
|
|
btrfs_dec_nocow_writers(fs_info,
|
|
disk_bytenr);
|
|
disk_bytenr);
|
|
@@ -1532,8 +1517,6 @@ out_check:
|
|
EXTENT_CLEAR_DATA_RESV,
|
|
EXTENT_CLEAR_DATA_RESV,
|
|
PAGE_UNLOCK | PAGE_SET_PRIVATE2);
|
|
PAGE_UNLOCK | PAGE_SET_PRIVATE2);
|
|
|
|
|
|
- if (!nolock && nocow)
|
|
|
|
- btrfs_end_write_no_snapshotting(root);
|
|
|
|
cur_offset = extent_end;
|
|
cur_offset = extent_end;
|
|
|
|
|
|
/*
|
|
/*
|