[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZoIWVthXmtZKesSO@dread.disaster.area>
Date: Mon, 1 Jul 2024 12:37:10 +1000
From: Dave Chinner <david@...morbit.com>
To: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
Cc: willy@...radead.org, chandan.babu@...cle.com, djwong@...nel.org,
brauner@...nel.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, yang@...amperecomputing.com,
linux-mm@...ck.org, john.g.garry@...cle.com,
linux-fsdevel@...r.kernel.org, hare@...e.de, p.raghav@...sung.com,
mcgrof@...nel.org, gost.dev@...sung.com, cl@...amperecomputing.com,
linux-xfs@...r.kernel.org, hch@....de, Zi Yan <zi.yan@...t.com>
Subject: Re: [PATCH v8 06/10] iomap: fix iomap_dio_zero() for fs bs > system
page size
On Tue, Jun 25, 2024 at 11:44:16AM +0000, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@...sung.com>
>
> iomap_dio_zero() will pad a fs block with zeroes if the direct IO size
> < fs block size. iomap_dio_zero() has an implicit assumption that fs block
> size < page_size. This is true for most filesystems at the moment.
>
> If the block size > page size, this will send the contents of the page
> next to zero page(as len > PAGE_SIZE) to the underlying block device,
> causing FS corruption.
>
> iomap is a generic infrastructure and it should not make any assumptions
> about the fs block size and the page size of the system.
>
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
> Reviewed-by: Hannes Reinecke <hare@...e.de>
Looks fine, so:
Reviewed-by: Dave Chinner <dchinner@...hat.com>
but....
> +/*
> + * Used for sub block zeroing in iomap_dio_zero()
> + */
> +#define ZERO_PAGE_64K_SIZE (65536)
> +#define ZERO_PAGE_64K_ORDER (get_order(ZERO_PAGE_64K_SIZE))
> +static struct page *zero_page_64k;
.....
> @@ -753,3 +765,17 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
> return iomap_dio_complete(dio);
> }
> EXPORT_SYMBOL_GPL(iomap_dio_rw);
> +
> +static int __init iomap_dio_init(void)
> +{
> + zero_page_64k = alloc_pages(GFP_KERNEL | __GFP_ZERO,
> + ZERO_PAGE_64K_ORDER);
> +
> + if (!zero_page_64k)
> + return -ENOMEM;
> +
> + set_memory_ro((unsigned long)page_address(zero_page_64k),
> + 1U << ZERO_PAGE_64K_ORDER);
^^^^^^^^^^^^^^^^^^^^^^^^^
isn't that just ZERO_PAGE_64K_SIZE?
-Dave.
--
Dave Chinner
david@...morbit.com
Powered by blists - more mailing lists