[4/5] btrfs: replace all uses of btrfs_ordered_update_i_size
diff mbox series

Message ID 20200107194237.145694-5-josef@toxicpanda.com
State New
Headers show
Series
  • btrfs: fix hole corruption issue with !NO_HOLES
Related show

Commit Message

Josef Bacik Jan. 7, 2020, 7:42 p.m. UTC
Now that we have a safe way to update the i_size, replace all uses of
btrfs_ordered_update_i_size with btrfs_inode_safe_disk_i_size_write.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/file.c  |  2 +-
 fs/btrfs/inode.c | 12 ++++++------
 fs/btrfs/ioctl.c |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Filipe Manana Jan. 15, 2020, 5:13 p.m. UTC | #1
On Tue, Jan 7, 2020 at 7:43 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Now that we have a safe way to update the i_size, replace all uses of
> btrfs_ordered_update_i_size with btrfs_inode_safe_disk_i_size_write.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/file.c  |  2 +-
>  fs/btrfs/inode.c | 12 ++++++------
>  fs/btrfs/ioctl.c |  2 +-
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index f1c880c06ca2..35fdc5b99804 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2941,7 +2941,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
>
>         inode->i_ctime = current_time(inode);
>         i_size_write(inode, end);
> -       btrfs_ordered_update_i_size(inode, end, NULL);
> +       btrfs_inode_safe_disk_i_size_write(inode, 0);
>         ret = btrfs_update_inode(trans, root, inode);
>         ret2 = btrfs_end_transaction(trans);
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 5d34007aa7ec..4a3ef3174d73 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3119,7 +3119,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
>                  */
>                 btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset,
>                                        ordered_extent->len);
> -               btrfs_ordered_update_i_size(inode, 0, ordered_extent);
> +               btrfs_inode_safe_disk_i_size_write(inode, 0);
>                 if (freespace_inode)
>                         trans = btrfs_join_transaction_spacecache(root);
>                 else
> @@ -3207,7 +3207,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
>                 goto out;
>         }
>
> -       btrfs_ordered_update_i_size(inode, 0, ordered_extent);
> +       btrfs_inode_safe_disk_i_size_write(inode, 0);
>         ret = btrfs_update_inode_fallback(trans, root, inode);
>         if (ret) { /* -ENOMEM or corruption */
>                 btrfs_abort_transaction(trans, ret);
> @@ -5007,7 +5007,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
>                 ASSERT(last_size >= new_size);
>                 if (!ret && last_size > new_size)
>                         last_size = new_size;
> -               btrfs_ordered_update_i_size(inode, last_size, NULL);
> +               btrfs_inode_safe_disk_i_size_write(inode, last_size);
>         }
>
>         btrfs_free_path(path);
> @@ -5337,7 +5337,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
>                 }
>
>                 i_size_write(inode, newsize);
> -               btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL);
> +               btrfs_inode_safe_disk_i_size_write(inode, 0);
>                 pagecache_isize_extended(inode, oldsize, newsize);
>                 ret = btrfs_update_inode(trans, root, inode);
>                 btrfs_end_write_no_snapshotting(root);
> @@ -9319,7 +9319,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
>                         ret = PTR_ERR(trans);
>                         goto out;
>                 }
> -               btrfs_ordered_update_i_size(inode, inode->i_size, NULL);
> +               btrfs_inode_safe_disk_i_size_write(inode, 0);
>         }
>
>         if (trans) {
> @@ -10578,7 +10578,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
>                         else
>                                 i_size = cur_offset;
>                         i_size_write(inode, i_size);
> -                       btrfs_ordered_update_i_size(inode, i_size, NULL);
> +                       btrfs_inode_safe_disk_i_size_write(inode, 0);
>                 }
>
>                 ret = btrfs_update_inode(trans, root, inode);
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 291dda3b6547..2a02a21cac59 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3334,7 +3334,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_ordered_update_i_size(inode, endoff, NULL);
> +               btrfs_inode_safe_disk_i_size_write(inode, 0);
>         }
>
>         ret = btrfs_update_inode(trans, root, inode);
> --
> 2.23.0
>

Patch
diff mbox series

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f1c880c06ca2..35fdc5b99804 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2941,7 +2941,7 @@  static int btrfs_fallocate_update_isize(struct inode *inode,
 
 	inode->i_ctime = current_time(inode);
 	i_size_write(inode, end);
-	btrfs_ordered_update_i_size(inode, end, NULL);
+	btrfs_inode_safe_disk_i_size_write(inode, 0);
 	ret = btrfs_update_inode(trans, root, inode);
 	ret2 = btrfs_end_transaction(trans);
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5d34007aa7ec..4a3ef3174d73 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3119,7 +3119,7 @@  static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
 		 */
 		btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset,
 				       ordered_extent->len);
-		btrfs_ordered_update_i_size(inode, 0, ordered_extent);
+		btrfs_inode_safe_disk_i_size_write(inode, 0);
 		if (freespace_inode)
 			trans = btrfs_join_transaction_spacecache(root);
 		else
@@ -3207,7 +3207,7 @@  static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
 		goto out;
 	}
 
-	btrfs_ordered_update_i_size(inode, 0, ordered_extent);
+	btrfs_inode_safe_disk_i_size_write(inode, 0);
 	ret = btrfs_update_inode_fallback(trans, root, inode);
 	if (ret) { /* -ENOMEM or corruption */
 		btrfs_abort_transaction(trans, ret);
@@ -5007,7 +5007,7 @@  int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 		ASSERT(last_size >= new_size);
 		if (!ret && last_size > new_size)
 			last_size = new_size;
-		btrfs_ordered_update_i_size(inode, last_size, NULL);
+		btrfs_inode_safe_disk_i_size_write(inode, last_size);
 	}
 
 	btrfs_free_path(path);
@@ -5337,7 +5337,7 @@  static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 		}
 
 		i_size_write(inode, newsize);
-		btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL);
+		btrfs_inode_safe_disk_i_size_write(inode, 0);
 		pagecache_isize_extended(inode, oldsize, newsize);
 		ret = btrfs_update_inode(trans, root, inode);
 		btrfs_end_write_no_snapshotting(root);
@@ -9319,7 +9319,7 @@  static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 			ret = PTR_ERR(trans);
 			goto out;
 		}
-		btrfs_ordered_update_i_size(inode, inode->i_size, NULL);
+		btrfs_inode_safe_disk_i_size_write(inode, 0);
 	}
 
 	if (trans) {
@@ -10578,7 +10578,7 @@  static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
 			else
 				i_size = cur_offset;
 			i_size_write(inode, i_size);
-			btrfs_ordered_update_i_size(inode, i_size, NULL);
+			btrfs_inode_safe_disk_i_size_write(inode, 0);
 		}
 
 		ret = btrfs_update_inode(trans, root, inode);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 291dda3b6547..2a02a21cac59 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3334,7 +3334,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_ordered_update_i_size(inode, endoff, NULL);
+		btrfs_inode_safe_disk_i_size_write(inode, 0);
 	}
 
 	ret = btrfs_update_inode(trans, root, inode);