mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
btrfs: props: change how empty value is interpreted
Based on user feedback and actual problems with compression property, there's no support to unset any compression options, or to force no compression flag. Note: This has changed recently in e2fsprogs 1.46.2, 'chattr +m' (setting NOCOMPRESS). In btrfs properties, the empty value should really mean reset to defaults, for all properties in general. Right now there's only the compression one, so this change should not cause too many problems. Old behaviour: $ lsattr file ---------------------- file # the NOCOMPRESS bit is set $ btrfs prop set file compression '' $ lsattr file ---------------------m file This is equivalent to 'btrfs prop set file compression no' in current btrfs-progs as the 'no' or 'none' values are translated to an empty string. This is where the new behaviour is different: empty string drops the compression flag (-c) and nocompress (-m): $ lsattr file ---------------------- file # No change $ btrfs prop set file compression '' $ lsattr file ---------------------- file $ btrfs prop set file compression lzo $ lsattr file --------c------------- file $ btrfs prop get file compression compression=lzo $ btrfs prop set file compression '' # Reset to the initial state $ lsattr file ---------------------- file # Set NOCOMPRESS bit $ btrfs prop set file compression no $ lsattr file ---------------------m file This obviously brings problems with backward compatibility, so this patch should not be backported without making sure the updated btrfs-progs are also used and that scripts have been updated to use the new semantics. Summary: - old kernel: no, none, "" - set NOCOMPRESS bit - new kernel: no, none - set NOCOMPRESS bit "" - drop all compression flags, ie. COMPRESS and NOCOMPRESS Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f216562731
commit
5548c8c6f5
@ -260,6 +260,10 @@ static int prop_compression_validate(const char *value, size_t len)
|
||||
if (btrfs_compress_is_valid_type(value, len))
|
||||
return 0;
|
||||
|
||||
if ((len == 2 && strncmp("no", value, 2) == 0) ||
|
||||
(len == 4 && strncmp("none", value, 4) == 0))
|
||||
return 0;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -269,7 +273,17 @@ static int prop_compression_apply(struct inode *inode, const char *value,
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||
int type;
|
||||
|
||||
/* Reset to defaults */
|
||||
if (len == 0) {
|
||||
BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
|
||||
BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
|
||||
BTRFS_I(inode)->prop_compress = BTRFS_COMPRESS_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set NOCOMPRESS flag */
|
||||
if ((len == 2 && strncmp("no", value, 2) == 0) ||
|
||||
(len == 4 && strncmp("none", value, 4) == 0)) {
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
|
||||
BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
|
||||
BTRFS_I(inode)->prop_compress = BTRFS_COMPRESS_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user