Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3144249rwi; Sun, 16 Oct 2022 06:04:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61eiLamhBOC1i3VpQxnK23H0rOoXMZOr6dSH/q6gVXjwgNnFT+/Z7zsyyWSsOiGdBvr3Fj X-Received: by 2002:a17:907:8a17:b0:782:6e72:7aba with SMTP id sc23-20020a1709078a1700b007826e727abamr5229352ejc.474.1665925471605; Sun, 16 Oct 2022 06:04:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665925471; cv=pass; d=google.com; s=arc-20160816; b=TjS0H67xt7AX0CWWNuWcWM48kGmqEEmEpQ8UHPkPSR8mgKWEoVO+bfvPox3NM4OfoB HRKywMfyOcOc2nqUmGr0eJDRUz8AhaGgNJA86yDFVEN7zuW6sqKHpSOi0RHo8J4X+PkF yxY991Wm14Zyx8OpexF6uvCrkw9bMAcvF8P/xq8Vg4g8wcv/vYWxqTdXdg7XRg/NOwwr ffizYldFqcUC9iXfVUD1dO5EqBjzDZv7nlpqC43bp06Blt7KNe1ng3nTjzX2TQ5zQ4Fd zb7Z26pxN0z7P46jred/jQMKWcSUyyro2SsOG8oPjJ2Yhoc5f/KWOb+kynY4ZlP2ofTm zJzA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a05640211c900b00458c0c36dd3si8498725edw.65.2022.10.16.06.04.05; Sun, 16 Oct 2022 06:04:31 -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 + 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 ); 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 ; 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 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 Subject: [PATCH] erofs: protect s_inodes with s_inode_list_lock Date: Sun, 16 Oct 2022 20:37:27 +0800 Message-ID: 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: edA3GGXdf9DbAUizvnHZRSKOFN0KcoWJ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cvP6s+INz/zMlMzzxJvExWpJVzjdnmTUk5U4Knx/M+Tg/I1g?= =?us-ascii?Q?n1DJIZVNmUWlfgocq9wnn8FXKJswSH5SxlrGYdH+yMLVTKK9OJ2z/Opmb4Qj?= =?us-ascii?Q?F6rVUrV8iDZ1fSVBYECk1yNbNoE328xH/jiWukEexA=3D=3D?= 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); + 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; -- 2.25.1