Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3600920pxp; Wed, 23 Mar 2022 01:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzODp89Xic7werJPkaW35zd9TF4siuSl3woz5Fy78/mtC7hceztIlveoQ6yKlw4AhgzJ3QF X-Received: by 2002:a17:906:facf:b0:6cd:ed0e:ed7 with SMTP id lu15-20020a170906facf00b006cded0e0ed7mr29422461ejb.376.1648025573040; Wed, 23 Mar 2022 01:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648025573; cv=none; d=google.com; s=arc-20160816; b=c5xaSrNBvfPwCtWC+hQB/uq4CSFZivH/0At1n3dXzW4SnCnTmqm57sxiRy/EerWhaq dCSrVvwzpq9pZAe6kvSKZ5jlFcCB2ZWy6DH7qk7ZksiPmameWY2/q5/z9T8J37YHJ9VV +fYqaUbHCo5AU+77QL4Hen8faX19JjiqqBukGBwCqWKTAv4amqMB1KRoLRVDfdY+I/hX WAoK9AZkGlNPPBH/UXMfNj9cGYtvz0Ink0QirsPS6FTr0yt2iRu7G9BFjUyK2E1F/pbC NRg7gxFfmhhjvISfXUbrdTkET1mEJblMKJ/R7KhiZyjHdxZrk9jkG1pLQd1UkvXjW7xA d2zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tvfGn2XyNN2H8ULNDs0UMOmkBf7BAZ/39bQLfAuHGOc=; b=m5n7S6QjBkgA6itKaCYS9zVofoCdmJuNmh5CsEIxrU8D2VpbvjAdfj/s4HyjFbg3Cp ArJSSP2f2bI8SuVYXzdkBo6TfNg7P/wq5dG1ztQywFTrKc2ELWn8w0/cb1FZqbT+gEro ZyYB4sQk9VkbL3hL/qJuXJ2+L7ZsxcUivdIMQ7gBLoGeXFKkt1g+/0tE6f14qjTv7vrA tGuz6QlutkJihIKbIS2dINdk8ZIGivt+F9JeM9osV0xv107WsmeO9qcbamHAKJa7B5L4 7clcLvG7JokZgRczQ+FjcotWy4E/GvYs99dDp4NgQRp+Yg5i3n1WuQO30j6JL9fd0JFs fSKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t235VQFq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a170906208600b006df76385e30si13833922ejq.720.2022.03.23.01.52.27; Wed, 23 Mar 2022 01:52:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t235VQFq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237331AbiCVORr (ORCPT + 99 others); Tue, 22 Mar 2022 10:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236830AbiCVOP2 (ORCPT ); Tue, 22 Mar 2022 10:15:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746616C1D4; Tue, 22 Mar 2022 07:13:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E2DE2615C7; Tue, 22 Mar 2022 14:13:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3DA1C340F0; Tue, 22 Mar 2022 14:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647958431; bh=g+3TErgpBR+P4iTf0U+5WmixGEzQBkI4DHrS3H3uW10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t235VQFqIY+9hsTVQcnEz0YG3+5X4TZ4tNTxv3yXtE9yBDh1eG66wWHCfFGzyp+mN CZ9omUyTa/2F9AeNrZ3zT/ingpo/x3YK5g2mWPdnu1vxHPy2s2sGLESKZ4zarg8vv/ cZa5t42hMnl9B28UJDxxMFfQId55MthciD7dzABijvfIA2+5Ub9/tOkQAZCkJtABSl Ia0wNNOD/hI5QGDsGKjtBpX5IyzbHXKnF+FbU49a0J5EP4CT4BcnNrxL3YrkX3G1YG G3gIRSwtxp58e7DP4LXkEyQt3HHCDhubwJVN/CIKMhxpvDHjSzxVJ5BVme8mk4y7Ex coFbBrketKHcQ== From: Jeff Layton To: idryomov@gmail.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, lhenriques@suse.de Subject: [RFC PATCH v11 34/51] ceph: get file size from fscrypt_file when present in inode traces Date: Tue, 22 Mar 2022 10:12:59 -0400 Message-Id: <20220322141316.41325-35-jlayton@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322141316.41325-1-jlayton@kernel.org> References: <20220322141316.41325-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we get an inode trace from the MDS, grab the fscrypt_file field if the inode is encrypted, and use it to populate the i_size field instead of the regular inode size field. Signed-off-by: Jeff Layton --- fs/ceph/inode.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 599e27dae8c8..b905c49fc7a9 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -989,6 +989,16 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, from_kgid(&init_user_ns, inode->i_gid)); ceph_decode_timespec64(&ci->i_btime, &iinfo->btime); ceph_decode_timespec64(&ci->i_snap_btime, &iinfo->snap_btime); + +#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 } if ((new_version || (new_issued & CEPH_CAP_LINK_SHARED)) && @@ -1012,6 +1022,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, if (new_version || (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) { + u64 size = le64_to_cpu(info->size); s64 old_pool = ci->i_layout.pool_id; struct ceph_string *old_ns; @@ -1025,10 +1036,21 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, pool_ns = old_ns; + if (IS_ENCRYPTED(inode) && size && (iinfo->fscrypt_file_len == sizeof(__le64))) { + u64 fsize = __le64_to_cpu(*(__le64 *)iinfo->fscrypt_file); + + if (size == round_up(fsize, CEPH_FSCRYPT_BLOCK_SIZE)) { + size = fsize; + } else { + pr_warn("fscrypt size mismatch: size=%llu fscrypt_file=%llu, discarding fscrypt_file size.\n", + info->size, size); + } + } + queue_trunc = ceph_fill_file_size(inode, issued, - le32_to_cpu(info->truncate_seq), - le64_to_cpu(info->truncate_size), - le64_to_cpu(info->size)); + le32_to_cpu(info->truncate_seq), + le64_to_cpu(info->truncate_size), + size); /* only update max_size on auth cap */ if ((info->cap.flags & CEPH_CAP_FLAG_AUTH) && ci->i_max_size != le64_to_cpu(info->max_size)) { @@ -1068,16 +1090,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); -- 2.35.1