btrfs: make btrfs_cont_expand take btrfs_inode
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.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:
parent
217f42eb3d
commit
b06359a325
|
@ -3118,7 +3118,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
|
|||
int btrfs_orphan_add(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_inode *inode);
|
||||
int btrfs_orphan_cleanup(struct btrfs_root *root);
|
||||
int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size);
|
||||
int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size);
|
||||
void btrfs_add_delayed_iput(struct inode *inode);
|
||||
void btrfs_run_delayed_iputs(struct btrfs_fs_info *fs_info);
|
||||
int btrfs_wait_on_delayed_iputs(struct btrfs_fs_info *fs_info);
|
||||
|
|
|
@ -1628,7 +1628,7 @@ static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from,
|
|||
/* Expand hole size to cover write data, preventing empty gap */
|
||||
loff_t end_pos = round_up(pos + count, fs_info->sectorsize);
|
||||
|
||||
ret = btrfs_cont_expand(inode, oldsize, end_pos);
|
||||
ret = btrfs_cont_expand(BTRFS_I(inode), oldsize, end_pos);
|
||||
if (ret) {
|
||||
current->backing_dev_info = NULL;
|
||||
return ret;
|
||||
|
@ -3348,7 +3348,7 @@ static long btrfs_fallocate(struct file *file, int mode,
|
|||
* But that's a minor problem and won't do much harm BTW.
|
||||
*/
|
||||
if (alloc_start > inode->i_size) {
|
||||
ret = btrfs_cont_expand(inode, i_size_read(inode),
|
||||
ret = btrfs_cont_expand(BTRFS_I(inode), i_size_read(inode),
|
||||
alloc_start);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
|
|
@ -4847,14 +4847,14 @@ static int maybe_insert_hole(struct btrfs_root *root, struct btrfs_inode *inode,
|
|||
* these file extents so that btrfs_get_extent will return a EXTENT_MAP_HOLE for
|
||||
* the range between oldsize and size
|
||||
*/
|
||||
int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
|
||||
int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
|
||||
struct btrfs_root *root = inode->root;
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
struct extent_io_tree *io_tree = &inode->io_tree;
|
||||
struct extent_map *em = NULL;
|
||||
struct extent_state *cached_state = NULL;
|
||||
struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
|
||||
struct extent_map_tree *em_tree = &inode->extent_tree;
|
||||
u64 hole_start = ALIGN(oldsize, fs_info->sectorsize);
|
||||
u64 block_end = ALIGN(size, fs_info->sectorsize);
|
||||
u64 last_byte;
|
||||
|
@ -4867,18 +4867,18 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
|
|||
* rest of the block before we expand the i_size, otherwise we could
|
||||
* expose stale data.
|
||||
*/
|
||||
err = btrfs_truncate_block(BTRFS_I(inode), oldsize, 0, 0);
|
||||
err = btrfs_truncate_block(inode, oldsize, 0, 0);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (size <= hole_start)
|
||||
return 0;
|
||||
|
||||
btrfs_lock_and_flush_ordered_range(BTRFS_I(inode), hole_start,
|
||||
block_end - 1, &cached_state);
|
||||
btrfs_lock_and_flush_ordered_range(inode, hole_start, block_end - 1,
|
||||
&cached_state);
|
||||
cur_offset = hole_start;
|
||||
while (1) {
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset,
|
||||
em = btrfs_get_extent(inode, NULL, 0, cur_offset,
|
||||
block_end - cur_offset);
|
||||
if (IS_ERR(em)) {
|
||||
err = PTR_ERR(em);
|
||||
|
@ -4892,22 +4892,22 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
|
|||
if (!test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) {
|
||||
struct extent_map *hole_em;
|
||||
|
||||
err = maybe_insert_hole(root, BTRFS_I(inode),
|
||||
err = maybe_insert_hole(root, inode, cur_offset,
|
||||
hole_size);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
err = btrfs_inode_set_file_extent_range(inode,
|
||||
cur_offset, hole_size);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
err = btrfs_inode_set_file_extent_range(BTRFS_I(inode),
|
||||
cur_offset, hole_size);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
btrfs_drop_extent_cache(BTRFS_I(inode), cur_offset,
|
||||
btrfs_drop_extent_cache(inode, cur_offset,
|
||||
cur_offset + hole_size - 1, 0);
|
||||
hole_em = alloc_extent_map();
|
||||
if (!hole_em) {
|
||||
set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
|
||||
&BTRFS_I(inode)->runtime_flags);
|
||||
&inode->runtime_flags);
|
||||
goto next;
|
||||
}
|
||||
hole_em->start = cur_offset;
|
||||
|
@ -4927,14 +4927,13 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
|
|||
write_unlock(&em_tree->lock);
|
||||
if (err != -EEXIST)
|
||||
break;
|
||||
btrfs_drop_extent_cache(BTRFS_I(inode),
|
||||
cur_offset,
|
||||
btrfs_drop_extent_cache(inode, cur_offset,
|
||||
cur_offset +
|
||||
hole_size - 1, 0);
|
||||
}
|
||||
free_extent_map(hole_em);
|
||||
} else {
|
||||
err = btrfs_inode_set_file_extent_range(BTRFS_I(inode),
|
||||
err = btrfs_inode_set_file_extent_range(inode,
|
||||
cur_offset, hole_size);
|
||||
if (err)
|
||||
break;
|
||||
|
@ -4982,7 +4981,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
|
|||
* this truncation.
|
||||
*/
|
||||
btrfs_drew_write_lock(&root->snapshot_lock);
|
||||
ret = btrfs_cont_expand(inode, oldsize, newsize);
|
||||
ret = btrfs_cont_expand(BTRFS_I(inode), oldsize, newsize);
|
||||
if (ret) {
|
||||
btrfs_drew_write_unlock(&root->snapshot_lock);
|
||||
return ret;
|
||||
|
|
|
@ -654,7 +654,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
|
|||
if (destoff > inode->i_size) {
|
||||
const u64 wb_start = ALIGN_DOWN(inode->i_size, bs);
|
||||
|
||||
ret = btrfs_cont_expand(inode, inode->i_size, destoff);
|
||||
ret = btrfs_cont_expand(BTRFS_I(inode), inode->i_size, destoff);
|
||||
if (ret)
|
||||
return ret;
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue