Merge tag 'f2fs-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[linux-2.6-block.git] / fs / f2fs / f2fs.h
index 7c5f121edac531428c16b5a31afda9c9ded89eba..4024790028aab1ecdc1d984b9bb724da31de7125 100644 (file)
@@ -154,6 +154,7 @@ struct f2fs_mount_info {
 #define F2FS_FEATURE_LOST_FOUND                0x0200
 #define F2FS_FEATURE_VERITY            0x0400
 #define F2FS_FEATURE_SB_CHKSUM         0x0800
+#define F2FS_FEATURE_CASEFOLD          0x1000
 
 #define __F2FS_HAS_FEATURE(raw_super, mask)                            \
        ((raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -418,6 +419,9 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
 #define F2FS_IOC_PRECACHE_EXTENTS      _IO(F2FS_IOCTL_MAGIC, 15)
 #define F2FS_IOC_RESIZE_FS             _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
 
+#define F2FS_IOC_GET_VOLUME_NAME       FS_IOC_GETFSLABEL
+#define F2FS_IOC_SET_VOLUME_NAME       FS_IOC_SETFSLABEL
+
 #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
 #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
 #define F2FS_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT
@@ -1172,6 +1176,10 @@ struct f2fs_sb_info {
        int valid_super_block;                  /* valid super block no */
        unsigned long s_flag;                           /* flags for sbi */
        struct mutex writepages;                /* mutex for writepages() */
+#ifdef CONFIG_UNICODE
+       struct unicode_map *s_encoding;
+       __u16 s_encoding_flags;
+#endif
 
 #ifdef CONFIG_BLK_DEV_ZONED
        unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
@@ -1643,6 +1651,7 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f)
 static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock)
 {
        unsigned long flags;
+       unsigned char *nat_bits;
 
        /*
         * In order to re-enable nat_bits we need to call fsck.f2fs by
@@ -1653,10 +1662,12 @@ static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock)
        if (lock)
                spin_lock_irqsave(&sbi->cp_lock, flags);
        __clear_ckpt_flags(F2FS_CKPT(sbi), CP_NAT_BITS_FLAG);
-       kvfree(NM_I(sbi)->nat_bits);
+       nat_bits = NM_I(sbi)->nat_bits;
        NM_I(sbi)->nat_bits = NULL;
        if (lock)
                spin_unlock_irqrestore(&sbi->cp_lock, flags);
+
+       kvfree(nat_bits);
 }
 
 static inline bool enabled_nat_bits(struct f2fs_sb_info *sbi,
@@ -1763,7 +1774,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
        if (time_to_inject(sbi, FAULT_BLOCK)) {
                f2fs_show_injection_info(FAULT_BLOCK);
                release = *count;
-               goto enospc;
+               goto release_quota;
        }
 
        /*
@@ -1808,6 +1819,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
 
 enospc:
        percpu_counter_sub(&sbi->alloc_valid_block_count, release);
+release_quota:
        dquot_release_reservation_block(inode, release);
        return -ENOSPC;
 }
@@ -2362,13 +2374,16 @@ static inline void f2fs_change_bit(unsigned int nr, char *addr)
 #define F2FS_INDEX_FL                  0x00001000 /* hash-indexed directory */
 #define F2FS_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
 #define F2FS_PROJINHERIT_FL            0x20000000 /* Create with parents projid */
+#define F2FS_CASEFOLD_FL               0x40000000 /* Casefolded file */
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define F2FS_FL_INHERITED (F2FS_SYNC_FL | F2FS_NODUMP_FL | F2FS_NOATIME_FL | \
-                          F2FS_DIRSYNC_FL | F2FS_PROJINHERIT_FL)
+                          F2FS_DIRSYNC_FL | F2FS_PROJINHERIT_FL | \
+                          F2FS_CASEFOLD_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
-#define F2FS_REG_FLMASK                (~(F2FS_DIRSYNC_FL | F2FS_PROJINHERIT_FL))
+#define F2FS_REG_FLMASK                (~(F2FS_DIRSYNC_FL | F2FS_PROJINHERIT_FL | \
+                               F2FS_CASEFOLD_FL))
 
 /* Flags that are appropriate for non-directories/regular files. */
 #define F2FS_OTHER_FLMASK      (F2FS_NODUMP_FL | F2FS_NOATIME_FL)
@@ -2935,6 +2950,11 @@ int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
                                                        bool hot, bool set);
 struct dentry *f2fs_get_parent(struct dentry *child);
 
+extern int f2fs_ci_compare(const struct inode *parent,
+                          const struct qstr *name,
+                          const struct qstr *entry,
+                          bool quick);
+
 /*
  * dir.c
  */
@@ -2998,8 +3018,8 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi);
 /*
  * hash.c
  */
-f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info,
-                               struct fscrypt_name *fname);
+f2fs_hash_t f2fs_dentry_hash(const struct inode *dir,
+               const struct qstr *name_info, struct fscrypt_name *fname);
 
 /*
  * node.c
@@ -3442,6 +3462,9 @@ static inline void f2fs_destroy_root_stats(void) { }
 #endif
 
 extern const struct file_operations f2fs_dir_operations;
+#ifdef CONFIG_UNICODE
+extern const struct dentry_operations f2fs_dentry_ops;
+#endif
 extern const struct file_operations f2fs_file_operations;
 extern const struct inode_operations f2fs_file_inode_operations;
 extern const struct address_space_operations f2fs_dblock_aops;
@@ -3576,6 +3599,7 @@ F2FS_FEATURE_FUNCS(inode_crtime, INODE_CRTIME);
 F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
 F2FS_FEATURE_FUNCS(verity, VERITY);
 F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
+F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
 
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
@@ -3694,11 +3718,14 @@ static inline bool f2fs_force_buffered_io(struct inode *inode,
         */
        if (f2fs_sb_has_blkzoned(sbi))
                return true;
-       if (test_opt(sbi, LFS) && (rw == WRITE) &&
-                               block_unaligned_IO(inode, iocb, iter))
-               return true;
+       if (test_opt(sbi, LFS) && (rw == WRITE)) {
+               if (block_unaligned_IO(inode, iocb, iter))
+                       return true;
+               if (F2FS_IO_ALIGNED(sbi))
+                       return true;
+       }
        if (is_sbi_flag_set(F2FS_I_SB(inode), SBI_CP_DISABLED) &&
-                                       !(inode->i_flags & S_SWAPFILE))
+                                       !IS_SWAPFILE(inode))
                return true;
 
        return false;