aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/f2fs.h
diff options
context:
space:
mode:
authorGravatar Chao Yu <yuchao0@huawei.com> 2020-03-21 20:19:33 +0800
committerGravatar Jaegeuk Kim <jaegeuk@kernel.org> 2020-03-30 20:46:24 -0700
commit8c7d4b57607bbcd1d754be58de34138d9429f3e4 (patch)
treeb608a19ad40cf707027e579370d94eae9a47fec6 /fs/f2fs/f2fs.h
parentf2fs: fix to avoid potential deadlock (diff)
downloadlinux-8c7d4b57607bbcd1d754be58de34138d9429f3e4.tar.gz
linux-8c7d4b57607bbcd1d754be58de34138d9429f3e4.tar.bz2
linux-8c7d4b57607bbcd1d754be58de34138d9429f3e4.zip
f2fs: clean up f2fs_may_encrypt()
Merge below two conditions into f2fs_may_encrypt() for cleanup - IS_ENCRYPTED() - DUMMY_ENCRYPTION_ENABLED() Check IS_ENCRYPTED(inode) condition in f2fs_init_inode_metadata() is enough since we have already set encrypt flag in f2fs_new_inode(). Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r--fs/f2fs/f2fs.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e720054c9062..47c8c763a9b5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3935,15 +3935,20 @@ static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
}
-static inline bool f2fs_may_encrypt(struct inode *inode)
+static inline bool f2fs_may_encrypt(struct inode *dir, struct inode *inode)
{
#ifdef CONFIG_FS_ENCRYPTION
+ struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
umode_t mode = inode->i_mode;
- return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode));
-#else
- return false;
+ /*
+ * If the directory encrypted or dummy encryption enabled,
+ * then we should encrypt the inode.
+ */
+ if (IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi))
+ return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode));
#endif
+ return false;
}
static inline bool f2fs_may_compress(struct inode *inode)