From patchwork Thu Mar 16 18:14:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 70943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp633782wrt; Thu, 16 Mar 2023 11:24:45 -0700 (PDT) X-Google-Smtp-Source: AK7set9jZII4TG9YRroMvPU0uGEok6vR9ANLn5boIuUogzB1Ng9/Xp9Ag3A0xUBgrucA1xwjhyo+ X-Received: by 2002:a05:6a20:cd5d:b0:d5:1863:fe5f with SMTP id hn29-20020a056a20cd5d00b000d51863fe5fmr338141pzb.2.1678991085618; Thu, 16 Mar 2023 11:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678991085; cv=none; d=google.com; s=arc-20160816; b=oheoXg761t0s+yPnQQtFSXEbj+ak/bpH2W8fHTtG/D9slt1GIi4yIK4K1Gfd+CssDa 6rl/QC+vsAZKuwbqgZS8gD6b6cslt9ljBKfBddKQwSvFz1C9ysUxfwXOp9rUi7Hu4P5B xavlgqNBzl9YsOm+xvQ2/5ef70VM7e9Fj2ldpNGJIlmf9hS50HNTBFnA7Rz3wBWV1ucq 9KvtpsJpigzJhlBJLf+evf7X3yDnVlilfsPGWp3/Lz9COtDHKd/eM3bDEidek5CkJfDz d85c80+pUHjMElv6nrFs7wOMnSraKu9F7vCmp7AtQe5/zMKZLZuF1JQfZZRQBLgY+Fq9 g+Pw== 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:dkim-signature; bh=ou1/13qoxG1JQp/epUpYkQ70pH9c9U2ESCM5qF4Wi6k=; b=e+uwLL+TTKFw7alAejnrZC1VpdKQp7oryx8boXK1WzZzOO7GmawNlji5Ly+ZlgPg5H z42Sg7y0JUOx6ZX4MwGXsoyI2Op2r5v14qIvSknMv1OVCOg9/IXTv/BaJ1++Q+oCvqmf 2/QyoSP/By2EBAvpprDgUXwddGuUAkRSsonY/LDqhaTtyY4+F0loKJJGpXjMerZxsZN9 pQ5b+exZEurUstJVHpo3/7T8DHJhBJgixk4ENvxURoEFyCNYODoQObEs/qt1NS8cWW9M 0pHl1MqQESRrbm/E1AGSA2tKw/vI3t1GoYiCm3i8sAVKe/nj08vLwaLQv8PjrTl++OX5 Q7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=rLznZhUK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=v3EIYhd8; 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=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d26-20020aa797ba000000b005a8adc698casi45416pfq.189.2023.03.16.11.24.16; Thu, 16 Mar 2023 11:24:45 -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=@suse.de header.s=susede2_rsa header.b=rLznZhUK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=v3EIYhd8; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbjCPSOg (ORCPT + 99 others); Thu, 16 Mar 2023 14:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjCPSOX (ORCPT ); Thu, 16 Mar 2023 14:14:23 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31C4544AE; Thu, 16 Mar 2023 11:14:21 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3D7D121A3D; Thu, 16 Mar 2023 18:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678990460; h=from:from:reply-to: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=ou1/13qoxG1JQp/epUpYkQ70pH9c9U2ESCM5qF4Wi6k=; b=rLznZhUKOkzoRM0gzYCmtCU+4z2usvidg7hnOrhUmwqW59GUBqOL/ehFxjdH1RosPSowNG rXiqaF2co3vs72McrKJloUIWG7t6nNCnIu961cuLaT90QPCS5mT2ByJ+fQ6Gtk4n0SG3+/ LvfcRAAG3i/TqG+sAugYug4JsgREtVI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678990460; h=from:from:reply-to: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=ou1/13qoxG1JQp/epUpYkQ70pH9c9U2ESCM5qF4Wi6k=; b=v3EIYhd8A5KaeE6SeYgRGWnU2HNkBTL+CUbZM73+VGmH+qRIZKglisMhsXlc3OyLOZklaB nSPThNEbtXccWcAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8B683133E0; Thu, 16 Mar 2023 18:14:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gP+OHntcE2RtXAAAMHmgww (envelope-from ); Thu, 16 Mar 2023 18:14:19 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id 2900566f; Thu, 16 Mar 2023 18:14:14 +0000 (UTC) From: =?utf-8?q?Lu=C3=ADs_Henriques?= To: Eric Biggers , Xiubo Li , Jeff Layton Cc: "Theodore Y. Ts'o" , Jaegeuk Kim , Ilya Dryomov , linux-fscrypt@vger.kernel.org, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Lu?= =?utf-8?q?=C3=ADs_Henriques?= Subject: [PATCH v3 2/3] ceph: switch ceph_open() to use new fscrypt helper Date: Thu, 16 Mar 2023 18:14:12 +0000 Message-Id: <20230316181413.26916-3-lhenriques@suse.de> In-Reply-To: <20230316181413.26916-1-lhenriques@suse.de> References: <20230316181413.26916-1-lhenriques@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760549756548095903?= X-GMAIL-MSGID: =?utf-8?q?1760549756548095903?= Instead of setting the no-key dentry in ceph_lookup(), use the new fscrypt_prepare_lookup_partial() helper. We still need to mark the directory as incomplete if the directory was just unlocked. Signed-off-by: Luís Henriques --- fs/ceph/dir.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index d8cc6e9d5351..836bc695e2e0 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -784,14 +784,15 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, return ERR_PTR(-ENAMETOOLONG); if (IS_ENCRYPTED(dir)) { - err = ceph_fscrypt_prepare_readdir(dir); + bool had_key = fscrypt_has_encryption_key(dir); + + err = fscrypt_prepare_lookup_partial(dir, dentry); if (err < 0) return ERR_PTR(err); - if (!fscrypt_has_encryption_key(dir)) { - spin_lock(&dentry->d_lock); - dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); - } + + /* mark directory as incomplete if it has been unlocked */ + if (!had_key && fscrypt_has_encryption_key(dir)) + ceph_dir_clear_complete(dir); } /* can we conclude ENOENT locally? */