Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp968578ybv; Wed, 19 Feb 2020 13:03:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwT02hfZ95cW1UWuZB5jhFi5w/DwYw/XLLqwDOfgoc0gHRJZn9ZJD4T2rH3jY4jP7WUAJiW X-Received: by 2002:a9d:7a56:: with SMTP id z22mr19788548otm.201.1582146193663; Wed, 19 Feb 2020 13:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582146193; cv=none; d=google.com; s=arc-20160816; b=SzfkJvTKjhmzcgGZvpLPg3YlLlc+KdzBUnMZj4cCi1B977ruOqMyE5YZynZ6YG4zE3 zeKol1IxNYtHdT7RjhNORRj0iWG7vYzEEx/Lrlrtt83LY5l+Etxqc3u9bw9vsbTOg8iy cNuiTFR3UaramiiwRIxDj9WTM/znK00ZMZZjKJfD13UsScCWi6TaIiQzeJd1jPgecY77 VCw1Qz4KHd6lESljqK868z7o9VDaZxY4HBniRwPmCU6vnMkN5uxlyy7taRTydYUtxBUd WrW8lsogarZWN7Cc3dkK6G0/i7Tj0dAbee9a5P/L9BJNmBp1sv/6ErRGsIBuNClrKa3N U0YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vmBYSWiADbzhrnAmLI0opbogq5zBVEJUJhOq4kDcPa8=; b=ZBaQ/9fhIw2THsN33pN+cHiQaRnp9IVlKaf5EHp9K614E8We0UDvNho/K3QP/S5e6M BSH5lRlRfSs5Spi/yMEowK1CIlGfCeakliscMHeDiPEI13xYKH0HNcVDplQWj/54dbUA NvNSfJAMS8fpjOEbA+sHhJgrUSt2tfeByJS1sbl2uAbJuTQ6tqI0yOdlNFco4mOqewmg Wj/u40h2GrpUO16swx9vF4X+XJC3983tfW95fDY1ram4J0KjwxPupxTESo4zFRytmQf8 lI7CVc2VF6l+Bh4sTIgLN/vOhYoHwkin2hNWYK6CZP31e8PmFwC9glJdAYYWAwXAuE8Z ABPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=biXztY+3; 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 c11si10017753oic.20.2020.02.19.13.03.01; Wed, 19 Feb 2020 13:03:13 -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=biXztY+3; 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 S1728062AbgBSVCm (ORCPT + 99 others); Wed, 19 Feb 2020 16:02:42 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:35886 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727462AbgBSVBG (ORCPT ); Wed, 19 Feb 2020 16:01:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vmBYSWiADbzhrnAmLI0opbogq5zBVEJUJhOq4kDcPa8=; b=biXztY+3Z9WN5sTV1wTWo+FYtC fyTLTZ2+VVA1QPrvOIzyXZq3siFLwW97EtZ5Hdy/Um6FDkRN/R0v8XLsBlBrMyXp/DHLPmZQf9uBd oWgoSp52Sqhh72al/g5OWZ86Y4OZYKezFsUCtP7/Y6JjTk1KkthUkLhOAHgO+axb4+ZTXyi2MVMdC 1w+jqtDWZsAkWFckpZiNhzBHA1V60OjeOaHUSSltkFLEzv/HuZZ7ynXRe2J9/mNLqA9kETj5kHu2f lfRgSf/ZiGlLtwaAhVPKoSDqInGyKtmCBHAZWydrKjH/INNkasmnjZAiK6s7wD5sniPUvzo3nkaRq 7C1aTKPQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4WSv-0008UE-9y; Wed, 19 Feb 2020 21:01:05 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, ocfs2-devel@oss.oracle.com, linux-xfs@vger.kernel.org, Gao Xiang , Dave Chinner Subject: [PATCH v7 16/24] erofs: Convert compressed files from readpages to readahead Date: Wed, 19 Feb 2020 13:00:55 -0800 Message-Id: <20200219210103.32400-17-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200219210103.32400-1-willy@infradead.org> References: <20200219210103.32400-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Matthew Wilcox (Oracle)" Use the new readahead operation in erofs. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Gao Xiang Reviewed-by: Dave Chinner --- fs/erofs/zdata.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 17f45fcb8c5c..e64d8ab0900d 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1303,28 +1303,23 @@ static bool should_decompress_synchronously(struct erofs_sb_info *sbi, return nr <= sbi->max_sync_decompress_pages; } -static int z_erofs_readpages(struct file *filp, struct address_space *mapping, - struct list_head *pages, unsigned int nr_pages) +static void z_erofs_readahead(struct readahead_control *rac) { - struct inode *const inode = mapping->host; + struct inode *const inode = rac->mapping->host; struct erofs_sb_info *const sbi = EROFS_I_SB(inode); - bool sync = should_decompress_synchronously(sbi, nr_pages); + bool sync = should_decompress_synchronously(sbi, readahead_count(rac)); struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode); - gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL); - struct page *head = NULL; + struct page *page, *head = NULL; LIST_HEAD(pagepool); - trace_erofs_readpages(mapping->host, lru_to_page(pages)->index, - nr_pages, false); + trace_erofs_readpages(inode, readahead_index(rac), + readahead_count(rac), false); - f.headoffset = (erofs_off_t)lru_to_page(pages)->index << PAGE_SHIFT; - - for (; nr_pages; --nr_pages) { - struct page *page = lru_to_page(pages); + f.headoffset = readahead_pos(rac); + while ((page = readahead_page(rac))) { prefetchw(&page->flags); - list_del(&page->lru); /* * A pure asynchronous readahead is indicated if @@ -1333,11 +1328,6 @@ static int z_erofs_readpages(struct file *filp, struct address_space *mapping, */ sync &= !(PageReadahead(page) && !head); - if (add_to_page_cache_lru(page, mapping, page->index, gfp)) { - list_add(&page->lru, &pagepool); - continue; - } - set_page_private(page, (unsigned long)head); head = page; } @@ -1366,11 +1356,10 @@ static int z_erofs_readpages(struct file *filp, struct address_space *mapping, /* clean up the remaining free pages */ put_pages_list(&pagepool); - return 0; } const struct address_space_operations z_erofs_aops = { .readpage = z_erofs_readpage, - .readpages = z_erofs_readpages, + .readahead = z_erofs_readahead, }; -- 2.25.0