From patchwork Wed Dec 16 18:23:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11978401 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 B1A4BC4361B for ; Wed, 16 Dec 2020 18:47:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4455B233F6 for ; Wed, 16 Dec 2020 18:47:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4455B233F6 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 449888D0009; Wed, 16 Dec 2020 13:47:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FAE98D0002; Wed, 16 Dec 2020 13:47:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 311ED8D0009; Wed, 16 Dec 2020 13:47:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 137A88D0002 for ; Wed, 16 Dec 2020 13:47:07 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D49D7181AEF09 for ; Wed, 16 Dec 2020 18:47:06 +0000 (UTC) X-FDA: 77600027652.27.mask03_32041232742e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id B10733D663 for ; Wed, 16 Dec 2020 18:47:06 +0000 (UTC) X-HE-Tag: mask03_32041232742e X-Filterd-Recvd-Size: 3303 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 18:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=UgpvbXlrAkn91gctm5bwthgBha1dzfDC1MtleM1dKlc=; b=sspeqssMAikfub+pZEyfzlry6z CxtJKfgj2OVYYpoAIDjXIOzitXN+IQg5PlrE/lIN5oRd8wWNtFKzetv2eAqtOlDzsmh6en2ORxdxq knuLrVETJxXPwVCtrhvYcq75cftkY1wbm3j30IeMPV5XZySO7GhLSFpshQ7HmiDJWFmVBmnXQHdNx ZcBdv2dhVBC5dYo3R4TmtdBt8490Nv1PIr316MH2mC+jwCNfTS4Iis259LEXgwHqfaO9FBFL2RSFQ ZcF+xqC7VsntFBUqxLqarx1BGELYBybOLc4jM8H6l1c5FYs/vwvtHaIJRCGl11xndKC8qHkOSRO84 WIAJmgBQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpbSg-00078O-Pk; Wed, 16 Dec 2020 18:23:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 18/25] btrfs: Use readahead_batch_length Date: Wed, 16 Dec 2020 18:23:28 +0000 Message-Id: <20201216182335.27227-19-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201216182335.27227-1-willy@infradead.org> References: <20201216182335.27227-1-willy@infradead.org> MIME-Version: 1.0 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: Implement readahead_batch_length() to determine the number of bytes in the current batch of readahead pages and use it in btrfs. Signed-off-by: Matthew Wilcox (Oracle) --- fs/btrfs/extent_io.c | 6 ++---- include/linux/pagemap.h | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 6e3b72e63e42..42936a83a91b 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4436,10 +4436,8 @@ void extent_readahead(struct readahead_control *rac) int nr; while ((nr = readahead_page_batch(rac, pagepool))) { - u64 contig_start = page_offset(pagepool[0]); - u64 contig_end = page_offset(pagepool[nr - 1]) + PAGE_SIZE - 1; - - ASSERT(contig_start + nr * PAGE_SIZE - 1 == contig_end); + u64 contig_start = readahead_pos(rac); + u64 contig_end = contig_start + readahead_batch_length(rac); contiguous_readpages(pagepool, nr, contig_start, contig_end, &em_cached, &bio, &bio_flags, &prev_em_start); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 630a0a589073..81ff21289722 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1048,6 +1048,15 @@ static inline unsigned int readahead_count(struct readahead_control *rac) return rac->_nr_pages; } +/** + * readahead_batch_length - The number of bytes in the current batch. + * @rac: The readahead request. + */ +static inline loff_t readahead_batch_length(struct readahead_control *rac) +{ + return rac->_batch_count * PAGE_SIZE; +} + static inline unsigned long dir_pages(struct inode *inode) { return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>