Message ID | TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1000348wrs; Sun, 16 Oct 2022 05:44:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44018ijgtIrMLvFI8zGdxYz+e8g/xCvUa0ELQRcpbnodCz0dWl3QxqUpnTVuLwLFBJ9jJj X-Received: by 2002:a17:906:401:b0:73d:af73:b78 with SMTP id d1-20020a170906040100b0073daf730b78mr5164757eja.122.1665924287771; Sun, 16 Oct 2022 05:44:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665924287; cv=pass; d=google.com; s=arc-20160816; b=qFDVmJtRH4csLP1ELdG6g8xNTWeZ8BUsyT7RrpCvtIQw/p9qG9PcfwTvq4eCiSvHwE 1uOBGArfC1BdE8APim1UdH5qAHj55LA1WuEuGOLnvMix4ZeSD8islthlCDlnFrZH7oJT jpf/930ZzhWjmLvVaWr+B9Xy97NZylaqOGgSZnIkXupu8+AViV1FipetSuhS3eJ8/4hN fV5bLxDHr1jv97MOvciH2PfqO44YM2fr2xS1efcp/7oX2l7cl7PIFROHB4o21P6UjVnK cWSuSTTW2Ee2m03zAiz5qEM6a1obsqiK0RKiEnrpcJgHgrS6XYwnnigTgV+7rwzQxAli vWsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=WK7gp5/Aa/+dSRRDiVrvrlJIjgTrN7AtJ42tWhg73Oc=; b=wOHM6bUgwUVWEXIq6NF5cCK0ZGEzIyxRVTFVcXzW3/jFNFgRV0C6heHR02wZ18U/1b yDbB0dFjJv9jaECNYGaeakdbX7+K1CaDb0byPDh2nOMgSFS07A1Ho5EPUjKZPGZypak8 7OYcUxOcP9RRjklnsonDU6/r0rnXF8VGaF1s5e46KMyKO3jFmMzFGTGWp1qmVN2dWkHM GeWCbXLta1/lKQ47zT2BmY2cqxCJvvaGuUVabP7RxGP0gvG0Ky7hJzS5B9aqzISrlhv/ q0LufAv/JFVfs1N2sPhsywoG+ju0zsTgeYdg5ny9PorBUg17fAqPoCANprI2D3tbwU1r OWWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="Yq/ONTiV"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg11-20020a170907320b00b007813b1924ccsi6978091ejb.934.2022.10.16.05.44.16; Sun, 16 Oct 2022 05:44:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="Yq/ONTiV"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbiJPMhq (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Sun, 16 Oct 2022 08:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiJPMhp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 16 Oct 2022 08:37:45 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2084.outbound.protection.outlook.com [40.92.98.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 160BF36DC9 for <linux-kernel@vger.kernel.org>; Sun, 16 Oct 2022 05:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uud50/3g0yiBR1vN8igjogIINwxVHhVByR3vAMfJzqWPdGzKCwh32tKS3LM+KOXK+HMJ1Obmyl2K0P9o2iw8ykQ2qynCwjuw7zW/onSsViQladNlGBxhVOdnLGQZBekEiFvzotG9ahCWsg8Qg0e0ZBG4JmqN1ShToPpJyOY6Bf7mmCi2bUmfkMGQgqtXbnygbf/1LK9hl8OpzJEeUXzdcNVjRfm4sv6y5zJCKmz17Y5hUYwud918JHIiG8aFJ4FPLsDD5lo/nqtUZ/j5vY0/nq6u/WCpvY0WPsKz2r6hXq0kpmVccWHvu4c2CrxHCOriFYh9ndJdiy8PrzAp0Hy5dg== 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=WK7gp5/Aa/+dSRRDiVrvrlJIjgTrN7AtJ42tWhg73Oc=; b=IQNGMv/iheVpKycsoXStkYO7HD2IZ6IwwTvdlpdRF0jvtBsaZvCznagC+8UCtxDumk+Xijk068w6LTvMGHX1XWUk64zMvBD6/+JE0YUVARD+QmmP+4CUn/YZ9t5PTNffPMZexYhy45EvI61uw4T00QVI08AD1YmI2rFQDs+eVvubQeaHPasDZ/OeJ8V+PBJUcCfJaDz+wL8R+5CXNhL9F/fIKzca76c4ux254DYqkWalbAfO2NsZKduiRmqrh8701cD/6HGucJpjKP2eELWQ8cE+KkfGn6YYVfEMI477JsLhm397e/2qLnBP830UleSpp42nsDuZkOULRXlxNwmgaA== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WK7gp5/Aa/+dSRRDiVrvrlJIjgTrN7AtJ42tWhg73Oc=; b=Yq/ONTiVRQD5t3j85umKjNN0BCIgaXaeAMSeMDV3iHGbHFdSYlJQx6f/uiRY4klHF/eUuymTQQciI6Rps4zVcfa+swccZoyoL5Di2KyRZez7ia3pkO4vrZt95Aj9knUMC96TNcR/PbGFGhauK+99oD5Cy8D663bZeukbpauJJotmojOOPKhSUY5eN4r6+VOPCiDz+mzgvz8oSArop1btSRNB+LN4jZ4feLbathlEFBs9GQiobC5pNapPX7/9GgIKALY2iNlLtdi/3zabXOFKU/QVcFH0IA38l9ec/QLlmrAybcGrRZHjz8j6Onygkcj3NUhVvOh8AO11TmdwoLsdQQ== Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) by OS3P286MB1995.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1a2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Sun, 16 Oct 2022 12:37:38 +0000 Received: from TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::4722:62da:4861:9d73]) by TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM ([fe80::4722:62da:4861:9d73%3]) with mapi id 15.20.5723.032; Sun, 16 Oct 2022 12:37:38 +0000 From: Dawei Li <set_pte_at@outlook.com> To: xiang@kernel.org, chao@kernel.org Cc: huyue2@coolpad.com, jefflexu@linux.alibaba.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Dawei Li <set_pte_at@outlook.com> Subject: [PATCH] erofs: protect s_inodes with s_inode_list_lock Date: Sun, 16 Oct 2022 20:37:27 +0800 Message-ID: <TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [PbdqvwTyeoR3jwn62LfPi26ITmOTXWFk] X-ClientProxiedBy: TYAPR04CA0013.apcprd04.prod.outlook.com (2603:1096:404:15::25) To TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::9) X-Microsoft-Original-Message-ID: <20221016123727.968140-1-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2323:EE_|OS3P286MB1995:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fe8c52a-684a-4826-27e4-08daaf733582 X-MS-Exchange-SLBlob-MailProps: rYPt1fhvLTUem4+YyY73AHtcx1Y7uWZY7h8dTY5gRgdLwDc/DfIlDBdyAyhkMh2RyyrUK3oItCkCUNAecS6PDZlRSCADoGgzPK/D8AphLX/CM8c7qtsHUK/7m24ivIwMOKmF/eDZWvt0TtS9YhgbbntMGvTuSCHCxNdcnJlkRBP8BWHVbmVKLtg5V+RwIAjQUUEAYVUmExqtzcwumcWik5rmK47FXWgNy+wBVUUtgEBL+Bc1jMC7Rk3vNSL7PFy3o5ohPrBb+RrwtpAyCqaAUNlCH3hXRMJ3hI0IjupFctZBF7/vSYHyCrf/izUlYEIdz60IcD3zeHueEG3eRK9UMqhUIYXjwUGNBoW7/aH6aeFxrOkBbCojCCsTN/6y9ViOlX8FSupfp5HSCjKuNFaDc+GC+GoBwA4C8EvxtUjDyxYv/Z2tI08glIPPA1vVBYMDRBR9B+wb70pmbL7lgeX0qmnUcdklS/a1oPbBRiReIjd+lpOTY4YoO3CwhtbMa+uvAd9lYFtjX/Gwubzv+onKbWCvCKr8AuGsvIbK5gOdKu4PYsouipWRdefk0omgxfw4gYXVgKrVfWcTP9/Vv2hjfhtmU6JcboRddSieVYshR7a8o0atfFkFRcYNMnK2XYW7cCjwaCKFtywfRH9InJDmyAmwe/WZecVpOeG0PXzVBZVnZ9XZQZYEXeVSbLpq1al0A162iltt8RvkcG5Jdjfd4g== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: edA3GGXdf9DbAUizvnHZRSKOFN0KcoWJ1PPVSUtCuJb8/zJpQdYANJaXeVp6ZSjsAOrMZ8XPTuO3oIC2oq3aJ/lO+fC2ZGK5q8siwxS1sGFac/6sv0N+nne/oXEbVzpygK7GvRfTFupoznsWookwY5FUHPVxlfWDZhi8U3rSYiicUrdR+OwP1YawTihSOXW3mhjoJ8hoAbLhbxxhIj0CQ40qCY0+ccRx/7wt+qMnGn8vBLVBo2L0GhFsQtqs+191YyDl3oRm4QvmYMeME8zCrydwUK8BjpAvuzUY4wokMWB7xYI4zGlH78c299UnkiK3yyilQuKFcRjjhF/z3pp5BhPX2WYZOJOcPXZY0CoG9QPwYKDINJC/Ic9x9FH/oGU5mq9UUcOkMfzA+LgEzfjfEtg8+jV2fPUsLWazBX3PcE+2E1U72R4mciw+N+6j58LaI95dLJd6ZJw/uHcc+WC9WkXUIUKJeonTSeRnQMLkfbjCf3SiHpj/LKEm7bxvX3IpQ8UWeOp/WqVt+bxJEhh0LbDKXB+4NoVdpLKbgl0Wv2ScG/crloAYmXRF57ep+oncEFU31prn6sK0w9m3AR0/WG5kLDurmcp6v6PPpfXZ492gAR/5d/FRPNWlpK56VR1YkZkIqfg105iy0ArBQcBB2XAQ79olVc9vgnUoGDIY3gZVx0deihvnZPZHmJ3eR3tj X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AkUkBAqEhjYXSaWyqxx7QLzdSxsjKUGG8DuKxZEuKU2nyxrxFTotZCSRCNYQbBScwQJVNgM2je91KACn/JPLJNF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zxJvExWpJVzjdnmTUk5U4Knx/M+Tg/I1gn1DJIZVNmUWlfgocq9wnn8FXKJswSH5SxlrGYdH+yMLVTKK9OJ2z/Opmb4QjF6rVUrV8iDZ1fSVBYECk1yNbNoE328xH/jiWukEexA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fe8c52a-684a-4826-27e4-08daaf733582 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2022 12:37:38.2042 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB1995 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746848226086745966?= X-GMAIL-MSGID: =?utf-8?q?1746848226086745966?= |
Series |
erofs: protect s_inodes with s_inode_list_lock
|
|
Commit Message
Dawei Li
Oct. 16, 2022, 12:37 p.m. UTC
s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.
base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
fs/erofs/fscache.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
在 2022/10/16 20:37, Dawei Li 写道: > s_inodes is superblock-specific resource, which should be > protected by sb's specific lock s_inode_list_lock. > > base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1 > > Signed-off-by: Dawei Li <set_pte_at@outlook.com> > --- > fs/erofs/fscache.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c > index 998cd26a1b3b..bbf5268440df 100644 > --- a/fs/erofs/fscache.c > +++ b/fs/erofs/fscache.c > @@ -589,15 +589,18 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb, > struct erofs_domain *domain = EROFS_SB(sb)->domain; > struct super_block *psb = erofs_pseudo_mnt->mnt_sb; > > - mutex_lock(&erofs_domain_cookies_lock); Hi Dawei, Thanks for catching this. I would suggest holding this mutex lock during inode searches and inserts to avoid the following case: P1 P2 lock inode_list lock traverse sb->s_inodes unlock inode_list lock lock inode_list traverse sb->s_inodes unlock inode_list domain_init_cookie domain_init_cookie Thanks, Jia > + spin_lock(&psb->s_inode_list_lock); > list_for_each_entry(inode, &psb->s_inodes, i_sb_list) { > ctx = inode->i_private; > if (!ctx || ctx->domain != domain || strcmp(ctx->name, name)) > continue; > igrab(inode); > - mutex_unlock(&erofs_domain_cookies_lock); > + spin_unlock(&psb->s_inode_list_lock); > return ctx; > } > + spin_unlock(&psb->s_inode_list_lock); > + > + mutex_lock(&erofs_domain_cookies_lock); > ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode); > mutex_unlock(&erofs_domain_cookies_lock); > return ctx;
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 998cd26a1b3b..bbf5268440df 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -589,15 +589,18 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb, struct erofs_domain *domain = EROFS_SB(sb)->domain; struct super_block *psb = erofs_pseudo_mnt->mnt_sb; - mutex_lock(&erofs_domain_cookies_lock); + spin_lock(&psb->s_inode_list_lock); list_for_each_entry(inode, &psb->s_inodes, i_sb_list) { ctx = inode->i_private; if (!ctx || ctx->domain != domain || strcmp(ctx->name, name)) continue; igrab(inode); - mutex_unlock(&erofs_domain_cookies_lock); + spin_unlock(&psb->s_inode_list_lock); return ctx; } + spin_unlock(&psb->s_inode_list_lock); + + mutex_lock(&erofs_domain_cookies_lock); ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode); mutex_unlock(&erofs_domain_cookies_lock); return ctx;