Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5078907rwb; Sun, 13 Nov 2022 21:20:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf7h9SBGikAK4YiX32OYm9UNWBcrFhzDM5MaPgMZEWiBTzgKL1SM7fNMF7Hz/+inLOUeiwff X-Received: by 2002:a17:902:cf06:b0:178:7040:9917 with SMTP id i6-20020a170902cf0600b0017870409917mr12233444plg.109.1668403239305; Sun, 13 Nov 2022 21:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668403239; cv=none; d=google.com; s=arc-20160816; b=OsZc9QECi2FsaXL+sbwvlN9DOueWTKC+uoZeI/jA/6tKhlCwEmp81MhF/EEEcR6Mlv /aXtzbCysj8VmXPoHm9v1QjQGsGCTe+cN0XnFE1DSR5cdTe0UHwvOn2h26gyZ8U1293q pBj2/FalmGEES/ku6nEWdUFmQd5CB06tGcmkdN8w0ID8CW+fceBFMg6M4LlUx6tfypaS dzc8kb57yQW53eTkEUskPJ7FVy3fZTEIIpc4uQkDoAWBJQJP7vL50bExf8gDDDw0OhZ1 UV7YWUBbazUTyHeZvThJwxPkNmUgVrEoAg94w7G/pNcWCNQME3Xl6Ap/TmKcPl9MQ/5d W3NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dkcpciNK9YxajzbfzLobehcyKvXgMbvcOqQ1Tnfdkfk=; b=KT1Nvdo6XizcAewScoWyCHk9HagWdXT1Ke9G00JqZDB47ydPV2PhXMnyPbXKRJbE9m SgGy7VQgK3YWYWjELSNtmI6arRTaUB0pI9QdRTDoaVk+lCPBiaByhTImvaxOpGV/H8EV A2214YlgQHd/f/A8Q9xLZRw19q1I5Lgp3Qz3o/W1GfzeLhzHUBUTLUtyLw669fQEHWEL nU9Fk5u5fBzV4PCmWhjK5f1DUgbJIrGSWZV94+FpKvA1J8s8m2u84C0L/Q3uDOyOsoNf fWXu10CJFRPpjy9Mph11oeRPfNcJqh3szSPQcHPpiLvaXF8Gw79sRBdowMs7e+NIDzF6 qgRA== 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 n11-20020a170902d2cb00b001871c762261si9970847plc.189.2022.11.13.21.20.26; Sun, 13 Nov 2022 21:20:39 -0800 (PST) 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 S235855AbiKNEmm (ORCPT + 89 others); Sun, 13 Nov 2022 23:42:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235851AbiKNEmh (ORCPT ); Sun, 13 Nov 2022 23:42:37 -0500 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D88BC167EE for ; Sun, 13 Nov 2022 20:42:35 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VUgLRrf_1668400950; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VUgLRrf_1668400950) by smtp.aliyun-inc.com; Mon, 14 Nov 2022 12:42:32 +0800 Date: Mon, 14 Nov 2022 12:42:29 +0800 From: Gao Xiang To: Jingbo Xu Cc: xiang@kernel.org, chao@kernel.org, yinxin.x@bytedance.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, dhowells@redhat.com Subject: Re: [PATCH] erofs: fix missing xas_retry() in fscache mode Message-ID: References: <20221111090813.72068-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221111090813.72068-1-jefflexu@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, 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 Fri, Nov 11, 2022 at 05:08:13PM +0800, Jingbo Xu wrote: > The xarray iteration only holds RCU and thus may encounter > XA_RETRY_ENTRY if there's process modifying the xarray concurrently. > This will cause oops when referring to the invalid entry. > > Fix this by adding the missing xas_retry(), which will make the > iteration wind back to the root node if XA_RETRY_ENTRY is encountered. > > Fixes: d435d53228dd ("erofs: change to use asynchronous io for fscache readpage/readahead") > Signed-off-by: Jingbo Xu Reviewed-by: Gao Xiang Thanks, Gao Xiang > --- > fs/erofs/fscache.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c > index fe05bc51f9f2..458c1c70ef30 100644 > --- a/fs/erofs/fscache.c > +++ b/fs/erofs/fscache.c > @@ -75,11 +75,15 @@ static void erofs_fscache_rreq_unlock_folios(struct netfs_io_request *rreq) > > rcu_read_lock(); > xas_for_each(&xas, folio, last_page) { > - unsigned int pgpos = > - (folio_index(folio) - start_page) * PAGE_SIZE; > - unsigned int pgend = pgpos + folio_size(folio); > + unsigned int pgpos, pgend; > bool pg_failed = false; > > + if (xas_retry(&xas, folio)) > + continue; > + > + pgpos = (folio_index(folio) - start_page) * PAGE_SIZE; > + pgend = pgpos + folio_size(folio); > + > for (;;) { > if (!subreq) { > pg_failed = true; > -- > 2.19.1.6.gb485710b