Enable ext4 support for per-file/directory dax operations
[linux-block.git] / fs / ext4 / ext4.h
index 598e00a9453fc7d2b0d1a628cae820f3ec48b21a..5148cbb0b4b34f7c29139fafd9ac6d382098d8e9 100644 (file)
@@ -36,6 +36,7 @@
 #include <crypto/hash.h>
 #include <linux/falloc.h>
 #include <linux/percpu-rwsem.h>
+#include <linux/fiemap.h>
 #ifdef __KERNEL__
 #include <linux/compat.h>
 #endif
 #define ext4_debug(fmt, ...)   no_printk(fmt, ##__VA_ARGS__)
 #endif
 
+ /*
+  * Turn on EXT_DEBUG to enable ext4_ext_show_path/leaf/move in extents.c
+  */
+#define EXT_DEBUG__
+
 /*
- * Turn on EXT_DEBUG to get lots of info about extents operations.
+ * Dynamic printk for controlled extents debugging.
  */
-#define EXT_DEBUG__
-#ifdef EXT_DEBUG
-#define ext_debug(fmt, ...)    printk(fmt, ##__VA_ARGS__)
+#ifdef CONFIG_EXT4_DEBUG
+#define ext_debug(ino, fmt, ...)                                       \
+       pr_debug("[%s/%d] EXT4-fs (%s): ino %lu: (%s, %d): %s:" fmt,    \
+                current->comm, task_pid_nr(current),                   \
+                ino->i_sb->s_id, ino->i_ino, __FILE__, __LINE__,       \
+                __func__, ##__VA_ARGS__)
 #else
-#define ext_debug(fmt, ...)    no_printk(fmt, ##__VA_ARGS__)
+#define ext_debug(ino, fmt, ...)       no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 /* data type for block offset of block group */
@@ -142,6 +151,8 @@ enum SHIFT_DIRECTION {
 #define EXT4_MB_USE_ROOT_BLOCKS                0x1000
 /* Use blocks from reserved pool */
 #define EXT4_MB_USE_RESERVED           0x2000
+/* Do strict check for free blocks while retrying block allocation */
+#define EXT4_MB_STRICT_CHECK           0x4000
 
 struct ext4_allocation_request {
        /* target inode for block we're allocating */
@@ -171,10 +182,10 @@ struct ext4_allocation_request {
  * well as to store the information returned by ext4_map_blocks().  It
  * takes less room on the stack than a struct buffer_head.
  */
-#define EXT4_MAP_NEW           (1 << BH_New)
-#define EXT4_MAP_MAPPED                (1 << BH_Mapped)
-#define EXT4_MAP_UNWRITTEN     (1 << BH_Unwritten)
-#define EXT4_MAP_BOUNDARY      (1 << BH_Boundary)
+#define EXT4_MAP_NEW           BIT(BH_New)
+#define EXT4_MAP_MAPPED                BIT(BH_Mapped)
+#define EXT4_MAP_UNWRITTEN     BIT(BH_Unwritten)
+#define EXT4_MAP_BOUNDARY      BIT(BH_Boundary)
 #define EXT4_MAP_FLAGS         (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
                                 EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
 
@@ -420,7 +431,7 @@ struct flex_groups {
 
 #define EXT4_INLINE_DATA_FL            0x10000000 /* Inode has inline data. */
 #define EXT4_PROJINHERIT_FL            0x20000000 /* Create with parents projid */
-#define EXT4_CASEFOLD_FL               0x40000000 /* Casefolded file */
+#define EXT4_CASEFOLD_FL               0x40000000 /* Casefolded directory */
 #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
 
 #define EXT4_FL_USER_VISIBLE           0x725BDFFF /* User visible flags */
@@ -500,6 +511,7 @@ enum {
        EXT4_INODE_DAX          = 25,   /* Inode is DAX */
        EXT4_INODE_INLINE_DATA  = 28,   /* Data in inode. */
        EXT4_INODE_PROJINHERIT  = 29,   /* Create with parents projid */
+       EXT4_INODE_CASEFOLD     = 30,   /* Casefolded directory */
        EXT4_INODE_RESERVED     = 31,   /* reserved for ext4 lib */
 };
 
@@ -545,6 +557,7 @@ static inline void ext4_check_flag_values(void)
        CHECK_FLAG_VALUE(EA_INODE);
        CHECK_FLAG_VALUE(INLINE_DATA);
        CHECK_FLAG_VALUE(PROJINHERIT);
+       CHECK_FLAG_VALUE(CASEFOLD);
        CHECK_FLAG_VALUE(RESERVED);
 }
 
@@ -619,8 +632,6 @@ enum {
 #define EXT4_GET_BLOCKS_METADATA_NOFAIL                0x0020
        /* Don't normalize allocation size (used for fallocate) */
 #define EXT4_GET_BLOCKS_NO_NORMALIZE           0x0040
-       /* Request will not result in inode size update (user for fallocate) */
-#define EXT4_GET_BLOCKS_KEEP_SIZE              0x0080
        /* Convert written extents to unwritten */
 #define EXT4_GET_BLOCKS_CONVERT_UNWRITTEN      0x0100
        /* Write zeros to newly created written extents */
@@ -642,6 +653,7 @@ enum {
  */
 #define EXT4_EX_NOCACHE                                0x40000000
 #define EXT4_EX_FORCE_CACHE                    0x20000000
+#define EXT4_EX_NOFAIL                         0x10000000
 
 /*
  * Flags used by ext4_free_blocks
@@ -732,7 +744,7 @@ enum {
 #define EXT4_MAX_BLOCK_FILE_PHYS       0xFFFFFFFF
 
 /* Max logical block we can support */
-#define EXT4_MAX_LOGICAL_BLOCK         0xFFFFFFFF
+#define EXT4_MAX_LOGICAL_BLOCK         0xFFFFFFFE
 
 /*
  * Structure of an inode on the disk
@@ -2063,7 +2075,7 @@ struct ext4_dir_entry_2 {
        __le32  inode;                  /* Inode number */
        __le16  rec_len;                /* Directory entry length */
        __u8    name_len;               /* Name length */
-       __u8    file_type;
+       __u8    file_type;              /* See file type macros EXT4_FT_* below */
        char    name[EXT4_NAME_LEN];    /* File name */
 };
 
@@ -3367,7 +3379,7 @@ struct ext4_extent;
  */
 #define EXT_MAX_BLOCKS 0xffffffff
 
-extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
+extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode);
 extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
 extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
                               struct ext4_map_blocks *map, int flags);