Print this page
Use the LZ4 algorithm to compress metadata when the corresponding feature is enabled

@@ -22,10 +22,11 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  */
 /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
 /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
+/* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */
 
 #include <sys/dmu.h>
 #include <sys/dmu_impl.h>
 #include <sys/dmu_tx.h>
 #include <sys/dbuf.h>

@@ -42,10 +43,11 @@
 #include <sys/zfs_ioctl.h>
 #include <sys/zap.h>
 #include <sys/zio_checksum.h>
 #include <sys/zio_compress.h>
 #include <sys/sa.h>
+#include <sys/zfeature.h>
 #ifdef _KERNEL
 #include <sys/vmsystm.h>
 #include <sys/zfs_znode.h>
 #endif
 

@@ -1588,13 +1590,21 @@
         if (ismd) {
                 /*
                  * XXX -- we should design a compression algorithm
                  * that specializes in arrays of bps.
                  */
-                compress = zfs_mdcomp_disable ? ZIO_COMPRESS_EMPTY :
-                    ZIO_COMPRESS_LZJB;
+                boolean_t lz4_ac = spa_feature_is_active(os->os_spa,
+                    SPA_FEATURE_LZ4_COMPRESS);
 
+                if (zfs_mdcomp_disable) {
+                        compress = ZIO_COMPRESS_EMPTY;
+                } else if (lz4_ac) {
+                        compress = ZIO_COMPRESS_LZ4;
+                } else {
+                        compress = ZIO_COMPRESS_LZJB;
+                }
+
                 /*
                  * Metadata always gets checksummed.  If the data
                  * checksum is multi-bit correctable, and it's not a
                  * ZBT-style checksum, then it's suitable for metadata
                  * as well.  Otherwise, the metadata checksum defaults