Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2501241pxb; Wed, 9 Feb 2022 21:52:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQP2K4MoGdaGr7K8RwVhAd+spYEKFQz2dIel8wMFIiWwkiuzIuWFgqnqOXnfnwbrpLhPeF X-Received: by 2002:a50:ab11:: with SMTP id s17mr6711651edc.208.1644472324433; Wed, 09 Feb 2022 21:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644472324; cv=none; d=google.com; s=arc-20160816; b=n5yzEPFZaJswrnAJpbssGwFvIRRLs7CdO23rPJBJ3SY41jhPGbsdvrqvLxzMGywcN7 oOJieSd1x8rAh/dwQpD1rnz6MYuhu1Jdzk5cwcUJOJbW14aHxZwqeqU4Ac/oUSp5Wp6b C7va+XSkWdsIcLA5CwhgdmglSy6Ypr+7BTer83lR0soJuDCx6hIgcUzSXqVx5j2sIOh4 Ve/HYXk67nftnG5eOp3elOMK8swGhYo0dqG5/QTdbzEQSwzZLIbYsQ3cRP0OLbcYLKUJ F+D8tb8JbOsNxUJSSCM5kW4/PVPEb+8S6ui6KGOR3eym4DqG5Sn8b0eYIS4VoeqYC3jK LK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=Tft3SoinWu7UxepEf8WEuD+UlaGfn26eHEwniJocVAs=; b=KXLVBOIDx5NIKS6KNIFR5+lVM37fwAegysCnmC0bQCQ0ta+EsasW0SpNqPlPZH3Bjz /PqTj8RnDOFjcPnScXQIKAKIkC2E69itfriQTpsPA+vO9dPTRhDjXzHH5KCuImn30UOW e3gXzcyPz/yI9hjKz1B35IGojwHVfnYKqRcfsgWxQ+ZogCh/LX2LZi4cUsuwSJUnnLiZ DaZfW7nHpqeEFW+s5DuXIXhKsdAmyb9WDTaj9Ct2Jziwuqc3xoOi04kkYLRUVHadfsKY 7eroEzzXjv3Pc+wJabZSmnzCGtjzDAtUvUltDsvU5yLb2nZZdwOMNDSC6fLJvU3kf5SF bSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=AZtdCcwJ; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p21si9887717edx.255.2022.02.09.21.51.36; Wed, 09 Feb 2022 21:52:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.de header.s=susede2_rsa header.b=AZtdCcwJ; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234330AbiBJFjP (ORCPT + 99 others); Thu, 10 Feb 2022 00:39:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbiBJFiw (ORCPT ); Thu, 10 Feb 2022 00:38:52 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5061D10CC; Wed, 9 Feb 2022 21:38:54 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D576F1F43F; Thu, 10 Feb 2022 05:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644471532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tft3SoinWu7UxepEf8WEuD+UlaGfn26eHEwniJocVAs=; b=AZtdCcwJujZVCHcdXkKOM6szi0SH98wyFfZVUIfLZbgfuKnWcUV9h+nOyBGfZYHb4fgg9q 0bzK8zlrysy2kvIK7aPM5QM5vklJlDnFMRJyEFrhh2ywPGPQAZRjcJ0eaWwg/TWCT1jT1c Y7P/mxpVQ0jyTZnT5empOfYlfVQmIKo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644471532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tft3SoinWu7UxepEf8WEuD+UlaGfn26eHEwniJocVAs=; b=yNiRicVz0d7OW6BOtosPuVbsxI1wCRGRy4fi5NKnYLY2dFaJO1i8uBQffBceecqdSDIthz JkyQL6tOSv8newBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4058513519; Thu, 10 Feb 2022 05:38:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AC9zO+SkBGLMOAAAMHmgww (envelope-from ); Thu, 10 Feb 2022 05:38:44 +0000 Subject: [PATCH 03/11] MM: improve cleanup when ->readpages doesn't process all pages. From: NeilBrown To: Andrew Morton , Jan Kara , Wu Fengguang , Jaegeuk Kim , Chao Yu , Jeff Layton , Ilya Dryomov , Miklos Szeredi , Trond Myklebust , Anna Schumaker , Ryusuke Konishi , "Darrick J. Wong" , Philipp Reisner , Lars Ellenberg , Paolo Valente , Jens Axboe Cc: linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, ceph-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Date: Thu, 10 Feb 2022 16:37:52 +1100 Message-ID: <164447147258.23354.15753542879688740872.stgit@noble.brown> In-Reply-To: <164447124918.23354.17858831070003318849.stgit@noble.brown> References: <164447124918.23354.17858831070003318849.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org If ->readpages doesn't process all the pages, then it is best to act as though they weren't requested so that a subsequent readahead can try again. So: - remove any 'ahead' pages from the page cache so they can be loaded with ->readahead() rather then multiple ->read()s - update the file_ra_state to reflect the reads that were actually submitted. This allows ->readpages() to abort early due e.g. to congestion, which will then allow us to remove the inode_read_congested() test from page_Cache_async_ra(). Signed-off-by: NeilBrown --- mm/readahead.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index c44b2957f59f..35a7ebfcb504 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -104,7 +104,13 @@ * for necessary resources (e.g. memory or indexing information) to * become available. Pages in the final ``async_size`` may be * considered less urgent and failure to read them is more acceptable. - * They will eventually be read individually using ->readpage(). + * In this case it is best to use delete_from_page_cache() to remove the + * pages from the page cache as is automatically done for pages that + * were not fetched with readahead_page(). This will allow a + * subsequent synchronous read ahead request to try them again. If they + * are left in the page cache, then they will be read individually using + * ->readpage(). + * */ #include @@ -226,8 +232,17 @@ static void read_pages(struct readahead_control *rac, struct list_head *pages, if (aops->readahead) { aops->readahead(rac); - /* Clean up the remaining pages */ + /* + * Clean up the remaining pages. The sizes in ->ra + * maybe be used to size next read-ahead, so make sure + * they accurately reflect what happened. + */ while ((page = readahead_page(rac))) { + rac->ra->size -= 1; + if (rac->ra->async_size > 0) { + rac->ra->async_size -= 1; + delete_from_page_cache(page); + } unlock_page(page); put_page(page); }