]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
btrfs: export compression buffer limits in a header
authorDavid Sterba <dsterba@suse.com>
Tue, 14 Feb 2017 18:30:39 +0000 (19:30 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 13:26:35 +0000 (14:26 +0100)
Move the buffer limit definitions out of compress_file_range.

Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.h
fs/btrfs/inode.c

index cfcec709c61bffcf316005f5a3cfb44fa536d293..619e64c274449a2ce8fe402384fc3a0b600a9a25 100644 (file)
 #ifndef __BTRFS_COMPRESSION_
 #define __BTRFS_COMPRESSION_
 
+/*
+ * We want to make sure that amount of RAM required to uncompress an extent is
+ * reasonable, so we limit the total size in ram of a compressed extent to
+ * 128k.  This is a crucial number because it also controls how easily we can
+ * spread reads across cpus for decompression.
+ *
+ * We also want to make sure the amount of IO required to do a random read is
+ * reasonably small, so we limit the size of a compressed extent to 128k.
+ */
+
+/* Maximum length of compressed data stored on disk */
+#define BTRFS_MAX_COMPRESSED           (SZ_128K)
+/* Maximum size of data before compression */
+#define BTRFS_MAX_UNCOMPRESSED         (SZ_128K)
+
 void btrfs_init_compress(void);
 void btrfs_exit_compress(void);
 
index 83bbe1e31869d5db27b0f423a0b3ac3a9493def0..77fb24b94a9ebaf1ed75719ab9f15eebaee8134a 100644 (file)
@@ -471,16 +471,6 @@ again:
           (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
                goto cleanup_and_bail_uncompressed;
 
-       /* we want to make sure that amount of ram required to uncompress
-        * an extent is reasonable, so we limit the total size in ram
-        * of a compressed extent to 128k.  This is a crucial number
-        * because it also controls how easily we can spread reads across
-        * cpus for decompression.
-        *
-        * We also want to make sure the amount of IO required to do
-        * a random read is reasonably small, so we limit the size of
-        * a compressed extent to 128k.
-        */
        total_compressed = min(total_compressed, max_uncompressed);
        num_bytes = ALIGN(end - start + 1, blocksize);
        num_bytes = max(blocksize,  num_bytes);