Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3949244rwi; Sun, 16 Oct 2022 22:14:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vS7t/A8aXT7FaBqeNBCKbIiss9DR1lrCjpKya62wjDCLGdwI8UrJfO5NWO2k2m6Uhy72D X-Received: by 2002:a17:906:7944:b0:73c:838:ac3d with SMTP id l4-20020a170906794400b0073c0838ac3dmr7202906ejo.242.1665983649312; Sun, 16 Oct 2022 22:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665983649; cv=none; d=google.com; s=arc-20160816; b=uGHhMnKgGDmqsJ1uSU/1TYOvunCqhsY8Z5KGpsn8AwOG/xc+tWD2FPMlwrBNSU3aws UL2EufxbhejSR0H5FJgGQtKa0BXfuHsGf4EJ+xTcB4GiqEl2PvQoWNuY4sFWcXLz69eb gbsXd0s+ZM6Iyc29VqeYBifhFv1mi1DmAKlZqNPGorlNAtcDSRnrQfnqM6vXuhdY7WrN nmrAx0E2LibBhCHFIpZWQGDBOQwcx3vNjt8cNX2lRm4hDYn50+0V2MRFmIglwYYQqf8d thwi2NSqKwR0LIRYo00mHJsOxTW21J6hTHqq4JfLz9n/PJwbjEqDkOmDFM3Zav955Ngq 9U4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=nYvjpm8M61jqbsFXFZtKPqg1wXegMjfmZKzqeo8Dvgc=; b=mwZaqdBeRPT0hs+CVkwSPsH8UGSxLavLtr0s/xpGNiIErtECNTwz7GvjeOHT29r06a xEAUOB0niZth+hgqcXkiPvjjeRwB/Y46Q2P27VNTZIrQexV7KQRp6qGOWlSUfPdCFlMM rzo0vuiNw8kuFefew2bsiXKWx96YoHwyH8ruzWw9cGMK8PEE8RMahCiEmztb6EUCxUQi e1B9ztEPnLd7dwMLj/UMmwXwodZv+jAYY0mmFlrk7P/EUt2U232ywUdzPnMEHFGhODL8 VSVeCQIUvYh+I3iBX/+x2UfosX6EnXRiBHG3lVG7QZ6irMzGhTy+T3/3Q5+a8Cg2GdyB UqzQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr17-20020a170906d55100b007800b181a0csi8116244ejc.300.2022.10.16.22.13.43; Sun, 16 Oct 2022 22:14:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiJQE7A (ORCPT + 99 others); Mon, 17 Oct 2022 00:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiJQE65 (ORCPT ); Mon, 17 Oct 2022 00:58:57 -0400 Received: from out199-10.us.a.mail.aliyun.com (out199-10.us.a.mail.aliyun.com [47.90.199.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242244F66E for ; Sun, 16 Oct 2022 21:58:55 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VSHTNAs_1665982730; Received: from 30.221.131.120(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VSHTNAs_1665982730) by smtp.aliyun-inc.com; Mon, 17 Oct 2022 12:58:51 +0800 Message-ID: Date: Mon, 17 Oct 2022 12:58:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock Content-Language: en-US To: Dawei Li , xiang@kernel.org, chao@kernel.org Cc: zhujia.zj@bytedance.com, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: From: JeffleXu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 On 10/17/22 9:55 AM, Dawei Li wrote: > s_inodes is superblock-specific resource, which should be > protected by sb's specific lock s_inode_list_lock. > > v2: update the locking mechanisim to protect mutual-exclusive access > both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the > reviewing comments from Jia Zhu. > > v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/ > > base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1 > > Signed-off-by: Dawei Li Fixes: 7d41963759fe ("erofs: Support sharing cookies in the same domain") LGTM. Reviewed-by: Jingbo Xu > --- > fs/erofs/fscache.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c > index 998cd26a1b3b..fe05bc51f9f2 100644 > --- a/fs/erofs/fscache.c > +++ b/fs/erofs/fscache.c > @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb, > 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); > + spin_unlock(&psb->s_inode_list_lock); > mutex_unlock(&erofs_domain_cookies_lock); > return ctx; > } > + spin_unlock(&psb->s_inode_list_lock); > ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode); > mutex_unlock(&erofs_domain_cookies_lock); > return ctx; -- Thanks, Jingbo