Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>

authored by

Chandan Rajendra and committed by
Theodore Ts'o
62230e0d 592ddec7

+18 -23
+2 -2
fs/f2fs/data.c
··· 1465 1465 } 1466 1466 1467 1467 if (size) { 1468 - if (f2fs_encrypted_inode(inode)) 1468 + if (IS_ENCRYPTED(inode)) 1469 1469 flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; 1470 1470 1471 1471 ret = fiemap_fill_next_extent(fieinfo, logical, ··· 1736 1736 if (policy & (0x1 << F2FS_IPU_ASYNC) && 1737 1737 fio && fio->op == REQ_OP_WRITE && 1738 1738 !(fio->op_flags & REQ_SYNC) && 1739 - !f2fs_encrypted_inode(inode)) 1739 + !IS_ENCRYPTED(inode)) 1740 1740 return true; 1741 1741 1742 1742 /* this is only set during fdatasync */
+5 -5
fs/f2fs/dir.c
··· 385 385 if (err) 386 386 goto put_error; 387 387 388 - if ((f2fs_encrypted_inode(dir) || dummy_encrypt) && 388 + if ((IS_ENCRYPTED(dir) || dummy_encrypt) && 389 389 f2fs_may_encrypt(inode)) { 390 390 err = fscrypt_inherit_context(dir, inode, page, false); 391 391 if (err) ··· 399 399 400 400 if (new_name) { 401 401 init_dent_inode(new_name, page); 402 - if (f2fs_encrypted_inode(dir)) 402 + if (IS_ENCRYPTED(dir)) 403 403 file_set_enc_name(inode); 404 404 } 405 405 ··· 819 819 goto out; 820 820 } 821 821 822 - if (f2fs_encrypted_inode(d->inode)) { 822 + if (IS_ENCRYPTED(d->inode)) { 823 823 int save_len = fstr->len; 824 824 825 825 err = fscrypt_fname_disk_to_usr(d->inode, ··· 862 862 struct fscrypt_str fstr = FSTR_INIT(NULL, 0); 863 863 int err = 0; 864 864 865 - if (f2fs_encrypted_inode(inode)) { 865 + if (IS_ENCRYPTED(inode)) { 866 866 err = fscrypt_get_encryption_info(inode); 867 867 if (err && err != -ENOKEY) 868 868 goto out; ··· 924 924 925 925 static int f2fs_dir_open(struct inode *inode, struct file *filp) 926 926 { 927 - if (f2fs_encrypted_inode(inode)) 927 + if (IS_ENCRYPTED(inode)) 928 928 return fscrypt_get_encryption_info(inode) ? -EACCES : 0; 929 929 return 0; 930 930 }
+1 -6
fs/f2fs/f2fs.h
··· 3463 3463 /* 3464 3464 * crypto support 3465 3465 */ 3466 - static inline bool f2fs_encrypted_inode(struct inode *inode) 3467 - { 3468 - return file_is_encrypt(inode); 3469 - } 3470 - 3471 3466 static inline bool f2fs_encrypted_file(struct inode *inode) 3472 3467 { 3473 - return f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode); 3468 + return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode); 3474 3469 } 3475 3470 3476 3471 static inline void f2fs_set_encrypted_inode(struct inode *inode)
+5 -5
fs/f2fs/file.c
··· 582 582 zero_user(page, offset, PAGE_SIZE - offset); 583 583 584 584 /* 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)); 586 586 if (!cache_only) 587 587 set_page_dirty(page); 588 588 f2fs_put_page(page, 1); ··· 711 711 stat->attributes |= STATX_ATTR_APPEND; 712 712 if (flags & F2FS_COMPR_FL) 713 713 stat->attributes |= STATX_ATTR_COMPRESSED; 714 - if (f2fs_encrypted_inode(inode)) 714 + if (IS_ENCRYPTED(inode)) 715 715 stat->attributes |= STATX_ATTR_ENCRYPTED; 716 716 if (flags & F2FS_IMMUTABLE_FL) 717 717 stat->attributes |= STATX_ATTR_IMMUTABLE; ··· 1563 1563 if (!S_ISREG(inode->i_mode)) 1564 1564 return -EINVAL; 1565 1565 1566 - if (f2fs_encrypted_inode(inode) && 1566 + if (IS_ENCRYPTED(inode) && 1567 1567 (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE))) 1568 1568 return -EOPNOTSUPP; 1569 1569 ··· 1647 1647 struct f2fs_inode_info *fi = F2FS_I(inode); 1648 1648 unsigned int flags = fi->i_flags; 1649 1649 1650 - if (f2fs_encrypted_inode(inode)) 1650 + if (IS_ENCRYPTED(inode)) 1651 1651 flags |= F2FS_ENCRYPT_FL; 1652 1652 if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode)) 1653 1653 flags |= F2FS_INLINE_DATA_FL; ··· 2414 2414 if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode)) 2415 2415 return -EINVAL; 2416 2416 2417 - if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) 2417 + if (IS_ENCRYPTED(src) || IS_ENCRYPTED(dst)) 2418 2418 return -EOPNOTSUPP; 2419 2419 2420 2420 if (src == dst) {
+2 -2
fs/f2fs/inode.c
··· 43 43 new_fl |= S_NOATIME; 44 44 if (flags & F2FS_DIRSYNC_FL) 45 45 new_fl |= S_DIRSYNC; 46 - if (f2fs_encrypted_inode(inode)) 46 + if (file_is_encrypt(inode)) 47 47 new_fl |= S_ENCRYPTED; 48 48 inode_set_flags(inode, new_fl, 49 49 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC| ··· 453 453 inode->i_mapping->a_ops = &f2fs_dblock_aops; 454 454 inode_nohighmem(inode); 455 455 } else if (S_ISLNK(inode->i_mode)) { 456 - if (f2fs_encrypted_inode(inode)) 456 + if (file_is_encrypt(inode)) 457 457 inode->i_op = &f2fs_encrypted_symlink_inode_operations; 458 458 else 459 459 inode->i_op = &f2fs_symlink_inode_operations;
+3 -3
fs/f2fs/namei.c
··· 75 75 set_inode_flag(inode, FI_NEW_INODE); 76 76 77 77 /* 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)) && 79 79 f2fs_may_encrypt(inode)) 80 80 f2fs_set_encrypted_inode(inode); 81 81 ··· 476 476 if (err) 477 477 goto out_iput; 478 478 } 479 - if (f2fs_encrypted_inode(dir) && 479 + if (IS_ENCRYPTED(dir) && 480 480 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && 481 481 !fscrypt_has_permitted_context(dir, inode)) { 482 482 f2fs_msg(inode->i_sb, KERN_WARNING, ··· 803 803 if (unlikely(f2fs_cp_error(sbi))) 804 804 return -EIO; 805 805 806 - if (f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) { 806 + if (IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) { 807 807 int err = fscrypt_get_encryption_info(dir); 808 808 if (err) 809 809 return err;