mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
btrfs: qgroup: Add handler for NOCOW and inline
For NOCOW and inline case, there will be no delayed_ref created for them, so we should free their reserved data space at proper time(finish_ordered_io for NOCOW and cow_file_inline for inline). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
7cf5b97650
commit
94ed938aba
2 changed files with 21 additions and 1 deletions
|
@ -4052,7 +4052,12 @@ int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Use new btrfs_qgroup_reserve_data to reserve precious data space */
|
/*
|
||||||
|
* Use new btrfs_qgroup_reserve_data to reserve precious data space
|
||||||
|
*
|
||||||
|
* TODO: Find a good method to avoid reserve data space for NOCOW
|
||||||
|
* range, but don't impact performance on quota disable case.
|
||||||
|
*/
|
||||||
ret = btrfs_qgroup_reserve_data(inode, start, len);
|
ret = btrfs_qgroup_reserve_data(inode, start, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,6 +310,13 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
|
||||||
btrfs_delalloc_release_metadata(inode, end + 1 - start);
|
btrfs_delalloc_release_metadata(inode, end + 1 - start);
|
||||||
btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
|
btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
|
||||||
out:
|
out:
|
||||||
|
/*
|
||||||
|
* Don't forget to free the reserved space, as for inlined extent
|
||||||
|
* it won't count as data extent, free them directly here.
|
||||||
|
* And at reserve time, it's always aligned to page size, so
|
||||||
|
* just free one page here.
|
||||||
|
*/
|
||||||
|
btrfs_qgroup_free_data(inode, 0, PAGE_CACHE_SIZE);
|
||||||
btrfs_free_path(path);
|
btrfs_free_path(path);
|
||||||
btrfs_end_transaction(trans, root);
|
btrfs_end_transaction(trans, root);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2838,6 +2845,14 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
|
||||||
|
|
||||||
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
|
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
|
||||||
BUG_ON(!list_empty(&ordered_extent->list)); /* Logic error */
|
BUG_ON(!list_empty(&ordered_extent->list)); /* Logic error */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For mwrite(mmap + memset to write) case, we still reserve
|
||||||
|
* space for NOCOW range.
|
||||||
|
* As NOCOW won't cause a new delayed ref, just free the space
|
||||||
|
*/
|
||||||
|
btrfs_qgroup_free_data(inode, ordered_extent->file_offset,
|
||||||
|
ordered_extent->len);
|
||||||
btrfs_ordered_update_i_size(inode, 0, ordered_extent);
|
btrfs_ordered_update_i_size(inode, 0, ordered_extent);
|
||||||
if (nolock)
|
if (nolock)
|
||||||
trans = btrfs_join_transaction_nolock(root);
|
trans = btrfs_join_transaction_nolock(root);
|
||||||
|
|
Loading…
Reference in a new issue