erofs: introduce physical cluster slab pools
[linux-2.6-microblaze.git] / fs / erofs / erofs_fs.h
index 9ad1615..7677767 100644 (file)
  * be incompatible with this kernel version.
  */
 #define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING    0x00000001
+#define EROFS_FEATURE_INCOMPAT_COMPR_CFGS      0x00000002
 #define EROFS_ALL_FEATURE_INCOMPAT             EROFS_FEATURE_INCOMPAT_LZ4_0PADDING
 
-/* 128-byte erofs on-disk super block */
+#define EROFS_SB_EXTSLOT_SIZE  16
+
+/* erofs on-disk super block (currently 128 bytes) */
 struct erofs_super_block {
        __le32 magic;           /* file system magic number */
        __le32 checksum;        /* crc32c(super_block) */
        __le32 feature_compat;
        __u8 blkszbits;         /* support block_size == PAGE_SIZE only */
-       __u8 reserved;
+       __u8 sb_extslots;       /* superblock size = 128 + sb_extslots * 16 */
 
        __le16 root_nid;        /* nid of root directory */
        __le64 inos;            /* total valid ino # (== f_files - f_favail) */
@@ -39,7 +42,13 @@ struct erofs_super_block {
        __u8 uuid[16];          /* 128-bit uuid for volume */
        __u8 volume_name[16];   /* volume name */
        __le32 feature_incompat;
-       __u8 reserved2[44];
+       union {
+               /* bitmap for available compression algorithms */
+               __le16 available_compr_algs;
+               /* customized sliding window size instead of 64k by default */
+               __le16 lz4_max_distance;
+       } __packed u1;
+       __u8 reserved2[42];
 };
 
 /*
@@ -75,6 +84,9 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
 #define EROFS_I_VERSION_BIT             0
 #define EROFS_I_DATALAYOUT_BIT          1
 
+#define EROFS_I_ALL    \
+       ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
+
 /* 32-byte reduced form of an ondisk inode */
 struct erofs_inode_compact {
        __le16 i_format;        /* inode format hints */
@@ -189,11 +201,21 @@ static inline unsigned int erofs_xattr_entry_size(struct erofs_xattr_entry *e)
                                 e->e_name_len + le16_to_cpu(e->e_value_size));
 }
 
+/* maximum supported size of a physical compression cluster */
+#define Z_EROFS_PCLUSTER_MAX_SIZE      (1024 * 1024)
+
 /* available compression algorithm types (for h_algorithmtype) */
 enum {
        Z_EROFS_COMPRESSION_LZ4 = 0,
        Z_EROFS_COMPRESSION_MAX
 };
+#define Z_EROFS_ALL_COMPR_ALGS         (1 << (Z_EROFS_COMPRESSION_MAX - 1))
+
+/* 14 bytes (+ length field = 16 bytes) */
+struct z_erofs_lz4_cfgs {
+       __le16 max_distance;
+       u8 reserved[12];
+} __packed;
 
 /*
  * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on)
@@ -214,9 +236,7 @@ struct z_erofs_map_header {
        __u8    h_algorithmtype;
        /*
         * bit 0-2 : logical cluster bits - 12, e.g. 0 for 4096;
-        * bit 3-4 : (physical - logical) cluster bits of head 1:
-        *       For example, if logical clustersize = 4096, 1 for 8192.
-        * bit 5-7 : (physical - logical) cluster bits of head 2.
+        * bit 3-7 : reserved.
         */
        __u8    h_clusterbits;
 };