Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp10561ybj; Fri, 8 May 2020 05:25:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLT3XL4XrvAlQd5kXnyJ98i1X7s9zoz+kW8Jaeyu+9o7t6pGWaLaO1Ey6EQuh7HhQhkyGGD X-Received: by 2002:a05:6402:2293:: with SMTP id cw19mr1881855edb.351.1588940758016; Fri, 08 May 2020 05:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588940758; cv=none; d=google.com; s=arc-20160816; b=Pg11YnEw1z2JHVWJGeCrI3rYQxUoP3Ugnd++tofz37Rf2lPGG1wafIJmU90vZ4CaId +Gu+Bg6GovMUqMHVFFITKKa8ZGhI6yT3O8NkzL7F/JU48uEEKkUlj5Yo0PqYvtuW0SSr CoZkWRh44n5e9WS5BTELPzcQNYU8esRoigsUItlE7AtLvfRYj2CbXKE8hVwJZ7RiJV8l jGuFmFolD2+yjO3d/GYiVR/AJxh2nJEfnxTKk0R21uQ0J6s6YoNxLlBg4LqazQ203psz VrU8yV3fhqMfWpi5cx9L5HEZBYto9hA3xJmS2UIE0lFVSN6Ku+NL+6sCsgdfqJW0mtpH CoAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=JCfV9a+6LV7lO3l6vs+TYqJodxqNVXpsp3UM6EFrsaU=; b=DALNyPdxyE7AxJI3CEnhreTWRussXMBQKqELAegSlavJm0cgl/Jj9m6kPd+ffMhxp5 p2tLFXswFs6jLOD25WblaWDaAW4QIbJ9L/Bg0K3UZL9qXrKN0PGZXNDEVKm/apiaccuB fXcXgvQpS9vGcEa4iAjJpnRGhsc1jm9bPObxfZG0TPVMHrTZ7JyYf0ZLzyKB3T3nj/rE bJ+0g/6DV2cRcyRqbtk0vVZI4vL+BDH9TJOSRklthNmf5KK6CWDIEWoraoNUvZ9htY30 k6vnPN4EjUKT7Q3RdPwgxD+0ADO20hgmf1tsT962DrCAc4n989ORGUvn9D1UKekRiHHa iluA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=GB1sHnQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si915473edx.314.2020.05.08.05.25.35; Fri, 08 May 2020 05:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=GB1sHnQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbgEHMXl (ORCPT + 99 others); Fri, 8 May 2020 08:23:41 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:57310 "EHLO forwardcorp1o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727774AbgEHMXe (ORCPT ); Fri, 8 May 2020 08:23:34 -0400 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 20EE72E1612; Fri, 8 May 2020 15:23:32 +0300 (MSK) Received: from myt5-70c90f7d6d7d.qloud-c.yandex.net (myt5-70c90f7d6d7d.qloud-c.yandex.net [2a02:6b8:c12:3e2c:0:640:70c9:f7d]) by mxbackcorp1o.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id ca7YkIQC43-NVbiCTJc; Fri, 08 May 2020 15:23:32 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1588940612; bh=JCfV9a+6LV7lO3l6vs+TYqJodxqNVXpsp3UM6EFrsaU=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=GB1sHnQLxmHeY5kYs6x5t0JS4qxbIgMT4npqmTRhL4nq211peBqHxULbblvWc6RNI NdcAdlZYpnAl6sRV19ayiqoCglrGK2rryvjg4ifVoJ3sWLaN1CX9jDEqejWApa7iuQ CNvETOlNi/7mABcXwm9qNZIZ8bTp4XnhRf4kk8MQ= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-vpn.dhcp.yndx.net (dynamic-vpn.dhcp.yndx.net [2a02:6b8:b080:7008::1:4]) by myt5-70c90f7d6d7d.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 74uZNHjqL4-NVWKuJN9; Fri, 08 May 2020 15:23:31 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Subject: [PATCH RFC 7/8] dcache: push releasing dentry lock into sweep_negative From: Konstantin Khlebnikov To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro Cc: Waiman Long Date: Fri, 08 May 2020 15:23:30 +0300 Message-ID: <158894061026.200862.15846101347037556126.stgit@buzz> In-Reply-To: <158893941613.200862.4094521350329937435.stgit@buzz> References: <158893941613.200862.4094521350329937435.stgit@buzz> User-Agent: StGit/0.22-32-g6a05 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is preparation for the next patch. Signed-off-by: Konstantin Khlebnikov --- fs/dcache.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 0fd2e02e507b..60158065891e 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -636,15 +636,17 @@ static inline struct dentry *lock_parent(struct dentry *dentry) * Move cached negative dentry to the tail of parent->d_subdirs. * This lets walkers skip them all together at first sight. * Must be called at dput of negative dentry. + * dentry->d_lock must be held, returns with it unlocked. */ static void sweep_negative(struct dentry *dentry) + __releases(dentry->d_lock) { struct dentry *parent; if (!d_is_tail_negative(dentry)) { parent = lock_parent(dentry); if (!parent) - return; + goto out; if (!d_count(dentry) && d_is_negative(dentry) && !d_is_tail_negative(dentry)) { @@ -654,6 +656,8 @@ static void sweep_negative(struct dentry *dentry) spin_unlock(&parent->d_lock); } +out: + spin_unlock(&dentry->d_lock); } /* @@ -747,7 +751,8 @@ static struct dentry *dentry_kill(struct dentry *dentry) spin_unlock(&parent->d_lock); if (d_is_negative(dentry)) sweep_negative(dentry); - spin_unlock(&dentry->d_lock); + else + spin_unlock(&dentry->d_lock); return NULL; } @@ -905,7 +910,8 @@ void dput(struct dentry *dentry) if (likely(retain_dentry(dentry))) { if (d_is_negative(dentry)) sweep_negative(dentry); - spin_unlock(&dentry->d_lock); + else + spin_unlock(&dentry->d_lock); return; }