From 37833daff8f290a95d2feb08bbc8225d7d3ba36b Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 17 Jul 2017 19:17:20 +0200 Subject: btrfs: rename variable holding per-inode compression type This is preparatory for separating inode compression requested by defrag and set via properties. This will fix a usability bug when defrag will reset compression type to NONE. If the file has compression set via property, it will not apply anymore (until next mount or reset through command line). We're going to fix that by adding another variable just for the defrag call and won't touch the property. The defrag will have higher priority when deciding whether to compress the data. Signed-off-by: David Sterba --- fs/btrfs/btrfs_inode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/btrfs/btrfs_inode.h') diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index b8622e4d1744..0c9ba8b96782 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -179,9 +179,9 @@ struct btrfs_inode { unsigned reserved_extents; /* - * always compress this one file + * Cached values if inode properties */ - unsigned force_compress; + unsigned prop_compress; /* per-file compression algorithm */ struct btrfs_delayed_node *delayed_node; -- cgit v1.2.3 From 9dc75da8c4a2cfc0cddec3c9ccf95f5d28a89084 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 17 Jul 2017 19:41:31 +0200 Subject: btrfs: separate defrag and property compression Add new value for compression to distinguish between defrag and property. Previously, a single variable was used and this caused clashes when the per-file 'compression' was set and a defrag -c was called. The property-compression is loaded when the file is open, defrag will overwrite the same variable and reset to 0 (ie. NONE) at when the file defragmentaion is finished. That's considered a usability bug. Now we won't touch the property value, use the defrag-compression. The precedence of defrag is higher than for property (and whole-filesystem). Signed-off-by: David Sterba --- fs/btrfs/btrfs_inode.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fs/btrfs/btrfs_inode.h') diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 0c9ba8b96782..d71ad059ca7c 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -182,6 +182,11 @@ struct btrfs_inode { * Cached values if inode properties */ unsigned prop_compress; /* per-file compression algorithm */ + /* + * Force compression on the file using the defrag ioctl, could be + * different from prop_compress and takes precedence if set + */ + unsigned defrag_compress; struct btrfs_delayed_node *delayed_node; -- cgit v1.2.3