Re: [RFC PATCH v2 3/3] btrfs: Use kmap_local_page() on "in_page" in zlib_compress_pages()
From: Fabio M. De Francesco
Date: Sat Jun 18 2022 - 05:05:03 EST
On sabato 18 giugno 2022 00:16:15 CEST Qu Wenruo wrote:
>
> On 2022/6/18 02:13, Fabio M. De Francesco wrote:
[snip]
>
> Thanks for pointing to the doc, and that doc is enough to answer my
> question.
>
Well, this confirms that my changes were quite helpful :-)
[snip]
> > As I said in a recent email, I'm relatively new to kernel development,
> > especially to Btrfs and other filesystems.
>
> That's not a big deal, that's why we're here to provide help.
>
> >
> > However, I noted that this code does different handling depending
> > on how many "in_page" is going to map. I am not able to say why...
>
> AFAIK the reason is optimization.
>
> The idea is like this, if there are multiple pages left as input, we
> copy the pages from page cache into the workspace buffer.
>
> If there is no more than one page left, we use that page from page cache
> directly.
>
> I believe that's the problem causing the difficult in converting to
> kmap_local_page().
>
[snip]
>
> I'll send out a cleanup for zlib_compress_pages(), mostly to make the
> (strm.avail_in == 0) branch to call kmap() and kunmap() in pairs,
> without holding @in_page mapped.
>
> Would that make it easier?
>
I was doubtful when you asked this question. However, when this morning I
saw your patch, I soon understood that it would make that task so easy that
a silly script could do a mechanical conversion.
Thanks so much,
Fabio