From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7002FC43460 for ; Thu, 15 Apr 2021 16:25:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E7C96113B for ; Thu, 15 Apr 2021 16:25:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E7C96113B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 00E876B0036; Thu, 15 Apr 2021 12:25:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F05D56B006C; Thu, 15 Apr 2021 12:25:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEE266B0070; Thu, 15 Apr 2021 12:25:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id C682D6B0036 for ; Thu, 15 Apr 2021 12:25:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7473A1803DCEA for ; Thu, 15 Apr 2021 16:25:12 +0000 (UTC) X-FDA: 78035126064.05.FEE739E Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [142.44.231.140]) by imf22.hostedemail.com (Postfix) with ESMTP id 6FA0AC0007C6 for ; Thu, 15 Apr 2021 16:25:07 +0000 (UTC) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lX4nh-005Xmq-I8; Thu, 15 Apr 2021 16:25:05 +0000 Date: Thu, 15 Apr 2021 16:25:05 +0000 From: Al Viro To: Gautham Ananthakrishna Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, matthew.wilcox@oracle.com, khlebnikov@yandex-team.ru Subject: Re: [PATCH RFC 1/6] dcache: sweep cached negative dentries to the end of list of siblings Message-ID: References: <1611235185-1685-1-git-send-email-gautham.ananthakrishna@oracle.com> <1611235185-1685-2-git-send-email-gautham.ananthakrishna@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6FA0AC0007C6 X-Stat-Signature: 6nu7paypwmzopg4co1ua97ycyotxer84 Received-SPF: none (ftp.linux.org.uk>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=zeniv-ca.linux.org.uk; client-ip=142.44.231.140 X-HE-DKIM-Result: none/none X-HE-Tag: 1618503907-634862 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000262, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 14, 2021 at 03:41:10AM +0000, Al Viro wrote: > > + if (!d_is_tail_negative(dentry)) { > > + parent = lock_parent(dentry); > > + if (!parent) > > + return; > > Wait a minute. It's not a good environment for calling lock_parent(). > Who said that dentry won't get freed right under it? [snip] FWIW, in that state (dentry->d_lock held) we have * stable ->d_flags * stable ->d_count * stable ->d_inode IOW, we can bloody well check ->d_count *before* bothering with lock_parent(). It does not get rid of the problems with lifetimes, though. We could do something along the lines of rcu_read_lock() if retain_dentry() parent = NULL if that dentry might need to be moved in list parent = lock_parent() // if reached __dentry_kill(), d_count() will be -128, // so the check below will exclude those if that dentry does need to be moved move it to the end of list unlock dentry and parent (if any) rcu_read_unlock() return here, but your other uses of lock_parent() also need attention. And recursive call of dput() in trim_negative() (#6/6) is really asking for trouble.