btrfs: make copy_inline_to_page take btrfs_inode
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Родитель
3c5641a83a
Коммит
998acfe8ff
|
@ -45,19 +45,20 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int copy_inline_to_page(struct inode *inode,
|
static int copy_inline_to_page(struct btrfs_inode *inode,
|
||||||
const u64 file_offset,
|
const u64 file_offset,
|
||||||
char *inline_data,
|
char *inline_data,
|
||||||
const u64 size,
|
const u64 size,
|
||||||
const u64 datal,
|
const u64 datal,
|
||||||
const u8 comp_type)
|
const u8 comp_type)
|
||||||
{
|
{
|
||||||
const u64 block_size = btrfs_inode_sectorsize(BTRFS_I(inode));
|
const u64 block_size = btrfs_inode_sectorsize(inode);
|
||||||
const u64 range_end = file_offset + block_size - 1;
|
const u64 range_end = file_offset + block_size - 1;
|
||||||
const size_t inline_size = size - btrfs_file_extent_calc_inline_size(0);
|
const size_t inline_size = size - btrfs_file_extent_calc_inline_size(0);
|
||||||
char *data_start = inline_data + btrfs_file_extent_calc_inline_size(0);
|
char *data_start = inline_data + btrfs_file_extent_calc_inline_size(0);
|
||||||
struct extent_changeset *data_reserved = NULL;
|
struct extent_changeset *data_reserved = NULL;
|
||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
|
struct address_space *mapping = inode->vfs_inode.i_mapping;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ASSERT(IS_ALIGNED(file_offset, block_size));
|
ASSERT(IS_ALIGNED(file_offset, block_size));
|
||||||
|
@ -68,24 +69,23 @@ static int copy_inline_to_page(struct inode *inode,
|
||||||
* reservation here. Also we must not do the reservation while holding
|
* reservation here. Also we must not do the reservation while holding
|
||||||
* a transaction open, otherwise we would deadlock.
|
* a transaction open, otherwise we would deadlock.
|
||||||
*/
|
*/
|
||||||
ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
|
ret = btrfs_delalloc_reserve_space(inode, &data_reserved, file_offset,
|
||||||
file_offset, block_size);
|
block_size);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
page = find_or_create_page(inode->i_mapping, file_offset >> PAGE_SHIFT,
|
page = find_or_create_page(mapping, file_offset >> PAGE_SHIFT,
|
||||||
btrfs_alloc_write_mask(inode->i_mapping));
|
btrfs_alloc_write_mask(mapping));
|
||||||
if (!page) {
|
if (!page) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_page_extent_mapped(page);
|
set_page_extent_mapped(page);
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, file_offset, range_end,
|
clear_extent_bit(&inode->io_tree, file_offset, range_end,
|
||||||
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
||||||
0, 0, NULL);
|
0, 0, NULL);
|
||||||
ret = btrfs_set_extent_delalloc(BTRFS_I(inode), file_offset, range_end,
|
ret = btrfs_set_extent_delalloc(inode, file_offset, range_end, 0, NULL);
|
||||||
0, NULL);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ out_unlock:
|
||||||
put_page(page);
|
put_page(page);
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
|
btrfs_delalloc_release_space(inode, data_reserved, file_offset,
|
||||||
file_offset, block_size, true);
|
block_size, true);
|
||||||
btrfs_delalloc_release_extents(BTRFS_I(inode), block_size);
|
btrfs_delalloc_release_extents(inode, block_size);
|
||||||
out:
|
out:
|
||||||
extent_changeset_free(data_reserved);
|
extent_changeset_free(data_reserved);
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ static int clone_copy_inline_extent(struct inode *dst,
|
||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
|
|
||||||
if (new_key->offset > 0) {
|
if (new_key->offset > 0) {
|
||||||
ret = copy_inline_to_page(dst, new_key->offset, inline_data,
|
ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
|
||||||
size, datal, comp_type);
|
inline_data, size, datal, comp_type);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ static int clone_copy_inline_extent(struct inode *dst,
|
||||||
* inline extent's data to the page.
|
* inline extent's data to the page.
|
||||||
*/
|
*/
|
||||||
ASSERT(key.offset > 0);
|
ASSERT(key.offset > 0);
|
||||||
ret = copy_inline_to_page(dst, new_key->offset,
|
ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
|
||||||
inline_data, size, datal,
|
inline_data, size, datal,
|
||||||
comp_type);
|
comp_type);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -213,8 +213,8 @@ static int clone_copy_inline_extent(struct inode *dst,
|
||||||
BTRFS_FILE_EXTENT_INLINE)
|
BTRFS_FILE_EXTENT_INLINE)
|
||||||
goto copy_inline_extent;
|
goto copy_inline_extent;
|
||||||
|
|
||||||
ret = copy_inline_to_page(dst, new_key->offset, inline_data,
|
ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
|
||||||
size, datal, comp_type);
|
inline_data, size, datal, comp_type);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +231,8 @@ copy_inline_extent:
|
||||||
* clone. Deal with all these cases by copying the inline extent
|
* clone. Deal with all these cases by copying the inline extent
|
||||||
* data into the respective page at the destination inode.
|
* data into the respective page at the destination inode.
|
||||||
*/
|
*/
|
||||||
ret = copy_inline_to_page(dst, new_key->offset, inline_data,
|
ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
|
||||||
size, datal, comp_type);
|
inline_data, size, datal, comp_type);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче