Re: [PATCH 05/17] btrfs: handle checksum generation in the storage layer

Josef Bacik
2022-09-07T20:33:42Z

On Thu, Sep 01, 2022 at 10:42:04AM +0300, Christoph Hellwig wrote:
> Instead of letting the callers of btrfs_submit_bio deal with checksumming
> the (meta)data in the bio and making decisions on when to offload the
> checksumming to the bio, leave that to btrfs_submit_bio. Do do so the
> existing btrfs_submit_bio function is split into an upper and a lower
> half, so that the lower half can be offloaded to a workqueue.
>
> The driver-private REQ_DRV flag is used to indicate the special 'bio must
> be contained in a single ordered extent case' that is used by the
> compressed write case instead of passing a new flag all the way down the
> stack.
>
> Note that this changes the behavior for direct writes to raid56 volumes so
> that async checksum offloading is not skipped when more I/O is expected.
> This runs counter to the argument explaining why it was done, although I
> can't measure any affects of the change. Commits later in this series
> will make sure the entire direct writes is offloaded to the workqueue
> at once and thus make sure it is sent to the raid56 code from a single
> thread.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/btrfs/compression.c | 13 +--
> fs/btrfs/ctree.h | 4 +-
> fs/btrfs/disk-io.c | 170 ++-------------------------------
> fs/btrfs/disk-io.h | 5 -
> fs/btrfs/extent_io.h | 3 -
> fs/btrfs/file-item.c | 25 ++---
> fs/btrfs/inode.c | 89 +-----------------
> fs/btrfs/volumes.c | 208 ++++++++++++++++++++++++++++++++++++-----
> fs/btrfs/volumes.h | 7 +-
> 9 files changed, 215 insertions(+), 309 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index f932415a4f1df..53f9e123712b0 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -351,9 +351,9 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
> u64 cur_disk_bytenr = disk_start;
> u64 next_stripe_start;
> blk_status_t ret = BLK_STS_OK;
> - int skip_sum = inode->flags & BTRFS_INODE_NODATASUM;
> const bool use_append = btrfs_use_zone_append(inode, disk_start);
> - const enum req_op bio_op = use_append ? REQ_OP_ZONE_APPEND : REQ_OP_WRITE;
> + const enum req_op bio_op = REQ_BTRFS_ONE_ORDERED |
> + (use_append ? REQ_OP_ZONE_APPEND : REQ_OP_WRITE);
>

I'd rather see this as a separate change. Keeping logical changes to themselves
makes it easier to figure out what was going on when we look back at the
history. Other than that you can add

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef