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

Pankaj Raghav (Samsung)
2024-06-17T15:08:38Z

On Wed, Jun 12, 2024 at 01:40:25PM -0700, Darrick J. Wong wrote:
> On Fri, Jun 07, 2024 at 02:58:58PM +0000, Pankaj Raghav (Samsung) wrote:
> > From: Pankaj Raghav <p.raghav@samsung.com>
> >
> > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> > index f3b43d223a46..b95600b254a3 100644
> > --- a/fs/iomap/direct-io.c
> > +++ b/fs/iomap/direct-io.c
> > @@ -27,6 +27,13 @@
> > #define IOMAP_DIO_WRITE (1U << 30)
> > #define IOMAP_DIO_DIRTY (1U << 31)
> >
> > +/*
> > + * Used for sub block zeroing in iomap_dio_zero()
> > + */
> > +#define ZERO_FSB_SIZE (65536)
> > +#define ZERO_FSB_ORDER (get_order(ZERO_FSB_SIZE))
> > +static struct page *zero_fs_block;
>
> Er... zero_page_64k ?
>
> Since it's a permanent allocation, can we also mark the memory ro?

Sounds good.
>
> > +
> > struct iomap_dio {
> > struct kiocb *iocb;
> > const struct iomap_dio_ops *dops;
> > @@ -52,6 +59,16 @@ struct iomap_dio {
> > };
> > };
> >
> > +int iomap_dio_init(void)
> > +{
> > + zero_fs_block = alloc_pages(GFP_KERNEL | __GFP_ZERO, ZERO_FSB_ORDER);
> > +
> > + if (!zero_fs_block)
> > + return -ENOMEM;
> > +
> > + return 0;
> > +}
>
> Can't we just turn this into another fs_initcall() instead of exporting
> it just so we can call it from iomap_init? And maybe rename the
> existing iomap_init to iomap_pagecache_init or something, for clarity's
> sake?

Yeah, probably iomap_pagecache_init() in fs/iomap/buffered-io.c and
iomap_dio_init() in fs/iomap/direct-io.c
>
> --D
>