Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08212993 authored by Chandan Rajendra's avatar Chandan Rajendra Committed by Jaegeuk Kim
Browse files

f2fs: use IS_ENCRYPTED() to check encryption status



This commit removes the f2fs specific f2fs_encrypted_inode() and makes
use of the generic IS_ENCRYPTED() macro to check for the encryption
status of an inode.

Acked-by: default avatarChao Yu <yuchao0@huawei.com>
Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarChandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 72d457d3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1466,7 +1466,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
	}

	if (size) {
		if (f2fs_encrypted_inode(inode))
		if (IS_ENCRYPTED(inode))
			flags |= FIEMAP_EXTENT_DATA_ENCRYPTED;

		ret = fiemap_fill_next_extent(fieinfo, logical,
@@ -1736,7 +1736,7 @@ static inline bool check_inplace_update_policy(struct inode *inode,
	if (policy & (0x1 << F2FS_IPU_ASYNC) &&
			fio && fio->op == REQ_OP_WRITE &&
			!(fio->op_flags & REQ_SYNC) &&
			!f2fs_encrypted_inode(inode))
			!IS_ENCRYPTED(inode))
		return true;

	/* this is only set during fdatasync */
+5 −5
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir,
		if (err)
			goto put_error;

		if ((f2fs_encrypted_inode(dir) || dummy_encrypt) &&
		if ((IS_ENCRYPTED(dir) || dummy_encrypt) &&
					f2fs_may_encrypt(inode)) {
			err = fscrypt_inherit_context(dir, inode, page, false);
			if (err)
@@ -399,7 +399,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir,

	if (new_name) {
		init_dent_inode(new_name, page);
		if (f2fs_encrypted_inode(dir))
		if (IS_ENCRYPTED(dir))
			file_set_enc_name(inode);
	}

@@ -824,7 +824,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
			goto out;
		}

		if (f2fs_encrypted_inode(d->inode)) {
		if (IS_ENCRYPTED(d->inode)) {
			int save_len = fstr->len;

			err = fscrypt_fname_disk_to_usr(d->inode,
@@ -867,7 +867,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
	struct fscrypt_str fstr = FSTR_INIT(NULL, 0);
	int err = 0;

	if (f2fs_encrypted_inode(inode)) {
	if (IS_ENCRYPTED(inode)) {
		err = fscrypt_get_encryption_info(inode);
		if (err && err != -ENOKEY)
			goto out;
@@ -929,7 +929,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)

static int f2fs_dir_open(struct inode *inode, struct file *filp)
{
	if (f2fs_encrypted_inode(inode))
	if (IS_ENCRYPTED(inode))
		return fscrypt_get_encryption_info(inode) ? -EACCES : 0;
	return 0;
}
+1 −6
Original line number Diff line number Diff line
@@ -3492,14 +3492,9 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi);
/*
 * crypto support
 */
static inline bool f2fs_encrypted_inode(struct inode *inode)
{
	return file_is_encrypt(inode);
}

static inline bool f2fs_encrypted_file(struct inode *inode)
{
	return f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode);
	return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
}

static inline void f2fs_set_encrypted_inode(struct inode *inode)
+5 −5
Original line number Diff line number Diff line
@@ -582,7 +582,7 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
	zero_user(page, offset, PAGE_SIZE - offset);

	/* An encrypted inode should have a key and truncate the last page. */
	f2fs_bug_on(F2FS_I_SB(inode), cache_only && f2fs_encrypted_inode(inode));
	f2fs_bug_on(F2FS_I_SB(inode), cache_only && IS_ENCRYPTED(inode));
	if (!cache_only)
		set_page_dirty(page);
	f2fs_put_page(page, 1);
@@ -709,7 +709,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat,
		stat->attributes |= STATX_ATTR_APPEND;
	if (flags & F2FS_COMPR_FL)
		stat->attributes |= STATX_ATTR_COMPRESSED;
	if (f2fs_encrypted_inode(inode))
	if (IS_ENCRYPTED(inode))
		stat->attributes |= STATX_ATTR_ENCRYPTED;
	if (flags & F2FS_IMMUTABLE_FL)
		stat->attributes |= STATX_ATTR_IMMUTABLE;
@@ -1558,7 +1558,7 @@ static long f2fs_fallocate(struct file *file, int mode,
	if (!S_ISREG(inode->i_mode))
		return -EINVAL;

	if (f2fs_encrypted_inode(inode) &&
	if (IS_ENCRYPTED(inode) &&
		(mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
		return -EOPNOTSUPP;

@@ -1642,7 +1642,7 @@ static int f2fs_ioc_getflags(struct file *filp, unsigned long arg)
	struct f2fs_inode_info *fi = F2FS_I(inode);
	unsigned int flags = fi->i_flags;

	if (f2fs_encrypted_inode(inode))
	if (IS_ENCRYPTED(inode))
		flags |= F2FS_ENCRYPT_FL;
	if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode))
		flags |= F2FS_INLINE_DATA_FL;
@@ -2416,7 +2416,7 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
	if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode))
		return -EINVAL;

	if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst))
	if (IS_ENCRYPTED(src) || IS_ENCRYPTED(dst))
		return -EOPNOTSUPP;

	if (src == dst) {
+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ void f2fs_set_inode_flags(struct inode *inode)
		new_fl |= S_NOATIME;
	if (flags & F2FS_DIRSYNC_FL)
		new_fl |= S_DIRSYNC;
	if (f2fs_encrypted_inode(inode))
	if (file_is_encrypt(inode))
		new_fl |= S_ENCRYPTED;
	inode_set_flags(inode, new_fl,
			S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|
@@ -468,7 +468,7 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
		inode->i_mapping->a_ops = &f2fs_dblock_aops;
		inode_nohighmem(inode);
	} else if (S_ISLNK(inode->i_mode)) {
		if (f2fs_encrypted_inode(inode))
		if (file_is_encrypt(inode))
			inode->i_op = &f2fs_encrypted_symlink_inode_operations;
		else
			inode->i_op = &f2fs_symlink_inode_operations;
Loading