From patchwork Fri Nov 24 06:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13466990 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="bzl/4PNt" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03554D71; Thu, 23 Nov 2023 22:04:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=t2zwzPnF/uf/2oUVGi0n4GR0yi2cLzOWPO2ZTLid9cY=; b=bzl/4PNtx7A7UmHIJuWGbYesMX 3YBns84+Z3wUeS19etV4FUGGskdaoSPZZ35wqX46z7gSRPDYGO09ETLKALzHsMUpqgLREz9q0zQAe 08WzGcqFC7Bi49RK/90zKSBklXfKYhGySNc+hKFExGVBZsrUs7s7izI6Vx+kZsSWNygX4FXQjNjNV vZZRweGyBQIBWerpNK4ZPB/B9VGGWObgYRhBcuhAax6GJ0tWuYJl+0TEWJ6uCI6d8b4JKlHvG7Czz +oj0fsYCrvfQ/CbVELuI3K5rNQoGe8TU4fdy36JTMIo7YLRuP7p//WL91yRdqbr+nP0QBvbH5ClMg Au1GWXRw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PIc-002Ptf-25; Fri, 24 Nov 2023 06:04:22 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Christian Brauner , linux-kernel@vger.kernel.org Subject: [PATCH v3 02/21] coda_flag_children(): cope with dentries turning negative Date: Fri, 24 Nov 2023 06:04:03 +0000 Message-Id: <20231124060422.576198-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231124060422.576198-1-viro@zeniv.linux.org.uk> References: <20231124060200.GR38156@ZenIV> <20231124060422.576198-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro ->d_lock on parent does not stabilize ->d_inode of child. We don't do much with that inode in there, but we need at least to avoid struct inode getting freed under us... Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- fs/coda/cache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/coda/cache.c b/fs/coda/cache.c index 3b8c4513118f..bfbc03c6b632 100644 --- a/fs/coda/cache.c +++ b/fs/coda/cache.c @@ -92,13 +92,16 @@ static void coda_flag_children(struct dentry *parent, int flag) { struct dentry *de; + rcu_read_lock(); spin_lock(&parent->d_lock); list_for_each_entry(de, &parent->d_subdirs, d_child) { + struct inode *inode = d_inode_rcu(de); /* don't know what to do with negative dentries */ - if (d_inode(de) ) - coda_flag_inode(d_inode(de), flag); + if (inode) + coda_flag_inode(inode, flag); } spin_unlock(&parent->d_lock); + rcu_read_unlock(); return; }