fscrypto/f2fs: allow fs-specific key prefix for fs encryption
[cascardo/linux.git] / fs / f2fs / f2fs.h
index d550a95..dbd277e 100644 (file)
 enum {
        FAULT_KMALLOC,
        FAULT_PAGE_ALLOC,
+       FAULT_ALLOC_NID,
+       FAULT_ORPHAN,
+       FAULT_BLOCK,
+       FAULT_DIR_DEPTH,
        FAULT_MAX,
 };
 
@@ -424,11 +428,11 @@ struct f2fs_inode_info {
 };
 
 static inline void get_extent_info(struct extent_info *ext,
-                                       struct f2fs_extent i_ext)
+                                       struct f2fs_extent *i_ext)
 {
-       ext->fofs = le32_to_cpu(i_ext.fofs);
-       ext->blk = le32_to_cpu(i_ext.blk);
-       ext->len = le32_to_cpu(i_ext.len);
+       ext->fofs = le32_to_cpu(i_ext->fofs);
+       ext->blk = le32_to_cpu(i_ext->blk);
+       ext->len = le32_to_cpu(i_ext->len);
 }
 
 static inline void set_raw_extent(struct extent_info *ext,
@@ -707,6 +711,10 @@ enum {
        MAX_TIME,
 };
 
+#ifdef CONFIG_F2FS_FS_ENCRYPTION
+#define F2FS_KEY_DESC_PREFIX "f2fs:"
+#define F2FS_KEY_DESC_PREFIX_SIZE 5
+#endif
 struct f2fs_sb_info {
        struct super_block *sb;                 /* pointer to VFS super block */
        struct proc_dir_entry *s_proc;          /* proc entry */
@@ -714,6 +722,10 @@ struct f2fs_sb_info {
        int valid_super_block;                  /* valid super block no */
        int s_flag;                             /* flags for sbi */
 
+#ifdef CONFIG_F2FS_FS_ENCRYPTION
+       u8 key_prefix[F2FS_KEY_DESC_PREFIX_SIZE];
+       u8 key_prefix_size;
+#endif
        /* for node-related operations */
        struct f2fs_nm_info *nm_info;           /* node manager */
        struct inode *node_inode;               /* cache node blocks */
@@ -1087,6 +1099,12 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
        block_t valid_block_count;
 
        spin_lock(&sbi->stat_lock);
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_BLOCK)) {
+               spin_unlock(&sbi->stat_lock);
+               return false;
+       }
+#endif
        valid_block_count =
                sbi->total_valid_block_count + (block_t)count;
        if (unlikely(valid_block_count > sbi->user_block_count)) {
@@ -1901,7 +1919,7 @@ void ra_meta_pages_cond(struct f2fs_sb_info *, pgoff_t);
 long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
 void add_ino_entry(struct f2fs_sb_info *, nid_t, int type);
 void remove_ino_entry(struct f2fs_sb_info *, nid_t, int type);
-void release_ino_entry(struct f2fs_sb_info *);
+void release_ino_entry(struct f2fs_sb_info *, bool);
 bool exist_written_data(struct f2fs_sb_info *, nid_t, int);
 int acquire_orphan_inode(struct f2fs_sb_info *);
 void release_orphan_inode(struct f2fs_sb_info *);