btrfs: add per-inode compression levels in xattrs
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest posting 4/46 patches 0 repliesNew
- v6 posting 3/46 patches 0 repliesSuperseded
- v6 posting 2/46 patches 0 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 posting 1/4 | 6 patches | 0 replies | Superseded | |
| v5 | 6 patches | 0 replies | Superseded | |
| v4 | 6 patches | 0 replies | Superseded | |
| v3 | 5 patches | 2 replies | Superseded | |
| v2 | 4 patches | 11 replies | Superseded | |
| v1 | 4 patches | 16 replies | Superseded |
Changes in v6 from the cover letter
* switch from kmemdup_nul() to a stack-based buffer to avoid a possible deadlock spotted by sashiko[4], and because it's cleaner, so also move the BTRFS_COMPRESS_PROP_MAX_LEN definition to patch 2/6 instead of later in the series
Patches in v6 posting 4/4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | btrfs: export btrfs_match_compress_type(), move it to compression.hfs/ fs/ fs/ | +18 | 0 replies | |
| 2/6 | btrfs: also validate compression levels in btrfs_compress_is_valid_type()fs/ fs/ fs/ | +33 | 0 replies | |
| 3/6 | btrfs: add per-inode compression levels in xattrsfs/ fs/ fs/ | +39 | 0 replies | |
| 4/6 | btrfs: support inheritance for per-inode compression levelsfs/ | +11 | 0 replies | |
| 5/6 | btrfs: add btrfs_compress_typelevel2str() helperfs/ fs/ fs/ | +25 | 0 replies | |
| 6/6 | btrfs: preserve btrfs.compression when setting inode flagsfs/ fs/ fs/ | +23 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.
Cover letter [PATCH v6 RESEND 0/6] btrfs: add per-inode compression levels in xattrs
Add per-inode compression levels using
btrfs property set /path/to/file compression "algo:level", using the same syntax as the compress mount option.
If set on folders, all new children will inherit the setting, while already existing children will be unaffected.
This patch series also fixes a small bug: before, when setting btrfs.compression, it would keep the mount option level, even if the algo was different (!!), so with e.g. compress=zstd:15 and btrfs.compression=zlib the data gets compressed at zlib:9 (because it would still get clamped at the right range).
After this patch series, if the user doesn't specify a level (e.g. "zstd") btrfs inherits the level from the mount option, while if instead the user specifies a level it will use that (e.g. "zstd:0" would use the default for the algorithm, and "zstd:10" would of course use level 10).
I also want to thank Zygo for helping me by explaining stuff and for noticing this bug.
Now, there is the question of having a fix for the bug as a separate patch to be backported or not, and there are 3 possibilities for that (original email listing them[1]):
- Option 1:
don't have a specific patch to be backported, keep the current behaviour on older kernels.
This is the option I personally prefer[2].
Pros:
* documentation[3] can be made clear about this behaviour, telling users that kernels < 7.X will "support" cross-algo level specification, while >= 7.X won't and will only inherit the level if the algorithm is the same
* won't break any existing use-case
Cons:
* new users on older kernels will encounter this bug
- Option 2:
have a specific patch to be backported that keeps the current behaviour, but only if the compress= algo is the same as the btrfs.compression one, if they aren't, use the default for the btrfs.compression algo (e.g. compress=zstd:15 and btrfs.compression=zlib would compress at zlib:3 instead of clamp(zlib, 15) = 9).
Pros:
* fixes the cross-algo bug without breaking setups that rely on level inheritance in a way that makes sense
Cons:
* documentation has to mention that the behaviour might be the bugged one or this one, depending on if the kernel has this bugfix patch
* may break some weird use-cases, but no one should really expect the level to be inherited if the algorithm is different
- Option 3:
have a specific patch to be backported that fixes the behaviour entirely, using the default level in all btrfs.compression cases, since levels wouldn't be supported.
Equivalent of setting algo:0 after this patch series gets applied.
Pros:
* very simple code fix, 2 lines of compress_level = 0, while option 2 would need an additional if to check the compress type against the fs_info one
Cons:
* documentation has to mention that the behaviour might be the bugged one or this one, depending on if the kernel has this bugfix patch
* breaks all use-cases relying on level inheritance from the mount option to the xattr
Changes in v4:
* remove the single patch for the bug, as per [2]
* reduce code duplication by putting the level parsing logic after the algorithm type logic, using a level_pos variable to indicate the position of the ':' instead of having the same exact code for each algo.
* add btrfs_compress_typelevel2str() helper
* fix btrfs.compression not being preserved when *any* chattr operation gets executed
Changes in v5:
* this is exactly the same patch series as v4, but with merge conflicts caused by Commit e8a0095c7df170 ("btrfs: preserve the compression property when other inode flags change") fixed
Changes in v6:
* switch from kmemdup_nul() to a stack-based buffer to avoid a possible deadlock spotted by sashiko[4], and because it's cleaner, so also move the BTRFS_COMPRESS_PROP_MAX_LEN definition to patch 2/6 instead of later in the series
[1]: https://lore.kernel.org/linux-btrfs/[email protected]
[2]: https://lore.kernel.org/linux-btrfs/[email protected]
[3]: https://github.com/kdave/btrfs-progs/pull/1152
[4]: https://sashiko.dev/#/patchset/20260907200518.428277-1-koray.fra%40gmail.com?part=3
koraynilay (6):
btrfs: export btrfs_match_compress_type(), move it to compression.h
btrfs: also validate compression levels in
btrfs_compress_is_valid_type()
btrfs: add per-inode compression levels in xattrs
btrfs: support inheritance for per-inode compression levels
btrfs: add btrfs_compress_typelevel2str() helper
btrfs: preserve btrfs.compression when setting inode flags
fs/btrfs/btrfs_inode.h | 1 + fs/btrfs/compression.c | 55 ++++++++++++++++++++++++++++++++++--- fs/btrfs/compression.h | 5 +++- fs/btrfs/inode.c | 10 +++++++ fs/btrfs/ioctl.c | 27 ++++++++++--------- fs/btrfs/props.c | 61 ++++++++++++++++++++++++++++++------------ fs/btrfs/props.h | 9 +++++++ fs/btrfs/super.c | 8 ------ 8 files changed, 134 insertions(+), 42 deletions(-)
base-commit: 6255426d70f2755968bb5436ae7b43dae742ac38
prerequisite-patch-id: dc4e24d82d513b8e80e171875a73d397d7ec0762
Signature · 1 line
2.56.0