Message ID | 20230308165251.2078898-6-dhowells@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp447112wrd; Wed, 8 Mar 2023 08:57:39 -0800 (PST) X-Google-Smtp-Source: AK7set/crs4BATvV22lfGqxI4ncEH0D7W4xIaP6768SvR7E6Zq3wRm5JVwIcN/95EYuKzFEylO38 X-Received: by 2002:a17:903:2290:b0:19c:dbce:dce8 with SMTP id b16-20020a170903229000b0019cdbcedce8mr23404490plh.15.1678294659298; Wed, 08 Mar 2023 08:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678294659; cv=none; d=google.com; s=arc-20160816; b=mGN7aXt12ojCbnagwfxNlOXBPIglcpesoV8bEjL5n8xVcJ2iWhXUczmSqHARGhV5FQ SO7rO9J3JDx0p6hK/tIdZX7/iqN+tdwQiZhPuoBt2SE2E5AaWDRYskioWY3TP1NQzdir BQJ/p1Nw7JmZPEjrFg2p+dFpq+qDBLLxbzPYVjQC9tN/LbRbpWkZpgNvCSl7sfxBeOz7 JzT3qHGf2ZjdArllnW8nHb0Nmq9VR4/bNYpa4UCEauQjD1/3H8DH5JaBWmUt0OTjEfRt 7ZLhW3sR3j5rzfyUwPApvYLtaXQpjrcH75K1DwYfvdNQQ+kLnPSKcv4ajghe9OiH6ZKq ok+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PhbxTzWahXdd/JlmGrRowyeASqSlq5EbDSo0Q9TZAGc=; b=EXCQ6qEnMMf5sdW7l/yDGB/Hyh2cM10ctbiYv+vt9jKKMkAG2miKm/gxFQMZmPMjRu +J3Rh+CrrB7JxIU+We1uxbhD2i/uhSMymcTk7N8j99wdnaeB8xezBoW0x3Lj0h/QD1p+ 5WxyLJ8EQwLWf4m1aQ6ssTp5P/DEsSGBaA3XWa8EGy9uKbWdDT0VNuNyIfFH0jW3Cyvo 9QDnhu6TMCGmTxO4zNR/tRVUNBHsbunq/DYy2zPttN3P9eM5JaqbBHXZ8VyLEWhXK6NW Wh8tX+Rl14Bc/ttuYwRHr28P6tNqzSF6WFdqo90zvycRDBVTUH679J/1CTeCA591NW1J 4x8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hM0nRbrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a170902bc4800b0019a9d97c6d6si14690571plz.468.2023.03.08.08.57.26; Wed, 08 Mar 2023 08:57:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hM0nRbrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbjCHQye (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Wed, 8 Mar 2023 11:54:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjCHQyI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Mar 2023 11:54:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE1B61A9D for <linux-kernel@vger.kernel.org>; Wed, 8 Mar 2023 08:53:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678294400; 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=PhbxTzWahXdd/JlmGrRowyeASqSlq5EbDSo0Q9TZAGc=; b=hM0nRbrF1MoXBP7RU9/atMQ+2yAGE/JncDHrVqEMsvniy4HISLKJqLedPdFkehZJDswxF6 z87kAhTPw4nEe5oY7VUupjLNUG+lOZ8rXiOwfsnSFAQLQcfjDq0IqMuy4tRJnXlMxIJirg x7n03L5S2ldAK0xcz54MSEVzuwymcYI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-18-Nut58j8COw2eSbYYTRM5UQ-1; Wed, 08 Mar 2023 11:53:14 -0500 X-MC-Unique: Nut58j8COw2eSbYYTRM5UQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1025F1C12983; Wed, 8 Mar 2023 16:53:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E0E9492B04; Wed, 8 Mar 2023 16:53:10 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Jens Axboe <axboe@kernel.dk>, Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org> Cc: David Howells <dhowells@redhat.com>, Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>, Jeff Layton <jlayton@kernel.org>, David Hildenbrand <david@redhat.com>, Jason Gunthorpe <jgg@nvidia.com>, Logan Gunthorpe <logang@deltatee.com>, Hillf Danton <hdanton@sina.com>, Linus Torvalds <torvalds@linux-foundation.org>, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jan Harkes <jaharkes@cs.cmu.edu>, Christoph Hellwig <hch@lst.de>, John Hubbard <jhubbard@nvidia.com>, coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org Subject: [PATCH v17 05/14] coda: Implement splice-read Date: Wed, 8 Mar 2023 16:52:42 +0000 Message-Id: <20230308165251.2078898-6-dhowells@redhat.com> In-Reply-To: <20230308165251.2078898-1-dhowells@redhat.com> References: <20230308165251.2078898-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759819500436999638?= X-GMAIL-MSGID: =?utf-8?q?1759819500436999638?= |
Series |
splice, block: Use page pinning and kill ITER_PIPE
|
|
Commit Message
David Howells
March 8, 2023, 4:52 p.m. UTC
Implement splice-read for coda by passing the request down a layer rather
than going through generic_file_splice_read() which is going to be changed
to assume that ->read_folio() is present on buffered files.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jan Harkes <jaharkes@cs.cmu.edu>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: John Hubbard <jhubbard@nvidia.com>
cc: David Hildenbrand <david@redhat.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: coda@cs.cmu.edu
cc: codalist@coda.cs.cmu.edu
cc: linux-unionfs@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
---
Notes:
ver #17)
- Use vfs_splice_read() helper rather than open-coding checks.
fs/coda/file.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
Comments
That actually looks better than the original code because this brings in the experimental read intent hinting which allows userspace to mediate access to partially cached files. Jan On Wed, Mar 08, 2023 at 11:53:19AM -0500, David Howells wrote: > Implement splice-read for coda by passing the request down a layer rather > than going through generic_file_splice_read() which is going to be changed > to assume that ->read_folio() is present on buffered files. > > Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Jan Harkes <jaharkes@cs.cmu.edu> > cc: Jan Harkes <jaharkes@cs.cmu.edu> > cc: Christoph Hellwig <hch@lst.de> > cc: Jens Axboe <axboe@kernel.dk> > cc: Al Viro <viro@zeniv.linux.org.uk> > cc: John Hubbard <jhubbard@nvidia.com> > cc: David Hildenbrand <david@redhat.com> > cc: Matthew Wilcox <willy@infradead.org> > cc: coda@cs.cmu.edu > cc: codalist@coda.cs.cmu.edu > cc: linux-unionfs@vger.kernel.org > cc: linux-block@vger.kernel.org > cc: linux-fsdevel@vger.kernel.org > cc: linux-mm@kvack.org > --- > > Notes: > ver #17) > - Use vfs_splice_read() helper rather than open-coding checks. > > fs/coda/file.c | 29 ++++++++++++++++++++++++++++- > 1 file changed, 28 insertions(+), 1 deletion(-) > > diff --git a/fs/coda/file.c b/fs/coda/file.c > index 3f3c81e6b1ab..12b26bd13564 100644 > --- a/fs/coda/file.c > +++ b/fs/coda/file.c > @@ -23,6 +23,7 @@ > #include <linux/slab.h> > #include <linux/uaccess.h> > #include <linux/uio.h> > +#include <linux/splice.h> > > #include <linux/coda.h> > #include "coda_psdev.h" > @@ -94,6 +95,32 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) > return ret; > } > > +static ssize_t > +coda_file_splice_read(struct file *coda_file, loff_t *ppos, > + struct pipe_inode_info *pipe, > + size_t len, unsigned int flags) > +{ > + struct inode *coda_inode = file_inode(coda_file); > + struct coda_file_info *cfi = coda_ftoc(coda_file); > + struct file *in = cfi->cfi_container; > + loff_t ki_pos = *ppos; > + ssize_t ret; > + > + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), > + &cfi->cfi_access_intent, > + len, ki_pos, CODA_ACCESS_TYPE_READ); > + if (ret) > + goto finish_read; > + > + ret = vfs_splice_read(in, ppos, pipe, len, flags); > + > +finish_read: > + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), > + &cfi->cfi_access_intent, > + len, ki_pos, CODA_ACCESS_TYPE_READ_FINISH); > + return ret; > +} > + > static void > coda_vm_open(struct vm_area_struct *vma) > { > @@ -302,5 +329,5 @@ const struct file_operations coda_file_operations = { > .open = coda_open, > .release = coda_release, > .fsync = coda_fsync, > - .splice_read = generic_file_splice_read, > + .splice_read = coda_file_splice_read, > }; > >
diff --git a/fs/coda/file.c b/fs/coda/file.c index 3f3c81e6b1ab..12b26bd13564 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -23,6 +23,7 @@ #include <linux/slab.h> #include <linux/uaccess.h> #include <linux/uio.h> +#include <linux/splice.h> #include <linux/coda.h> #include "coda_psdev.h" @@ -94,6 +95,32 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t +coda_file_splice_read(struct file *coda_file, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *coda_inode = file_inode(coda_file); + struct coda_file_info *cfi = coda_ftoc(coda_file); + struct file *in = cfi->cfi_container; + loff_t ki_pos = *ppos; + ssize_t ret; + + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), + &cfi->cfi_access_intent, + len, ki_pos, CODA_ACCESS_TYPE_READ); + if (ret) + goto finish_read; + + ret = vfs_splice_read(in, ppos, pipe, len, flags); + +finish_read: + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), + &cfi->cfi_access_intent, + len, ki_pos, CODA_ACCESS_TYPE_READ_FINISH); + return ret; +} + static void coda_vm_open(struct vm_area_struct *vma) { @@ -302,5 +329,5 @@ const struct file_operations coda_file_operations = { .open = coda_open, .release = coda_release, .fsync = coda_fsync, - .splice_read = generic_file_splice_read, + .splice_read = coda_file_splice_read, };