Re: [PATCH v3] squashfs: cache partial compressed blocks

From: Christoph Hellwig
Date: Wed May 17 2023 - 03:11:13 EST


This looks generally good, but I have two more nitpicks (sorry for
beeing annoying):

> + struct inode *cache_inode = msblk->cache_inode;
> + struct address_space *cache_mapping = cache_inode ? cache_inode->i_mapping : NULL;
>
> + struct page *page = NULL;
> +
> + if (cache_mapping)
> + page = find_get_page(cache_mapping,
> + read_start + i * PAGE_SIZE);

Given we only ever use the cache inode mapping, I'd suggest to store
that in the super_block and the just use mapping->host for the iput
on unmount.

> + if (cache_mapping) {
> + /*
> + * Use the __ version to avoid merging since we need
> + * each page to be separate when we check for and avoid
> + * cached pages.
> + */
> + __bio_add_page(bio, page, len, offset);
> + } else if (!bio_add_page(bio, page, len, offset)) {
> error = -EIO;
> goto out_free_bio;

And given that random alloc_page pages are basically never mergable
we should be able to just use __bio_add_page here unconditionally.