[PATCH 2/4] btrfs: introduce new compression property to disable compression at all

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Naohiro Aota <naota@xxxxxxxxx>

This new compression property, "off", to disable compression of
the file at all.

Signed-off-by: Naohiro Aota <naota@xxxxxxxxx>
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@xxxxxxxxxxxxxx>
---
 fs/btrfs/props.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index bf005f4..38efbe1 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -382,6 +382,8 @@ static int prop_compression_validate(const char *value, size_t len)
 		return 0;
 	else if (!strncmp("zlib", value, len))
 		return 0;
+	else if (!strncmp("off", value, len))
+		return 0;
 
 	return -EINVAL;
 }
@@ -400,6 +402,14 @@ static int prop_compression_apply(struct inode *inode,
 		return 0;
 	}
 
+	if (!strncmp("off", value, len)) {
+		BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
+		BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
+		BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_NONE;
+
+		return 0;
+	}
+
 	if (!strncmp("lzo", value, len))
 		type = BTRFS_COMPRESS_LZO;
 	else if (!strncmp("zlib", value, len))
@@ -423,5 +433,8 @@ static const char *prop_compression_extract(struct inode *inode)
 		return "lzo";
 	}
 
+	if (BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS)
+		return "off";
+
 	return NULL;
 }
-- 1.8.3.1 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux