diff mbox series

[RFC,13/31] btrfs: do not checksum for free space inode

Message ID acd977c106057ee19f4c965b718460605add1cc0.1623567940.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs buffered iomap support | expand

Commit Message

Goldwyn Rodrigues June 13, 2021, 1:39 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Free space inode writes should not be checksummed.

Q: Now sure why this is required now (as opposed to earlier), but it
would fail on writing free_space_inode. How is this avoided in the
existing code?

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/disk-io.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Nikolay Borisov June 16, 2021, 2:46 p.m. UTC | #1
On 13.06.21 г. 16:39, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> Free space inode writes should not be checksummed.
> 
> Q: Now sure why this is required now (as opposed to earlier), but it
> would fail on writing free_space_inode. How is this avoided in the
> existing code?
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
>  fs/btrfs/disk-io.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index d1d5091a8385..3af505ec22dc 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -946,9 +946,12 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
>  			goto out_w_error;
>  		ret = btrfs_map_bio(fs_info, bio, mirror_num);
>  	} else if (!should_async_write(fs_info, BTRFS_I(inode))) {
> -		ret = btree_csum_one_bio(bio);
> -		if (ret)
> -			goto out_w_error;
> +		/* Do not checksum free space inode */
> +		if (!btrfs_is_free_space_inode(BTRFS_I(inode))) {
> +			ret = btree_csum_one_bio(bio);
> +			if (ret)
> +				goto out_w_error;
> +		}

Something is broken here, the freespace inode is considered a data
inode, this means that this check should always be true i.e this patch
is a null op?  I.e the only inode you should be writing through
submit_metadata_bio is the btree_inode.

>  		ret = btrfs_map_bio(fs_info, bio, mirror_num);
>  	} else {
>  		/*
>
diff mbox series

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d1d5091a8385..3af505ec22dc 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -946,9 +946,12 @@  blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
 			goto out_w_error;
 		ret = btrfs_map_bio(fs_info, bio, mirror_num);
 	} else if (!should_async_write(fs_info, BTRFS_I(inode))) {
-		ret = btree_csum_one_bio(bio);
-		if (ret)
-			goto out_w_error;
+		/* Do not checksum free space inode */
+		if (!btrfs_is_free_space_inode(BTRFS_I(inode))) {
+			ret = btree_csum_one_bio(bio);
+			if (ret)
+				goto out_w_error;
+		}
 		ret = btrfs_map_bio(fs_info, bio, mirror_num);
 	} else {
 		/*