Message ID | 20230519074047.1739879-8-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 E657FC7EE2A for <linux-mm@archiver.kernel.org>; Fri, 19 May 2023 07:41:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 803E790000D; Fri, 19 May 2023 03:41:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78AD9900003; Fri, 19 May 2023 03:41:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B6C490000D; Fri, 19 May 2023 03:41:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4BE3D900003 for <linux-mm@kvack.org>; Fri, 19 May 2023 03:41:32 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 16E418098C for <linux-mm@kvack.org>; Fri, 19 May 2023 07:41:32 +0000 (UTC) X-FDA: 80806209624.02.5B1A022 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 543DC20013 for <linux-mm@kvack.org>; Fri, 19 May 2023 07:41:30 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D2SHVNFa; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482090; a=rsa-sha256; cv=none; b=FWBkJyrsDRElA3aiUsqX8MMx7CHqz/0MgO7mMhFvAKYdcNg3u3yPyogKfFVFTRZ8WH7qru MmhmJY5J+a6AwhTixI62ogu+b7P1e3PkI5DEUURKoe3XWHEngEgda7vJRNQL/TuL8i69+o pXl9QrpJmR+Qj7yLfDdiODiNa4DUw7U= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D2SHVNFa; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684482090; 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=74aMisHJvcrsbS5g8R7662ZNEA+1A6hMiypJVvVd5yo=; b=Lnbg1Aqcg2VN9k9RG4NO8lyEKAYVqP4uqJvLGQhJTanEntCnayun31nkNdK7u5ZwVbFVNJ vmZnPLY2eWFY7CDaPOzDUEuIDLQOtTRRe+2iUTLGwc0an8EPGBPjV1Qdt1qWl0N9DIBLHs t7x0RjufA2mc3n6W07Jf2A/eDuL6leE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482089; 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=74aMisHJvcrsbS5g8R7662ZNEA+1A6hMiypJVvVd5yo=; b=D2SHVNFaVrDaOMXstah3E9Ncve1zCPNrv5du4jxn4QC/KvAeVNMvt47UYocxaDllK5eOe6 TUczKNUVrUpR/ib8YXL5kM2XPaiiaJ+Qb9d3Ll3R3rApbCvQZaWg9V1pigLgZ4SQrJJ+mt NRRMLH4hLNxSLi8XCFYTyVFeOE+iBGk= 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-271-zhDNyJpoN6uuRXwKl_ogyg-1; Fri, 19 May 2023 03:41:26 -0400 X-MC-Unique: zhDNyJpoN6uuRXwKl_ogyg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 591D03804098; Fri, 19 May 2023 07:41:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1119C2166B25; Fri, 19 May 2023 07:41:22 +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>, Christian Brauner <brauner@kernel.org>, 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, Christoph Hellwig <hch@lst.de>, John Hubbard <jhubbard@nvidia.com>, Miklos Szeredi <miklos@szeredi.hu>, linux-unionfs@vger.kernel.org Subject: [PATCH v20 07/32] overlayfs: Implement splice-read Date: Fri, 19 May 2023 08:40:22 +0100 Message-Id: <20230519074047.1739879-8-dhowells@redhat.com> In-Reply-To: <20230519074047.1739879-1-dhowells@redhat.com> References: <20230519074047.1739879-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 543DC20013 X-Stat-Signature: yof99n4m1qtzdfsmp86eugx61qw5uzr9 X-Rspam-User: X-HE-Tag: 1684482090-844376 X-HE-Meta: U2FsdGVkX19Tj03wO5d2UVJA3B3y7ZmQv50gZWeuV4XWImPh9nM69w79/pAi2RalnVJPXeMuOrvkxlKDjtkVKVGlrZizmr1+NFvkZLP9s2RUMGLvy5PJ5sjvimR7mq/iDYbsVwv77ekrpzCbDODeMqgJzRNp4mOGspfiKv+hNnTh/heAzLTDZD+4cpfmLeXEoxqv+eGF4fZZDObA9L1Y+vIh/zrU+mJ3UyAkPhgGMb5UTJOy5ckcJP9PmCIPZ4VuBbnjCfGiEDxSekKUhFxMGZsKh3GPtMQ1jTEZRsvA2WmJSAIokifgPgZgSiC+ECqsae9BjkwF9O1vzAcmQ97ZwsxOzrhY4TAw9CLKJfLbDnX9OfIAvaKToYmyzgpRKL8bkkedXAM9WQiCGpMWzgMQVKtk4o7pY+VOP877zV6f5xJqWxB4XqomzSLP4PlP0O52/gtdwXY9YNjGjzkrUbtFWMye7eRviV1Kdm3zrGy5b/o5y+irCuxhCKcut1GRIIBe0EKeUZQCFh5DasjILN9+nLkWuzblKNiZFUTkgOxNXc6Ei64foikljr+inwCn8YGqlzJl0VA1ZOg2vdnHF4MFVogOS3eFRo9a5W7gohjwQm9LpNjZ8ueQm6fBruCXcYSbMPsaiHCosfDOcL+gKShN+fHKFGcwGhHZxVFkZm1Hh2SneCD83W06juNhMn9EMVmq3rQp4SCbn9La+hGReJRtSrfBN7ZOGEjbj/BzEEM2KVaKdaAttxzsB8OIEyCfEn5iTBwA1I10UoTvk3xHN0uCmJx2yXzDX9bGCkLMMMxDz8lbezXhKfJGWLj0Q3ZT3uoGpu07fI4FZAgwt9pjL9B9tYH9t9r/ZXVojhdDl7Uus5g1T9cGaEb54V4AqBcHTuPiZfh6x0qsD6pHib6nkHjCK7oc7TshbWvmUpnzZTmQ68I/yQYiS9rh6UiILtRmt3aS46oFsrbCQAJuWS+d16T V7Rg4tQ6 No/f28nzyXMUveGYk3XydHU9Qxty4gUogKlqi0Fls7NPR7MTQJ49k8aDew6QgSJgGJ/zG1cracWZFEuiwbQmetRUiJgWwoYNkoxn1o8AkF435ffcYlpzaxv7oln7UZUa4gkZ6HiAdvyskRGNx5Y2GPortSK++9NxVqZMvHIrK3HjbszO5TZaaYIC1d9vo4dX4vKAGd9PXsr9toHi4cH+R6Au7z00cC/CNk5q21uzvfeiV3mPWyYUssyK6/XymgAwuoyRUdrFx0cN/3hLyiO7jMKEJJIZdOuIQIj+ADBol0CAoOTXYBiCN//hEX0pg1rv1RJLm9I5JuyPToN/HSbjEBdU0v23LZfGNQsfgHwgubQDRJzgMgPfTjvanOcORai9Icxs1DMGL0gYD8Gtg0zTqHEI5z79PUrMTQkotir62bi5X6vyFMojwH1KRrA== 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: <linux-mm.kvack.org> |
Series |
splice, block: Use page pinning and kill ITER_PIPE
|
expand
|
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 7c04f033aadd..86197882ff35 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -419,6 +419,27 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) return ret; } +static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags) +{ + const struct cred *old_cred; + struct fd real; + ssize_t ret; + + ret = ovl_real_fdget(in, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(in)->i_sb); + ret = vfs_splice_read(real.file, ppos, pipe, len, flags); + revert_creds(old_cred); + ovl_file_accessed(in); + + fdput(real); + return ret; +} + /* * Calling iter_file_splice_write() directly from overlay's f_op may deadlock * due to lock order inversion between pipe->mutex in iter_file_splice_write() @@ -695,7 +716,7 @@ const struct file_operations ovl_file_operations = { .fallocate = ovl_fallocate, .fadvise = ovl_fadvise, .flush = ovl_flush, - .splice_read = generic_file_splice_read, + .splice_read = ovl_splice_read, .splice_write = ovl_splice_write, .copy_file_range = ovl_copy_file_range,
Implement splice-read for overlayfs 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: 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: Miklos Szeredi <miklos@szeredi.hu> 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. ver #15) - Remove redundant FMODE_CAN_ODIRECT check on real file. - Do rw_verify_area() on the real file, not the overlay file. - Fix a file leak. fs/overlayfs/file.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)