From patchwork Mon May 22 13:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E34D6C77B73 for ; Mon, 22 May 2023 13:52:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BF60900008; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7624428000E; Mon, 22 May 2023 09:52:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DC91900008; Mon, 22 May 2023 09:52:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 502D9900006 for ; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 253AC4020D for ; Mon, 22 May 2023 13:52:02 +0000 (UTC) X-FDA: 80818029684.17.E05517E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 58EC6C0008 for ; Mon, 22 May 2023 13:51:59 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rm+uqknd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684763519; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=d05WbB8biEgCD4p+OO2LDaxF6v/UDORhO7ObNrAbhyo=; b=s1G15xZu+Az/ad4JJZx7T5LdtclieBVYrO/ePweb+Nz1drMgy0Lp2qKi9k/7AI1q8H0sDg 6ZpYkfAKPVOjZslvBz0+UJJYokwbi+uDhVczQuS4Uf1hBQv0NTeb+7S0tqcHVxrXH6fMSD vW5c+zWbRIHaY3S+wYi4JGJToCQaQeI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rm+uqknd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763519; a=rsa-sha256; cv=none; b=dtZmkVpRrLQTtjkIiDehZYPDZ1YRxNfm/NNwglhradd7rwSKGgUcTk2IFkKBy4Nx/PAXUa +GATBMzMhUmdyv2Z5EIJipB9hiZXrL/PIXYVNzIiXLXqefJGxiQTjn3q7Cj1XyRjwF/0Bp ZpoxNWyUy64CoF/23zewSJzb4REP1Rk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d05WbB8biEgCD4p+OO2LDaxF6v/UDORhO7ObNrAbhyo=; b=Rm+uqkndABUsJMSZbwJtTWM+ieBQLrGbLdya4GmwbimO23DAxi+5yNrlmtNur1v8zvqwI5 DVXFpvkUoYvn9eDCgHkozPQFi2l0gIDnVqeQjKH4QIMrPntUZEHDlqVCxFCS2peCPLJUW9 +ubpqxO7tP7bbjcrQbI1zblmVTXrfbw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-TCrleTLlPQazmOU7dZvwBg-1; Mon, 22 May 2023 09:51:57 -0400 X-MC-Unique: TCrleTLlPQazmOU7dZvwBg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1AF63185A793; Mon, 22 May 2023 13:51:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3119D140E95D; Mon, 22 May 2023 13:51:53 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Mike Marshall , Martin Brandenburg , devel@lists.orangefs.org Subject: [PATCH v22 23/31] orangefs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:10 +0100 Message-Id: <20230522135018.2742245-24-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 58EC6C0008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xbjdjy7ub3o4f9tkbie3ew45mpk796hh X-HE-Tag: 1684763519-804808 X-HE-Meta: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2bcDtFiAINm00I5RXhyR5EXKWSRcngepO2E+DUPUWxTc9xa8/MlTD0tewzKM9mzLrWl0EgP9riBbrgOQZCaKCEfFPXwghh2+l/OYL0vll2KYSy/notrKSKdmdDQrY+4YuCSqR68mcHbA78ZfXQfySnC+uyaAHjOVv69L89i8pBLiIvY/pGAegRXG+tfAbVaEomU19cAVtPRLEGpKGgCnvzGgTJC3UGKzyNgEGov3tmdYzea8HzhEmc/31aFeYceen9ahQjlahDwEvIJU9h4ty7VVNjhT3X53XNWRQ1Waw5YFdJNRL9mzwuAw1Z23JzUS5peqcrYnKice6i1JYe7UGzJnzqq1Xj5l1jhkm4ZXw0VxaOtJ8CVFA7+S45naBA1PRieyuzQ== 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: Provide a splice_read wrapper for ocfs2. This increments the read stats and then locks the inode across the call to filemap_splice_read() and a revalidation of the mapping. Splicing from direct I/O is done by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Mike Marshall cc: Martin Brandenburg cc: devel@lists.orangefs.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/orangefs/file.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index 1a4301a38aa7..d68372241b30 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -337,6 +337,26 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, return ret; } +static ssize_t orangefs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + ssize_t ret; + + orangefs_stats.reads++; + + down_read(&inode->i_rwsem); + ret = orangefs_revalidate_mapping(inode); + if (ret) + goto out; + + ret = filemap_splice_read(in, ppos, pipe, len, flags); +out: + up_read(&inode->i_rwsem); + return ret; +} + static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) { @@ -556,7 +576,7 @@ const struct file_operations orangefs_file_operations = { .lock = orangefs_lock, .mmap = orangefs_file_mmap, .open = generic_file_open, - .splice_read = generic_file_splice_read, + .splice_read = orangefs_file_splice_read, .splice_write = iter_file_splice_write, .flush = orangefs_flush, .release = orangefs_file_release,