fscrypt: switch from ->is_encrypted() to IS_ENCRYPTED()
authorEric Biggers <ebiggers@google.com>
Mon, 9 Oct 2017 19:15:36 +0000 (12:15 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 5 Jan 2018 00:17:27 +0000 (16:17 -0800)
IS_ENCRYPTED() now gives the same information as
i_sb->s_cop->is_encrypted() but is more efficient, since IS_ENCRYPTED()
is just a simple flag check.  Prepare to remove ->is_encrypted() by
switching all callers to IS_ENCRYPTED().

Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/crypto/crypto.c
fs/crypto/fname.c
fs/crypto/keyinfo.c
fs/crypto/policy.c
include/linux/fscrypt_notsupp.h

index d262a93d9b31cb35a9055c443b67e681f0552bf6..4723267377177bc48b1f6c1fdb5ef8ad5440672d 100644 (file)
@@ -340,7 +340,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
                return -ECHILD;
 
        dir = dget_parent(dentry);
-       if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) {
+       if (!IS_ENCRYPTED(d_inode(dir))) {
                dput(dir);
                return 0;
        }
index 8606da1df0aa7e129810e3d73b86f50fa2216270..4da19a09111ebe5889df1ef220cbc003e730ae43 100644 (file)
@@ -383,8 +383,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
        memset(fname, 0, sizeof(struct fscrypt_name));
        fname->usr_fname = iname;
 
-       if (!dir->i_sb->s_cop->is_encrypted(dir) ||
-                               fscrypt_is_dot_dotdot(iname)) {
+       if (!IS_ENCRYPTED(dir) || fscrypt_is_dot_dotdot(iname)) {
                fname->disk_name.name = (unsigned char *)iname->name;
                fname->disk_name.len = iname->len;
                return 0;
index a38630214058214dec6c30eca64f74f3f7f693df..523c1b2112579278ab8b4227288b8c27afac7f06 100644 (file)
@@ -274,7 +274,7 @@ int fscrypt_get_encryption_info(struct inode *inode)
        res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
        if (res < 0) {
                if (!fscrypt_dummy_context_enabled(inode) ||
-                   inode->i_sb->s_cop->is_encrypted(inode))
+                   IS_ENCRYPTED(inode))
                        return res;
                /* Fake up a context for an unencrypted directory */
                memset(&ctx, 0, sizeof(ctx));
index a120649beeca4e5e9b0e54d6e7ed16de7fb47f17..c6d431a5cce932fd80385415fe598aca0f74ba05 100644 (file)
@@ -110,7 +110,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
        struct fscrypt_policy policy;
        int res;
 
-       if (!inode->i_sb->s_cop->is_encrypted(inode))
+       if (!IS_ENCRYPTED(inode))
                return -ENODATA;
 
        res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
@@ -167,11 +167,11 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
                return 1;
 
        /* No restrictions if the parent directory is unencrypted */
-       if (!cops->is_encrypted(parent))
+       if (!IS_ENCRYPTED(parent))
                return 1;
 
        /* Encrypted directories must not contain unencrypted files */
-       if (!cops->is_encrypted(child))
+       if (!IS_ENCRYPTED(child))
                return 0;
 
        /*
index 6865eb10b3248cdca1bf00ba69b97faedb534103..ca5bd51a376a18be75fc5eabef8aac18f0e75400 100644 (file)
@@ -101,7 +101,7 @@ static inline int fscrypt_setup_filename(struct inode *dir,
                                         const struct qstr *iname,
                                         int lookup, struct fscrypt_name *fname)
 {
-       if (dir->i_sb->s_cop->is_encrypted(dir))
+       if (IS_ENCRYPTED(dir))
                return -EOPNOTSUPP;
 
        memset(fname, 0, sizeof(struct fscrypt_name));