Commit 76aea537 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_inode_safe_disk_i_size_write take btrfs_inode

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent a55463c9
...@@ -3042,7 +3042,7 @@ int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start, ...@@ -3042,7 +3042,7 @@ int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start,
u64 len); u64 len);
int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start, int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start,
u64 len); 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); u64 btrfs_file_extent_end(const struct btrfs_path *path);
/* inode.c */ /* inode.c */
......
...@@ -38,27 +38,27 @@ ...@@ -38,27 +38,27 @@
* Finally new_i_size should only be set in the case of truncate where we're not * 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. * 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; u64 start, end, i_size;
int ret; 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)) { if (btrfs_fs_incompat(fs_info, NO_HOLES)) {
BTRFS_I(inode)->disk_i_size = i_size; inode->disk_i_size = i_size;
return; return;
} }
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
ret = find_contiguous_extent_bit(&BTRFS_I(inode)->file_extent_tree, 0, ret = find_contiguous_extent_bit(&inode->file_extent_tree, 0, &start,
&start, &end, EXTENT_DIRTY); &end, EXTENT_DIRTY);
if (!ret && start == 0) if (!ret && start == 0)
i_size = min(i_size, end + 1); i_size = min(i_size, end + 1);
else else
i_size = 0; i_size = 0;
BTRFS_I(inode)->disk_i_size = i_size; inode->disk_i_size = i_size;
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&inode->lock);
} }
/** /**
......
...@@ -3073,7 +3073,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode, ...@@ -3073,7 +3073,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
inode->i_ctime = current_time(inode); inode->i_ctime = current_time(inode);
i_size_write(inode, end); 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); ret = btrfs_update_inode(trans, root, inode);
ret2 = btrfs_end_transaction(trans); ret2 = btrfs_end_transaction(trans);
......
...@@ -2760,7 +2760,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -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)) { 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 */
btrfs_inode_safe_disk_i_size_write(inode, 0); btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
if (freespace_inode) if (freespace_inode)
trans = btrfs_join_transaction_spacecache(root); trans = btrfs_join_transaction_spacecache(root);
else else
...@@ -2835,7 +2835,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2835,7 +2835,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
EXTENT_DELALLOC_NEW | EXTENT_ADD_INODE_BYTES, EXTENT_DELALLOC_NEW | EXTENT_ADD_INODE_BYTES,
0, 0, &cached_state); 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); ret = btrfs_update_inode_fallback(trans, root, inode);
if (ret) { /* -ENOMEM or corruption */ if (ret) { /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -4633,7 +4633,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4633,7 +4633,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
ASSERT(last_size >= new_size); ASSERT(last_size >= new_size);
if (!ret && last_size > new_size) if (!ret && last_size > new_size)
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, unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start,
(u64)-1, &cached_state); (u64)-1, &cached_state);
} }
...@@ -4995,7 +4995,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -4995,7 +4995,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
} }
i_size_write(inode, newsize); 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); pagecache_isize_extended(inode, oldsize, newsize);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
btrfs_drew_write_unlock(&root->snapshot_lock); btrfs_drew_write_unlock(&root->snapshot_lock);
...@@ -8558,7 +8558,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback) ...@@ -8558,7 +8558,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
goto out; goto out;
} }
btrfs_inode_safe_disk_i_size_write(inode, 0); btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
} }
if (trans) { if (trans) {
...@@ -9789,7 +9789,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, ...@@ -9789,7 +9789,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
else else
i_size = cur_offset; i_size = cur_offset;
i_size_write(inode, i_size); 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); ret = btrfs_update_inode(trans, root, inode);
......
...@@ -31,7 +31,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans, ...@@ -31,7 +31,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
endoff = destoff + olen; endoff = destoff + olen;
if (endoff > inode->i_size) { if (endoff > inode->i_size) {
i_size_write(inode, endoff); 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); ret = btrfs_update_inode(trans, root, inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment