Re: [PATCH 05/12] iomap: Introduce IOMAP_ENCODED

From: Christoph Hellwig
Date: Tue Oct 08 2024 - 05:50:16 EST


On Fri, Oct 04, 2024 at 04:04:32PM -0400, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
>
> An encoded extent must be read completely. Make the bio just as a
> regular bio and let filesystem deal with the rest of the extent.
> A new bio must be created if a new iomap is returned.
> The filesystem must be informed that the bio to be read is
> encoded and the offset from which the encoded extent starts. So, pass
> the iomap associated with the bio while calling submit_io. Save the
> previous iomap (associated with the bio being submitted) in prev in
> order to submit when the iomap changes.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
> ---
> fs/iomap/buffered-io.c | 17 ++++++++++-------
> include/linux/iomap.h | 11 +++++++++--
> 2 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 0e682ff84e4a..4c734899a8e5 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -378,12 +378,13 @@ static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter,
> {
> const struct iomap *srcmap = iomap_iter_srcmap(iter);
>
> - return srcmap->type != IOMAP_MAPPED ||
> + return (srcmap->type != IOMAP_MAPPED &&
> + srcmap->type != IOMAP_ENCODED) ||
> (srcmap->flags & IOMAP_F_NEW) ||
> pos >= i_size_read(iter->inode);

Non-standard indentation for the new line. But at this point the
condition is becoming complex enough that it is best split into
multiple if statements anyway.


> sector = iomap_sector(iomap, pos);
> if (!ctx->bio ||
> + (iomap->type & IOMAP_ENCODED && iomap->offset != iter->prev.offset) ||

Overly long line. And this could really use a comment as well.

> -static loff_t iomap_readahead_iter(const struct iomap_iter *iter,
> +static loff_t iomap_readahead_iter(struct iomap_iter *iter,
> struct iomap_readpage_ctx *ctx)

Why is the iter de-constified?

In general I'm not a huge fan of the encoded magic here, but I'll
need to take a closer look at the caller if I can come up with
something better.