From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:54304 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753017AbeE1Csb (ORCPT ); Sun, 27 May 2018 22:48:31 -0400 Date: Mon, 28 May 2018 03:48:29 +0100 From: Al Viro To: Andreas Dilger Cc: linux-fsdevel@vger.kernel.org, Linus Torvalds Subject: Re: [RFC][PATCH] rmdir(),rename(): do shrink_dcache_parent() only on success Message-ID: <20180528024829.GW30522@ZenIV.linux.org.uk> References: <20180527222029.GR30522@ZenIV.linux.org.uk> <64F20BDA-00AB-429E-959E-1463AE6DCC4F@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <64F20BDA-00AB-429E-959E-1463AE6DCC4F@dilger.ca> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, May 27, 2018 at 08:14:30PM -0600, Andreas Dilger wrote: > > if (!(flags & RENAME_EXCHANGE) && target) { > > - if (is_dir) > > + if (is_dir) { > > + shrink_dcache_parent(new_dentry); > > target->i_flags |= S_DEAD; > > Would it be better to set S_DEAD on the removed directory before > shrink_dcache_parent() is called (here and in vfs_rmdir()), or is > there no way for a new dentry to be added to the parent after the > shrink is done? It's locked (exclusive). Lookups (as well as readdir preseeding of dcache in case of filesystems that do it) are under the same lock held at least shared. The same goes for all IS_DEADDIR callers - exact same locking is used for S_DEAD handling as well. So the order really doesn't matter here.