mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-18 02:46:06 +00:00
btrfs: make btrfs_inode_safe_disk_i_size_write 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
a55463c9f0
commit
76aea53796
@ -3042,7 +3042,7 @@ int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start,
|
||||
u64 len);
|
||||
int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start,
|
||||
u64 len);
|
||||
void btrfs_inode_safe_disk_i_size_write(struct inode *inode, u64 new_i_size);
|
||||
void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_size);
|
||||
u64 btrfs_file_extent_end(const struct btrfs_path *path);
|
||||
|
||||
/* inode.c */
|
||||
|
@ -38,27 +38,27 @@
|
||||
* Finally new_i_size should only be set in the case of truncate where we're not
|
||||
* ready to use i_size_read() as the limiter yet.
|
||||
*/
|
||||
void btrfs_inode_safe_disk_i_size_write(struct inode *inode, u64 new_i_size)
|
||||
void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_size)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
|
||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||
u64 start, end, i_size;
|
||||
int ret;
|
||||
|
||||
i_size = new_i_size ?: i_size_read(inode);
|
||||
i_size = new_i_size ?: i_size_read(&inode->vfs_inode);
|
||||
if (btrfs_fs_incompat(fs_info, NO_HOLES)) {
|
||||
BTRFS_I(inode)->disk_i_size = i_size;
|
||||
inode->disk_i_size = i_size;
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock(&BTRFS_I(inode)->lock);
|
||||
ret = find_contiguous_extent_bit(&BTRFS_I(inode)->file_extent_tree, 0,
|
||||
&start, &end, EXTENT_DIRTY);
|
||||
spin_lock(&inode->lock);
|
||||
ret = find_contiguous_extent_bit(&inode->file_extent_tree, 0, &start,
|
||||
&end, EXTENT_DIRTY);
|
||||
if (!ret && start == 0)
|
||||
i_size = min(i_size, end + 1);
|
||||
else
|
||||
i_size = 0;
|
||||
BTRFS_I(inode)->disk_i_size = i_size;
|
||||
spin_unlock(&BTRFS_I(inode)->lock);
|
||||
inode->disk_i_size = i_size;
|
||||
spin_unlock(&inode->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3073,7 +3073,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
|
||||
|
||||
inode->i_ctime = current_time(inode);
|
||||
i_size_write(inode, end);
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
ret2 = btrfs_end_transaction(trans);
|
||||
|
||||
|
@ -2760,7 +2760,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
|
||||
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
|
||||
BUG_ON(!list_empty(&ordered_extent->list)); /* Logic error */
|
||||
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
if (freespace_inode)
|
||||
trans = btrfs_join_transaction_spacecache(root);
|
||||
else
|
||||
@ -2835,7 +2835,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
|
||||
EXTENT_DELALLOC_NEW | EXTENT_ADD_INODE_BYTES,
|
||||
0, 0, &cached_state);
|
||||
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
ret = btrfs_update_inode_fallback(trans, root, inode);
|
||||
if (ret) { /* -ENOMEM or corruption */
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
@ -4633,7 +4633,7 @@ out:
|
||||
ASSERT(last_size >= new_size);
|
||||
if (!ret && last_size > new_size)
|
||||
last_size = new_size;
|
||||
btrfs_inode_safe_disk_i_size_write(inode, last_size);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), last_size);
|
||||
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start,
|
||||
(u64)-1, &cached_state);
|
||||
}
|
||||
@ -4995,7 +4995,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
|
||||
}
|
||||
|
||||
i_size_write(inode, newsize);
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
pagecache_isize_extended(inode, oldsize, newsize);
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
btrfs_drew_write_unlock(&root->snapshot_lock);
|
||||
@ -8558,7 +8558,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
|
||||
ret = PTR_ERR(trans);
|
||||
goto out;
|
||||
}
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
}
|
||||
|
||||
if (trans) {
|
||||
@ -9789,7 +9789,7 @@ next:
|
||||
else
|
||||
i_size = cur_offset;
|
||||
i_size_write(inode, i_size);
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
}
|
||||
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
|
@ -31,7 +31,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
|
||||
endoff = destoff + olen;
|
||||
if (endoff > inode->i_size) {
|
||||
i_size_write(inode, endoff);
|
||||
btrfs_inode_safe_disk_i_size_write(inode, 0);
|
||||
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
|
||||
}
|
||||
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user