From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F403C2D0DB for ; Sat, 25 Jan 2020 19:09:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0B8AA20838 for ; Sat, 25 Jan 2020 19:09:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fFmYgDNN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B8AA20838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 658246B0005; Sat, 25 Jan 2020 14:09:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 608C86B0006; Sat, 25 Jan 2020 14:09:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51F3E6B0007; Sat, 25 Jan 2020 14:09:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 3CBE66B0005 for ; Sat, 25 Jan 2020 14:09:57 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id D28D5824559C for ; Sat, 25 Jan 2020 19:09:56 +0000 (UTC) X-FDA: 76417096392.06.wing86_39ad7bf84c953 X-HE-Tag: wing86_39ad7bf84c953 X-Filterd-Recvd-Size: 3324 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Sat, 25 Jan 2020 19:09:56 +0000 (UTC) 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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!