From patchwork Tue Dec 14 00:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12675147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E5F7C4332F for ; Tue, 14 Dec 2021 00:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244546AbhLNAyD (ORCPT ); Mon, 13 Dec 2021 19:54:03 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:65200 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbhLNAxy (ORCPT ); Mon, 13 Dec 2021 19:53:54 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BDLBGN5021573; Tue, 14 Dec 2021 00:53:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=zIfhDDpSMs7x3BIxMmfYRyCBaLwg1LOuB8LVcVYO8K0=; b=uM8XF+ZaWhUZzdtPxmX3jJ454eWaVgZbm7BPr85Y/rolHyiWMAxECi345soupcC9X7kf AN4AXpihal9CMuCh5O5C2DvZxJy4iUzDn49kAcj96O/+SYn32m/HmpCGh/wZMiG04lf2 40XVX+d76ehQEdaNPvqOJuDH15goRPRvxEjLCoHNlYhaguNezDY0QCbv6HScqrCUkwxI VtownbrD24m5TqJzQTR1RUdmM0WVeztoD8GV2oFd6IU8d+GSigYNEFgzmuDThiSSeyOh dflgkuE60jGFRY1D0gtTEfJczCWizmVlYMrSuoYt0egVsNq9Dh9XbGRGzgEnyDtfy96Y aA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cx3ukab9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Dec 2021 00:53:53 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1BE0fWGB190002; Tue, 14 Dec 2021 00:53:52 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3030.oracle.com with ESMTP id 3cvh3weegj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Dec 2021 00:53:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvrfddpDrB+cPhHZocwQ4oP1rKsdRge3TrUVUJlU1jqcp2KaoqI+vV7D0GvnOgjRKhL3jlk2QLE3F4QfG11uqY840soipRgpfxVBTqVlzs86gjc1WqaZskJoYJ5RkD3IGXT0NO3Cxz5r3a8vOFFbbJZ60Aooi14OpXStNvAEQyLoTXoOWKbk9nq1tUAb8RD+qAnacTBEQFZrXD7vRDmmzDb6fI341lrORevMRIbB7ZgTzIMLJE0pz1QaCdMKbDgHNH+wwkUCe/181wCpUwmulJez/tbxfmQ0fURgnx7VfcmB61SEkRU04pFtW7WfKciKjROPWJ3Y8AUp04vQqhoOsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zIfhDDpSMs7x3BIxMmfYRyCBaLwg1LOuB8LVcVYO8K0=; b=UzPXp3ftxP+hFpbxF9fR7W9oPWMsdC4J2KUFJ85+iNzX6uh+7z4CIb+BWGjPL/phMLLIssLTaH9KbzGw3wYbzM/xZzJ148wkY0wM7Zx7w7Awh2Tf5c0utMPa278SP5gBNipuQOoKFr6J6L+I1c9cjdcH6hKA4Wfr8t6N5S+mYffFiRjB7ae3niNMOGO1TAciUoaST5PUTSttvAFS7DiTheT5L/Sp36RX6OzIa8Pasm/ltPz/3u9sF4ar+mH/4ffUQN9NJ8yMLXSqL7OFdlkBC9Jd0pJUTNuEcna9Rb0xmTMYAMsuwpROwtKrAXb8ipd+ZIX/whnzVu20fvcI77u1pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zIfhDDpSMs7x3BIxMmfYRyCBaLwg1LOuB8LVcVYO8K0=; b=ogk7CdvY9UHpXNxoGk7IfD6W1FOsU9qnhV+Kqm2WMh0oBwRttbtyO45ZUZy+tRF1BpDIkA3js+LSqVXc5qco5pQuz2+WCZyJl3NXkIaUpb6930KqWhkaxSBlPUcPAJXsuh6zqqsnEYghvnZCVhJWv4OYPIaHP7+mnSzO6b1S2Bw= Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH2PR10MB3893.namprd10.prod.outlook.com (2603:10b6:610:f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.16; Tue, 14 Dec 2021 00:53:50 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::8c57:aca7:e90d:1026]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::8c57:aca7:e90d:1026%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 00:53:50 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , Gautham Ananthakrishna , Konstantin Khlebnikov , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] dcache: stop walking siblings if remaining dentries all negative Date: Mon, 13 Dec 2021 16:53:37 -0800 Message-Id: <20211214005337.161885-5-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211214005337.161885-1-stephen.s.brennan@oracle.com> References: <20211214005337.161885-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SA9PR13CA0145.namprd13.prod.outlook.com (2603:10b6:806:27::30) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a3e9ae71-8d34-41d2-6b42-08d9be9c3168 X-MS-TrafficTypeDiagnostic: CH2PR10MB3893:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:115; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l6Hoha26YZJ8dij8UUsTWxwKOS8mjT/wKsc7/v4aFyP7rK+57fCGAHq0uBQv1/1sQjD2Yddv96x8jw+XcaEVJbsAG/6JlFaPzEzzDLII0+PhFPPPdau1LYewig+MAf5JLxkurJPdRC13QQFb43kKaPNqbrZ6rvgZgLX40X4+VZ733tBWTFpde05yDyk3Gv90Q7yMhuMzQ2Bd1ZJ3PrqBSHVz641pYHX46d9lvdKVQ8Bn1cKHlvNRUnLsNUx2AeU/g/+aVi6UD6KbydI8JcUytDd62oUEnzLJG1yLF2ZJaL6T5sAz5HA+5RmjG4OnJDebXaPInjdXnen8DKos8JHhmFAuBSsENX/pvc4LJEM0UYvZBRqQiFv0BZRRtiYlZCmj13Xqb2wIF83XCQFsA9y+ZhdBuF12/16ADOw1V1vqDwynxoZRv1HQ3brPNgzHuCE5qQ1IPsG4QwcZrMDLzKsz1L1IqqCGiv8oeFQ8VgNZzt2kYUvtb70I+VnSTq+KrP+KfzD4P5gg5loJBkdv1czA/cuhCjDnJZquynq8AccX+30p4nTSqxdHcNAVukRQVMGoAMTpH3gdTMDpXtx2CISM6CB4o3W87EQcXJNQ/Vbqpmq+xrNmgzv8PcqxJ/dvHTgRdfy+/rONRpTpPcDj5D7er95XaTVXrmWe/2QEhQjSvPLboLGQfszJ2r/L7Nuli6yxgU6yto7sapI2o6XqV5GNgQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(86362001)(36756003)(66556008)(66476007)(26005)(6506007)(6486002)(83380400001)(103116003)(38100700002)(38350700002)(6512007)(66946007)(316002)(4326008)(1076003)(54906003)(8936002)(2906002)(186003)(6666004)(8676002)(52116002)(5660300002)(508600001)(2616005)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mYCbIzaviqapGepHfSPzTIn1RE/px0dPclaeckwDMHoPJXRQWprAnxT154n9bOLHJfqf7cQQ2LltY0J57CIMngwJYGK70KRuquxgoFkMJij/MWAHApoCylHdVK7ZwcsJYZT17nz2BrDAWJKS+qxw4GBSSDnQYRsCs3pejPEZj6/hDTYB8psjfWTzpTIFbC4LKG7/476bwj5wRBVVfcsoV+M0iq77LMuzT4Ib4b7kgyxAoJFRwOJXq7eFbVEMbRivwpAiPpdJzrB6/6i5H3ZBAmwU3wuTK+7k3mednwc9U5P4+iXZ6V7FjXoYMslG/hTXPbvMqYCbWnxGWBxzUylI3y5ZrOrUwYkoomvhzXLbBb8EfwfjTiZamFNPzO0aUgrlnofQA/J/UuANZsdQ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OODfElMDKamUm8CYidEmTgOf9VyWTJJTDLqurwHx3/lqdavY9I8O3nNh5REZn3tw77lIjSVB2k2z+1Xr8cmaMNYc9uMd56O9KHIJrsE1zc5n6x6pXBVcDAekZWu12oXG9xmFGXgtt3JzT1ULepUbzMTJ0oNJvek1/NGZKU3L8M8VcxhQhzEg4XLECv9uHqh0skT3r+oONxB6ow== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3e9ae71-8d34-41d2-6b42-08d9be9c3168 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 00:53:50.3988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EE6imNkkmwvrgKKAIkL6J8FAxB56J91xwIV9qlfkviRFalRfz1elE1m2SuODWHhGhV1NxGdXBdfyQ63f5yLj+PgJsBew5oDz65F3cRe09WY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3893 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10197 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140001 X-Proofpoint-GUID: tqjzWpEJ83S9ccxRnTzL-IPdmgLOswWe X-Proofpoint-ORIG-GUID: tqjzWpEJ83S9ccxRnTzL-IPdmgLOswWe Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Konstantin Khlebnikov Most walkers are interested only in positive dentries. Changes in simple_* libfs helpers are mostly cosmetic: it shouldn't cache negative dentries unless uses d_delete other than always_delete_dentry(). Co-authored-by: Konstantin Khlebnikov Co-authored-by: Gautham Ananthakrishna Signed-off-by: Stephen Brennan --- fs/dcache.c | 9 +++++++++ fs/libfs.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 9083436f5dcb..85f33563936b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1505,6 +1505,8 @@ static enum d_walk_ret path_check_mount(void *data, struct dentry *dentry) struct check_mount *info = data; struct path path = { .mnt = info->mnt, .dentry = dentry }; + if (d_is_tail_negative(dentry)) + return D_WALK_SKIP_SIBLINGS; if (likely(!d_mountpoint(dentry))) return D_WALK_CONTINUE; if (__path_is_mountpoint(&path)) { @@ -1751,6 +1753,10 @@ void shrink_dcache_for_umount(struct super_block *sb) static enum d_walk_ret find_submount(void *_data, struct dentry *dentry) { struct dentry **victim = _data; + + if (d_is_tail_negative(dentry)) + return D_WALK_SKIP_SIBLINGS; + if (d_mountpoint(dentry)) { __dget_dlock(dentry); *victim = dentry; @@ -3231,6 +3237,9 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry) { struct dentry *root = data; if (dentry != root) { + if (d_is_tail_negative(dentry)) + return D_WALK_SKIP_SIBLINGS; + if (d_unhashed(dentry) || !dentry->d_inode) return D_WALK_SKIP; diff --git a/fs/libfs.c b/fs/libfs.c index ba7438ab9371..13cb44cf158e 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -411,6 +411,9 @@ int simple_empty(struct dentry *dentry) spin_lock(&dentry->d_lock); list_for_each_entry(child, &dentry->d_subdirs, d_child) { + if (d_is_tail_negative(child)) + break; + spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED); if (simple_positive(child)) { spin_unlock(&child->d_lock);