History

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.

Chandan Rajendra committed 7 years ago

Commit 62230e01 parent 592ddec6 files · +18 −23Browse files

Unified · Split

6 files
  1. fs/f2fs/data.c +2 −2
  2. fs/f2fs/dir.c +5 −5
  3. fs/f2fs/f2fs.h +1 −6
  4. fs/f2fs/file.c +5 −5
  5. fs/f2fs/inode.c +2 −2
  6. fs/f2fs/namei.c +3 −3
fs/f2fs/data.c+2−2
@@ -1465,7 +1465,7 @@ next: · 1464 unmodified lines
14651465 }
14661466
14671467 if (size) {
1468− if (f2fs_encrypted_inode(inode))
1468+ if (IS_ENCRYPTED(inode))
14691469 flags |= FIEMAP_EXTENT_DATA_ENCRYPTED;
14701470
14711471 ret = fiemap_fill_next_extent(fieinfo, logical,
@@ -1736,7 +1736,7 @@ static inline bool check_inplace_update_policy(struct inode *inode, · 264 unmodified lines
17361736 if (policy & (0x1 << F2FS_IPU_ASYNC) &&
17371737 fio && fio->op == REQ_OP_WRITE &&
17381738 !(fio->op_flags & REQ_SYNC) &&
1739− !f2fs_encrypted_inode(inode))
1739+ !IS_ENCRYPTED(inode))
17401740 return true;
17411741
17421742 /* this is only set during fdatasync */
fs/f2fs/dir.c+5−5
@@ -385,7 +385,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, · 384 unmodified lines
385385 if (err)
386386 goto put_error;
387387
388− if ((f2fs_encrypted_inode(dir) || dummy_encrypt) &&
388+ if ((IS_ENCRYPTED(dir) || dummy_encrypt) &&
389389 f2fs_may_encrypt(inode)) {
390390 err = fscrypt_inherit_context(dir, inode, page, false);
391391 if (err)
@@ -399,7 +399,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, · 7 unmodified lines
399399
400400 if (new_name) {
401401 init_dent_inode(new_name, page);
402− if (f2fs_encrypted_inode(dir))
402+ if (IS_ENCRYPTED(dir))
403403 file_set_enc_name(inode);
404404 }
405405
@@ -819,7 +819,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, · 413 unmodified lines
819819 goto out;
820820 }
821821
822− if (f2fs_encrypted_inode(d->inode)) {
822+ if (IS_ENCRYPTED(d->inode)) {
823823 int save_len = fstr->len;
824824
825825 err = fscrypt_fname_disk_to_usr(d->inode,
@@ -862,7 +862,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) · 36 unmodified lines
862862 struct fscrypt_str fstr = FSTR_INIT(NULL, 0);
863863 int err = 0;
864864
865− if (f2fs_encrypted_inode(inode)) {
865+ if (IS_ENCRYPTED(inode)) {
866866 err = fscrypt_get_encryption_info(inode);
867867 if (err && err != -ENOKEY)
868868 goto out;
@@ -924,7 +924,7 @@ out: · 55 unmodified lines
924924
925925 static int f2fs_dir_open(struct inode *inode, struct file *filp)
926926 {
927− if (f2fs_encrypted_inode(inode))
927+ if (IS_ENCRYPTED(inode))
928928 return fscrypt_get_encryption_info(inode) ? -EACCES : 0;
929929 return 0;
930930 }
fs/f2fs/f2fs.h+1−6
@@ -3463,14 +3463,9 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi); · 3462 unmodified lines
34633463 /*
34643464 * crypto support
34653465 */
3466−static inline bool f2fs_encrypted_inode(struct inode *inode)
3467−{
3468− return file_is_encrypt(inode);
3469−}
3470−
34713466 static inline bool f2fs_encrypted_file(struct inode *inode)
34723467 {
3473− return f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode);
3468+ return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
34743469 }
34753470
34763471 static inline void f2fs_set_encrypted_inode(struct inode *inode)
fs/f2fs/file.c+5−5
@@ -582,7 +582,7 @@ truncate_out: · 581 unmodified lines
582582 zero_user(page, offset, PAGE_SIZE - offset);
583583
584584 /* An encrypted inode should have a key and truncate the last page. */
585− f2fs_bug_on(F2FS_I_SB(inode), cache_only && f2fs_encrypted_inode(inode));
585+ f2fs_bug_on(F2FS_I_SB(inode), cache_only && IS_ENCRYPTED(inode));
586586 if (!cache_only)
587587 set_page_dirty(page);
588588 f2fs_put_page(page, 1);
@@ -711,7 +711,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, · 122 unmodified lines
711711 stat->attributes |= STATX_ATTR_APPEND;
712712 if (flags & F2FS_COMPR_FL)
713713 stat->attributes |= STATX_ATTR_COMPRESSED;
714− if (f2fs_encrypted_inode(inode))
714+ if (IS_ENCRYPTED(inode))
715715 stat->attributes |= STATX_ATTR_ENCRYPTED;
716716 if (flags & F2FS_IMMUTABLE_FL)
717717 stat->attributes |= STATX_ATTR_IMMUTABLE;
@@ -1563,7 +1563,7 @@ static long f2fs_fallocate(struct file *file, int mode, · 845 unmodified lines
15631563 if (!S_ISREG(inode->i_mode))
15641564 return -EINVAL;
15651565
1566− if (f2fs_encrypted_inode(inode) &&
1566+ if (IS_ENCRYPTED(inode) &&
15671567 (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
15681568 return -EOPNOTSUPP;
15691569
@@ -1647,7 +1647,7 @@ static int f2fs_ioc_getflags(struct file *filp, unsigned long arg) · 77 unmodified lines
16471647 struct f2fs_inode_info *fi = F2FS_I(inode);
16481648 unsigned int flags = fi->i_flags;
16491649
1650− if (f2fs_encrypted_inode(inode))
1650+ if (IS_ENCRYPTED(inode))
16511651 flags |= F2FS_ENCRYPT_FL;
16521652 if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode))
16531653 flags |= F2FS_INLINE_DATA_FL;
@@ -2414,7 +2414,7 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · 760 unmodified lines
24142414 if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode))
24152415 return -EINVAL;
24162416
2417− if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst))
2417+ if (IS_ENCRYPTED(src) || IS_ENCRYPTED(dst))
24182418 return -EOPNOTSUPP;
24192419
24202420 if (src == dst) {
fs/f2fs/inode.c+2−2
@@ -43,7 +43,7 @@ void f2fs_set_inode_flags(struct inode *inode) · 42 unmodified lines
4343 new_fl |= S_NOATIME;
4444 if (flags & F2FS_DIRSYNC_FL)
4545 new_fl |= S_DIRSYNC;
46− if (f2fs_encrypted_inode(inode))
46+ if (file_is_encrypt(inode))
4747 new_fl |= S_ENCRYPTED;
4848 inode_set_flags(inode, new_fl,
4949 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|
@@ -453,7 +453,7 @@ make_now: · 403 unmodified lines
453453 inode->i_mapping->a_ops = &f2fs_dblock_aops;
454454 inode_nohighmem(inode);
455455 } else if (S_ISLNK(inode->i_mode)) {
456− if (f2fs_encrypted_inode(inode))
456+ if (file_is_encrypt(inode))
457457 inode->i_op = &f2fs_encrypted_symlink_inode_operations;
458458 else
459459 inode->i_op = &f2fs_symlink_inode_operations;
fs/f2fs/namei.c+3−3
@@ -75,7 +75,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) · 74 unmodified lines
7575 set_inode_flag(inode, FI_NEW_INODE);
7676
7777 /* If the directory encrypted, then we should encrypt the inode. */
78− if ((f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) &&
78+ if ((IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) &&
7979 f2fs_may_encrypt(inode))
8080 f2fs_set_encrypted_inode(inode);
8181
@@ -476,7 +476,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · 394 unmodified lines
476476 if (err)
477477 goto out_iput;
478478 }
479− if (f2fs_encrypted_inode(dir) &&
479+ if (IS_ENCRYPTED(dir) &&
480480 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
481481 !fscrypt_has_permitted_context(dir, inode)) {
482482 f2fs_msg(inode->i_sb, KERN_WARNING,
@@ -803,7 +803,7 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) · 320 unmodified lines
803803 if (unlikely(f2fs_cp_error(sbi)))
804804 return -EIO;
805805
806− if (f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) {
806+ if (IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) {
807807 int err = fscrypt_get_encryption_info(dir);
808808 if (err)
809809 return err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t