From patchwork Tue Nov 10 03:37:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11893123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE5C1697 for ; Tue, 10 Nov 2020 03:38:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6ADE1221FB for ; Tue, 10 Nov 2020 03:37:55 +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="NIUhbufB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ADE1221FB 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 F37CA6B0083; Mon, 9 Nov 2020 22:37:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ED24E6B0085; Mon, 9 Nov 2020 22:37:28 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3CFA6B0087; Mon, 9 Nov 2020 22:37:28 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id A774C6B0083 for ; Mon, 9 Nov 2020 22:37:28 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 580F13629 for ; Tue, 10 Nov 2020 03:37:28 +0000 (UTC) X-FDA: 77467098576.04.bite95_0917f5a272f1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 3D7828004D1D for ; Tue, 10 Nov 2020 03:37:28 +0000 (UTC) X-Spam-Summary: 1,0,0,f06b851385adfa64,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:69:355:379:541:800:960:973:982:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1544:1605:1711:1730:1747:1777:1792:1981:2194:2198:2199:2200:2393:2559:2562:2895:3138:3139:3140:3141:3142:3865:3866:3867:3868:3871:3872:3874:4117:4250:4321:4605:5007:6119:6261:6653:7514:7576:7875:7903:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12555:12679:12683:12895:13894:14096:14181:14394:14721:21063:21080:21451:21627:21990:30012:30029:30034:30054:30070,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04yf4ehn43o51gh8go57bftf6dd6fyccmkdxdkzicud4ykkpfq3p8bcq9zdctr9.3r9xp6upo7e6tu3i89u54w1c4gkr8b354e816zxyi6x797eg6o9b1fn5zn1ttmu.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:70,LUA_SUMMARY:none X-HE-Tag: bite95_0917f5a272f1 X-Filterd-Recvd-Size: 6302 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 03:37:27 +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=EVIQGcV0X9Un+rKYn9QWhP6gZwoxngzc+MlftT44IBE=; b=NIUhbufBRk5flTnomGqT601aaL 3EYpFhT0Erkm9fVPLRLLM4OBnMvkHSOgbiZuwmiRD71DWseDhQfjdGHLuEUwkqmEKPLF2rNc/kycB Kah/k6bmdGZoQzIDrq4+RW/vcnaE6I2B8UTiWY6nx2nBQTb2zA3Uo/tkVg1jL1Sb42vUx8cAgFRz3 ohiK5BRCGJl64JFmgsJ4K/gErytfYv4JkCPyubS+kwWdj5h7bA88WDwW2HXHWYFfm3TzbcdN0lGSu Af41aaZeUaFyk8qkq/yBIvbAkp23DHRSxT26Xs4htZKEhqokcxf96x1MGF5b8VSJxFfJ4UEJkNqZv lmAUGySw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcKTB-00068Y-IP; Tue, 10 Nov 2020 03:37:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Christoph Hellwig , kent.overstreet@gmail.com, Matthew Wilcox Subject: [PATCH v3 17/18] mm/filemap: Rename generic_file_buffered_read to filemap_read Date: Tue, 10 Nov 2020 03:37:02 +0000 Message-Id: <20201110033703.23261-18-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201110033703.23261-1-willy@infradead.org> References: <20201110033703.23261-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: From: Christoph Hellwig Rename generic_file_buffered_read to match the naming of filemap_fault, also update the written parameter to a more descriptive name and improve the kerneldoc comment. Signed-off-by: Christoph Hellwig Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Kent Overstreet --- fs/btrfs/file.c | 2 +- include/linux/fs.h | 4 ++-- mm/filemap.c | 35 ++++++++++++++++------------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 87355a38a654..1a4913e1fd12 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3633,7 +3633,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } - return generic_file_buffered_read(iocb, to, ret); + return filemap_read(iocb, to, ret); } const struct file_operations btrfs_file_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index 4ccc879ae845..413e327fa1c6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2946,8 +2946,8 @@ extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); extern int generic_write_check_limits(struct file *file, loff_t pos, loff_t *count); extern int generic_file_rw_checks(struct file *file_in, struct file *file_out); -extern ssize_t generic_file_buffered_read(struct kiocb *iocb, - struct iov_iter *to, ssize_t already_read); +ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *to, + ssize_t already_read); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index e39a255200d5..a080200a9fa0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2394,23 +2394,20 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, } /** - * generic_file_buffered_read - generic file read routine - * @iocb: the iocb to read - * @iter: data destination - * @written: already copied + * filemap_read - Read data from the page cache. + * @iocb: The iocb to read. + * @iter: Destination for the data. + * @already_read: Number of bytes already read by the caller. * - * This is a generic file read routine, and uses the - * mapping->a_ops->readpage() function for the actual low-level stuff. + * Copies data from the page cache. If the data is not currently present, + * uses the readahead and readpage address_space operations to fetch it. * - * This is really ugly. But the goto's actually try to clarify some - * of the logic when it comes to error handling etc. - * - * Return: - * * total number of bytes copied, including those the were already @written - * * negative error code if nothing was copied + * Return: Total number of bytes copied, including those already read by + * the caller. If an error happens before any bytes are copied, returns + * a negative error number. */ -ssize_t generic_file_buffered_read(struct kiocb *iocb, - struct iov_iter *iter, ssize_t written) +ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, + ssize_t already_read) { struct file *filp = iocb->ki_filp; struct file_ra_state *ra = &filp->f_ra; @@ -2434,7 +2431,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb, * can no longer safely return -EIOCBQUEUED. Hence mark * an async read NOWAIT at that point. */ - if ((iocb->ki_flags & IOCB_WAITQ) && written) + if ((iocb->ki_flags & IOCB_WAITQ) && already_read) iocb->ki_flags |= IOCB_NOWAIT; error = filemap_get_pages(iocb, iter, &pvec); @@ -2494,7 +2491,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb, copied = copy_page_to_iter(page, offset, bytes, iter); - written += copied; + already_read += copied; iocb->ki_pos += copied; ra->prev_pos = iocb->ki_pos; @@ -2511,9 +2508,9 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb, file_accessed(filp); - return written ? written : error; + return already_read ? already_read : error; } -EXPORT_SYMBOL_GPL(generic_file_buffered_read); +EXPORT_SYMBOL_GPL(filemap_read); /** * generic_file_read_iter - generic filesystem read routine @@ -2587,7 +2584,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) goto out; } - retval = generic_file_buffered_read(iocb, iter, retval); + retval = filemap_read(iocb, iter, retval); out: return retval; }