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.
Unified · Split
| @@ -1465,7 +1465,7 @@ next: · 1464 unmodified lines | ||
| 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,7 +1736,7 @@ static inline bool check_inplace_update_policy(struct inode *inode, · 264 unmodified lines | ||
| 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 */ |
| @@ -385,7 +385,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, · 384 unmodified lines | ||
| 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,7 +399,7 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, · 7 unmodified lines | ||
| 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,7 +819,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, · 413 unmodified lines | ||
| 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,7 +862,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) · 36 unmodified lines | ||
| 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,7 +924,7 @@ out: · 55 unmodified lines | ||
| 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 | } |
| @@ -3463,14 +3463,9 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi); · 3462 unmodified lines | ||
| 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) |
| @@ -582,7 +582,7 @@ truncate_out: · 581 unmodified lines | ||
| 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,7 +711,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, · 122 unmodified lines | ||
| 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,7 +1563,7 @@ static long f2fs_fallocate(struct file *file, int mode, · 845 unmodified lines | ||
| 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,7 +1647,7 @@ static int f2fs_ioc_getflags(struct file *filp, unsigned long arg) · 77 unmodified lines | ||
| 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,7 +2414,7 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · 760 unmodified lines | ||
| 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) { |
| @@ -43,7 +43,7 @@ void f2fs_set_inode_flags(struct inode *inode) · 42 unmodified lines | ||
| 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,7 +453,7 @@ make_now: · 403 unmodified lines | ||
| 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; |
| @@ -75,7 +75,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) · 74 unmodified lines | ||
| 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,7 +476,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · 394 unmodified lines | ||
| 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,7 +803,7 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) · 320 unmodified lines | ||
| 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; |