Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1894896ybl; Sat, 25 Jan 2020 11:10:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwPP0Tex1cauTdV+7IyT920MmTEpRNvbR6uwMHN2pLfhkwVBOdScIl0UwRhq+fOYGpupcuY X-Received: by 2002:aca:53c6:: with SMTP id h189mr3080103oib.11.1579979457237; Sat, 25 Jan 2020 11:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579979457; cv=none; d=google.com; s=arc-20160816; b=WOJvpWvv0ESWIuOxtXpon9J6gIJMNVrUQRTD/MI0FJxotwq00q3dcB9XWEbzMzGWkl B0NALECdAzUbudGLB90j10I4yGGael4/p/kwaHF4ot5H3j0edrDJaL1JlkDogxbiDt2P 805W/kWStjpn1pqJGB5nGkEIuXoDgFY3ralGclDjnFymz6q4xBUHPNTV6VGnrbKJESjp kI8E5z4bRj/KaCoMElCNvozKL3VNDDSPnEKMd0tg7EkOdLfbqFiWvCX4qkBny0d0SJLp 0iEcGOehzMxUNa+JzCVYSvthfblUxXrUZrxEBLms+h1B1lT2ggBbQDPYR4q5+kCLKBZV m5ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=My5//NJQysYMT+Wea8KLUdQ/Ww11h9Uv4t+v7jFecDU=; b=F2+0uxNJcjUuHegsxD5H0ZpL3lb0ppZiG/5rm4ODqMEo4d6HeLT4r2e7H04Yo7kuQJ pxw2w4ytUtMxlkeMvE5TKV6Cvcv2tBWHIHWpbKqDsVdab4zy9OyKqbWGVrKvXso+hz2y kPLljGZxyWhYGGM7KkR6AiMtweL5xNnGrusDIAHhivd4eCNs3UsMw2G6ruozGBrQOvp3 f33Rw9tma1yLclYB3TIapu6rvLq7waKjZGZ1Bi8RZ87JanbR0GMpy68WKROinF62ORR4 CspzzFHDny+vGhqRit/uyPikV3CM9uM8YLJar8eyjz+wrsLYZBOBYBQjP8I7y0eOpaeO ekIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fFmYgDNN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y26si4775083otk.315.2020.01.25.11.10.44; Sat, 25 Jan 2020 11:10:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fFmYgDNN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726772AbgAYTJw (ORCPT + 99 others); Sat, 25 Jan 2020 14:09:52 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57876 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgAYTJw (ORCPT ); Sat, 25 Jan 2020 14:09:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=My5//NJQysYMT+Wea8KLUdQ/Ww11h9Uv4t+v7jFecDU=; b=fFmYgDNNvt77kQV4xKWYDlosj tCRnFy39irUUteCkoPzUlBM/Wm5FkejDjX1gLGOh1AOSU9xWtasFCl6Yk4gnJp6YHhDtEnfffUKLF EBp2IlTESitbhAv7sRphU+1LFGbjMg61Nw3xVl/bb+yYBk+izXwb/6w33+zt3U0xxf/W/ggVQJ07u C+r9ejvmR76/vpb7qv/B3UnJlBSOjzyCBm6eBaw8FGfOYR0uAYkhizpzn61a5zTykX2GN2qAM6O8x MUsWC+f6ZstKPT6dK6hp2fpwysNavccb6La+1kyQ4NeJT5uZiEB2XGltOcYtJtuxj3lzmJR+FTww1 4eL0GLFtA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ivQoZ-00036i-67; Sat, 25 Jan 2020 19:09:51 +0000 Date: Sat, 25 Jan 2020 11:09:51 -0800 From: Matthew Wilcox To: Gao Xiang Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/12] erofs: Convert uncompressed files from readpages to readahead Message-ID: <20200125190951.GN4675@bombadil.infradead.org> References: <20200125013553.24899-1-willy@infradead.org> <20200125013553.24899-8-willy@infradead.org> <20200125015323.GA9918@hsiangkao-HP-ZHAN-66-Pro-G1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200125015323.GA9918@hsiangkao-HP-ZHAN-66-Pro-G1> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 25, 2020 at 09:53:29AM +0800, Gao Xiang wrote: > > + /* all the page errors are ignored when readahead */ > > + if (IS_ERR(bio)) { > > + pr_err("%s, readahead error at page %lu of nid %llu\n", > > + __func__, page->index, > > + EROFS_I(mapping->host)->nid); > > > > - bio = NULL; > > - } > > + bio = NULL; > > + put_page(page); > > Out of curiously, some little question... Why we need put_page(page) twice > if erofs_read_raw_page returns with error... > > One put_page(page) is used as a temporary reference count for this request, > we could put_page(page) in advance since pages are still locked before endio. > > Another put_page(page) is used for page cache xarray. I think in this case > the page has been successfully inserted to the page cache anyway, after erroring > out it will trigger .readpage again... so probably we need to keep this > refcount count for page cache xarray? > > If I'm missing something, kindly correct me if I'm wrong.... You're quite right. After readahead has completed, the page should have a refcount of 1 and be unlocked. If we hit an error, the page should be !uptodate. It doesn't matter whether we set PageError or not in this case; filemap_fault() will ClearPageError() before retrying if the page is !uptodate. This extra put_page() is wrong, and I'll remove it from the next version. Thanks!