Re: [PATCH 01/11] btrfs: add macros for compression type and level
From: Dennis Zhou
Date: Thu Jan 31 2019 - 11:17:30 EST
On Thu, Jan 31, 2019 at 05:00:10PM +0100, David Sterba wrote:
> On Mon, Jan 28, 2019 at 04:24:27PM -0500, Dennis Zhou wrote:
> > It is very easy to miss places that rely on a certain bitshifting for
> > decyphering the type_level overloading. Make macros handle this instead.
>
> This encoding was a simple way to introduce the combined type and level
> for zlib and it could certainly be improved. Either we'll use helpers
> like you suggest or add a new structure that contains type and level as
> members. That way we'd see where the level still matters and where the
> just the type is ok.
>
> I haven't checked how much intrusive this would be, so that's for later
> consideration. Some indirection can be removed for the .set_level
> callbacks as it does not necessarily need to be a function so I'm
> expecting that the code around that would be touched anyway.
The only user of type_level is btrfs_compress_pages(). I do make an
extra call to .set_level() there just to be safe, but that can be taken
out as it should be correctly set from when we mounted.
I envisioned .set_level() to be called when setting the compression
level of the mount. This can be used in the same place if we were to add
per-file compression levels too. I mention later, but an important part
of .set_level() is to repurpose the meaning of 0 from meaning use the
default to meaning use any workspace available.
Thanks,
Dennis