Re: [RFC 01/23] fs: Allow fine-grained control of folio sizes

From: Matthew Wilcox
Date: Fri Sep 15 2023 - 15:04:29 EST


On Fri, Sep 15, 2023 at 08:38:26PM +0200, Pankaj Raghav wrote:
> +static inline void mapping_set_folio_orders(struct address_space *mapping,
> + unsigned int min, unsigned int max)
> +{
> + /*
> + * XXX: max is ignored as only minimum folio order is supported
> + * currently.
> + */

I think we need some sanity checking ...

if (min == 1)
min = 2;
if (max < min)
max = min;
if (max > MAX_PAGECACHE_ORDER)
max = MAX_PAGECACHE_ORDER;

> + mapping->flags = (mapping->flags & ~AS_FOLIO_ORDER_MASK) |
> + (min << AS_FOLIO_ORDER_MIN) |
> + (MAX_PAGECACHE_ORDER << AS_FOLIO_ORDER_MAX);
> +}