From patchwork Wed Feb 9 23:14:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12741059 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 15832C433EF for ; Wed, 9 Feb 2022 23:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237062AbiBIXOX (ORCPT ); Wed, 9 Feb 2022 18:14:23 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237000AbiBIXOW (ORCPT ); Wed, 9 Feb 2022 18:14:22 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F0CE00FA52; Wed, 9 Feb 2022 15:14:24 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 219KHRkH013515; Wed, 9 Feb 2022 23:14:14 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=MDaJPMYx1J2RPymtQvDWDIW7V7lnUSXVpeOxhsEcfEI=; b=Pz/Aiy3MIGjyn2Av7NGUvrPBarpYziSp/7Q7uzz6IzGhLjLuP5nxWYAbL8YeL9FHIPAo NynsxsossNMIzqeBuMlcdG0IdZoadAtPPkzM9rbQUb0FqV8VsSMBujeNUmSlGQtiPIWW cs1NajTBNaUuUetfZbR45ggUoVILIxCiKlV58ZVV4IVv+3usLDMLhkXNPn7aFYLvPOvp cyY76l80CWoSFRKoc8bwyP4KS7AZJscD2N4s+br7HivrUPIfps9aB1Z7Uvt2xTapC908 /hMhL+Vlp+QMbCdviMk3zI71M4kTltmuEWao2CvTNgE0VEBueqAeZwIQ2Ghq6iqKry3Y 0Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3e345sr034-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 219NAAZ4141612; Wed, 9 Feb 2022 23:14:13 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by aserp3030.oracle.com with ESMTP id 3e1f9j6spa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKns04JMu1qUcSHZyG0OGCSGvW7YRhSnXYeIjk4nyMKp2HiuSzvg3K9qRt32QgpYhkFJxVrzrEDq8LjqMO0AhU3W6jDuQ7pwBPQWgxZBCmOjqC0jGtVQ4Ixq7YdV9FhaM32iH9NREwN1dRTyt5nUzcuLJuc9Mkwqfakwj8ArfI9gELdiZKBK0alPiJT7iK/m8b5QkhTOVYHHBQVuq0Rzr+Pooqwg0cK9pyyKhG6Iyaelv55R4+FysVoS9YyvRjq93YQh9hABm4Bsblh1WUOjQRBQlH4khsWMAGy63Ongc7Ahi8DYMQ6F6Wh5n8a4oOvhVDO4cYMmG8vT4+tssCOLfQ== 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=MDaJPMYx1J2RPymtQvDWDIW7V7lnUSXVpeOxhsEcfEI=; b=isGndDwYvw02uyVDsKD1jtqazWUFWJSwtHJvksqriflTav4H1PdFtfZTp3t6OCcX1Vw89M9STvLXd9PDcwkTYH9Rq+GOT9vjA6Hb4VTUDoWtCts2ZxOtQGhuyHG7FGUJzSwDFAUeqbbBi3+4oaAHfOpG/Zu9IVIm4W6G4wz49/+fJlwrwh38YFSej9slIYB8pRKqNZHHcvk/eb3Cm/7nvKlxcHRIHxrOMF2xZXh68QR9YSdWB5VC5yc3Ndy35m82CTKctomCj0hWOeOwHlC5geEj2ztLk1JnZB2Lkq3mBxM5cFewFduUWvcN+uN/n11viKtNpCkXh9c7pYQChlV/SQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=MDaJPMYx1J2RPymtQvDWDIW7V7lnUSXVpeOxhsEcfEI=; b=COta/DC+0WL2/7TTQ27Gp5XQEqoJgIWemhM/2fvvL5pcDQ+NmwJZG4zTDjBQOpXtdIdir/DPoVJw/ojJUxBxnNNWfdn10uaLocUg2lEJAmNrxr4UTsG0HMFSbrbq9wKsOWcRqANWhQ+ET6sQw0VFzEooVCMixoXYl/HrzzHw15E= Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by BLAPR10MB4884.namprd10.prod.outlook.com (2603:10b6:208:30c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 23:14:11 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a%4]) with mapi id 15.20.4951.018; Wed, 9 Feb 2022 23:14:11 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-kernel@vger.kernel.org, Luis Chamberlain , Andrew Morton , Jan Kara , linux-fsdevel@vger.kernel.org, Arnd Bergmann , Amir Goldstein Subject: [PATCH v2 1/4] dcache: sweep cached negative dentries to the end of list of siblings Date: Wed, 9 Feb 2022 15:14:03 -0800 Message-Id: <20220209231406.187668-2-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209231406.187668-1-stephen.s.brennan@oracle.com> References: <20220209231406.187668-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SA9PR03CA0013.namprd03.prod.outlook.com (2603:10b6:806:20::18) 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: 6e61368a-705c-4b0a-821b-08d9ec21e178 X-MS-TrafficTypeDiagnostic: BLAPR10MB4884:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zGEdAStFCuRmpZkvlJeQUPWx8LbHVsJuQi9oRCpFwd4So3674qvzLFTKZ33puxzJXHN34mrRW2yhRX2LUENLISYyLGvbeCGqerY3Dmxb236+Zs8vJcdOeNdduSpTtjUreKEN5FwhC5XvcCgTNuH7y/ungrDzgbu8xt9TpUMybFXT5H4/o4zThHR8EYAzdCGj7YE/xu0cd00koDCEOTO3TDZn/iSBLm6111QX+IQHf9laLkbXnNIL1KPJtHDO0w4TmTGS/C5czciEJu3eLl7GvygCfFbN0KJzj0IBmqZZ7+9PhA4DUQgVTxONMwNy6P0Y++9n+hvmU4ZIe3ojIH9ezKq8uD0MhHqJm6xmZScnkrjisgOOOaEg6nKldOwzCkmvutTZFjvek2YZCKpttT8TJb4m9An7KIiD7dZgXTFm9U4eUX5Hfdt9fg6zgKSFUqGdwN0gQoYy7ujTPllpY5ZaoiBJ4wEuyi9eZ+R6DQVhHzamoG8Af7rQs2/CIYvmKqw6V1sA2FvpkxQQFidwljyf+ZPRqR5gB5giKOgI+wFWLFzD3gu9GnPa41dbHdN7PsJOsvmlTNM1bdGW9IeiI/A2kaG6N0MjGmBtdBs/6Rp0Qh8qDQXdwQkvAOxQFGUm4tvxz4oWM+Kvr6bry9mXhrAGXOTcXM81GDqfIJ6hZtNt4VkYUFh87SddInY8GLJkwJvNx1OPzpzsXnuUa2g4P+NpUQ== 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:(13230001)(366004)(66476007)(86362001)(52116002)(8676002)(6666004)(6506007)(8936002)(103116003)(66946007)(83380400001)(66556008)(508600001)(4326008)(2616005)(38100700002)(1076003)(186003)(26005)(54906003)(2906002)(5660300002)(6486002)(38350700002)(6916009)(36756003)(316002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q6LdJAB+YrcusCmKhLYPE/B6yHmcK9dwL1f7YphdJeexY+njyPu6al3ZjPG0uaTFdqSghEbjUlbA2coJ1DuCwhs/HgVDqqEkDQVFvNFBeTTndKLOWnc5ZkA3GYCl4qeb2lsgsr0VK20zP6wPD3bdum4gbguw9bKvGT7AiL25pW9BmP/NC8Gl8SWaWy43ibY0gKMkHnffxumORr+9A01kOgUU70FfCTihzm7EMpbgSWMjtzDD+T6/Fs1il37XOg8i4CbtrhfxcLn8gpfp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49s6OlAef2/s8AQBe7ORVBKMuj8aDFfTWqE5wNBegRXNKdMu6GSAcIXQ8ulT3q5LdCSVajjSDDy9dmTKka+XJ7LIXijupIXEPzr9f8HmoTgMDaHbbH5so2iD3zRcFplFKuYnvefSwaV/bwBiYXiGcnqv8JXUBrp1kytjUfUIvwzbTsm9va5brMA5NK+gNMcS9zDw6nMZB6TwhuE3aNQY850PtJOx+Qc1p6MUk/D4s23fFoRoO0pCklwS6lVVq714lve9VMp6ey7FECgudvs11v0aN/1mc5+a7j9nUJDEp1ukbDkU8fs8XKibH7CJkku8waQnMSyeDw6ahA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e61368a-705c-4b0a-821b-08d9ec21e178 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 23:14:11.2201 (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: iGi78ykHEDxhJhm554VqHGQDewRxbM1XbtasB9QD11oZ/nHk9bctOAHSeJ7tOsPnBWdt7sfX29ogLWNT77TxaiZcNYTe5vPzcnJOmQZYawc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4884 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10253 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=783 suspectscore=0 mlxscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202090121 X-Proofpoint-GUID: MKfrETwLELtsFyA-ZRthyh_WxSJ-PWhB X-Proofpoint-ORIG-GUID: MKfrETwLELtsFyA-ZRthyh_WxSJ-PWhB Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org For disk filesystems result of every negative lookup is cached, content of directories is usually cached too. Production of negative dentries isn't limited with disk speed. It's really easy to generate millions of them if system has enough memory. Negative dentries are linked into siblings list along with normal positive dentries. Some operations walks dcache tree but looks only for positive dentries: most important is fsnotify/inotify. This patch sweeps negative dentries to the end of list at final dput() and marks with flag which tells that all following dentries are negative too. We do this carefully to avoid corruption in case the dentry is killed when we try to lock its parent. Reverse operation (recycle) is required before instantiating tail negative dentry, or calling d_add() with non-NULL inode. Co-authored-by: Konstantin Khlebnikov Co-authored-by: Gautham Ananthakrishna Signed-off-by: Stephen Brennan --- Notes: v2: Remove the sweep_negative() call in __d_add() when inode is NULL. fs/dcache.c | 85 +++++++++++++++++++++++++++++++++++++++--- include/linux/dcache.h | 6 +++ 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index c84269c6e8bf..0960de9b9c36 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -660,6 +660,58 @@ static inline struct dentry *lock_parent(struct dentry *dentry) return __lock_parent(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 with d_lock held. + * Releases d_lock. + */ +static void sweep_negative(struct dentry *dentry) +{ + struct dentry *parent; + + rcu_read_lock(); + parent = lock_parent(dentry); + if (!parent) { + rcu_read_unlock(); + return; + } + + /* + * If we did not hold a reference to dentry (as in the case of dput), + * and dentry->d_lock was dropped in lock_parent(), then we could now be + * holding onto a dead dentry. Be careful to check d_count and unlock + * before dropping RCU lock, otherwise we could corrupt freed memory. + */ + if (!d_count(dentry) && d_is_negative(dentry) && + !d_is_tail_negative(dentry)) { + dentry->d_flags |= DCACHE_TAIL_NEGATIVE; + list_move_tail(&dentry->d_child, &parent->d_subdirs); + } + + spin_unlock(&parent->d_lock); + spin_unlock(&dentry->d_lock); + rcu_read_unlock(); +} + +/* + * Undo sweep_negative() and move to the head of parent->d_subdirs. + * Must be called before converting negative dentry into positive. + * Must hold dentry->d_lock, we may drop and re-grab it via lock_parent(). + * Must be hold a reference or be otherwise sure the dentry cannot be killed. + */ +static void recycle_negative(struct dentry *dentry) +{ + struct dentry *parent; + + parent = lock_parent(dentry); + dentry->d_flags &= ~DCACHE_TAIL_NEGATIVE; + if (parent) { + list_move(&dentry->d_child, &parent->d_subdirs); + spin_unlock(&parent->d_lock); + } +} + static inline bool retain_dentry(struct dentry *dentry) { WARN_ON(d_in_lookup(dentry)); @@ -765,7 +817,7 @@ static struct dentry *dentry_kill(struct dentry *dentry) static inline bool fast_dput(struct dentry *dentry) { int ret; - unsigned int d_flags; + unsigned int d_flags, required; /* * If we have a d_op->d_delete() operation, we sould not @@ -813,6 +865,8 @@ static inline bool fast_dput(struct dentry *dentry) * a 'delete' op, and it's referenced and already on * the LRU list. * + * Cached negative dentry must be swept to the tail. + * * NOTE! Since we aren't locked, these values are * not "stable". However, it is sufficient that at * some point after we dropped the reference the @@ -830,11 +884,16 @@ static inline bool fast_dput(struct dentry *dentry) */ smp_rmb(); d_flags = READ_ONCE(dentry->d_flags); + + required = DCACHE_REFERENCED | DCACHE_LRU_LIST | + (d_flags_negative(d_flags) ? DCACHE_TAIL_NEGATIVE : 0); + d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | - DCACHE_DISCONNECTED | DCACHE_DONTCACHE; + DCACHE_DISCONNECTED | DCACHE_DONTCACHE | + DCACHE_TAIL_NEGATIVE; /* Nothing to do? Dropping the reference was all we needed? */ - if (d_flags == (DCACHE_REFERENCED | DCACHE_LRU_LIST) && !d_unhashed(dentry)) + if (d_flags == required && !d_unhashed(dentry)) return true; /* @@ -906,7 +965,10 @@ void dput(struct dentry *dentry) rcu_read_unlock(); if (likely(retain_dentry(dentry))) { - spin_unlock(&dentry->d_lock); + if (d_is_negative(dentry) && !d_is_tail_negative(dentry)) + sweep_negative(dentry); /* drops d_lock */ + else + spin_unlock(&dentry->d_lock); return; } @@ -1998,6 +2060,8 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode) WARN_ON(d_in_lookup(dentry)); spin_lock(&dentry->d_lock); + if (d_is_tail_negative(dentry)) + recycle_negative(dentry); /* * Decrement negative dentry count if it was in the LRU list. */ @@ -2722,6 +2786,13 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode) struct inode *dir = NULL; unsigned n; spin_lock(&dentry->d_lock); + /* + * Tail negative dentries must become positive before associating an + * inode. recycle_negative() is safe to use because we hold a reference + * to dentry. + */ + if (inode && d_is_tail_negative(dentry)) + recycle_negative(dentry); if (unlikely(d_in_lookup(dentry))) { dir = dentry->d_parent->d_inode; n = start_dir_add(dir); @@ -2738,7 +2809,11 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode) __d_rehash(dentry); if (dir) end_dir_add(dir, n); - spin_unlock(&dentry->d_lock); + + if (!inode && !d_is_tail_negative(dentry)) + sweep_negative(dentry); /* drops d_lock */ + else + spin_unlock(&dentry->d_lock); if (inode) spin_unlock(&inode->i_lock); } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..7cc1bd384912 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -211,6 +211,7 @@ struct dentry_operations { #define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */ #define DCACHE_DENTRY_CURSOR 0x20000000 #define DCACHE_NORCU 0x40000000 /* No RCU delay for freeing */ +#define DCACHE_TAIL_NEGATIVE 0x80000000 /* All following siblings are negative */ extern seqlock_t rename_lock; @@ -489,6 +490,11 @@ static inline int simple_positive(const struct dentry *dentry) return d_really_is_positive(dentry) && !d_unhashed(dentry); } +static inline bool d_is_tail_negative(const struct dentry *dentry) +{ + return unlikely(dentry->d_flags & DCACHE_TAIL_NEGATIVE); +} + extern void d_set_fallthru(struct dentry *dentry); static inline bool d_is_fallthru(const struct dentry *dentry) From patchwork Wed Feb 9 23:14:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12741061 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 41081C433EF for ; Wed, 9 Feb 2022 23:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237080AbiBIXOa (ORCPT ); Wed, 9 Feb 2022 18:14:30 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237050AbiBIXOX (ORCPT ); Wed, 9 Feb 2022 18:14:23 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA0EE04FF12; Wed, 9 Feb 2022 15:14:25 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 219KHBeB013543; Wed, 9 Feb 2022 23:14:17 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=Fbv57XCFOh/NLtiwOFrBhwGoKiNYyK7jHBz6SqSu4nQ=; b=usu3rZGCQtDUOEG4v2cMTJx7xvh36xpXt2JeWz+1in0rXPmsNMDtncjS4fU1eKW7P0BI 9iZO1LpOedwB/nFwx5w5jbYN8+3/c4d6Z/wNwOlaalwx8lBNWNMS3YhLYbT+pbMWgLtu Nl6u9pq2shKIywqr+KSjiHXJ7ge0wIR01O5Gf+NJ/1t1hhnUNB01kQxeTdG+Hfw6RTm9 1lJGF5j8OU5+PIDfrNJ23vdtJDwG3XwzqgMZMQxYEd8kM1FDPeLFSflQCtoXynFROQRA zQMj+bLyzALosCEsFdpNMLeBIjbwTfYmnrdChFbboJ0TneT4IGmu0WSDo5NU78oTQX/t fA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3e345sr036-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:16 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 219NAAZ7141612; Wed, 9 Feb 2022 23:14:16 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by aserp3030.oracle.com with ESMTP id 3e1f9j6sr8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WkGJTPRzlmluYqE4DidhyP1PD6nUoI9ytGDOi3K3zAWL03H1GCvhFZj+ZTv+/ylkvPzFjOawbKGXAVYzSr+5r/+5+fh+yUK8ncafbvLx9pYLiUE74RKBKHkLGd9J/JKKkmwkVM9VqcbI66Yl8syH5fPvALmJULRJ8AZmvJa0yqPKocWg6HPdJhnHQmUCh2As4yA47CSMHqDY5zDMtF5GkcMtfyHQ9rEPXSeF1xFSWIDcb/xEqFG1lAnzEH64ksZs+Uh4vYLHEpsK8CGskLiPXKdFSWDLWTqJWNFXoU5cWjX6OHShgyb9qYu21Mqzuczi70WmqeHnO3kWuTbJ57kz9g== 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=Fbv57XCFOh/NLtiwOFrBhwGoKiNYyK7jHBz6SqSu4nQ=; b=OAgLLDEjfzL/Nsx0RqIGZGMLU98LPWNRxbjcfc97mMUNOFGu8kkES1cDSnSr1KO9QUjAvcsJmX5Q1P43g8jNbyxaraCLEhmkZm5AAs7swtpJorttC25KwB8p1yxYcmhIp4MZB/ibQPpPInbnOa6YAb0Tf5j6fpw9x088iUJ/J3ddBWmIqlx6hhYLbIFzNvRDu4CCvS7CXpe4TfzNsGKw7Pcme2LhkH7JkRCBv41aWqgEJpcORTBMiDGSa/RtjGvb7gSWn2Po33jaZGUPihICoxtS/771PQRBDoH30ap4vcpkmcGEt8TigOXyjLBGJ2qennyMTDilJEUWRejjR4XZbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=Fbv57XCFOh/NLtiwOFrBhwGoKiNYyK7jHBz6SqSu4nQ=; b=KzF89FwQJhn0W3Hw1So+9yFiLFPy2TMnpzT6jXhipjFbnlWxaGTHhoT2sBLSHFvBRPPBouyuZlifkrdb+gEQWB82gciSP3Reqb5nlvQnOjj+Vw7bM8Islm+PEUp/aTl2reWHhgkWujSQJrip60TMI/rBRE92iCHLuk9uKBJf6BE= Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by BLAPR10MB4884.namprd10.prod.outlook.com (2603:10b6:208:30c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 23:14:13 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a%4]) with mapi id 15.20.4951.018; Wed, 9 Feb 2022 23:14:13 +0000 From: Stephen Brennan To: Jan Kara Cc: Stephen Brennan , linux-kernel@vger.kernel.org, Luis Chamberlain , Andrew Morton , linux-fsdevel@vger.kernel.org, Alexander Viro , Arnd Bergmann , Amir Goldstein Subject: [PATCH v2 2/4] fsnotify: stop walking child dentries if remaining tail is negative Date: Wed, 9 Feb 2022 15:14:04 -0800 Message-Id: <20220209231406.187668-3-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209231406.187668-1-stephen.s.brennan@oracle.com> References: <20220209231406.187668-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SA9PR03CA0006.namprd03.prod.outlook.com (2603:10b6:806:20::11) 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: b58b7fc7-1df4-4f7b-8390-08d9ec21e2f1 X-MS-TrafficTypeDiagnostic: BLAPR10MB4884:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EpQXzILnnr8NLYX6yeQr879iX8kzpixgj32XeHwmTPkSFuA0Ln2GIfi3gikp5lxj6EKp11uW9TpiPTtSSC13MAgx56Zc+B4Qr7HqFEaqi6zJTNLB7Abpa6UYr/d8Y8Yk8rif6D9+qb56ud8XXg4IwdS1xcnlQg0P0XcvZcd5s+wdzYpfmUZTqwtDgeevELomWOEvqs4zK7fWWsdEQPmXAXnBg4UNUFD/PhoM35Tv8nIUZYeInxvlHTgzkCiomq/YcsRrD5z122JJ46OYGk/sKzvc23qt2lqPfn7dAP+YTJsFElKGk6j1UVWeLJs99RJiz9C6Z6tOi1bgc4itqCAz3v0Dq44wJjU/ZR9VAjBviE3VdURbFoiet5zG+SPQRozU/9xBUy2WcIS3a08HYIf+WMuBjDAyxegcLxrIek4pxlb0amffED3ZO9kWpHkSahbpNiDXfAKs7OjBMNa6ar8MhV9pgdQyn+C907q1SLB389yKZVGZO68Wpqrb6sZZHYfh8UXkDQCiSmNSfXbUpL056pGxWS6qtUn66k5rtGrWwwrHz+LZvQLvXBxWkA6XSxqBCiGaACpy+9SzpcpexITLmdBQDvA0vfE5L1x75eS+43CDvWEl63Go6EulLapjyugW6F1OjkBduVA56Y09mzp2cCrWDNfdHU9uQgLm0BR1xyXFWsLO+Mc3U+jujsy/p58t5QqqOxzSFe2WXaLCIqdAlg== 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:(13230001)(366004)(66476007)(86362001)(52116002)(8676002)(6666004)(6506007)(8936002)(103116003)(66946007)(83380400001)(66556008)(508600001)(4326008)(2616005)(38100700002)(1076003)(186003)(26005)(54906003)(2906002)(5660300002)(6486002)(38350700002)(6916009)(36756003)(316002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PI51jsMNHwdcu4LXXYP/SEogKXO5iIGDJV0td/RdRNWDT7lhTB4ypiJBogDngVVvkvK2B26tS1jCOfoZHh1tt89g0K6vQNXppSVZtqLkbXzL0/zOvI8p+CEXyZPpqSRreDRoZ7PMAKVolHMVj2vzvUOmd7rviGZOckc1ATpmE2n9UVrrzpFMOYTK/hMQ9jFyAufsbGOd/Gf2/VqXgcH9yqs0KhfsHzOKlZ3Odj3lxYqRZnWpOv9IftqTJG43jnrunNaNepAhkmrtvhSP07xCI8W0XoNF9Fb9eoW92ggaCuNoG9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cF1RfXHIZfn+iSb7z+0as6RgAJWRqvl8FJGww/HA7mV/MENu3oSfwMYXOnbHTYKQn/nBGVuuU41brIlKCKeJLs0wRJEOVLNYU/uBLLtrMbaibeCCHBcfU/mONQcEdVdvMi3Avczb9z/W7mG8JaD5EfYHosB3LZzYwAIMsD8e7yhAJnAn6szCMbmpNGz82CbUqMoUtagE2wJCaoksIcLppNVHUIn/FxNhAmhJi5uWDUarOAQ9nbJUkGbxPlgQvRK+puxI0TQez9y5eglID6UiY3X4pFMjjoJV5aQP3PD5dZzg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b58b7fc7-1df4-4f7b-8390-08d9ec21e2f1 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 23:14:13.6742 (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: 3CJnvUJsFpuYQcZ906AvswoKfQLuhhKepBRQiwXC0aUJpzrmuh/lEb9w4ig0+oCZ+QCxb02vzRwQu1Br7DAJiygeMauYSh3tcVAwbpT8ySM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4884 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10253 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202090121 X-Proofpoint-GUID: x1zn8pvFdr8IKE0YJmCSrFwxKZ_djL33 X-Proofpoint-ORIG-GUID: x1zn8pvFdr8IKE0YJmCSrFwxKZ_djL33 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org When notification starts/stops listening events from inode's children it has to update dentry->d_flags of all positive child dentries. Scanning may take a long time if the directory has a lot of negative child dentries. Use the new tail negative flag to detect when the remainder of the children are negative, and skip them. This speeds up fsnotify/inotify watch creation, and in some extreme cases can avoid a soft lockup, for example, with 200 million negative dentries in a single directory: watchdog: BUG: soft lockup - CPU#20 stuck for 9s! [inotifywait:9528] CPU: 20 PID: 9528 Comm: inotifywait Kdump: loaded Not tainted 5.16.0-rc4.20211208.el8uek.rc1.x86_64 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.4.1 12/03/2020 RIP: 0010:__fsnotify_update_child_dentry_flags+0xad/0x120 Call Trace: fsnotify_add_mark_locked+0x113/0x160 inotify_new_watch+0x130/0x190 inotify_update_watch+0x11a/0x140 __x64_sys_inotify_add_watch+0xef/0x140 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae Co-authored-by: Konstantin Khlebnikov Co-authored-by: Gautham Ananthakrishna Signed-off-by: Stephen Brennan --- fs/notify/fsnotify.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index ab81a0776ece..1f314f85f4c1 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -127,8 +127,12 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode) * original inode) */ spin_lock(&alias->d_lock); list_for_each_entry(child, &alias->d_subdirs, d_child) { - if (!child->d_inode) + if (!child->d_inode) { + /* all remaining children are negative */ + if (d_is_tail_negative(child)) + break; continue; + } spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED); if (watched) From patchwork Wed Feb 9 23:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12741060 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 7F0FCC433F5 for ; Wed, 9 Feb 2022 23:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbiBIXO0 (ORCPT ); Wed, 9 Feb 2022 18:14:26 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237054AbiBIXOX (ORCPT ); Wed, 9 Feb 2022 18:14:23 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA360E00D0E1; Wed, 9 Feb 2022 15:14:25 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 219KYQul020178; Wed, 9 Feb 2022 23:14:19 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=IjpUwYdnyj8IMOcG4YQLpPXNd2LUgTj3nWSXRDhJbKM=; b=gJxzyENWXHjThvwbkAXow/pE+ASpewwHmjmtxFzyQOG6cxMiw4qU9VqotN+QGmxEhnfO Mm3x+3mc38X17H5rE0jvuAwS6W7c/SQzhLHOYKJIVUgWPOtJWKzKWa8nApZ4e7e+q+TR FXxYa4gUhurrPhbNZdH5niTGxUUul3q5Jjf0H3sDega0wopELk0eaMoFJfe/xJnooPeA beDX/f69nr61T/BpWBNblmPDTuPJadE0sWip+GUCi/Q1gokL5w9ye62MxtdQu6DciWF9 msNf4FLPUJQzlN+4UmEgMzcmFoklp6MVOpHHOtVlr2WQNTHrHeZqlhav7aIKc36u/h8H QA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e366wybq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:19 +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 219NBqmL104943; Wed, 9 Feb 2022 23:14:18 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by userp3030.oracle.com with ESMTP id 3e1ec3kf7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QGaCocY4kelpKzJbbzbx6z6vHCL7/JBFvWdl/HoSyOixMFKcCGP6j8eAEUagFclAebSi0Ergtm5DShqEqN8R6ThxFBwZsyU5tKR6HaGshieH7DXXuAM6H6y86xaxi389QPh2UZR3wfTlLDTbE789SvcdYLakU7tsyXINTVZ96MrCAJDpEvfWIuj1QugmkTQ3aBdseTD4BCBpwykr6Ua1xvqVwRnMqYsZlVbqr2JvDcbQ9bSf+0bk/YxDyCBsuaS3YNZ8A4jvmRNXah1/UTwjvDH+SevTLsMMjORxaVk+PqxHJwQId+p9yzkj29qMO+Bhb8NZTdj0uIw2gbtyr5XfSA== 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=IjpUwYdnyj8IMOcG4YQLpPXNd2LUgTj3nWSXRDhJbKM=; b=aHlEzIDz3rT9B+X62q38Jlv7lJJmEKNrNpJRoReQpwj1fIoNC+hwyRiPXi5Ui7F9wCvw5dBbi6hnwgEPB9/2TmIxw5amfnf5JOxZmykEtyCydGi+DYlrsoBM/7om49sWi+86/rHIxJcwngq18I4N0Ds9qEWZ6qMNVo8PYWBKYEP9J5O23fdCpBHfW4j00I1r+AqGHYzpDdE4mZi02X8b41tZ/NyiXg5BE4Qz+Zmt26AEl7gmsP7AXcbtsqyvGTdRVSRn0BNMUf7mBWX4qKrWCHYZrjF8MWocsfURH9M3fkUyTaxuHs0jIQ9XoFNXFM8N/Q1/ZA0uMpWSPlL6lsuN3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=IjpUwYdnyj8IMOcG4YQLpPXNd2LUgTj3nWSXRDhJbKM=; b=dhPlWrqN88aPHfES/Ql4vDrvZlKbrpMmzre1HP+omQhaWqLDkKAVqgiJbuopU3KL+HE2Qf9HhY5GVsMn1595Mbk1qjLmmSEFHm2UL3FhYGfCedieho0DWRDy3J7q1xJsUxz5jaLY027e4AuE6kUL1ZXpqm7r3/WKJx8cHO0JfIw= Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by BLAPR10MB4884.namprd10.prod.outlook.com (2603:10b6:208:30c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 23:14:16 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a%4]) with mapi id 15.20.4951.018; Wed, 9 Feb 2022 23:14:16 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-kernel@vger.kernel.org, Luis Chamberlain , Andrew Morton , Jan Kara , linux-fsdevel@vger.kernel.org, Arnd Bergmann , Amir Goldstein Subject: [PATCH v2 3/4] dcache: add action D_WALK_SKIP_SIBLINGS to d_walk() Date: Wed, 9 Feb 2022 15:14:05 -0800 Message-Id: <20220209231406.187668-4-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209231406.187668-1-stephen.s.brennan@oracle.com> References: <20220209231406.187668-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SA9PR03CA0016.namprd03.prod.outlook.com (2603:10b6:806:20::21) 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: 0df24ea9-0677-4861-fc9b-08d9ec21e467 X-MS-TrafficTypeDiagnostic: BLAPR10MB4884:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:632; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hs9H4bSmB3vpHvgFeXT1F6qZMdQRhg1X1s4udv9cyImHCOjY00/rNxrGUlwU3yUYs9raCipNoD5W1Sqc4wiz3OLiRrBHoqA2rwcQCdwPaSFuTKKwy5b3e7IGfD7j4WEbDwA9LUytaqBWfEbR4t2zwgJKOjXjRx1MrRB3gr83CtkQCssyy6lGUDhWesBvPW4TK1Y/b5mQmHWMQ9j2SMarrbIlKpBiME4N1Kq01bC2B1aDX5SeaphIuGGIR5rI8/sLnbvl6hNZ6cXY2pruNDLYtkJ3yNjHskmu+SSwC/IobHKfbl++/EY+XnOwHzOsIK6rl7rfRMaJ7GKVgyTs5EA/OvcJg9mR9pDsou3HRDD6MWXVRp3Os8RK/cgrgysxQa7O7Yh/G4AmAjSb7wzkZ0PYEDe3/BJVRSHEHHLv4ojohflVRCHjQhRKmgSEANBToSQFEUBjnZBpskioa3yh4IIVX3eJvopn+gPBk2fxicMkWK2HOGLv8rPqDwEKSVxu4Bt1nM4W0lr4ozi4FhiM1u6mxBCdlrmkuAX3ATUHvL7aIaccILq/0D2HjaMa/faPys+9peWVZY2o4c8XwtvzHpD7EpvH3vHB+fdNcZJGJ8E5muI3h6Wl3Aar3pu2S2ZKEYYvkaEbMbZretk0nZ7lXMJFn4yPy70MKI++94wLKcQlxQxlAl5/R90XhmirvBfLMJ0P+67BdWesy1cq8NSko+8ovw== 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:(13230001)(366004)(66476007)(86362001)(52116002)(8676002)(6666004)(6506007)(8936002)(103116003)(66946007)(83380400001)(66556008)(508600001)(4326008)(2616005)(38100700002)(1076003)(186003)(26005)(54906003)(2906002)(5660300002)(6486002)(38350700002)(6916009)(36756003)(316002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QWjQbdlJx5qP8GD2EZBW/VkX2LBiLN7likCQf3hYS18R48kR+tsGvHFWyOnsm+FHpB6wVfL+9zpF2E+H+kbcxGJVW55e/k2QB9yJyjb26wo1+AHp7rr5Mv9pdfhJ0dVXV7hS2zZeqZUNEHHOYABJQhD0M9w7DJtbYoL5tgZCj8vHWdNZD9RMqy7m42GW5sWzqmHA+m6ILN/Py+0py7oS40xsPJFgluU5ynjAa5Uy35rSpGjd+p97Tas6zknVTUjiyhPR+VhCqXob8PxDjeU+GJIW6GUkmSOaA4h/WC4OfQfgu0s6XlUpQBcH8M+kf57PyNbpYkmM035ZSOH2NuKwBbHam67BAQEmXDUMybXUAN8TqrvNSAR6dDlOmntW6kUXDowigoJsvXC+x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56UOAsAlkGFfHBUkU+9ZxfbV8GWewrNQ1BDlS25Wc98YNQEwr5/Z1J3to+Q6VFHm0iZxuomXe+3P8xsV2xdl28r9LoE0+soLgl/SqZYuHSFyxCf5GjHuCs+yAAKvmjDyf5F+6EKZR8Y2U+KVPJVQy0EpuvpV46oobar7o/4qQqBDMYgbMCpZz15bAaRcCkAMK1p4v4mGGL3SKpuqQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0df24ea9-0677-4861-fc9b-08d9ec21e467 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 23:14:16.0825 (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: PgduZWKZSbYBEC+XT3ygZXBeEnq6KAgpZz5JpSz/fv5cYBV4AxmHoL4c5Jq70FPnrPLdDxq8kWeoloW28YYXY20vx0ZGTvf30rASPZsHq04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4884 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10253 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202090121 X-Proofpoint-GUID: _n_bxwDVEw-hliyxpAA9vqD7_uzuZZdB X-Proofpoint-ORIG-GUID: _n_bxwDVEw-hliyxpAA9vqD7_uzuZZdB Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Konstantin Khlebnikov This lets skip remaining siblings at seeing d_is_tail_negative(). Signed-off-by: Konstantin Khlebnikov Signed-off-by: Gautham Ananthakrishna Signed-off-by: Stephen Brennan --- fs/dcache.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 0960de9b9c36..8809643a4d5b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1391,12 +1391,14 @@ EXPORT_SYMBOL(shrink_dcache_sb); * @D_WALK_QUIT: quit walk * @D_WALK_NORETRY: quit when retry is needed * @D_WALK_SKIP: skip this dentry and its children + * @D_WALK_SKIP_SIBLINGS: skip siblings and their children */ enum d_walk_ret { D_WALK_CONTINUE, D_WALK_QUIT, D_WALK_NORETRY, D_WALK_SKIP, + D_WALK_SKIP_SIBLINGS, }; /** @@ -1427,6 +1429,7 @@ static void d_walk(struct dentry *parent, void *data, break; case D_WALK_QUIT: case D_WALK_SKIP: + case D_WALK_SKIP_SIBLINGS: goto out_unlock; case D_WALK_NORETRY: retry = false; @@ -1458,6 +1461,9 @@ static void d_walk(struct dentry *parent, void *data, case D_WALK_SKIP: spin_unlock(&dentry->d_lock); continue; + case D_WALK_SKIP_SIBLINGS: + spin_unlock(&dentry->d_lock); + goto skip_siblings; } if (!list_empty(&dentry->d_subdirs)) { @@ -1469,6 +1475,7 @@ static void d_walk(struct dentry *parent, void *data, } spin_unlock(&dentry->d_lock); } +skip_siblings: /* * All done at this level ... ascend and resume the search. */ From patchwork Wed Feb 9 23:14:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Brennan X-Patchwork-Id: 12741062 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 00CFDC433F5 for ; Wed, 9 Feb 2022 23:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237054AbiBIXOg (ORCPT ); Wed, 9 Feb 2022 18:14:36 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbiBIXO0 (ORCPT ); Wed, 9 Feb 2022 18:14:26 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76FFEE050B81; Wed, 9 Feb 2022 15:14:29 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 219KYQum020178; Wed, 9 Feb 2022 23:14:22 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=ejzW0VqgQdVY08sCESJZErpFCOudvGY9O+7ETievUYY=; b=orttwnEgjYH7p6Az1IvNTU61x4nQ4j1NR6J5Q/meTrOnqN5FyBh9IVOrIWoqmlrWiwHw YYhvlxy0fMzBy6w1JwRA7JFMbYA9dnIT0w87veDTNc/IG/2RSkI9ft6iDKtV7FR+V69d 2VYuSsy4ojMuaCojP210e2xO2ZSbTDZK9ySoFj9zRJX8w8vVHcLRrcJpGm35dHFXbWKO Onwxo0CYgaWVzLzqEbBS5CQvJFm+EjjFppxRsWKnVbYmwKVmlHM1epAE/wdCJBRZp1fK OXDbzkALLifSXqwXUVQLxhmJyINl+X21X2RR6/HkqliiomcOiyoNsu52H5FAivYMKThH 8w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3e366wybq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:22 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 219NAQr7039265; Wed, 9 Feb 2022 23:14:21 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by userp3020.oracle.com with ESMTP id 3e1jptxr01-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Feb 2022 23:14:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iotmn/2fo/RFlhI0IY7w+mQJ1SawUzErwear5UcIBxhppVuCdinNroxdMWowsK+ZxzmcQdZpwZL6oqVKhPr/9jbqGY7uLqMUDlz+AAHPW3PhRksHMnHvJ8xf0npkM29qQaktMThE12k9GnlKMpAlyK3/ARrZ+zf7p4e02aCoDVTvbkKHRQQvRcZAFbV1kGL6HkFChoE52z5RnryzPj0xocdzYDCfcz2/dI+q4JYX+V4RzKlqavYCCpJpk678JYydbjmtGmxmSjLJHkEOYBPEKfYyvRWW7o7KlXIjws7E9m0EQZivDIu/JeJYZA/YQCuHq9MMd6F75f4nT74PCET9Mw== 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=ejzW0VqgQdVY08sCESJZErpFCOudvGY9O+7ETievUYY=; b=Kh5fCTzzVZ8YNZMNh3zX9RtFhsfyPSFCbHY0XAXPt8U7pDtoB30tIUcwuALzNHXdQJfNpMR6oTjA4/IvxF517sdjbGgBc19d1fx0vBx6MPh13Ma5hFY8nRR6T3JozIwIZVO2kNRT28OjB5pNHWp9D+axLVSNEnrzg8f8fwLSb6ErxmMGHKFVXibWUeE+USkratBzKxJ9w/OhrmbinllpCCK0ZItDyTWO+OCpzeGkyLnx/nCnbyayno2PQIzPCdgEHxw8L0em604Y5exyvcVf7n8bhcGgzpYTOX3UIi/tBiZnkvuQkLL9Tv8hjRUynHJWNEgtNNlFlH81ixYKOm+9hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=ejzW0VqgQdVY08sCESJZErpFCOudvGY9O+7ETievUYY=; b=x0cN7SH4+RH+xXWIETkYlfhfePmFZ4pxKAmzYPOuMLqcvYR4iqVVFVuzemwU0X51R5nn39enofIIa1Sifwbi5tZ1By+WSN97BRBTnTTS3kn7xBki6v/dt8Sb38lJcB8yTdFfrB8us1lPUA/1TBt5qTB7jogzIHDH7cIVqWyXAIo= Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by BLAPR10MB4884.namprd10.prod.outlook.com (2603:10b6:208:30c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 23:14:18 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::f4d7:8817:4bf5:8f2a%4]) with mapi id 15.20.4951.018; Wed, 9 Feb 2022 23:14:18 +0000 From: Stephen Brennan To: Alexander Viro Cc: Stephen Brennan , linux-kernel@vger.kernel.org, Luis Chamberlain , Andrew Morton , Jan Kara , linux-fsdevel@vger.kernel.org, Arnd Bergmann , Amir Goldstein Subject: [PATCH v2 4/4] dcache: stop walking siblings if remaining dentries all negative Date: Wed, 9 Feb 2022 15:14:06 -0800 Message-Id: <20220209231406.187668-5-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209231406.187668-1-stephen.s.brennan@oracle.com> References: <20220209231406.187668-1-stephen.s.brennan@oracle.com> X-ClientProxiedBy: SA0PR13CA0018.namprd13.prod.outlook.com (2603:10b6:806:130::23) 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: 0a31cfea-42a2-4e54-95ff-08d9ec21e610 X-MS-TrafficTypeDiagnostic: BLAPR10MB4884: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: ucxoMeSg03HfKvQ74qt/5pnCb7DqKhU5eUWXos0SgXTVJiEkAZFp1CWCSJFx1pMG4QnCy19B5RacG2Cn9RFVBQ+l7//dYAAifG7/ZkWCC7anjYJcb/Zm6H0xIVH0u4Dh+vag6DTzvYFQEgjH0Hx3JYFrLzCi1I8+HjHIqBvn+p+Q1g+4B6nWilCausT5F4gf5EIs7hzbMWeuRyJzRHpGklvSp8x2ix52lFyjFnwJBe6DY2Lo3HLqdQRt7YGUeWoluoq6aOaBd1/B8vGQJt3oJAqTMwJVqlurhQSmGMzHAj4vti6XDrb+VcHQZcyFeGTZ09iX4w6dIo7jWf1wHopmFog4sZ8j6+44mBGiyOtHgS7guwoU33OrpCJfTmtfOaOoOPI9v9XT3ivpswbq2igsS4nFcCGW9HZgtezMVye2sHw0E1gmwYry+bxa5w8MkVwqOfHk94rj+ENcFZ/I0SPAs1eIEgAa/Mtx+XmckmwODv+6CMPMWle1vPhtKT6LyNlccVG93X5O1de819MjhHzjMeYSVU0KrQYBXcU4ztst5bd7dM1oQE+WeP99U4gMvf2BqTaXenGiCmqm9+JxhUN0boShCFS978bxuUHUuhmL45MzjTNFOB3EpBoBXxslkIpAXK0CObifmvsfPQTOp39wGXS0Vnp0hgCvBWgBc6TooXwhAvNPG9qcE73SGPSXMi671xoe96pQrsOpe3+JqRxReA== 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:(13230001)(366004)(66476007)(86362001)(52116002)(8676002)(6666004)(6506007)(8936002)(103116003)(66946007)(83380400001)(66556008)(508600001)(4326008)(2616005)(38100700002)(1076003)(186003)(26005)(54906003)(2906002)(5660300002)(6486002)(38350700002)(6916009)(36756003)(316002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nO6rmJCpwVgiNVBJc6HkOKarNnUJ2w43PuCQIbIAaLB3rsQ42qW7xzxqly0gaCL4TRNrfT9w1I1VlopJwpvlprGrZdjSR/F6ZifMsGu+TM8Q2u1g+sa3XR57k3KqgEdOgBS32i/h9XsCVAfd0ntnk/J2jTWG7W+YuhrQQzUCADvJiUu5DGfNJruacZ5ajsgM++Zrm9ld/8S/XIqvkpOWfKFDw0U412wryVbfT/NRc9twofPeta2XDPGYGs3IDsvWAw1s2YMrYxiAFm3KWCoDjceocKIAYS+gmsVrfEQycxHJEjTsAuyzu5q9ZobYALXaA9LoE+5/1VeFj8g9SGQAVaSxVBhZ52cqMWl/KBYOuTx5A9/Q0uMt2pjZ2PLxQtTGQjJ9LwdrNdTjGSdIGNjgmatr5REtc6wUA67IFrIhuVw2pWq3a05x3xQ9pNK7vWldxt1UWWg6GKrvwXHAfdEZoXmXHLM9tG9MQcnT/WcgOg0czchcvbgV8XEmxAuw3B0aFfs2spptHV9vuWR8VIxZwWynl0Tcd3twJCwLK23hunJUF18Sw2Lb4qcGpPuTqCUSlbPt7QEdpcYa+SngH+wFfoYqxjD27/loeFaqzHKAJPkCXfBZUs/dg+q5tjjS5j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exchange-CrossTenant-Network-Message-Id: 0a31cfea-42a2-4e54-95ff-08d9ec21e610 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 23:14:18.8964 (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: 6S0zAcyCq3CYjRMRUQ7NO6ncJe5QnVil3EO75o2MsWbEMG4N4chiNKmJx/nIoI6ydAnb2OnVNKueQPMbtX0bT/RNoQQKnHYnPDa/enZGzTQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4884 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10253 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202090121 X-Proofpoint-GUID: zibqtQpcc6YnNWemx6tb3GRAy9FmN7rv X-Proofpoint-ORIG-GUID: zibqtQpcc6YnNWemx6tb3GRAy9FmN7rv 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(). Signed-off-by: Konstantin Khlebnikov Signed-off-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 8809643a4d5b..e98079ed86be 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1530,6 +1530,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)) { @@ -1776,6 +1778,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; @@ -3256,6 +3262,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);