Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp588564ybz; Wed, 15 Apr 2020 14:38:34 -0700 (PDT) X-Google-Smtp-Source: APiQypJvmEQAPdv/R4yNg6Id3ReO5ZCcgZwQPKkQCe1LQMS3o9dk9fimuJHnDMjxiNhmc+EBkfcP X-Received: by 2002:a17:906:4bc9:: with SMTP id x9mr5131887ejv.27.1586986714360; Wed, 15 Apr 2020 14:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986714; cv=none; d=google.com; s=arc-20160816; b=p0gJWmeLBU5XhZuBJ+n6z6YIK5xwBY6xTit6ydYZDYiukAZXbmx6JqVqnAnMi301TD ykYpmiK9TWuBpkroIllV/U/JNoMCI/yHxE/u7wZoxkCMvqH62m+uq6m/ea4dxfpTFhfZ XyRNHzPXItgpmOEuXEDEVLjOqFWW/JNx7k3Nn/M1g9ws14nWhrRop6Ct1ftWJGHzMNGv XZG6aNoOwTlyZSMIAzkb0fBINxkA79PCVL1LiWmUej7xx5nZZOVM6VWyrL2cPUBrBeVZ kGME7KK+FSyWNQ2B39BXTwjhZIAg9xHGCb1caUjstXR+WyPF+wcqRsdcOG+qzHvx2+WD NTtw== 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=5xtzI73tsael5P9Mn13Ci8Ukj/IQUzznhyBGn3+PxwY=; b=aYr+dOrO047AuK7Yp4996dhBusADneDuJyK1kxCnXueGtgpyAnrLqIpamHOKNz5a4b Ywgi+VzlsD+0eegs6ZSFEcNba59SULyVYMpDf2f93TWBbDtWmX6w7tPdALaiUHkI1Fzh BeIR1YALNgKaU6mP+HVWExlNfEE2h8ZmfcygVnYOb2k553jBoScmHK+WKb7GuXYvNxuL R8dip3DS/3i1+dmSGPuuT8DkiW1LwV7SpOLxKZNRSJclWY7AAAsEuyMFzI1wZz+bKKCj X+Snpy8VKNHdwUtXNOY8JBp+FmzMNIy734k1KrY/OFmxuYLv5SZRYvftgitFzpI/PfZV Yhog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="W/RDR8Jl"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si10231616eje.123.2020.04.15.14.38.10; Wed, 15 Apr 2020 14:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="W/RDR8Jl"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405707AbgDNPCv (ORCPT + 99 others); Tue, 14 Apr 2020 11:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405591AbgDNPCk (ORCPT ); Tue, 14 Apr 2020 11:02:40 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD9BC061A10; Tue, 14 Apr 2020 08:02:39 -0700 (PDT) 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=5xtzI73tsael5P9Mn13Ci8Ukj/IQUzznhyBGn3+PxwY=; b=W/RDR8JllrTHU8ajujUbYfEY8d OvBv/wqTj6aAMkQQn8QE+BnX4iylZrqT9st8/6T7ofezX9y0hJFYXTVL+r+xHb+7TSGFWmzNy9Wbh aX21nABD/GYCixn76h4sN0/cfuqPVcorIwRo4QKJZFg2ktVh9+inye7nJpmaXUIlXOwsgRzxjTDk8 TKBPhWJP6LAD648YsfESWDHGppKgVl3LhdpyICVUpDmW8Yj1qHewPRBl5ou8cBnsTT7blrhOEeYKk l2hrP1kIdkCUFFarelKmkiOO47CR1S4gvnrWiWwDJf/ux1nznRHXed8acl7wpoxb3Y9OQ8qGrM8eu OSAdf+hg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jON5A-0006PK-DB; Tue, 14 Apr 2020 15:02:36 +0000 From: Matthew Wilcox To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, 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 , William Kucharski , Chao Yu Subject: [PATCH v11 19/25] erofs: Convert compressed files from readpages to readahead Date: Tue, 14 Apr 2020 08:02:27 -0700 Message-Id: <20200414150233.24495-20-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200414150233.24495-1-willy@infradead.org> References: <20200414150233.24495-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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 Reviewed-by: William Kucharski Reviewed-by: Chao Yu --- 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 a78108128af3..187f93b4900e 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1305,28 +1305,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 @@ -1335,11 +1330,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; } @@ -1368,11 +1358,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.1