]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: ensure that we accept a new context from MDS for new inodes
authorJeff Layton <jlayton@kernel.org>
Wed, 30 Mar 2022 15:17:04 +0000 (11:17 -0400)
committerXiubo Li <xiubli@redhat.com>
Thu, 18 Aug 2022 02:59:49 +0000 (10:59 +0800)
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/inode.c

index 6310f7dc42aecc3df6ebbabb1e6787c75d6fd2bf..37f36b54c6b248b4cc827bbf147824f143a25f79 100644 (file)
@@ -944,6 +944,17 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
 
        __ceph_update_quota(ci, iinfo->max_bytes, iinfo->max_files);
 
+#ifdef CONFIG_FS_ENCRYPTION
+       if (iinfo->fscrypt_auth_len && (inode->i_state & I_NEW)) {
+               kfree(ci->fscrypt_auth);
+               ci->fscrypt_auth_len = iinfo->fscrypt_auth_len;
+               ci->fscrypt_auth = iinfo->fscrypt_auth;
+               iinfo->fscrypt_auth = NULL;
+               iinfo->fscrypt_auth_len = 0;
+               inode_set_flags(inode, S_ENCRYPTED, S_ENCRYPTED);
+       }
+#endif
+
        if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) &&
            (issued & CEPH_CAP_AUTH_EXCL) == 0) {
                inode->i_mode = mode;
@@ -1033,16 +1044,6 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
                xattr_blob = NULL;
        }
 
-#ifdef CONFIG_FS_ENCRYPTION
-       if (iinfo->fscrypt_auth_len && !ci->fscrypt_auth) {
-               ci->fscrypt_auth_len = iinfo->fscrypt_auth_len;
-               ci->fscrypt_auth = iinfo->fscrypt_auth;
-               iinfo->fscrypt_auth = NULL;
-               iinfo->fscrypt_auth_len = 0;
-               inode_set_flags(inode, S_ENCRYPTED, S_ENCRYPTED);
-       }
-#endif
-
        /* finally update i_version */
        if (le64_to_cpu(info->version) > ci->i_version)
                ci->i_version = le64_to_cpu(info->version);