Re: [PATCH v4 07/11] iomap: fix iomap_dio_zero() for fs bs > system page size

Matthew Wilcox
2024-04-27T03:26:54Z

On Thu, Apr 25, 2024 at 11:22:35PM -0700, Christoph Hellwig wrote:
> On Thu, Apr 25, 2024 at 01:37:42PM +0200, Pankaj Raghav (Samsung) wrote:
> > From: Pankaj Raghav <p.raghav@samsung.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.
>
> So what happened to the plan to making huge_zero_page a folio and have

There's a series of commits in linux-mm with the titles:

sparc: use is_huge_zero_pmd()
mm: add is_huge_zero_folio()
mm: add pmd_folio()
mm: convert migrate_vma_collect_pmd to use a folio
mm: convert huge_zero_page to huge_zero_folio
mm: convert do_huge_pmd_anonymous_page to huge_zero_folio
dax: use huge_zero_folio
mm: rename mm_put_huge_zero_page to mm_put_huge_zero_folio

> it available for non-hugetlb setups? Not only would this be cleaner
> and more efficient, but it would actually work for the case where you'd
> have to zero more than 1MB on a 4k PAGE_SIZE system, which doesn't
> seem impossible with 2MB folios.

It is available for non-hugetlb setups. It is however allocated on
demand, so it might not be available.