From patchwork Mon Apr 17 03:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 674562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B7EAC77B70 for ; Mon, 17 Apr 2023 03:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbjDQDgk (ORCPT ); Sun, 16 Apr 2023 23:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbjDQDgR (ORCPT ); Sun, 16 Apr 2023 23:36:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AECE4C21 for ; Sun, 16 Apr 2023 20:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681702405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yu7gf8xWcAldAFS01M0YAQCprE2DqFfADWe3S2lo3P0=; b=ULxR+McPay5UuVIoXNkjJeq2qegwOA0Yz/87P31ZyksPvCMLPVwTiAQDfba84jiuLjtal+ m3VsPDHVAfW4HVtA+OHSR6IqBBl6mua/lSVfC6hRM4CGrqIfn8P/7TibpgyePqH0qLMp4b wlx2TZY+vZi6w6ALxJBAVeAIb0GxYfY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-5AOGCXkMPJKTiLMmbgT0tg-1; Sun, 16 Apr 2023 23:33:14 -0400 X-MC-Unique: 5AOGCXkMPJKTiLMmbgT0tg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6FE2857FB3; Mon, 17 Apr 2023 03:33:13 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (ovpn-12-181.pek2.redhat.com [10.72.12.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB3C8202717C; Mon, 17 Apr 2023 03:33:09 +0000 (UTC) From: xiubli@redhat.com To: idryomov@gmail.com, ceph-devel@vger.kernel.org Cc: jlayton@kernel.org, vshankar@redhat.com, lhenriques@suse.de, mchangir@redhat.com, Xiubo Li Subject: [PATCH v19 70/70] ceph: switch ceph_open_atomic() to use the new fscrypt helper Date: Mon, 17 Apr 2023 11:26:54 +0800 Message-Id: <20230417032654.32352-71-xiubli@redhat.com> In-Reply-To: <20230417032654.32352-1-xiubli@redhat.com> References: <20230417032654.32352-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Luís Henriques Switch ceph_atomic_open() to use new fscrypt helper function fscrypt_prepare_lookup_partial(). This fixes a bug in the atomic open operation where a dentry is incorrectly set with DCACHE_NOKEY_NAME when 'dir' has been evicted but the key is still available (for example, where there's a drop_caches). Tested-by: Luís Henriques Tested-by: Venky Shankar Signed-off-by: Luís Henriques Signed-off-by: Xiubo Li Reviewed-by: Milind Changire --- fs/ceph/file.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 317087ea017e..9e74ed673f93 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -791,11 +791,9 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, ihold(dir); if (IS_ENCRYPTED(dir)) { set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); - if (!fscrypt_has_encryption_key(dir)) { - spin_lock(&dentry->d_lock); - dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); - } + err = fscrypt_prepare_lookup_partial(dir, dentry); + if (err < 0) + goto out_req; } if (flags & O_CREAT) {