From patchwork Sat May 20 00:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248982 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 0DEEFC77B7A for ; Sat, 20 May 2023 00:01:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C4FB900005; Fri, 19 May 2023 20:01:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94E10900003; Fri, 19 May 2023 20:01:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EEB0900005; Fri, 19 May 2023 20:01:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6A1D3900003 for ; Fri, 19 May 2023 20:01:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3B497C0B00 for ; Sat, 20 May 2023 00:01:05 +0000 (UTC) X-FDA: 80808678090.26.A28C3D7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 02B901C000B for ; Sat, 20 May 2023 00:01:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Msprf/CS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540862; a=rsa-sha256; cv=none; b=WQR33ZCedF5pNYNtdyGLX5ZBYMsvN7S6AkVIFEqwamyvcXe9h7YY6VK3iZMMdY/pRH6DkZ pTXkGiPMyPLV5Q1AXrOm2zHn+WT9EH4WZb8ZR64KWGNsUfD4XJH0zIbpVxW0H2VKs7+gZY YU65pkMb+n/hLNvRX6LFK/KJC+8U6Rc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Msprf/CS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540862; 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=j9lKnYQLAbUm3aZ6/GDqCuwrLRq8hWqBI2gRgBsDQ1U=; b=vJxgKQo6LZHN4SVGOcGYwI4filN9I4mWNuWi4XQPFc4UtjgVirYG8w8L/OO6CweIHRxtvR fkwKsa1iCMJJqfVvjmeW42rLTpvdfKKfl/yb+33+T7JLfNdEO0xTlJaxxrwIW18Bcej0Gh hPhOutc+Hxj5O6ZDmQZhfdt0ng4Cc74= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540861; 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=j9lKnYQLAbUm3aZ6/GDqCuwrLRq8hWqBI2gRgBsDQ1U=; b=Msprf/CSyhnY/NPUpdL63MrIinhyhh7jv6t7P2Ctw8yi2/691apfRQRQ8LikHNRs5bFtvl +zqgi5k0qBLI9PWOz79W8Xss/gIyC5Evd/Dw0wXJFh8a+Nvi4G2mxJfOa+InzlxsOX89LJ 5qQbhgv3fTuh4Fdvz+VjRjW9HeclVqc= 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-596-HCwIrqq4N0uEJGXPHYI5kg-1; Fri, 19 May 2023 20:00:57 -0400 X-MC-Unique: HCwIrqq4N0uEJGXPHYI5kg-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 EA588800969; Sat, 20 May 2023 00:00:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE04C2166B25; Sat, 20 May 2023 00:00:54 +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 , Steve French , John Hubbard Subject: [PATCH v21 01/30] splice: Fix filemap of a blockdev Date: Sat, 20 May 2023 01:00:20 +0100 Message-Id: <20230520000049.2226926-2-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 02B901C000B X-Stat-Signature: bes6jtmhi8aqytcfcxwzsuhmf8eqfo17 X-HE-Tag: 1684540861-379528 X-HE-Meta: U2FsdGVkX1/Wzie/1En/ycPxUQKhm5DEqW3E9R+1ylmMxaR9eTG5laM5k1LF1KQ2mJaVbNRwdVbxeZR+6eqrltt2OOhC8KtzjESFNZXEhqu4zLrd/hiRX9oz/STmnRiMSJ5ymEDwZQ8wCKrD7vg7ys8X6XWRUPLfImElL0PJaBa5MGB5oLDrrAgBjjUdTKMsQDxgcwM9eDQs959vSs9hEWRjsb04/6RV1C9xd5+3Iwv0qjpVWRDJZZBwgCIk7kHMfg5YcHx18JDM0nTu1cRjPyNdExfk56UqU/WSf7K74eXDHfQV/iKUDONqTALrqFiDFS+nxspGJ9j6frxuxXzaeDqiJ0FpFejdxPagEsRuMLtTFIrkzAXX3K5zU56yUgJKnD+c3xg3T1a/UZD9opWQHS9Dti/K12SrXlComeY9jGnO3shdEO2wvtbaCR7bPBYlsyi8ONY9bbzDSxyBXsFkOLXloptEDLy4+C7Zb6tnp7NEUmtrDBtA79vS34FGiEobkafyOvSqKtk1+0KQ+bVgbg2epoAYzqkOVprckG2ltyMFKbVPO7R9SY4FpE3wkynbXDi5zv81nLJEk8uJ+KyYph7/uK6ZvsosWgYg1P4IzFYAnIkzBQFW5VjcqQhSWQfB5lw0RtT8ydj9DlrpNlWAirrOyaky8b/1OfDrluRtZ8BFrY0JqHNprpZiWmub9GeIfb9eO2ygPOLq6ythz1C0XxA9/W/8dHd+QFJu8pu44bQZai5duMCNl260X/ISiWCF276gsZfKzvjwKQmX4qIUQJpvQG6qgH+uaO2vriV1EZ0v4RNZwL5oMWHYp3UXYDxjmK0e6divblLQ/3j3FETV9MiK8Ym0zcVOYUyYJAIm1Mnge9ZJID0Dv2Ay6uquXdds4xfP90VjncygYBEsxIbm1+pil4RDGJDgF383UzZqwcFvtw3dyPM81BTLq3oQ6TIwKoNEtK2dnCJF6Mv0kkq AqQLpSji u8OTxdgNFytKus+/wRBAu7xNXsWra3nT+fk/3r1jlP8mQve0jMHsXzB9VHyl9oT5CxlIjYe8k2+V2DjE5g0xjc+uUwtTqGu4KnJdqWUDXZeMlMMzPjT5uEO/8ubSOaM4SELcDiURgewcNA53Slqun756DrZ0Y4Gj1O+/6+7ig01EaMFv71dF+WmxzmH0+kWSte/e3urylz2jKQy2Q4bAZ/G3Jwxo8qzGQww01p1NwxFn06wKCD/O41c49O8r6e1MJ3iJs5oAyqlI9ihtzsKfiM1MXLK7t6K4hPXa20MRmANV0Y2UJ2bf2Cm2WeLs9PwpDSKwJSirk25esYuqBKFU05imUkEmQQJfCbp6ROc1DGw+nVTRT5kZdH9QgQwLu4/IvV5NVM4OgRJMTUAM= 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: Fix filemap_splice_read() to use file->f_mapping->host, not file->f_inode, as the source of the file size because in the case of a block device, file->f_inode points to the block-special file (which is typically 0 length) and not the backing store. Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE") Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Steve French cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christian Brauner --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index b4c9bd368b7e..a2006936a6ae 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2900,7 +2900,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, do { cond_resched(); - if (*ppos >= i_size_read(file_inode(in))) + if (*ppos >= i_size_read(in->f_mapping->host)) break; iocb.ki_pos = *ppos; @@ -2916,7 +2916,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, * part of the page is not copied back to userspace (unless * another truncate extends the file - this is desired though). */ - isize = i_size_read(file_inode(in)); + isize = i_size_read(in->f_mapping->host); if (unlikely(*ppos >= isize)) break; end_offset = min_t(loff_t, isize, *ppos + len); From patchwork Sat May 20 00:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248983 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 D22E6C77B7F for ; Sat, 20 May 2023 00:01:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E316900006; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46C59900003; Fri, 19 May 2023 20:01:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30D0B900006; Fri, 19 May 2023 20:01:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 221D2900003 for ; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F1595C0AFF for ; Sat, 20 May 2023 00:01:08 +0000 (UTC) X-FDA: 80808678216.24.B817400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 18A471C000D for ; Sat, 20 May 2023 00:01:06 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFeMIcKJ; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540867; 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=nJaiYO7hPfGCITlMv/e2fYDm8/jpubbHDQ4RMy5/oPM=; b=FfDyiqH74LQ5yLE+e0f3DYdB2GOuz+SCGlBsPfavPm0wOqYJxVD8aciHTT9W0YCu1Ohkyy TXO6LbdLJ5DPhBKt7EkndWd3HiC+OQKcQByfctTZrKKe7ajO1ebOCn2OBpCNj0+qCktYAk 6Ki3P4YHOZXHgDLOK2DwZPqBzCVUTfU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540867; a=rsa-sha256; cv=none; b=ZIydQTjkmX7xri+Ix2Uwhw0WEDPHQpRGVBpRov/4uwNLjG0JXcntOeO1m0tqZcdLjIGKur XZRGSRQWvM0EnGg2winxZg8MkXp0msymlZwq0lR5NBBhz2i+duYz1zuhwpJgNNLgUUF1LR eVenVfqSV9oY3z2P4zKHoNXYyY5uAwY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFeMIcKJ; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540866; 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=nJaiYO7hPfGCITlMv/e2fYDm8/jpubbHDQ4RMy5/oPM=; b=FFeMIcKJTqZbZKKj5LAW89UiFZhjInYtbaZrjqvE+5wBf0tZIl7mZGg1iKtLt4DSl1qGN1 KpajmYgvgmsTJtsLaiLqfeG+XTkkn+nbyTOZ0AModhY+LIH1MMgDMtxIXdAoyt93l7PO+8 bjbVSGJQSgLz0Oou5kdxcjPoA0bpQsk= 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-530-gdX8HUEaPSKe1E3KxEDqow-1; Fri, 19 May 2023 20:01:00 -0400 X-MC-Unique: gdX8HUEaPSKe1E3KxEDqow-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C53B1185A78E; Sat, 20 May 2023 00:00:59 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5751121314; Sat, 20 May 2023 00:00:57 +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 , Steve French , John Hubbard Subject: [PATCH v21 02/30] splice: Make filemap_splice_read() check s_maxbytes Date: Sat, 20 May 2023 01:00:21 +0100 Message-Id: <20230520000049.2226926-3-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 18A471C000D X-Rspam-User: X-Stat-Signature: a9kzop1n6iucozn9dqu6964ta7eujkda X-Rspamd-Server: rspam03 X-HE-Tag: 1684540866-244524 X-HE-Meta: U2FsdGVkX18eCax27I3OBwSYoonVxKqLB+VcEslQGT0Ox5hanG/hFwv76Z2UQEzY/vCOnZS8+DhzWjcsiR1xwN3fSHeeWucRy1yvMJEnh3n2/+8zIuDb8ekJhauvowX44sj2Qvym2BHYlNGAuXAht9exwlC+GNmU3k58YfWRMGm+MaQ1aGrJeZfIBBnwbK2CUAOzs86f4IGV7debolvgbDpXHXp/hfCmM8c8TjOOvgZQ/7GTml5Ae+xa9RdTx+YH8htpiIb1NwnDspl8apg/Tuvb7vW7fZn/mbhlgRuD95DmyXCp6WNR5OEUiPL55+24j/d8qzn47354v4rK3O2mlAZvylwxzQXaaTTUFhhqQeHKKIwFtL5fVzK5TcJJNYVLHzMc067oofjNTlbblgng4a7mu8BfF4eJQwVppgkRme+bMpYTARACiJAnAyMCcrSGzB3MfLkX6HLLPVYYi/Oum3MGNg5PPupdgdsKPwjhsrox28LPhtRnu3nKM1i2Qnv0QFB19t/V62Ituut9SjzvvkLMIr8qlmiIReR4M7mOpxDE5aYr6aejB/49avGuyuQUi1N4Or9c2O+izZ0s1YgiU4scE1LSeMOzKICFBmepWbvQsA6hRhkDJkV+qrDOWO1kBB6/WVkmxufgnlYpOSKmcvOi/k86EesWR7umugL93IiuZaNv+pXr/2tK5fzhD9f33pKvRsq4qQSPMP0mMorZMjnDPZSAlH65e1oZd2TcpD1eAzDmqdZP1CkZcSrN3o2RPjFcNBWK1ecbS67/Jkm8jR+xlbWVINWnhm4gNwVaFsf0zPRiUCjB4lbRV2y1J3DB3taYh7hZGBm37qRJvjfqkVNUYsUtBOj3VCueI5GM2hcZSJGntfCNcj2TNECxcI6KbJ1m4UOCucTx7vYMXrGb4hP2/Vy40jMeXxondStReEJClZwafDOFw6KE2G03gRMcr1nLhZDstm0CN+h9FmN uCtFiHJC 0OHg9ske5/YkdOBbMATkUjLhg65YaVDr9ivMa1t6PJdgOOACUAA379SzGzXl0aAR9XrhhuFMsG2LCG2DPtp4Lf+cAvtI699uxW25bLQdDcOmpAwYDW6nuuD6uc/KReAEZMqQJIqbXSEENTMxHMhD7+oxFl+88v4G2EZewqQgtD7kbaCwV4ngSCaqgYo685aN8nqf3ho5InRPfcS6CPwgpptWHdEJoKw7ErG5tlwFIdL3vNrPorItLcOt64NVQMrWoHW4MInfw1MClXQoTN/myrOEH33kvfTqvUDGtrBlNJeFgrY2I9kB7aHwKcpiZJAN1MVlvpM5gI6alkeJv3Ou/+hUn6u/YOMACuMTOnb7gy9WjyrJ/NuJAyyfvOIJRmUQSrHShA/kh64P6gPnStMBuTKd+IZ4GOyg5iIdS82GtqOR1iAr58L/pLlFnAWtfLawMEiST 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: Make filemap_splice_read() check s_maxbytes analogously to filemap_read(). Signed-off-by: David Howells cc: Christoph Hellwig cc: Steve French cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- mm/filemap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index a2006936a6ae..0fcb0b80c2e2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2887,6 +2887,9 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, bool writably_mapped; int i, error = 0; + if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes)) + return 0; + init_sync_kiocb(&iocb, in); iocb.ki_pos = *ppos; From patchwork Sat May 20 00:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248984 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 D108DC7EE23 for ; Sat, 20 May 2023 00:01:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD89E900003; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5F15280001; Fri, 19 May 2023 20:01:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88B13900007; Fri, 19 May 2023 20:01:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 771B3900003 for ; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 270081C7B4E for ; Sat, 20 May 2023 00:01:09 +0000 (UTC) X-FDA: 80808678258.14.9A2F954 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 75402160019 for ; Sat, 20 May 2023 00:01:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WtvG+3pf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540867; 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=f+CzZRPIOEI63Yig5Ocd0qzQo9k6vKIgNZsTOkrOnGQ=; b=6CAs3xM/J6vEmo3XMRxYQTwPJTFYlGwasj1Vc+Zjgj/wAh+I/DDyCrmNpf7sGwshN7ajJ9 R3qhH/hmp2j6sGA22vIKuTCmP8BtAbIkU//YZrZj84APiFw107nlkBwvyS9I9Vb2JUPk3t qkcAwJ58XtJZ+Rj9EAuIR7i/GeJRuW4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WtvG+3pf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540867; a=rsa-sha256; cv=none; b=BV70Uh5SRASUBuRbvCt9KEIUCc2uDnn8L1tbD+2BtgbUR+mVVTMEgd/rWPDo3pD4v8OEzk 5NGlZjR2BNpMPZUD7Inecyp/CDUJsjVi5jiYNZs+Q6Or/EqaHWeD7kwuPLgmp41YUNR+65 kph28GbD+s5+4pVb8+xdVA/MuP32kFQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540866; 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=f+CzZRPIOEI63Yig5Ocd0qzQo9k6vKIgNZsTOkrOnGQ=; b=WtvG+3pf44siRJcG4gqfF+5jvpTWZAzq4t7bV6QUGmB8J1qukzEnSNhOxBAvJrv6ME1rTZ FWJkM2pq56oHbxaOCxRC7jRkSijtBvIwVwD1lR/mqHxQYYKNAHMHgbBQt+PoijeOc9vlP6 dFbVZXY1wQeGsJ4fEaDNnBayI2HTzu8= 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-56-YEHt9biKO1iJWTOezthP0Q-1; Fri, 19 May 2023 20:01:03 -0400 X-MC-Unique: YEHt9biKO1iJWTOezthP0Q-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 9CA87811E86; Sat, 20 May 2023 00:01:02 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 614E94F2DE6; Sat, 20 May 2023 00:01:00 +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 , Steve French , linux-cifs@vger.kernel.org Subject: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read() Date: Sat, 20 May 2023 01:00:22 +0100 Message-Id: <20230520000049.2226926-4-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Stat-Signature: ucgbm1zszutdarr93m53urkdtn8bercc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 75402160019 X-HE-Tag: 1684540867-883761 X-HE-Meta: U2FsdGVkX18z35m6yfdlInrvg7V8rZrBts/2gJ/I1o9n0PAVxqyapfzoh8wQI179iv2mWVrFTvbonP/16Z9jr4aaIbmhFhCAEYsxU3AQf7xz+RmttqyTZLr1itvCozvI4Nr1yafwpf20fIR2mDtiD+KRbOBzRcAX12jNWu8vLng/VSz34k93w6nt29Z9TzglDOEhSVrE2rjgXL/0WAdVBM976Wgq6VCjc3dFu9UPXU4E1BvMSvfIFMGIJcR1TX79/CVaaV1VqdH+R0SjCy5kzoh5QGFF4CVO9jyq03UC5WlYM8/9Twk3n1iUTOV7xcUIrCRXK9JZg13lZYC2tBb2qjBrw2xYCIl+22Vt/+cT3SHfb9mI2hjPjtOD9LqAl16un9TQ9+xt93y375VFPgi2E2tojTP1w9cQ51ZMfadFVGEt2snCVsi0MlnhdoTXqH4+96WW6zzRgbzO11o8cx80Oc3Dnoa9eX+lAOxVikeY+jakDFsHjLSrD4DGN5+RSDLk665TVS1gpZrEn0iyV6NLwf35wbJA/e6bMe6bARQOMUsDRbyrqeI7JYRIH4LaSWNoSrnbv7q5SEsM89CaR91C+ndizf5ccJ4xmL/8AlLFx6+YV67kARvCPKwFHch5oDZhVwL+/Vgt+7JqsM4+17yz1FLVvi/4zNi/ofcSAJuh4N6jGpuBHTmYWOJARkh2VkreW0sZIR3Sz1xhpUzb6iEp4lKnCPAqSAYVXvXtRRRrt1BmJMKJhXeh5CYlm06cNdbJrhqYs+kdBjqbKcU1X8uKDInCyhY7RVreoexCuwbc3wR//mBeQljDoeUZ8z0GIz639fAs8ek2m8yLqlAdmVaOsnWECRaDbMsfTzVojbrhvSEamMxjT5VrdWMMCzpeZlGDrU5mzqQ2XGwLkZJ6XplhchaRg+KilP4hkr104GiE/31gun8k19iKu9gileCxVZCnHU58B6yRpfOtNCZsBSp t5xV3E7o FctiqG3YTt6gWVhd+S9wpdUOPD8LtKetJIzVOl3b5PFjfQb4hpC/8b43zfawithxoN9Wa6Ayv9XpbjcmRQi9UDq9LV4eqs+p/3x1NM03SayDuubp8qdoAKFLhwb22kyIy3ulHGcOC7C4d3g4QDwhlr5jNv+Isb3eH5mu8dO/Oz4ahlpxJSB56ILz5AfYw0LWoqakH9wfUXtDOcJ5dZYboXJUYxSakLsJtZVDr84Ry/CiQeMKThlEgnOTnpjD6V4GBJIql3o/B3JhYOPpgs7JW7oXWbN8w+GEi8oihmR+Ggr+JbWJMGJWgOH+7SROxwgeJhnNY1tpXL3NunIeaVW3E6kUGD9elPyDBpFuCA81N+9CnvHVKzbSXOhk/7eiGoTR1c3Sc1E9ob5WeRKKkhsdIvhOmb2IADgy9jNxp7691H6VtYwuVHBE/8DTRkwvFN8FcFrQ2nOUOCSbRtJU= 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: Rename direct_splice_read() to copy_splice_read() to better reflect as to what it does. Suggested-by: Christoph Hellwig Signed-off-by: David Howells cc: Christoph Hellwig cc: Steve French cc: Jens Axboe cc: Al Viro cc: linux-cifs@vger.kernel.org cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- fs/cifs/cifsfs.c | 4 ++-- fs/cifs/file.c | 2 +- fs/splice.c | 11 +++++------ include/linux/fs.h | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 43a4d8603db3..fa2477bbcc86 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1416,7 +1416,7 @@ const struct file_operations cifs_file_direct_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = direct_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, @@ -1470,7 +1470,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = direct_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, diff --git a/fs/cifs/file.c b/fs/cifs/file.c index c5fcefdfd797..023496207c18 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -5091,6 +5091,6 @@ ssize_t cifs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!len)) return 0; if (in->f_flags & O_DIRECT) - return direct_splice_read(in, ppos, pipe, len, flags); + return copy_splice_read(in, ppos, pipe, len, flags); return filemap_splice_read(in, ppos, pipe, len, flags); } diff --git a/fs/splice.c b/fs/splice.c index 3e06611d19ae..2478e065bc53 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -300,12 +300,11 @@ void splice_shrink_spd(struct splice_pipe_desc *spd) } /* - * Splice data from an O_DIRECT file into pages and then add them to the output - * pipe. + * Copy data from a file into pages and then splice those into the output pipe. */ -ssize_t direct_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, - size_t len, unsigned int flags) +ssize_t copy_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) { struct iov_iter to; struct bio_vec *bv; @@ -390,7 +389,7 @@ ssize_t direct_splice_read(struct file *in, loff_t *ppos, kfree(bv); return ret; } -EXPORT_SYMBOL(direct_splice_read); +EXPORT_SYMBOL(copy_splice_read); /** * generic_file_splice_read - splice data from file to a pipe diff --git a/include/linux/fs.h b/include/linux/fs.h index 21a981680856..e3c22efa413e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2752,9 +2752,9 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb, ssize_t filemap_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); -ssize_t direct_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, - size_t len, unsigned int flags); +ssize_t copy_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags); extern ssize_t generic_file_splice_read(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); extern ssize_t iter_file_splice_write(struct pipe_inode_info *, From patchwork Sat May 20 00:00:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248985 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 5A26CC77B7A for ; Sat, 20 May 2023 00:01:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E338F280002; Fri, 19 May 2023 20:01:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBAF5280001; Fri, 19 May 2023 20:01:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C347D280002; Fri, 19 May 2023 20:01:14 -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 B31AE280001 for ; Fri, 19 May 2023 20:01:14 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 803F280B7E for ; Sat, 20 May 2023 00:01:14 +0000 (UTC) X-FDA: 80808678468.28.C401FC6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id CACD9C0024 for ; Sat, 20 May 2023 00:01:12 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gVNek1Sc; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540872; 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=PT+Bun0dIbxZdwJScwf3VqpEC9/8xV7aRQjBWH3biT0=; b=4Smdnls3tLip57Zm2s4iDx6aijPgVCxu2wqGzPTGtSseyUQAaapECdv8gfZY1AhIZXS7R4 vfQ4+fwZYhnEXmn557pCtY3PdUJXufjjoxyoE3CsY91q6ASTIwpdINUoHRZ6xIGjw6y7LV vo6HOUATJcEVbjFRz1JqRXzZRFY4RSw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gVNek1Sc; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540872; a=rsa-sha256; cv=none; b=mKWiCwWAu8Z0cqQqfKOvUgM2YlIY9kS/TEDfHwRGAGJW76WhK7LVBF9sjmWs/FcQepvSrO tgMHAcNrCnM9VCShBia/WZ9aBx6YN3kwTXh3iJbvv26d7a6rDt5TMeyGNqI6UljitmEQ6w nr4OYjx67V1YShClajG+fJJKiPE8wq0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540872; 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=PT+Bun0dIbxZdwJScwf3VqpEC9/8xV7aRQjBWH3biT0=; b=gVNek1ScxdDpT0J0Yzf87Q2FONTwF/M347lP2HXsLGcj8utXvAbVM0F0rqPEry4vbDJcuv +UVnD6vCSGhx/M+yGSEx9nFRZv+NpYkPSxwOZLzKn4v33AoVRG/CnKhQ1/c7opU3QVDJeU vgOtu+9xIbeFd419fir61Hd0PsJCJzI= 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-624-hfhZbVVlMdejFFXt6z0GIA-1; Fri, 19 May 2023 20:01:06 -0400 X-MC-Unique: hfhZbVVlMdejFFXt6z0GIA-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 ABCF7101A53A; Sat, 20 May 2023 00:01:05 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 721554F2DE0; Sat, 20 May 2023 00:01:03 +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 , John Hubbard Subject: [PATCH v21 04/30] splice: Clean up copy_splice_read() a bit Date: Sat, 20 May 2023 01:00:23 +0100 Message-Id: <20230520000049.2226926-5-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: CACD9C0024 X-Rspam-User: X-Stat-Signature: 7jy4j5d1af1889qpg9bq1n7xu8ih1igu X-Rspamd-Server: rspam01 X-HE-Tag: 1684540872-168436 X-HE-Meta: U2FsdGVkX18ITyYSrg/uegvERH0sYHAXTpflPGf/Z4R8JQvt1E9lCMWzvKBrG34CYi+6SzMPXWWraYvK2razbJAiLe1L+nT7uY0WjTc509inkC04lwymONi0rtwSAJpJfksftCi+v1EqoNXDe4l1fsV5WPQ6R3nw+iL2hVyV9vKjyOE0eYdy21D3v7UqGOvFBjiXcxTdXducNJgOqw3ACR3H0ybNOO5aCw2R8ExQ8dh80T3fx6DrIjIMneWkazi+omSmXSNN1oeFZlLyMZbdYXakurrhKNuLdQR9929SRFy0RcQFMrqWalDKobz99EOflB1TKheIXkKrgZog+YcXPqMTHkss1aOvvRNjsoVJjnj4aRH4vIwRKrGVXrt2dieARGnsfr5psTL3WVdUn698ufl2ygQUOAXHREU0mM0FzFyvjKa6vpl37LRlV5KzPQw4gIr8ppqjzEyDQyEDf6sdDeNwtDJjD92UgWFxpzu4R/U1tw3tg0QivRCllX4S4DDYdGwcCs9g3szBmIi/mWosvk9RDclb0r8qIgxPqpYadQB3eR/9hBxBijp059b7UNqh+9zu8NWuoNuu6K+XtVNLDP+HCkOiBjeeQhCVtdzlrkSJd55SFXjnu62ETlH/yGhScSiY5aTOGAjpLexSrwQSuwTDke8mtfBKaEqGE37sTe01CmVYEXVN02USABEnb5vX5D3SYowts1XToXaqA0Jc6WZsMOEHMEnN8IktgM05E8KCeiQSiJF9eMUzRbpS0HBm0+snaucSy9esO/6bs9VEnTUZBAkwg706DMiL4WsjtFfxUabslBzmT7sC7UtlC+F+Z42T8A2qaH0PHIsjFkTrjFmg1Wc+UdGj0sv/SZY2llwhghMpupXhMmiTM+0TigsfS9JVGOFxbQYGiT5MJSaNWOsJFpbM1bfjqZsck0YgEs7skDmmH0VasVwtTa70r05eIKMOtB4HElN/YspM2xL EFc/BDAC K9T6fZwR889ZeMuPYMN2mMrx0fFT2erDmGYStgjmyFR2/X2uoK0VOlCakOL9CTjgZrJwLzrEyAVNWZd7p2DpLPeH9UbFSYQJl6CHsQudIIQY9f8tvklh7gJ2AJySQ2wT2L2ORgGUQ3FFIkVefgaeJM6Zj3aKhv6dBU008RT8RHyONJHQScYQ4xfWyK06TE2y7orHRbceCDqXrF0uUs4t2CnrrMiwtBeQ1Ko0fJ8hUoje+mXmG2Yda67y00DyU2PySa5seYL+hPnmKSyx9OiMe/zjPv6xN8vqrjI3Rbz6PkOl/lzzpbA0GD3xWs+hLJM/jwNIKwWc9urhQRecBsEfcPoCbwh5POrRMcBydWJV3MUsGuERE7f0JquNml5V9xeh1ZB5b5Wkna9XTv815atv9Vjf98Gwx0QXJWdaSw6YbgFUKvxn7/YNmlC8dUV8KEvDsYWumGOSFAK8B7n490d4aoXFAz1zoVwFpw+bU 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: Do a couple of cleanups to copy_splice_read(): (1) Cast to struct page **, not void *. (2) Simplify the calculation of the number of pages to keep/reclaim in copy_splice_read(). Suggested-by: Christoph Hellwig Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christian Brauner --- Notes: ver #21) - direct_splice_read() got renamed to copy_splice_read(). fs/splice.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 2478e065bc53..f9a9be797b0c 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -311,7 +311,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct kiocb kiocb; struct page **pages; ssize_t ret; - size_t used, npages, chunk, remain, reclaim; + size_t used, npages, chunk, remain, keep = 0; int i; /* Work out how much data we can actually add into the pipe */ @@ -325,7 +325,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, if (!bv) return -ENOMEM; - pages = (void *)(bv + npages); + pages = (struct page **)(bv + npages); npages = alloc_pages_bulk_array(GFP_USER, npages, pages); if (!npages) { kfree(bv); @@ -348,11 +348,8 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, kiocb.ki_pos = *ppos; ret = call_read_iter(in, &kiocb, &to); - reclaim = npages * PAGE_SIZE; - remain = 0; if (ret > 0) { - reclaim -= ret; - remain = ret; + keep = DIV_ROUND_UP(ret, PAGE_SIZE); *ppos = kiocb.ki_pos; file_accessed(in); } else if (ret < 0) { @@ -365,14 +362,12 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, } /* Free any pages that didn't get touched at all. */ - reclaim /= PAGE_SIZE; - if (reclaim) { - npages -= reclaim; - release_pages(pages + npages, reclaim); - } + if (keep < npages) + release_pages(pages + keep, npages - keep); /* Push the remaining pages into the pipe. */ - for (i = 0; i < npages; i++) { + remain = ret; + for (i = 0; i < keep; i++) { struct pipe_buffer *buf = pipe_head_buf(pipe); chunk = min_t(size_t, remain, PAGE_SIZE); From patchwork Sat May 20 00:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248986 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 E6D0CC77B7F for ; Sat, 20 May 2023 00:01:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C904280003; Fri, 19 May 2023 20:01:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 753EF280001; Fri, 19 May 2023 20:01:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A627280003; Fri, 19 May 2023 20:01:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 41AB8280001 for ; Fri, 19 May 2023 20:01:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDA1A1C6BDE for ; Sat, 20 May 2023 00:01:16 +0000 (UTC) X-FDA: 80808678552.23.A788B74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 0979D40010 for ; Sat, 20 May 2023 00:01:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T5Af40f4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540875; 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=nqg0PsCK+oTzlRLhXHvUNi3fY5C+vB/nfBPH52VrtTk=; b=B2GE13X53d18bbLtyDxjvKO7egl/qh5WHc9dpOH5tf38RAYcC7oAsX1mOUkN2XzMK9kx2Q 9PDauX5KGtA9PXmF2tz12X103mwSM3Tno00a+UWkmvbidszjHSTdOH6OZ1Hy+kocka4b4s qjJViAsbS3D6GD3fo5FuqBrW35ew6jw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T5Af40f4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540875; a=rsa-sha256; cv=none; b=J+Oo9xfpEF4E2IgFA11nGaygV8c/EteYdcd2F8KYb1YKfL9ZM06dkmYAX3Dmn9CG8YxAqg Tmdc2f4q3Fa6ri55GJRWOxDrvz6wXOHZiMCMsMl4iy01mncDobqGT4LiUgvUi3UKCK1+oy DgOGgdEHNqRBUmbvh3kk+nVUp04U+Uo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540873; 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=nqg0PsCK+oTzlRLhXHvUNi3fY5C+vB/nfBPH52VrtTk=; b=T5Af40f4wjTgRiCjjBVoElqaVa0WgmU72E/luVCD4qz0LDtrvAVN+VXFGjWNIypND39dIc 4MyO0UShLF5WTR0u/q2BHLK4Kvj6l+fjK1uef68Ow3SKdykFhxi4M+TiOTTuNlzuZicQ9f MV75/ZwxOUNPEAwqyvc+4ucCdmqqil0= 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-28-PVv0fparO1Kemo38SEKFRw-1; Fri, 19 May 2023 20:01:10 -0400 X-MC-Unique: PVv0fparO1Kemo38SEKFRw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08E53800141; Sat, 20 May 2023 00:01:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BB9340CFD45; Sat, 20 May 2023 00:01:06 +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 , Miklos Szeredi , John Hubbard , linux-unionfs@vger.kernel.org Subject: [PATCH v21 05/30] splice: Make do_splice_to() generic and export it Date: Sat, 20 May 2023 01:00:24 +0100 Message-Id: <20230520000049.2226926-6-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 0979D40010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: t7bqfnbb1146pzqua5zdnbf35nr3i6uz X-HE-Tag: 1684540874-120150 X-HE-Meta: U2FsdGVkX1/sa9QcQ+THzRYGcjw/iQ24LTeW/QxTi5cYNl0AX4l+7zHciY3VJbRtNuLfiPeF+OAg9U6McxodukcvEkCd2JOos8GujOWwBpyFOMirf8UsyZGJhFXpfTqOS2GaNK5/DTNpNZ9aA1/21dadepszTu4kMoIOCipp0WStYyJwZHWh+fpHkFDpPYRaS7s1EXknNC4MioPZHqz/xiSkRzJRJuUAZMSt3hZia47aFOb/MzA0A8XCzKeP42ddg3PAI1bUpw/ftwPo5eQ20EPMP+jx5sir7AzZf9tLtx2A5bKpAAEsG4gkBL/NfsKTYvCMwbTd912+HAv23gZoApJ51XrbU6bkRvue0xgQSF+Qhhq4St7NlYzWSntkcnqLNMEaD1a/QW/UaPYHuGDVr68DleCN0B4U9d6sPV4E+dVPaQ9MsBT4K47R9m0qfOyKB+Zz6GTB2YrE5xNEMdHWHZU2T9vvq17rP/hRCvVzrhS+dLjjLFWPGxasYkXMQc1F/bwCv/0/DxaJ3LDQT2llecROKPHFa8jcmV2UU8e6lwkZTcpnfWlmqxNGT7sbX1WsSzoLUj1EuSwgthnYnAIQq9IYFKuBNu66wIqTftbIlH7OPKL/NlC33dkJP0TL/YpcBmBgLjJBiG11yPNwskefhv+PbVgQx4veRL1jHQBJfGL24H1Sh0y4F0yh754HxNGOVNr0rPaw8yupFjKwDRPON4VXZRu6an1scL2b6jjDIyQKF0aicASIlRJbTZ2N7bwZnJKvQCJ8KnsxvWYxKYqLWPyzI2rsahkssuEzbET4J+r7jkw4AjBTVhGFKEJpEZD0rDw/hsvDNiiiji2a8NL2IbxbVBrco1cRR/NT4T7NQT/SJ6KriESHGc9HFNz0ccmpOHgqzF2q2Mtd+V7RlwdrZsuAejHdJqLoa83/YRcdtNMNUMqNdgPtB5ebdJ/Kxp9FMZt3psoZg8jwsp9zZRo QvKMtuJk i4ThgWwv2t6z5NCYjzSg2o4DEc/VG3YLmuDzfFxLGe9UaSc3xhVuYxTw09x4qc6+ZXMaVtfThM8ZFlinnQE4+GwnBLiLGm8Z5ngYN2BFpGT3XCXUNk/cf2t7a/kWXmkBOJYtwrJFswb57zIXnQrODSetFHHXL5VxyMvdtHVC6uygQGURH/2T+PjsAI/tv/kHMZEmCS4BMpMV8uAQr+z9ehTXyioefgxEpkDQbCxF4C7IWIaFZWJ2vTGEfHxH4U1Cxh+KualsSRS6tcftBgs1CKzCyPKMn7q+khlOeNrJwO6FJa4Fyi3P7leloIq7SZFsMlYe7Ii/x+ttgQZdD3lo8zhiBgFHK339KD2cnjcAb+AbUITqrFl2JNRwIIKx4hGTUWPHHWeZQAgugUysA4tnj1NwFR6GhOnKfJpqrY+qX5apzfWDyT9iqUnpfvO2XO4a4EgLZRrtetHjfwShYcVRzVgCypxNFl4Yzo9/jNJGPXKipBJdJzTc6ObQCN6smhGlq+vCo 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: Rename do_splice_to() to vfs_splice_read() and export it so that it can be used as a helper when calling down to a lower layer filesystem as it performs all the necessary checks[1]. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Miklos Szeredi cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: linux-unionfs@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/CAJfpeguGksS3sCigmRi9hJdUec8qtM9f+_9jC1rJhsXT+dV01w@mail.gmail.com/ [1] Reviewed-by: Christian Brauner --- fs/splice.c | 27 ++++++++++++++++++++------- include/linux/splice.h | 3 +++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index f9a9be797b0c..d815a69f6589 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -867,12 +867,24 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, return out->f_op->splice_write(pipe, out, ppos, len, flags); } -/* - * Attempt to initiate a splice from a file to a pipe. +/** + * vfs_splice_read - Read data from a file and splice it into a pipe + * @in: File to splice from + * @ppos: Input file offset + * @pipe: Pipe to splice to + * @len: Number of bytes to splice + * @flags: Splice modifier flags (SPLICE_F_*) + * + * Splice the requested amount of data from the input file to the pipe. This + * is synchronous as the caller must hold the pipe lock across the entire + * operation. + * + * If successful, it returns the amount of data spliced, 0 if it hit the EOF or + * a hole and a negative error code otherwise. */ -static long do_splice_to(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) +long vfs_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags) { unsigned int p_space; int ret; @@ -895,6 +907,7 @@ static long do_splice_to(struct file *in, loff_t *ppos, return warn_unsupported(in, "read"); return in->f_op->splice_read(in, ppos, pipe, len, flags); } +EXPORT_SYMBOL_GPL(vfs_splice_read); /** * splice_direct_to_actor - splices data directly between two non-pipes @@ -964,7 +977,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, size_t read_len; loff_t pos = sd->pos, prev_pos = pos; - ret = do_splice_to(in, &pos, pipe, len, flags); + ret = vfs_splice_read(in, &pos, pipe, len, flags); if (unlikely(ret <= 0)) goto out_release; @@ -1112,7 +1125,7 @@ long splice_file_to_pipe(struct file *in, pipe_lock(opipe); ret = wait_for_space(opipe, flags); if (!ret) - ret = do_splice_to(in, offset, opipe, len, flags); + ret = vfs_splice_read(in, offset, opipe, len, flags); pipe_unlock(opipe); if (ret > 0) wakeup_pipe_readers(opipe); diff --git a/include/linux/splice.h b/include/linux/splice.h index a55179fd60fc..8f052c3dae95 100644 --- a/include/linux/splice.h +++ b/include/linux/splice.h @@ -76,6 +76,9 @@ extern ssize_t splice_to_pipe(struct pipe_inode_info *, struct splice_pipe_desc *); extern ssize_t add_to_pipe(struct pipe_inode_info *, struct pipe_buffer *); +long vfs_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags); extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *, splice_direct_actor *); extern long do_splice(struct file *in, loff_t *off_in, From patchwork Sat May 20 00:00:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248987 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 C77C2C77B7A for ; Sat, 20 May 2023 00:01:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F5BD280004; Fri, 19 May 2023 20:01:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55871280001; Fri, 19 May 2023 20:01:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AB9B280004; Fri, 19 May 2023 20:01:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 221AF280001 for ; Fri, 19 May 2023 20:01:19 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EA22A1A0B78 for ; Sat, 20 May 2023 00:01:18 +0000 (UTC) X-FDA: 80808678636.25.EABF8AD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 149ED18000A for ; Sat, 20 May 2023 00:01:16 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qu2hdYVH; spf=pass (imf24.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=1684540877; 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=3G3sKLO6NWg4Qi1Gepthcp6ipQZ6DSu/XMOeps2uwWE=; b=BqvdNCI1OXIZtgGiQ1zYFxFMhxaRt6ZGvQKNZO09zBuCVjy4ENpr/jOuyIgV9EdGENFVcT idyzUa43t+1cARXLcjgVdXB45WAIpwgLjatMIAMKYUHIubmTjyZOLK+hUfy7AuTyHwVobX xz64s8cCZqqECS3wR8/xjnykF0QenYg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540877; a=rsa-sha256; cv=none; b=3/7UKSS16I3FLjUJmW71OFPIAFvVSM+iR87Ryd1gAtHrUduZvvX5psAUjYEq0+6I64+Jsj ZKvvqaHEUS2T2YMZ6/wrvnaMgKigCEAodxEJqQ6iumuggkyh4j96GLXCW/tQoqcDgYjCwt xIrPi4rHutW9N+TMI6szZLSt1/8FGAc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qu2hdYVH; spf=pass (imf24.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540876; 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=3G3sKLO6NWg4Qi1Gepthcp6ipQZ6DSu/XMOeps2uwWE=; b=Qu2hdYVHIHXuOBeqesZPLGHdGr9o4THJ1eXdrAT1Uk8mVF8oIZbMFxVcj/DYwF20clWzsP yB4O+46BqzxVJQbitJpeMpM8TWvFo5hQyWn5hxjWWaFzNuPFyBTh7MIa1+bLGVBot9JlPN Iks5h3CYsfsEXWkq79SaAlSD4p1WwT0= 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-551-CToXHsdXO_ifGZvqbzsW0w-1; Fri, 19 May 2023 20:01:12 -0400 X-MC-Unique: CToXHsdXO_ifGZvqbzsW0w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAB3C185A78E; Sat, 20 May 2023 00:01:11 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B202B2026D49; Sat, 20 May 2023 00:01:09 +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 Subject: [PATCH v21 06/30] splice: Check for zero count in vfs_splice_read() Date: Sat, 20 May 2023 01:00:25 +0100 Message-Id: <20230520000049.2226926-7-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: 149ED18000A X-Rspam-User: X-Stat-Signature: tkdtf87dgihb7mps6cngwxj16qz3wt75 X-Rspamd-Server: rspam03 X-HE-Tag: 1684540876-181738 X-HE-Meta: U2FsdGVkX1+swDu+w3zb2kJuEJQ55Q69X72CN62Da4GQYYBqdNqiZdS/wj2wAOhyaMOD6x8i0UuymzaOGMbGtcKrmu9cWBKSoiPDNVfBrPDsp1vzLucBGAYRCtYzjftNlX/hmgeC/AxxVfK+mxLVFMfbcubP0RN6HDZ9jRnyn/JKM8WStDweK5rUlzkUstcP3KCymCzR+bYv8waHkSW6/DNpsE5JmiAA6ggipsrZPWgEY4Du56rTLEAZubOmcd9vxiKePoq0aEkDOoq6LPACpREy6URtdpxxR9f1Olf/GUc6+iDc/O+dVx+ZrtTZyf1dPCr+104mVNchyWJiam+QKrhXOKWepCW1kak9BtezRUrF1u/pM5W+vzgg8CbrOnR65IJ+aLPfNRdlgjpfdYFUo6Ixg5I4ZKeUxuHtTC9S9nivNQ99mHGImgMT5lFbnrL3w8AD4W+fLbiRdSZEvgfhLH74FXenBNWlNB3r+LPS0UxtLEOJ3+6qFF/G1Pywh905K80u5f+ZuPbsXogyEfKGIfKQFvZYJpkNe/82mkSWeqI0XEwMXKBK33DdeDZbRcE4Adf58siae8pZLZTXzjiSTL0FMXnDP7+edhH6pMT52an+Mjt5k026e4SAR+XIBW6IHdzeb/mGZsQaF9I0aDAhg7TZwRAlAlWXDpEuhSGpssn0Eff7brZmFEY/7oAfMo3bbQEVqH+SBlGmSjZ1O5r0m2Rxq2D9VDAVX2Dr2kHfi3BoujeKX00U4meiMCXUHGT/U60Sz8NuZOKXsV7m0pp5OkhI6nxCe92QwGq4AMinoIW7wQCF47Gk8tyYO0ynmT86wt+g4++t5XCqWKxeYre4h26mWKpDHMtk5WdNahoiwaIfhFIbi2c9IO5g95umBaiKmXz/zg4Hx2bJRR9MPIimcN+HxSHzSjl4Afw7lH+1rZikodZ3622wg+RiOQHDeQ+TGNVtbkZnefbB+0zsDbx 5KrTBB9u 9T38iOKG05WVJTn3ZXYRVUBcngdsJ+/dmRsfPPmXf9RcRzj08OlxAKuObCFjNo1bufnaI4fn4Xk42X2QVLBH/Va+41HNkIDzfbWRJ4z28ebKIK1MEOgKs+vEQ1i9N0tEjEJy7f9OhjTyAPo9UeOr7J+v3x/TmKoxxOHUKs1BhdFKMtES3KdStykMRK0m91Xk9L1sqckckgsSON78eBr0W8qk5UVnyBo8HYkAKznykzWvEwPr2p9WYin7Khwd8OXBvnb2hKU49E6ljaoiktOrUxPpwVfWm8H2I6xjqdloj87/KOTtC6FCVoxS1mcixbe9OEmtIb0IQ0O+8Kk/cStQ5nvz85qdTiKFEzJM6liU7sUkEYsfNFMirv8u2n9YHzVg01/fqP4ar66xxzY4= 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: Make vfs_splice_read() return immediately if the length is 0. Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christian Brauner --- fs/splice.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index d815a69f6589..fe3309ffeb26 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -891,6 +891,8 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!(in->f_mode & FMODE_READ))) return -EBADF; + if (!len) + return 0; /* Don't try to read more the pipe has space for. */ p_space = pipe->max_usage - pipe_occupancy(pipe->head, pipe->tail); From patchwork Sat May 20 00:00:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248988 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 28C4CC77B7F for ; Sat, 20 May 2023 00:01:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2618280005; Fri, 19 May 2023 20:01:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AADA3280001; Fri, 19 May 2023 20:01:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9010F280005; Fri, 19 May 2023 20:01:22 -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 7D7C1280001 for ; Fri, 19 May 2023 20:01:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5FA58AE749 for ; Sat, 20 May 2023 00:01:22 +0000 (UTC) X-FDA: 80808678804.05.7360E2D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 8D8521A0025 for ; Sat, 20 May 2023 00:01:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540880; 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=dIGb/7Nt7dNT7r5bxwMphLPrFmTGpxHZQXf9F5C0+vE=; b=z2Rf4k4WCNjH/FN6SZmwmlQdSwjTj8UNYrN5nP+/nzU1mFOG/SG+mH+8dGDFUvwRLHrbS0 BBJoYcvKIK6tU2cOj++0sH7JYPa544/nTV3VtXQ3nGukHT9hmsOeW+8ekxTGxp8GaT3PKm gjiEaUDvUGPW/zx/dBdJHjnvBZ8+ALI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540880; a=rsa-sha256; cv=none; b=SbCrJOnk+VonyrLVzBAQtaA7Rh3hF56BKgwIcIS1BA4DqKZTiv3fUJFsnBVDE2E+IvsQaD T3pYCgy98zo8heZEBpyj9RN5cV0AJoWbG6qHGRiSRGhMEw4zq4pBIiKd42qulv9Pl5U+zB KUWSAxsrzhf8AqnGGBNVjDXU4ib30HI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540879; 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=dIGb/7Nt7dNT7r5bxwMphLPrFmTGpxHZQXf9F5C0+vE=; b=AZwqWMR3vFEGbXbDSBBUGJ4eIC4uHYrvxC/0Fjf/AD9ztuOWdpbfwq3bl7bxguL9pN/RAJ iB8bFiNXXBsvXG58ioLq1l+58JCjVh4VX7iH8WP7orFaN2+PxrWRojm6525h1bka+7CcYm xn/CHimXIl9OoWgNRCFMc1gQU3WTR58= 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-384-kv-DotIFPiO6JnwvLiQGkg-1; Fri, 19 May 2023 20:01:15 -0400 X-MC-Unique: kv-DotIFPiO6JnwvLiQGkg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D7391C05EDC; Sat, 20 May 2023 00:01:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55785492B0A; Sat, 20 May 2023 00:01:12 +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 Subject: [PATCH v21 07/30] splice: Make splice from an O_DIRECT fd use copy_splice_read() Date: Sat, 20 May 2023 01:00:26 +0100 Message-Id: <20230520000049.2226926-8-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Stat-Signature: z9ntjdssoks3skuhgepjtes6bnem8diu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8D8521A0025 X-Rspam-User: X-HE-Tag: 1684540880-128463 X-HE-Meta: U2FsdGVkX1+1HjYlqxquUzR1acX2zKJkSaMdPSPqV5/ADj4rFKHgho1hB9sDgdFLiL0k/rve1s8VRiYPYTc1HY17Nb+/PCbVGHa6CX/C+bUrbbvhdSZYcgkGSM2C6lDGYE78TEY+kRV8BU62tvk8helo1//PmqZt9Nx/Fyh5fVwea1pNme4tWSY1/ntTW8sYEyZkhEWw9/Om41Z1m/5QoqnWX05Za9nSmSlw5zwPnsRlwnAKpH0z4q41Gsw7HGucfSuHotjtVKfRk7uEHa3edjS1dj4JN2q/HdDrJHn9MJM/2S/SiQftbK0RhymO3rUHwp8am71zU56Y9D2jDMBDZxxOKz4pLspucN+EvHeFdSo3GF0HbE6sOvrofp0dajWgBKaPfgPa5UO3X2NtqkliNTFBXr5v7lr3X351/BveHGj0wk33UAYTn64D6WmZIF3V7k8W2omnO6YIRENsvzhOx9K0oc1kCynLkW+e2cZJtfuz3Dn4gzsIXBlJLxBctcJJJmQiBXMOqH1i7CzMHT54D2hG6WakWUyqwl7jQhXGcfSIdbMUeZ8FaHgZwHZtwhsashTwr1dEKQKiQOimF+q0gqs6fWV+n4Oe/cmCrz32CHAodyOHjE9sJvKa9aSGUVTP2GLd+vVzC6k+hNl5c2+12guT9rB2Z/v4BnpL9t7fLU8d8Znl2ATUfXK/pdA1RjH74OE+q39XLP9KXCxcHVeDFNE9SwZzHVigsA18P31uYbN6FSJOrLxJEBeomEda9KLK6MsHLrhM38281pcD1L7qdoRIqTzWwjvSTb91aCKKzRwciMV5c7FN3f1UDRO7ZxUbrmBkTR++wyDEYTnchPWkOjSaC1XXW+SBUBoS2poYBi0e2+nmuixfOCW5MpPpZh3nwCzQkCv+GmkH2/X0YZNb7kVDqBJ8Ghb+tL3GfQyC8YrT/lDINDIkMYMI0nyBUbrN5rrgFId/3TusEq/b7Tg cckiP0Hc Ruf7Afe4KonpLrFp5b2G4nXNih2JPjWKbS2Q2CkW/NJN9p4D9y86GVhbAmAuG2wumDMkkrFb2gIFXBopjjVgwU3vIRVixWQlCbYeoaRRwEXu2xSJpRPZ/UApWF7YGVzRtyoF+vNMEuGgQ2WkzUIz7zjRlEUiSNQ4G8AaONxztcAztJi8Qm/3UtQziZs5GqY+g1PvKgu/9Hbw3kt4dPL7fq6K81eGWrL//iuFwLENcww8mcs1kp0+fk60OYaPXUvXiF546cp03UVMUJ65/EwVTGsbaaEyuCRLxTi3sSGvmScpzLRozd2Y9Y9UteWHwXbTf8WhAcsxIO94lCKf0+G7BZpCNmrN62IL3wlgmW2hifsDSYKbdOlK4tVwoYbjyIYYszAfGAimIpvB1F7U= 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: Make a read splice from a file descriptor that's open O_DIRECT use copy_splice_read() to do the reading as filemap_splice_read() is unlikely to find any pagecache to splice. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- Notes: ver #21) - Needs to be in vfs_splice_read(), not generic_file_splice_read(). fs/splice.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index fe3309ffeb26..76126b1aafcb 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!in->f_op->splice_read)) return warn_unsupported(in, "read"); + /* + * O_DIRECT doesn't deal with the pagecache, so we allocate a buffer, + * copy into it and splice that into the pipe. + */ + if ((in->f_flags & O_DIRECT)) + return copy_splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags); } EXPORT_SYMBOL_GPL(vfs_splice_read); From patchwork Sat May 20 00:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248989 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 B9CAEC77B7A for ; Sat, 20 May 2023 00:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D489D280007; Fri, 19 May 2023 20:01:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD4E6280001; Fri, 19 May 2023 20:01:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFE4F280007; Fri, 19 May 2023 20:01:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 95869280001 for ; Fri, 19 May 2023 20:01:28 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6CDB1A02FB for ; Sat, 20 May 2023 00:01:28 +0000 (UTC) X-FDA: 80808679056.17.2D6F3FC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id B83F51A0018 for ; Sat, 20 May 2023 00:01:25 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hkLNtPNW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540885; 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=zbFi31jMxWzghDu9RJeKpwLNk82XZBGuvfsvQFuMAZA=; b=PxIhhsRoGXrZjsmWzQF3RhFqYEWapY/ct5ZnVCzwikPNoNLii/9qwGeKzLuqc3VO25/Fic tK4FRBiZqdqMNAyqI/mbKKmGEC7hd1VkwbEGPu+XOsss7pJ+H7OwbDGgJgD/jofpP4uovy r7XJh/ikYc4YZrTmmoJ1f6aiM/rBCuc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hkLNtPNW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540885; a=rsa-sha256; cv=none; b=7Z4CSVQuBXXia45aAh82Ow20cEOT+w9ZelQACSwDl7hugAjCXPsz4GxNab9Z3zdWyvHR7M EP8kyBN0ce2d3evhQD/klgchAnHAtTwHJ4G3+Nbw4svj7jFJ8+oH7cVIIZ1YZdW3egFH0b bs0Aw++DQnudNA9HLqrylm9fotEMBIM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540885; 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=zbFi31jMxWzghDu9RJeKpwLNk82XZBGuvfsvQFuMAZA=; b=hkLNtPNWe3gRR6EhmnZdL9VaqFS773XFpkoREwd2h7uw0bLi2AivPwzZmApDfg1U3lPSl2 UmVh9LKAsbupMJZ/w866EKLmQbIZ9vP4MjPoLFmOAu2BRbAS0qLKLzp4+ieVzRnTmeDevK VBA6nWE0hQ75c8dzYRXEfQxBF30OpP4= 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-498-boGls4mfOPmRYAKfMNAYJA-1; Fri, 19 May 2023 20:01:18 -0400 X-MC-Unique: boGls4mfOPmRYAKfMNAYJA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A57D3C01DB4; Sat, 20 May 2023 00:01:17 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BE5F40CFD46; Sat, 20 May 2023 00:01:14 +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 , linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() Date: Sat, 20 May 2023 01:00:27 +0100 Message-Id: <20230520000049.2226926-9-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: B83F51A0018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6zj5ctimzcehyxqg5dgkewhwuczy3una X-HE-Tag: 1684540885-910853 X-HE-Meta: U2FsdGVkX1+7m/UATrymbfU5uV0lwOYqNNJ14XmdAdP+MDe5FVAZalRgoHppXw74Mdlm9fdaNOUlZpTt7nWPyBy3zAWkthBVmxSO7QRL3oZR6SwcCDFY8SqEcMH0fiazArII8CKuRccEcMTVjWfr1aqk+YyCvcCss0syFp6ijHxWInEa0BIWB5bo5jMfG79ATZX0kPeB/K7OVpQBB+Zg3r1MMu0Xw85IdtsFemzMzy0GKkOJ50N5VhzXO62PckcTd+WYdar39UZLHluZX7yYfktUiEw3JYOz3NBTOYIew2lO/XyjhUFZkIMQnDw3ct6x6Jny76qCJSxR46/uzbNEI7UYNHwcSBwwxAVKcifwho84R/kWxFLiiAc8bFz45dyCvYkncGuTJS13vGvSEalDiMRfvcZBJ74AUCUp3Vo88zGoYvN/TGNYBRrlsUAJwnx48GAXxGze4m9pA6ESAJ90Jm+8699q8RxeRvPsKJKCcta+EidccqBLh+aJioDPKUxJ07dcU/cfVZ1QxYAupSqicte2d5Qc+N7Nd84jwrhmEfDmKA8I58NqoM6yHfi11InCFWkd08WJZorPL70DAGnLN8MgAdoZFIBtOZF9JzzL+nEsonyUjTj0RYzUh0ytsr74HtZRDsn50K1gLEyFK3Omml4acrroSCZjy0s+yNrFcygnie19CBKO34PcwAiw+4qSYyx/WlfAcp+kkHmogwe9tUaT3SywLsKkQtS2TuyMsI7tkdkCXcFjRazThjKmmFZLQ0aY5CpS5LVtthheur7CZeOVa+IYSQF3MwmSfYRmfMygSBw51kcEyzkuHcbpAkhglzZe/f2fp86x59ia5nzF3/bQeQpAGVB1InktDOMbtYau19exDszmzZhZsol8GQNupu0qKEtNnm4RMCftn8yeV6boDGY4fI/rzSI4h9HThqnfaJvsWEjSxvUIa7JFy6QHBNFr93Zt+ESFQ7+FuC9 Iv7SuH7v 2h3RYgPE64eDQGNK/scSxEaFLddodbiRS5ERHB9hpcWeU+7sgefmftXfRj6GIH7cDgo66SWNLY9ltHKPV1zhdWoOhGURHgvUFzI2CUCNFpPpBu+gCHP/1oF2b729hAeBXhOicduf9xREyCA51qinGtL1qawa/ffsK/nARtS+LYWnTcspKKb4ygL6RwZXdL1k0UjT3ifvrh1dCcgx2oiqDGtTa1nKFzb30IpE33X2mWJ5AZH4XMr0a3qoN7RtDwyhPRh2AJ9nEWWYWqAj7ELYXe5Q7Ox8ypjTJOt32s55M8ENXCWt0Gayf0Y97i4rIymQYJa6TacODl+3udwhKxa7O5uj5l26d/yDUhleGfFLZp08wMN8+IRlliH+UdEY6eF8WBFqMqaQMzxZqQX39Fg9h9gsPyE1YClthkhqM87VKbeQsY2XFqeNhY6wZ2uycZ+YlmnALSMpWxJICpi8= 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: Make a read splice from a DAX file go directly to copy_splice_read() to do the reading as filemap_splice_read() is unlikely to find any pagecache to splice. I think this affects only erofs, Ext2, Ext4, fuse and XFS. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: linux-erofs@lists.ozlabs.org cc: linux-ext4@vger.kernel.org cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner Reviewed-by: Theodore Ts'o Reviewed-by: Gao Xiang --- Notes: ver #21) - Don't need #ifdef CONFIG_FS_DAX as IS_DAX() is false if !CONFIG_FS_DAX. - Needs to be in vfs_splice_read(), not generic_file_splice_read(). fs/splice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 76126b1aafcb..8268248df3a9 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -908,10 +908,10 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!in->f_op->splice_read)) return warn_unsupported(in, "read"); /* - * O_DIRECT doesn't deal with the pagecache, so we allocate a buffer, - * copy into it and splice that into the pipe. + * O_DIRECT and DAX don't deal with the pagecache, so we allocate a + * buffer, copy into it and splice that into the pipe. */ - if ((in->f_flags & O_DIRECT)) + if ((in->f_flags & O_DIRECT) || IS_DAX(in->f_mapping->host)) return copy_splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags); } From patchwork Sat May 20 00:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248990 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 428DBC77B7F for ; Sat, 20 May 2023 00:01:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD215280006; Fri, 19 May 2023 20:01:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5AF4280001; Fri, 19 May 2023 20:01:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD5D0280006; Fri, 19 May 2023 20:01:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 969F5280001 for ; Fri, 19 May 2023 20:01:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 750A1140B11 for ; Sat, 20 May 2023 00:01:27 +0000 (UTC) X-FDA: 80808679014.01.CB1E05C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id A566F1C0017 for ; Sat, 20 May 2023 00:01:25 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhZXnfjJ; spf=pass (imf20.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=1684540885; 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=KUqjynheJXCaLvUnn68NO8vUOrcgRITgr951Lzay0lM=; b=n9HUOxUMr9p8g8xw5bAriIOpQMy3CjyxvG0X/yeWdAMakElZxQzwOBumb3r0sC5I46cAn/ NW8/UPw9OJNI8/jZ7ZBxbbnG9pI64Rkwc1wX+VLVrJkN6Lh8gRKYyxnsVKwGxQdaGtgQhX 7oCQ32CcV64SnwyOLzOvjFa7kgjyqNA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhZXnfjJ; spf=pass (imf20.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=1684540885; a=rsa-sha256; cv=none; b=HLDApr/it+Rg/GmuyZ3vQ6rmoEYM1DVqxpksDPZpdcRDs2lBIp0qY5GHXaVQdYZezK2ukj UgU43y8Yv8LahY6V7C9n6HPiqBj1EFDwOIDLLoccnWO3s2m9ukLgKOVlk75P76I/8PEawN 4Aer2sD3U9tCuRak3wioaWSb+mDDCf8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540885; 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=KUqjynheJXCaLvUnn68NO8vUOrcgRITgr951Lzay0lM=; b=OhZXnfjJv7bUvo7r1QQEdpXqLCmH28eM+2uYRx39bDyABEdOgX85c/cGZnvmL1Fop9iau/ MQENI87AJ7JR7tWlJNq8by1oAIySG6qf+ujmp8y6c/xeqsGeBMvE3NMo6EYGW2r6VCjdNR 00S8SW0e5bdSRV7tVRvZymQmVpoqolo= 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-445-fz4w9rXNMyW2QIqeSZgthw-1; Fri, 19 May 2023 20:01:21 -0400 X-MC-Unique: fz4w9rXNMyW2QIqeSZgthw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E2BA185A78E; Sat, 20 May 2023 00:01:20 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03AF840CFD46; Sat, 20 May 2023 00:01:17 +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, Daniel Golle , Guenter Roeck , Christoph Hellwig , John Hubbard , Hugh Dickins Subject: [PATCH v21 09/30] shmem: Implement splice-read Date: Sat, 20 May 2023 01:00:28 +0100 Message-Id: <20230520000049.2226926-10-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: A566F1C0017 X-Rspam-User: X-Stat-Signature: 18rrmnzo1sgdeafynrk5rdch3mmxm9uw X-Rspamd-Server: rspam01 X-HE-Tag: 1684540885-304619 X-HE-Meta: U2FsdGVkX18UV9ufgTWLV1WRKgiqCKE4sSpAa+s3y8HYqzBYOrAdaIEttoXKcBCMZGMsXaYPWxsFCpJ58mD1h9sN0/zNJ/OIHkCDKhrJCHQUlktHDV4y6QZfom4I3SslmAFyk2rxMjyWzKEvlaKWL58GTToUOO5HViTnBz5cRRehImv70UC1mBOXSNmGjpto+lr4x0Z9Y4r53N0jNfsRuvVMibtGj1oYwJMFHruIwaA4UxzR2ulgrv3c1zHz98jjf1y5IDW5wMu8VRON6l7/9PfzZCNhv/UZNMVfkeEOHFEkH+Pi1Sdw7HOzc/3eKGmW/0Daa/6KYWuizwQZ488F+EFsrsFpCDbuwh3+XJvfzmWqQQopynU+daNNuuLZxR0WcrJ+OH8ScdKBF+4Q+2H92icVg9xfpEcqrj7w+8QeT1BXFvTGwW4K2+mRcgIFrO+D1DsY/ICatPOfYx4VEwaD1sUkPvjP+Nwo0DPHXEdB6PE5XzXlk1MggLxpGCopSKSD2tRu+I44JAlTp9erOKYYeBuDGf1zlELznFWMtng/xKshU1zE3r8Iu9RXKX4EfKnx7cgrUFbKnv10ZlnTd29B7yEThBxCUHSG48VjBDQLPTmVc43+vt4P6CwlRxi56y0W2PyEusKRbP1iHvDJfY3P6thdr1iOQS2KJxT4MeZvHvIdqVOKwj/MULnh608G09TTOKt3xU5eaM7hoxg+DPPB2rCOlKtvPNl7qLU53NUDp5Y0I5dbPMWdYggaEBEr9K2TiUALPz+uISiTM6j/U47IW13fnAXphNZaHZKCBhdj2p+ntBQHbNcmlEJ/4U16+X5wYkiU0/GT5urN6vy3A6Y9X5C7R0OzfhDBjBIC52z1RhtBB6vtJig4vDrMnjPKMAvBmbcTXlhPrINT3KySa4by4GwLauOZOOHd/JJRF7cogoRKhrSL2Pv3kkQYyJ7iGbh1TPb8ekblG0AF5Yy6mNd h0DogqTb TFpEOAlEf2LEhaeaMShaaW5kscKLvPiEa6bfLDk5AQkw1ElklvY6g0JnWUszKAZp+6/9QuM++hv7K/kqfG8UrcJeJl6o15r52EpmUgp4QLbKcjmzQ99oyDdFFQQfbNwuAFH4heei3CGbG5wyBlYETiVXuACZxKnZynDXhP5BzAskvsxASetQAPvUo51BD39yc6yOW7eyjq1gQFTHnv+uOmUzzVNg9aX4586OU3LxNwimlCNajssAbmayswjbd9CoIx3/Aly9yK92+8IntubnWnU0u6urfEojSa6+gfzC+Ivm+xi+lqDj3pkHX+U7IvozITLsq73jZ0niLt+xNlNMFQ8cRrFYflUZGipWuPHMyuIGTlEeMrzjvTa9SIU9w9E276fkWQCM7nF9A8e459Iz58u0XDVqvzP2c79zj1YpEpwMMdl8CU2gt29rh+MJ1EpBtRli4dmn4XSWJYj89NvYynZieFumormvOTq+P1xTFoCJbV4jQnaXstrnhxwUjWQHFGpkYvoCpZqOOQlShuflPQnsAXG2IoNXrtX8t 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: The new filemap_splice_read() has an implicit expectation via filemap_get_pages() that ->read_folio() exists if ->readahead() doesn't fully populate the pagecache of the file it is reading from[1], potentially leading to a jump to NULL if this doesn't exist. shmem, however, (and by extension, tmpfs, ramfs and rootfs), doesn't have ->read_folio(), Work around this by equipping shmem with its own splice-read implementation, based on filemap_splice_read(), but able to paste in zero_page when there's a page missing. Signed-off-by: David Howells cc: Daniel Golle cc: Guenter Roeck cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Hugh Dickins cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/Y+pdHFFTk1TTEBsO@makrotopia.org/ [1] --- Notes: ver #19) - Remove a missed get_page() on the zero page. ver #18) - Don't take/release a ref on the zero page. mm/shmem.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index e40a08c5c6d7..1f504ed982cf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2731,6 +2731,138 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return retval ? retval : error; } +static bool zero_pipe_buf_get(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ + return true; +} + +static void zero_pipe_buf_release(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ +} + +static bool zero_pipe_buf_try_steal(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ + return false; +} + +static const struct pipe_buf_operations zero_pipe_buf_ops = { + .release = zero_pipe_buf_release, + .try_steal = zero_pipe_buf_try_steal, + .get = zero_pipe_buf_get, +}; + +static size_t splice_zeropage_into_pipe(struct pipe_inode_info *pipe, + loff_t fpos, size_t size) +{ + size_t offset = fpos & ~PAGE_MASK; + + size = min_t(size_t, size, PAGE_SIZE - offset); + + if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage)) { + struct pipe_buffer *buf = pipe_head_buf(pipe); + + *buf = (struct pipe_buffer) { + .ops = &zero_pipe_buf_ops, + .page = ZERO_PAGE(0), + .offset = offset, + .len = size, + }; + pipe->head++; + } + + return size; +} + +static ssize_t shmem_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); + struct address_space *mapping = inode->i_mapping; + struct folio *folio = NULL; + size_t total_spliced = 0, used, npages, n, part; + loff_t isize; + int error = 0; + + /* Work out how much data we can actually add into the pipe */ + used = pipe_occupancy(pipe->head, pipe->tail); + npages = max_t(ssize_t, pipe->max_usage - used, 0); + len = min_t(size_t, len, npages * PAGE_SIZE); + + do { + if (*ppos >= i_size_read(inode)) + break; + + error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, SGP_READ); + if (error) { + if (error == -EINVAL) + error = 0; + break; + } + if (folio) { + folio_unlock(folio); + + if (folio_test_hwpoison(folio)) { + error = -EIO; + break; + } + } + + /* + * i_size must be checked after we know the pages are Uptodate. + * + * Checking i_size after the check allows us to calculate + * the correct value for "nr", which means the zero-filled + * part of the page is not copied back to userspace (unless + * another truncate extends the file - this is desired though). + */ + isize = i_size_read(inode); + if (unlikely(*ppos >= isize)) + break; + part = min_t(loff_t, isize - *ppos, len); + + if (folio) { + /* + * If users can be writing to this page using arbitrary + * virtual addresses, take care about potential aliasing + * before reading the page on the kernel side. + */ + if (mapping_writably_mapped(mapping)) + flush_dcache_folio(folio); + folio_mark_accessed(folio); + /* + * Ok, we have the page, and it's up-to-date, so we can + * now splice it into the pipe. + */ + n = splice_folio_into_pipe(pipe, folio, *ppos, part); + folio_put(folio); + folio = NULL; + } else { + n = splice_zeropage_into_pipe(pipe, *ppos, len); + } + + if (!n) + break; + len -= n; + total_spliced += n; + *ppos += n; + in->f_ra.prev_pos = *ppos; + if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) + break; + + cond_resched(); + } while (len); + + if (folio) + folio_put(folio); + + file_accessed(in); + return total_spliced ? total_spliced : error; +} + static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) { struct address_space *mapping = file->f_mapping; @@ -3971,7 +4103,7 @@ static const struct file_operations shmem_file_operations = { .read_iter = shmem_file_read_iter, .write_iter = generic_file_write_iter, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = shmem_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = shmem_fallocate, #endif From patchwork Sat May 20 00:00:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248991 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 0D0C3C77B7A for ; Sat, 20 May 2023 00:01:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97733280008; Fri, 19 May 2023 20:01:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FFC4280001; Fri, 19 May 2023 20:01:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72BC3280008; Fri, 19 May 2023 20:01:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5E4C7280001 for ; Fri, 19 May 2023 20:01:32 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 315FC40B98 for ; Sat, 20 May 2023 00:01:32 +0000 (UTC) X-FDA: 80808679224.30.B3BC8AA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 728BF40010 for ; Sat, 20 May 2023 00:01:30 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fSpUNEGJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540890; 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=xQ2t4u4rThOkZRLMA9uKelfSlhpr/X6lAppYFOWSBHwHtP0anHtcCpwWyNPF+7hYyrzZNq 4L9ez4uRqu026YPN7zn3E5H/D5JsrUSPJP0eolM491NmFe/ap1f0J8F+uMVUHo61GWjOPk ezYg3cSvf1JEJhmzhbwwCT3tFphbw44= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fSpUNEGJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540890; a=rsa-sha256; cv=none; b=wYuqSWuSKqDhJnf5Pshuvp61mkpmtmsxqcp/R194AEpaxVb5/yOo1U7svj8X+vin5NUChH 6x0vpNYe2INlGAihj7f6AHs+NcBfQOnf3ySzThYcobDejgik35tsS+Z9ZuQPSB/G3+0Dwf eKlu4ZDFIKUXIfEgphCVBv3KkMrKScg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540889; 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=fSpUNEGJhNE0zYhngruldELX7seJXyvO8ti+Ui5RZ8y9KbQ7qP6GzYS+LOCKtZUrmZNdx9 ZzzA3ZM9ifVT3Uv5H6n4rt9jBX2fmtP1L6OVZJOY4D3a3TRvbFlETW7yP6wNxkLjLaIfyH 8d9W88toLSn6ajFqdsORNeJb5eAtvD4= 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-492-Pp1IPtIWMIWF9TLbVOsNMg-1; Fri, 19 May 2023 20:01:24 -0400 X-MC-Unique: Pp1IPtIWMIWF9TLbVOsNMg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8268C3C01DB4; Sat, 20 May 2023 00:01:23 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48D497AF5; Sat, 20 May 2023 00:01:21 +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 , John Hubbard , Miklos Szeredi , linux-unionfs@vger.kernel.org Subject: [PATCH v21 10/30] overlayfs: Implement splice-read Date: Sat, 20 May 2023 01:00:29 +0100 Message-Id: <20230520000049.2226926-11-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: qqk8i3x4omm51pb4szjepqnzr9ai6ucr X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 728BF40010 X-HE-Tag: 1684540890-875016 X-HE-Meta: U2FsdGVkX1+5snTEn59TUuJdD6GCm6pMaSLy2xiDls0nDwMsSHB+Z7QkbfarQpcQQ9Jm5tYZNViWlzdBD0lJjj4gejX4v2TKzY2L9tEjt66iBz07AhSpY6swRH8DcGsPxnJ948NuzUGA929LqTJ9lxSJyaBCO94CT8Oe+UtAe1BNMR2IFp/3/EXsxXQRxLP2YRYjSDWKcOLiCwFAochJ0E4AEFG/4/Ht4H1SsZ69qOygbL0S9ACw0ipXtwoJlksnStcWGZuErk1/y097pJGIgxVEFHw3d3HIRZsaAlzR4TCACUhwvtfrd6t0eI27faLzDPTQG4EoHccKf0LHYSXZ4ZEbZiJsiVPEdZMnov4Cz0bnLNGnSqTbEGvkBXzaFyLjM6JLYZrwv26A6MzI+EYI6ZpaoKPW83P7AGxX/urqe0jF26dUalT5PoAq9F8IDncmPGJugc/tiXho/RUrJA/VnJOm8+eM/DDxS4w9SAUKxU9N8cugHV/WLbrlTxHaeBUusbg4TCQj1xgIeUeTeK6x/MnDAMuyRuTzOtCYWoCsl2jnOPWSu0KX/ssfs9h+xrznbWeOLuGSli2JFRb+FFIPYBscXoe1VU9XH65zGjF6F3sCeNpmbtZQcMjblHaWKX10oL2BvyLqjihblVfaMdMJS7OyLYxVP7qvZaqqcz4abGu/CT6dcB9oeZ7IGqyk9lUp/HgIGLmnUSY6SVaGCTLl5KK+dls1uzmYlMUvbdJokq6LL5fwZ9ZWcvMlMSLSTmSeUeeI5jlfDlLp7HuqZPBqQvAq8alLoS0iNSwiG9cRnwII2dRaS6Xo3wZkW9MdAySSpdFMZ49SM1jksCNnHDJtges8x6yAE7IEFLeYtp+0L/+FcQXXMNc54OpCtZybijELKrQ6eWgUFh8s3Af0QKmD5oeHqOGWkGInKUzaO7m22fTqKt9ZBPFPpUdO+wXLwxzvmVwok6hMbqiciB07ZT7 4R9f6aZ8 AdxF2BVqHQuNs3MIunu+YSmDo6TAqYv2RT07lhVMXUdvsC8rTOtjf29gWI3ALd95hKGwm6eP0UH8epzmnrO0APF7BmSNE91Oa0K0ghlzN7r0SsFU08karVLHTPYmbCabm3Siw7K5ZtG1vc277GjK4+Ra7ZcFRxEVQkz3X7kfoIgJdud7FyudD65RkUCfRxHOyhnMlbD6Os+0o/8zmbD00KAqneM1M1V7iY3zTyXu6KfNX43SEaJws7nZQLF4lchZHiFVnIDbHocPD4iNMCsODykOArFSIUW+M8w/NmWZzq8QW8YM/7CtySg7l9JAYaeaGJhXTdRovijOHv8L4BOKTui3ARLg8ISewpamAdOHTODtKB1CR6ebOqMPw9PK4fVjeBgV7haMX/mwjiPki/jz38e5iwIjViuX6Hjrzf55eWY2wUIZrexTnnrhjZw== 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 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 cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Miklos Szeredi cc: linux-unionfs@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Acked-by: Christian Brauner --- 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(-) 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, From patchwork Sat May 20 00:00:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248992 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 5E67AC77B7A for ; Sat, 20 May 2023 00:01:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E58A1280009; Fri, 19 May 2023 20:01:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE188280001; Fri, 19 May 2023 20:01:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5B8F280009; Fri, 19 May 2023 20:01:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B26BD280001 for ; Fri, 19 May 2023 20:01:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 75CE0A0982 for ; Sat, 20 May 2023 00:01:35 +0000 (UTC) X-FDA: 80808679350.22.338A6AB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id B1EC18000C for ; Sat, 20 May 2023 00:01:33 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BaU8WPD0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1684540893; 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=Mo6NWBR6hkfydtMnZeO+F5U5GhN+vbQRFCzRyccP/1I=; b=lVCPwdGmI3RQpRrfXf3BhVEnk4L2ItjgWDpXnEnCoVAhJy0z6Fkib518LpR1n+AMrXvSd7 Zu2ehWZAlDoJDSvqHRPT3Yog/Ov4wz42XrQ1NBUI2plk5eCRnM6D9pWoa4CTjMIUVcyiAu F0rHI53jKmoK5Xfc/FxQ2u9mNJfUo60= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BaU8WPD0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1684540893; a=rsa-sha256; cv=none; b=CvMNI69ewyBZZQMXvzx1kHHIgA4aAd/Ifx0YJD0EVJHGG44ZwfRV11J9wgNYgM7Sr8Usus Gg7W3mvcBpxXi24BliCbJJpZTrdS2bg+1p7FjooEqnxn8vjOlZdvL3gHyksAQF/+soaHLy Mlp/jsL19T8hpGgVAtePYm4DCJO7V3A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540892; 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=Mo6NWBR6hkfydtMnZeO+F5U5GhN+vbQRFCzRyccP/1I=; b=BaU8WPD0W+uGgg5OvxdPipeiFAavpK2mr6Os6mZR3oNnIwmqVgPsvCM5JaA8CpNTp/baM0 DAn2GiTLCfh89htCTq31No1XGtrf8J7srQ9lqhUDboqHSrd8J/CUhunwKbD73Oi1qwVpra d5eNUornyCDvw7l1cKDFMlohdmmfYaA= 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-269-SoJDvSKvN3ST1yDutl5l3g-1; Fri, 19 May 2023 20:01:28 -0400 X-MC-Unique: SoJDvSKvN3ST1yDutl5l3g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCE281C041A2; Sat, 20 May 2023 00:01:26 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21827C154D1; Sat, 20 May 2023 00:01:24 +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, Jan Harkes , Christoph Hellwig , John Hubbard , coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org Subject: [PATCH v21 11/30] coda: Implement splice-read Date: Sat, 20 May 2023 01:00:30 +0100 Message-Id: <20230520000049.2226926-12-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: B1EC18000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: z1wf8554wrb53peyncub845j51yz3edu X-HE-Tag: 1684540893-653948 X-HE-Meta: U2FsdGVkX18VBV3/klk1obfD/8rPfJpmWBKjsl/d8cwhzKTksGEW+B0PuHefmhTs5j1L3bQMCaGmbh/s2wPw4t8cknqF2/gI1ZARI110rrV8DQdGebFaK2QKPg33Oci+S+RIshz4x2wJFaR1Cl4f8OWn/YuzW+Bfc5iQ4kAdh3nHaJtDleIaRKNVnCGfosapBlp0hdzGqi8Ttae7EMTAhxCaOk0klDDpc+aTqMdgIz+065GMuKAakhrOmD3NLhGZCYsxTwYkP8D01tg4uDTkqldOxG73M9o4ci2VvaQUrb07UDGzH75oDf+tzcUmAP58oR8j0RbaJ2KqF0BvQfKwESO02JeB+DoeXuKrM6rjoiRiuE8JRKLLLcme4YQG6CrYEKa7guArvyAl5YSx+ulQxi4J5uB0ksmzxtf6wXHmg/Zqz2YxF2kAFp28/RT0GYb3IM2by4zFZHkApoLCkVphTzdTYWRsQ0nftxZIsh87pwi9xo123Q/uOOkVDtaU/bdwrgsYaRul1/xVQ7feXXWmL4qV5MXD2HqtXAD1AcaldLlfMPgGeDbgu2mdbxWhYdriEm6DFygjWIkYEuRB06krUuBfLuNfqJkY1ZIqhexk81CiqKWqhfpjBy3V96I+Y03+XlFt/d96TBUiokYEiyZIiTanI34BOvORT7+4uYbF0bPDq+9Z0fegC0z6ZFnZERWUANQNQBnOF4gwYznGZrPkMwL/wPk8MXEb2/8fTdtwX5wcUZzYoOfEzTzw1XjBAsux3Bg5Sqe3p8j3teVtBnWKT7zY4RL4xNc3bBr29ep78jG3XQ67Z4yoGLlrxNVKrHCmpxCkek+JGEbajaQVOJlHQdJBr6evcioByThpr45q8fy/0qjlGE7CNdmlP+Tx1XgKo3kkaGedUq/zEPaoSbe3sLhMYlX6v48kXn7Ai1evQM+SIyCgAbkJ8WZRd3v6Yaxl1ZdC1uPTDh3Sh1SuoET NBkISdSk xz/rnWqzxhcTp7tmM7fXVixg/m4FwJxugMtZbCdeTNnUraNqv1utL/K/tsk4eg59zP6TMnOadSoncPH5uhCffXZa4f0nqkyu2WCAAxp8LL4Zsmh74F/ezRpnSuxyaoT5pHNuvcYwysksHYSjAO5KLydBj9ZWIU1x2GbOg0hr+uvMxEOCkaMn3VVf6p2ejJGehg+HXNTW1cA4gaIwkE64MO6Cys6ghc0RF8TljBZ+iL4/eHmL6OUCcDw1qqB/sTy+HYIngPBqjKzfU6vBEvtRsbeOUD+4rRksxmg9fC41K/Z3Ka2/u9tGH6GYDhBtsIj+Ain8hRBujBDOzIVNYGdXz4+1jPc3KVZQnGeoaJqc5h2JMma2YwIV2jfe9oOZv8Il6y+FClVtNZj+gYrenKI868L8c0shXLOS3PGbDD7HM1rXLuCw9nKbd5+iJAQ== 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 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 Acked-by: Jan Harkes cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox 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 #include #include +#include #include #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, }; From patchwork Sat May 20 00:00:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248993 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 E3BDBC7EE2A for ; Sat, 20 May 2023 00:01:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7547928000A; Fri, 19 May 2023 20:01:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DD3A280001; Fri, 19 May 2023 20:01:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 557BB28000A; Fri, 19 May 2023 20:01:38 -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 350C9280001 for ; Fri, 19 May 2023 20:01:38 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 099811206E0 for ; Sat, 20 May 2023 00:01:38 +0000 (UTC) X-FDA: 80808679476.18.4AE1E5C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 47FAA14001B for ; Sat, 20 May 2023 00:01:35 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tqq5ymnr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1684540896; a=rsa-sha256; cv=none; b=gSt/V+R4fQMngKP4h9mnwcpST/EbPFIW9MI9ukTyHQC9ENcPHOfZjPv6iVC6qEYh+NiGks jikMQPIqIdfoZtyJlM5ZAxl9/znFMYckZ8YT9FuV1xz44G1rRDAwabVVHI6U/xGc0zP39w pJdD88Nr6RY1csl9zTS/U4kuRZzamyY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tqq5ymnr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1684540896; 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=bxp9/2gLZL2I594j4SxMybgCNb+qE9Rj6mhPK/7tAtY=; b=2ALUUDS4rO7uUSiVqLqpTe/BZQsMM9wz7cZxOL/c+EAFM5G/ZIjtpzDlodOCr2A8legazx zV+TYQ8DlGcjF9BNW+3ZsGBWU35P8Mmol3WiTeD70VPjimTyfQzi4hECmbxIKBNkLIM9Ni 2hzmNng0FXiEbEgECF2SREvkqTKMFPM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540895; 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=bxp9/2gLZL2I594j4SxMybgCNb+qE9Rj6mhPK/7tAtY=; b=Tqq5ymnr3Fj0gGCWoja3oySZ0nbr2XNBIBsafUreyGb27zMJu7nq/V93uzHuKWsuPbCnJx +8CFhIhQHOgd9NvWg38GxIgWizENe2ojOaa/vkSiX1dyXdXTkInrlDYP4viS3w2CiT9yU5 Wh7vVEk+Ej99lgzqnRJqy5dWiYfygHU= 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-157-iOPimXDiOB6Q5UeXc2v1dQ-1; Fri, 19 May 2023 20:01:31 -0400 X-MC-Unique: iOPimXDiOB6Q5UeXc2v1dQ-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 CBF973C01DBD; Sat, 20 May 2023 00:01:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 855312166B25; Sat, 20 May 2023 00:01:27 +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, Greg Kroah-Hartman , Christoph Hellwig , John Hubbard , Miklos Szeredi , Arnd Bergmann Subject: [PATCH v21 12/30] tty, proc, kernfs, random: Use copy_splice_read() Date: Sat, 20 May 2023 01:00:31 +0100 Message-Id: <20230520000049.2226926-13-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 47FAA14001B X-Stat-Signature: wrqf8ih9jrghtsykkjcaw6h1rrmtg59r X-HE-Tag: 1684540895-173175 X-HE-Meta: U2FsdGVkX1//Nc/5zcO60xcFByKOUGNXPM1vo6scBTeYx2NoyeODXgzX3iG8mvk8NnsEl5J5lv5+gwiytbFjs0LhU+mSqrUmpfDNCb3smiW9uu4ASZmTDH2+Y3nqeo2I+Me4QQ0S3QqmnaHZ7NlLD0uTnw0zTaJH+OY9MfM1ieTbyQs0ryC8nzH+EU0ecfKg5VO78IhhoH9xXSwnCDndjZbrtA0DY+8481c4+9r2imTWVxQIbS2CCk4nTHrSPseA3H5g2AATVvL8+8rawhxR3nGUXHWCTh5iwuYx+qOYKmLlb6QI40SptbrTu4EEpqbsOHKTlNa6DDRihmALlqH+9eGXrRumDtSA1aBAXsfcp4VsoJymxaZB0l9szelC7b+SvNvPdRcThaYu+gGz9bhsFiDR0tP0PZTCH7zE/v0WQ5st/QUESJhJBH+7rSsEi1p2/m6g0c6O7p/RYX1xk3duGAYofbYLT3h+bo/1k8sXq08zp+9OFf+I1IWXuZigJK2OQD1V2oOPMZxVw9saIjAeKL+V22YwP/dl89UiV7MfhGWUMOiRaeqTmHgpvHg9NYeM1u41/hD7kwwerTbZBJjgcDSYg1QOjntpZIT//aQUDI53+GPYOEdpH4wmbIWornB1iuEVq3xL4RiRgymXQewdi2qUVGF7THscqkhgHM8NlxXUcRRY8XWU2j7Btaleyb/Mw7DzkuVh4QtauuP+yBLAt6rUZ5GW2v88DzZbCihIY482m3bEirVYGFQRcSz5NuI1l1aw/+DkN9r2vGH3z7vMV34MO5y6nqfeEHAtEw43iJ6paSrbd+ppujzZjACT62JJuVPP8Vq6sgccMEEdWCHMSSpZGF2uWBKRS5O6b3R53bBvR2sjFTzFYP4bHuBAgJ1qMyPlRrgPIDg9LLugZTyuKw7hTLK3xB4J12D67j+eCVJCoX1zzHQ/03H5AJ9FtPB+VZRWQdeU0ETU8dzknQ5 Twltui8d AFb0Lw+fDU1l/8GTYU3pRLtRwMIEy6UmCZ+c3MYazU79V8eAjyjzdC56SGzNUy9HgNf896H/UBEI77FdZgGriXXJN3ZwCAvBI++ynYnbUkksny5J0Zt/h8CDmoD3IUM5tvlRqcl8KXZpoxMV6fNZkBKu8ShgSqARziDgG8McQXFlzrxQsk0WvxOAEPyu+7m+afgDIVa2fVLjRG8Ao/H4xdcSOEHN2jP6yVMGe+AGdGCEudkXhjGfSqjHcvmOrK2lZlAh+cf5rZtv+gt2ccvXkY94LMMS/MhvqYbc/1m3oytuR7NUERoVHK3jI6Lx/233DrggCObqUVieUcNKuIU6hIHpxbIgqkrkSad0+b1Nw1LqvSTTVzp9x8UnACGwok3VESWkHWYfZAtIxkKNDd4jyjg+pOkdGEYgBUwpuNBKSnFdVXBjTO96aCwFIlKkKKH8E7QcDHQsi1axHmvSgktu2EQihv1Y65Mrq4mruYymOT5OXoxCVRafsPTT+2gst2r6Q1QO6BLFLRxtH50k3peK4qW/v1Ri1jr5cctNS 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: Use copy_splice_read() for tty, procfs, kernfs and random files rather than going through generic_file_splice_read() as they just copy the file into the output buffer and don't splice pages. This avoids the need for them to have a ->read_folio() to satisfy filemap_splice_read(). Signed-off-by: David Howells Acked-by: Greg Kroah-Hartman cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Miklos Szeredi cc: Arnd Bergmann cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- drivers/char/random.c | 4 ++-- drivers/tty/tty_io.c | 4 ++-- fs/kernfs/file.c | 2 +- fs/proc/inode.c | 4 ++-- fs/proc/proc_sysctl.c | 2 +- fs/proc_namespace.c | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 253f2ddb8913..3cb37760dfec 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1546,7 +1546,7 @@ const struct file_operations random_fops = { .compat_ioctl = compat_ptr_ioctl, .fasync = random_fasync, .llseek = noop_llseek, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; @@ -1557,7 +1557,7 @@ const struct file_operations urandom_fops = { .compat_ioctl = compat_ptr_ioctl, .fasync = random_fasync, .llseek = noop_llseek, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index c84be40fb8df..4737a8f92c2e 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -466,7 +466,7 @@ static const struct file_operations tty_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = tty_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, @@ -481,7 +481,7 @@ static const struct file_operations console_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = redirected_tty_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 40c4661f15b7..180906c36f51 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -1011,7 +1011,7 @@ const struct file_operations kernfs_file_fops = { .release = kernfs_fop_release, .poll = kernfs_fop_poll, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/proc/inode.c b/fs/proc/inode.c index f495fdb39151..67b09a1d9433 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -591,7 +591,7 @@ static const struct file_operations proc_iter_file_ops = { .llseek = proc_reg_llseek, .read_iter = proc_reg_read_iter, .write = proc_reg_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .poll = proc_reg_poll, .unlocked_ioctl = proc_reg_unlocked_ioctl, .mmap = proc_reg_mmap, @@ -617,7 +617,7 @@ static const struct file_operations proc_reg_file_ops_compat = { static const struct file_operations proc_iter_file_ops_compat = { .llseek = proc_reg_llseek, .read_iter = proc_reg_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .write = proc_reg_write, .poll = proc_reg_poll, .unlocked_ioctl = proc_reg_unlocked_ioctl, diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8038833ff5b0..ae832e982003 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -868,7 +868,7 @@ static const struct file_operations proc_sys_file_operations = { .poll = proc_sys_poll, .read_iter = proc_sys_read, .write_iter = proc_sys_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .llseek = default_llseek, }; diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 846f9455ae22..250eb5bf7b52 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -324,7 +324,7 @@ static int mountstats_open(struct inode *inode, struct file *file) const struct file_operations proc_mounts_operations = { .open = mounts_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll, @@ -333,7 +333,7 @@ const struct file_operations proc_mounts_operations = { const struct file_operations proc_mountinfo_operations = { .open = mountinfo_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll, @@ -342,7 +342,7 @@ const struct file_operations proc_mountinfo_operations = { const struct file_operations proc_mountstats_operations = { .open = mountstats_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, }; From patchwork Sat May 20 00:00:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248994 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 B7B03C77B7A for ; Sat, 20 May 2023 00:01:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E362900006; Fri, 19 May 2023 20:01:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46BC1280001; Fri, 19 May 2023 20:01:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E5C7900007; Fri, 19 May 2023 20:01:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1C79E900006 for ; Fri, 19 May 2023 20:01:43 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E9DEBC0ADA for ; Sat, 20 May 2023 00:01:42 +0000 (UTC) X-FDA: 80808679644.17.B4A0B2F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 3E60C2001C for ; Sat, 20 May 2023 00:01:40 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MdYStdPF; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540900; a=rsa-sha256; cv=none; b=egLs0PUhtiKQbFhL2Wn5Glizk0E+Lj0MUjERmgsedMwzQxMUNBtbfRw5/Cdo1SrU1+Ux4+ 0yTBF3/5tc+ARoMS85FIJU19eD15FadyXtBmA3itJjmQxF06QL5fYB+cPatzeT2b9n9j// 1xfWU3CWAUgGI0X5/Is5UjvzHmp0vuM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MdYStdPF; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540900; 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=gRzUovfXnw170GzVg3YWYDNx7Fcy6r2PjCbmCvJAFKQ=; b=YCh2BAao/LlFjJ3F57xhRoOarpD/sdBrPq9/rAa5zsKE0xFKRv/ydSdQgB4VtE7XXZBEkM NIZxcYUSOgnRSweji1V5TSnjiieZsb20+N3RMzvfPaB1SX6p96bvd8nSUfr6CjIUviTNS3 298iVBbL54N/0UycURofc5nWxPvHiVc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540899; 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=gRzUovfXnw170GzVg3YWYDNx7Fcy6r2PjCbmCvJAFKQ=; b=MdYStdPFewWlmVJPWIoViZLxFenCX184Fmmf8KG1X2ZXIfLh7eiecibre5LoQSuB9niARG Ic2ofDNX1zD9hsbYvHTWnALUyVGmHSFpCMOPo6aouZUJH7bHgFP1m3Ccrlm3+0jNMMJvhZ wQ5bj07e14e4wBjDDgskDU87ZiMnyiI= 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-672-1JhP-Y78PWKPthfxNC2xdQ-1; Fri, 19 May 2023 20:01:35 -0400 X-MC-Unique: 1JhP-Y78PWKPthfxNC2xdQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4596E1C041B8; Sat, 20 May 2023 00:01:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4E3740CFD48; Sat, 20 May 2023 00:01:31 +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, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christoph Hellwig , netdev@vger.kernel.org Subject: [PATCH v21 13/30] net: Make sock_splice_read() use copy_splice_read() by default Date: Sat, 20 May 2023 01:00:32 +0100 Message-Id: <20230520000049.2226926-14-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3E60C2001C X-Stat-Signature: 4uc85edps5raeznbawkz8i5ahumnz986 X-Rspam-User: X-HE-Tag: 1684540900-390507 X-HE-Meta: U2FsdGVkX1/QDKAZdF/qtXf5fAhGgJ7Q8arP8vWv7pmrmecHY3UFjejRiIOMvZND7uvLeQZXyhApmNWIR6pJnrZB//SVsSn7xk0x5dIOb8G5GSnlTMHHpnA7egeLIWnXXtl5lETj9if42KkTSI+EoWcHQI1FCHOwjtwd9VRep5N6ZvXLqY4n48bVrL0WbROG2HDZbcBnw6j7vm470PExtgC+eKqHQRNEmSQrgvvMEyu0wzEVnug7Pg6A/Nf8HMeJLDBB1bypGXIjeKPKj7uXvoTPmOMCWLXhhi2DaqzF3J339+J/cuh0oFlbZpWiuEWq3ESq6nDAKm0bqAQ3vPfviyz/XnleDi665QVUwDWaauUnesOqjBkAN9qv+mGEOEIcmrOQc7OuhWPUKdXdvLhpTL1ApzptC8S2Z7RTj4p5Co3zpwkePM1cpkn2RuD2Yw4FfqF3yK/51LOoqdtR1j9spGz1gzaF+vV0h6kjvs9PMnePfq+9Q7eexPM1Vo26OUmUaIOgYAeSBVjRfT8BDZNaER3wLjBnzTnqYdMbkMmuol1E15gtObbOVhTr6E/i85KDn5mTeaheQKdy/1tL0ntEESr0lnsHdeeOmjAXN3UjUcDzQLk18GO2JFRMfNNbcBL9Reus8UrucMzhX6GezeSj97DP4Q4NGrCkM7Ohw2LidQQEzXSTR34IBTpgU6Y7wSR1NPDIij8hiit8Wpqiby5EEqq5TXCTYv0e8z6pPl9aQeZiu8VM2ympabnGMM84PhibDNJSnHHGw8wPo+rjk0TL+W1eMicbYyKL5TJDYCZLuTToXnrZflw3jnBZmRc1yaNOBle3VjBopCqNtPApiJZOIrikjz3T/oE97Qyw268gkQnZ7vhOQjfaeKhPSNFy7rNWxTyXDtmyF7hA9GRnJbLxQvMj7z+ll3NnP9hx8Jk+bitcTJWVhkhmp6mtXF/9yXKFMmGWjpkn0swEsI7UjQj 3AHRyynf aZic/Sc+mSkTS1Xg9Mryr3h6MDGhUKCK6AKwbEhVY0mVBvUFIdf7qA8XHIFGXe3xYYkPnh+5vitJqYdmVWySZBN/wFqa385dSyM0mNazzmcc5dCeBHNPmdjWILf5nvB3Gg+Nvs0zEl/iNTOwIKWowJJxU9U6V4/KIu08TVPZG/hRqWmpB2Rh6DsqUzKw/t6Y3AT2I6nO0o0agtBdaY4seuzj7cVlGwCA1oACCJ63f07TdlhTyToQBKGxYJKJq7aDWg59zq07+NmSv/xY82RCFu3Vm756pZHSsut1s6QSrXgI07M9ssGtr9TjzgUeIh3Hglsy8rbvtobGZ5+1rN5Rl9Lsp95JCUqKAzVnEAcC0GymFmb/Qq9JASehq2Fpty6cprjfQUKmtqPc3stE6cdmuShyr7ahp5XPvLLF6D152JUVEdXZlBXjH3Epae8+vNpOBWwXQ/3WF3ufAF/I+/XQPOdXG534D5Ahl7s1E 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: Make sock_splice_read() use copy_splice_read() by default as file_splice_read() will return immediately with 0 as a socket has no pagecache and is a zero-size file. Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: netdev@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/socket.c b/net/socket.c index b7e01d0fe082..401778380195 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1093,7 +1093,7 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, struct socket *sock = file->private_data; if (unlikely(!sock->ops->splice_read)) - return generic_file_splice_read(file, ppos, pipe, len, flags); + return copy_splice_read(file, ppos, pipe, len, flags); return sock->ops->splice_read(sock, ppos, pipe, len, flags); } From patchwork Sat May 20 00:00:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248995 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 95D8DC77B7A for ; Sat, 20 May 2023 00:01:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35CBB28000B; Fri, 19 May 2023 20:01:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E58F280001; Fri, 19 May 2023 20:01:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1629B28000B; Fri, 19 May 2023 20:01:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 02121280001 for ; Fri, 19 May 2023 20:01:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CA91040B8D for ; Sat, 20 May 2023 00:01:45 +0000 (UTC) X-FDA: 80808679770.14.4F3E80A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 112FA80016 for ; Sat, 20 May 2023 00:01:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c8QJFDuy; spf=pass (imf30.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540904; a=rsa-sha256; cv=none; b=x+M2l45FDd5tksqNk/l0fvgXfBd2zHYjpPnTHM89amZl0UHnV5RloXIMdSFsuHGnnqlMPV UQ80HWvIpGPZbaNGDQVUaknu1qjJPVFIPBVqYnDDoGVcEBqQJcR1iIYLe3KkbjX4LznnP+ +054DMUGO5Ur/BNWD57NnOqQZdlc7Qg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c8QJFDuy; spf=pass (imf30.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540904; 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=L0untNcr1icklU0hwhU0ty94Xf23B/VjszjVy/DS5Ow=; b=MB/81mkE0qyZW7+CXD1M8vKzLAs25+bt5yAp7CMidqLedUJozqQzbiL91vSa7sfqsUPnsS /GZwn91MbXP1k3OV/WsyHJPkImqiHgtAEB7qwUsPDXrgdluQjB0IOCI9dnsyCeFA3pryKX TMupFjSgj49j8dtQTebLv60aBQI2NF0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540903; 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=L0untNcr1icklU0hwhU0ty94Xf23B/VjszjVy/DS5Ow=; b=c8QJFDuy5MYbgzbTt6diemFHS40briWr/q8WQ9sNyEW3tK6WA0cV3ech6dozvi8y814/hX U8Vj4ZVB+WDtvUS4m/V0M4Dfs1hnZqTkAU3ZsiUWilp+kIAI7Z11vne3SiWuI3vE6iXtqt j5Ph1MK9us8BMwFpssTLnv7XDRc1zg4= 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-144-ZoV9UQXCOsyihBFlh8yZBw-1; Fri, 19 May 2023 20:01:39 -0400 X-MC-Unique: ZoV9UQXCOsyihBFlh8yZBw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C79A38032FA; Sat, 20 May 2023 00:01:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0872492B0A; Sat, 20 May 2023 00:01:34 +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 , Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov , Christian Schoenebeck , v9fs@lists.linux.dev Subject: [PATCH v21 14/30] 9p: Add splice_read stub Date: Sat, 20 May 2023 01:00:33 +0100 Message-Id: <20230520000049.2226926-15-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 112FA80016 X-Stat-Signature: guutrnkx39s3sncucigxpf9isafowt6t X-Rspam-User: X-HE-Tag: 1684540903-539626 X-HE-Meta: U2FsdGVkX19mEajBZnNVU9Zcrvx4jbjNFlg1CbdOwkP/0UFDXELZFhQlgu8Adm/YVM2Jw+eDEIOIP1R/5/4c4y5oStXkIvPcyR3qUbpvlaYrBFXnS55NQ7ucG571qiPilnweOxCZKODWKAycF/6DNgDWgrfmfTTxoKUtijrikOiMsdEXqSwQYIULDsqj88WQe7R+l+Qz18MwsO6Oj2SX12VtrhDqFzwI1uPL7/4DFrrxeKMXvlbqbH8HYVsKmNoDbnWnmQOWxDG89ljvds+5RXk4zXV1BNizXbzQkF2Utv6iTmvNT3sOXwClq/rfMEP6f2zpRcVXFxw+El4/kYpa/pDurwPpxPuPScT97d9C0exjELj2XBluXm60kdpcd6kor0tTmAp1fqtGdjkh3cZxxQG8lPQOJ7VRWnpPOFi2KFVlvwJO87rXDsuZDyh3Ij9K3F/kI8AZ7tZkKDMbSxDZzl6HkXmLkLBoZ8hSrz2GiRYz+mfMdKlbVR3xp2+JIC/xnd69Z1LJ2ipiVtnSY0KcFIiCqvhStuhQYVpcQ3L64v5hjoHgwbJpnq5Dj6/qG1opCHG+ZzGOkhq4QwT6re1V5xesy1p6jgG5UPYA5yNOAGaPgnVekhUnlWfKff6Zyv8lda78HrI/JbYghDBuHzOuY22joBKGa/G72pugAExms0hrx3ldQiDyV1SMI8OfA+Ac/w7QKdnzdGiCaHAiBVpCIQWhMPrH26qTwT2WA1dGOkqPu8Sm1Te+hti/6kFqikRHEM2ikmxBb6qWrLVkw5u58jEBxphsLFulEBduEllceZfHCMBSXWyAP8K0N2LJ0rqTziMKllVeoYLHheIZcT5SB2HAi9uLhKib5kpRtu7l0xXRicvtsBry4UTgZMbiBkb7gYRqxBUwxFpLVrwOlIsIdLI78p7ZVJM/3LudjvJlLvCzS/VdR6/gSQraguaaUZGgak42xhYAejOEb55Iy1o qA7UH5UK GsLK64cUVf/XWUbeoE7NYElujkTZnfwzce+kTAsybpQSbcabQtsoxpOLY86fg79hMMa3G9gCT9ufjS72YpzRvPvc6BdyH3O1MqCWhEj7kpeQU5ocPOwnMHIClsMVm7647fqoppiARvrQ582n0+MHY2ywrqNkz34OGAtg9X4Sbr/5jS86gi9hhmfS9c2vqyyrvdp3SrpcufgTYJDBX/10WNy7KogUrvw8mQmO/fHYfC0XaoK17UjCwsm742ZQjW+vQVO1uOzoWZOu9/y0nURsSyFv6cUcG5TVIkF8VzP/S4Ck4/pvdD0eSnm5Hbo8kj3oFUKVkeL0DtwaxjoXmOW/vWoDm+M4eDxZ/zULVPMxdyE/wDCb/6cqO1dwR5IsUvwkXxZc7dntbqQRrLU343c84ap7TcAREwM59oYX4hT/BZpdKzMO3as0znD9MYwXB96Vsr/vg749gjZFGWY1xsoI45oC+VXiaGfPT5qBANJ7QMdkS1XqFNDLD7gRNlsC9p9XXyQuSdmkgLdA05wkGMjZMEHWfhgG3NVfHqlUKss8LG5DrIAj+QcunfMrp05k4wGhWU4DJimb1IIGltqs= 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: Add a splice_read stub for 9p. We should use copy_splice_read() if 9PL_DIRECT is set and filemap_splice_read() otherwise. Note that this doesn't seem to be particularly related to O_DIRECT. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Dominique Martinet cc: Eric Van Hensbergen cc: Latchesar Ionkov cc: Christian Schoenebeck cc: v9fs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/9p/vfs_file.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 6c31b8c8112d..2996fb00387f 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -374,6 +374,28 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +/* + * v9fs_file_splice_read - splice-read from a file + * @in: The 9p file to read from + * @ppos: Where to find/update the file position + * @pipe: The pipe to splice into + * @len: The maximum amount of data to splice + * @flags: SPLICE_F_* flags + */ +static ssize_t v9fs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct p9_fid *fid = in->private_data; + + p9_debug(P9_DEBUG_VFS, "fid %d count %zu offset %lld\n", + fid->fid, len, *ppos); + + if (fid->mode & P9L_DIRECT) + return copy_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); +} + /** * v9fs_file_write_iter - write to a file * @iocb: The operation parameters @@ -569,7 +591,7 @@ const struct file_operations v9fs_file_operations = { .release = v9fs_dir_release, .lock = v9fs_file_lock, .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync, }; @@ -583,7 +605,7 @@ const struct file_operations v9fs_file_operations_dotl = { .lock = v9fs_file_lock_dotl, .flock = v9fs_file_flock_dotl, .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, }; From patchwork Sat May 20 00:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248996 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 0AC5BC77B7F for ; Sat, 20 May 2023 00:01:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92AAE28000C; Fri, 19 May 2023 20:01:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DD8280001; Fri, 19 May 2023 20:01:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 668C028000C; Fri, 19 May 2023 20:01:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4D673280001 for ; Fri, 19 May 2023 20:01:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1D0901A0B78 for ; Sat, 20 May 2023 00:01:48 +0000 (UTC) X-FDA: 80808679896.12.1691A41 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 4FD2CC0008 for ; Sat, 20 May 2023 00:01:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i6gC5FIG; 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=1684540906; 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=up+z0f8N3Zv7uMXFjNiQsDQ9kDW1Zh9kN/9jDbkWuHc=; b=PN+f6tJqkss6SY5WYqj6HyNe3g79oEoo9PdlYUCJuG9cBSdPzLAo+sTS1FvHa9sUEmNcha Z3gzVX7qSZW8YNeUdWXcWYLJVr9LckHUrFcBsFIsslOZwjb0ImSb32SSMzcUq/YVZEM8Ef l1rkxkQm8vzGNhXQQsbawfaRI7GddLg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i6gC5FIG; 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=1684540906; a=rsa-sha256; cv=none; b=DmZyTHybWrbVgRQh85a7OPjR+wTILPGhCqm+c3wh+O1aw6FU+M0rcHGkvBFg47nG1J3qQf b4xXqlhYS4ShXKD771DRWLYvdY+au6qCURf/kK+7/TBDHsHtqVanJVCkLZD/hklXbOBAPX txPw3slaUdYjzglxpafDMCfXp6PNsOc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540905; 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=up+z0f8N3Zv7uMXFjNiQsDQ9kDW1Zh9kN/9jDbkWuHc=; b=i6gC5FIGhDEJy/ZjxhZT7L1fsrM/3wtPfiM9UvUt1cSFYmRrp8kqEuoh03iRtbXR6CBHW6 qgwUGKlXBOmILfTSgPh0UhBTtj25Qp90Q0uaPcmuAxJm+22s1EntHukiMIK0cjhldJvZKz HHvldDsXNiR2o44I5K18MOhk7YFBHAU= 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-539-gS634MneOxaFqMs-dNTBgA-1; Fri, 19 May 2023 20:01:42 -0400 X-MC-Unique: gS634MneOxaFqMs-dNTBgA-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 32340296A604; Sat, 20 May 2023 00:01:41 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66C3F140E954; Sat, 20 May 2023 00:01:38 +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 , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v21 15/30] afs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:34 +0100 Message-Id: <20230520000049.2226926-16-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 4FD2CC0008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: c7f5mo63qb7auf3fe64cd38aimp7pmug X-HE-Tag: 1684540906-358013 X-HE-Meta: U2FsdGVkX1+Ug7Efwy8vJ7gDcvJGASYFlNCSLOM2JjxcYE7cr06AXZg6MQnb/Ea8xVAZZIDvGLsDkZ3+CussHH0bJGPBAknVzG5s8K39PL4iqm/2aw6SR/uJucaAHCPUI91nuo/ys7IBVU8bjkgpxzM21ZhqjN9ArhjOKXjWZ94nAqcyD2Y1AmYa5Cx4mWZPPvJ5DsgaestUN1vD/XRtgBcomCgiSkk5Bad0NJCSuUY6UjzR/f/bNh4G8f0Dv1dHjATsiPN1r4HbjIEmqEd3NITFt3G5IdkGpSDACK6FxsfS0NOHlLIzUkW+PWQyKz32QL1a60atCG946/Xw/TDZ+pK86zIOmSqcWufueFV1OqWvLPo/AyWfF/q+6KuDO3DZXd6slKE2QDqQVmD3tlKK4VQyikuCNvFspiiA8Ro+qCKpShYVvv52DAI73p2yzpxePBhaTr4ieqUMdk5+XjhNLeT/nDhRYBPQuirNyvfUoakoLe50BfQNV5noaIqsdtC2Xq2FbAVasGll5kAINhdpfvhMh+EdQ4qL3X05bVsD0hSQG3Pzul4GQE/RZAhkgrqX8ocNhax/Klq3bsUWu2UejUi3jxuvTSae7EHs88DMtCwwDrs842zLLi3wHlBBuvyiyDPp1s+MlAqz2xZ3z6aVP9BOTpcXCzcZoibynmrtJ2AOKsiNicEET/6+O6pWegtTMtFNr7kC9FYh2Br90+UtGjmqmPGdcMkFJRBCdvxUc2WAfPy8JuoWC9rqiRqRrJeC7r/PfxIX4myKGE1IaVO322kA9r0sZGk+BSdbwYak7eweQs45GKhI3FmF+xR4C6yaCvFgKBW/Icbq+tnp3uk/BrTv4L7FLGPk9D1pMaK8DrpnYA3SILPmPqbcHVfb65yzKNb2io6uUKrd/Mnccig3bqI/ELOJRVtWGdN4DdpMa5ChZSEkvR7OYgRqVLMsA1vtGg44G8oHFNqfa+DiQ+j oIcuEyyr 5ENo2vu7/da8TYUmgYcIAzNUJpX4INfeNfzB1Qg4lk95HaDCncS0DymV5IEF16LiF4CnV2Z/iNkPYPKo+/mY6Q8MO6KJLdD+/+516yg7ViqHkdZAhl1ZAMwMVNyLLrJFMPjqFJVlVioesKqOZeEWtQ9F9s3PUrs1NIrhmfGQ6hRm86GIABJXijce2UpsKixSRwAZAE8gSFiZDpJKmXW8nj6xwB38Cv37a0JOkavc/4o/tmiYmf3UlllZjPI01sNWfsxe55gx8invRj71lRKE6XeG2cJmhh/ZOKSk8EF927fXAGdiz4ljd9g3V3Xp6Ok0bC3VEYEEOPB7/yNonStcw8lyvuD9po9aP78gQsajoCtNHEfYw1HyIjePuaPl9CPmDZfFAwi81+Pwb9r033WXW749OO2zJRDYJvj842g4XiPJ+mirwC0IdXwGOWw1O+y2Xq7FUCuxnGsJDzdmnpiUlNNK3uw== 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 stub for AFS to call afs_validate() before going into generic_file_splice_read() so that we're likely to have a callback promise from the server. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/afs/file.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/afs/file.c b/fs/afs/file.c index 719b31374879..d8a6b09dadf7 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -25,6 +25,9 @@ static void afs_invalidate_folio(struct folio *folio, size_t offset, static bool afs_release_folio(struct folio *folio, gfp_t gfp_flags); static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter); +static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags); static void afs_vm_open(struct vm_area_struct *area); static void afs_vm_close(struct vm_area_struct *area); static vm_fault_t afs_vm_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pgoff_t end_pgoff); @@ -36,7 +39,7 @@ const struct file_operations afs_file_operations = { .read_iter = afs_file_read_iter, .write_iter = afs_file_write, .mmap = afs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = afs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = afs_fsync, .lock = afs_lock, @@ -587,3 +590,18 @@ static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) return generic_file_read_iter(iocb, iter); } + +static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct afs_vnode *vnode = AFS_FS_I(file_inode(in)); + struct afs_file *af = in->private_data; + int ret; + + ret = afs_validate(vnode, af->key); + if (ret < 0) + return ret; + + return generic_file_splice_read(in, ppos, pipe, len, flags); +} From patchwork Sat May 20 00:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248997 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 F2E9CC7EE23 for ; Sat, 20 May 2023 00:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DA7428000D; Fri, 19 May 2023 20:01:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88A8F280001; Fri, 19 May 2023 20:01:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7044728000D; Fri, 19 May 2023 20:01:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5A7A8280001 for ; Fri, 19 May 2023 20:01:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 38E2AA02FB for ; Sat, 20 May 2023 00:01:53 +0000 (UTC) X-FDA: 80808680106.11.785DC90 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 8783F18001B for ; Sat, 20 May 2023 00:01:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XXwp6s99; spf=pass (imf06.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=1684540911; a=rsa-sha256; cv=none; b=w7EUCVKMyn6LZk0kuM7Gv5XAb8mRxVbYWijIxmiGTetLrwb+XC+mrYhnfd/lTkDhaKtOOQ z0eW6fBjkQYoVDelNp2IvM+GVGbj6Xag/wLZa8/3Zg/Ao9MtpFEV2TjiKu5/2daIAEfXuI PiL8Rft9jNBr3XFKE78Y1BT5z34h+78= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XXwp6s99; spf=pass (imf06.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=1684540911; 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=Cum1S+7gn4EZ2bOhEKX0VsfuPYHKWsPejiTdFi4FGTE=; b=294oYK8bOP6oaydoiwr06ZhGa00zPJXRgA13sbbZPZM7m3bcny2haNQPRDwzDh5JSeDiwm oJuqxulv7r8QmYOD93wcdaIUJB7jVG5Nd4ET1QzPB5aixsGJYIOKwtHRzU3sxsbAHNEFED CWfQWWW7FwUkvd4p+qhEreHAHwNBg2Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540910; 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=Cum1S+7gn4EZ2bOhEKX0VsfuPYHKWsPejiTdFi4FGTE=; b=XXwp6s99ARRTNY170wej4Sk4gq7j7nFpp8k4lWUseLmRfH8MAEBDfqiEhHU0Q9ABUWmlyo /Eko/nytmDUCTwODQdbb5apyerSiufWCYNnlpuSPpMbud138j5mHn/dboj86j1UFXmGavn eA1xjT2VUx8E1Jtw7gYV0Bsoi+K+3H0= 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-665-z6HIEepYPKSALy6n0W2a0g-1; Fri, 19 May 2023 20:01:45 -0400 X-MC-Unique: z6HIEepYPKSALy6n0W2a0g-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 5A1BE8032F5; Sat, 20 May 2023 00:01:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077812166B25; Sat, 20 May 2023 00:01:41 +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 , Xiubo Li , Ilya Dryomov , ceph-devel@vger.kernel.org Subject: [PATCH v21 16/30] ceph: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:35 +0100 Message-Id: <20230520000049.2226926-17-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8783F18001B X-Stat-Signature: 553e7uzjhzityrhd1d4uaj6bg5nj4wtz X-Rspam-User: X-HE-Tag: 1684540911-592252 X-HE-Meta: U2FsdGVkX1/+BiAu96HKqy3XVHbMspD5znv/GUzcWrSTBL/06hnLqoW3n3JMkzhN7YK1SQv/Xa2KOh7OUrK+z/JDFD11GWGiu0u1uY6Ng2KxWi2Eckc6L+YlgeuTGJ6ft7FNApPjumw0LCAWoiN4Fv7VuAjeIDorEw2GT+6rNdJVjzcmE/ePJqQbDVZIHFutnq7SG2AnsY+uzvmurffIF9N0MIrJudmfH7f+kuKU5c1MVkwHvWujgWYoC1wbHjMiq6uOtr6I/ZPPwf86IeF7H8ynSVf3k+7MCamE7k5FL/j4enIRiizDDVnFl0XK3OweJbZMfDOuj3AyPzUHs58COnagy0hElHIk29yagZ87V3mARQ9ntTBRbRJQxZupjaoV4ldZtW/zfVK/e63e/AdojuvTodyqHhOANtr1rxYDhd/Uae6Pf88ioEtNKVl+fRGSY8DqJklNRGy6Suc3RGViuoHN872nMHfyBPBaKuPMx3Azg1lMBk1jUTpVQI7Th6w6Q0M+UVKubjV0j3O6aSNNDmE8jsquWVgcmUSASMupe98kHAwWBrAGx3CUbijW1qgE4FoAjvenaDXZpe3u9colQ3G6Ql2C0RjRBQqHyK10TU8mLotarqNLTkPJUCVRq3zG2M5TDfq0tSe62RGsMjolVmfKLC13vJSuAHrc+yzjDQz788LdP51e21jpzH+qYyxs9BY1Yg9jsKkVj46ZiTZL4BeiRbwR1mYvzUsAs70/A2sPFnqkTMtdr0KELS4LFbzBb552M9xUTNPB9opcf6QR9lTf0TvMIF7W+G6DKU9g6CFIGxKZjBpniDz8ukYoIFz6sBj5H8cRw5zPnKZKC/gOA7ik/+dq+4LuMeUs7bXwocCJC6UaiR85usahV0IPw2VWeKhr+Xc8ua1kI+Mp8L2pwQl7ME4G+M0Gp7v7KQ0qiR8dITl7AeARl9ZVHGg7otWCDsiG4HRC/1tFRjAIOTk uoJP29v6 oI2egHhNeBBSE8LgJqOgh9JGR9B6WqxtuubXA9p49v5g6nkHlbhszTXp9wEARGRCMi2EuECZXxr0BuL1PKNRaiJoQOU6/zEihSEPvFlW30q0sTJKz0PAjZ/CVxWkVhxxPuF0ai2VVhVnLgogzSPxF9d5jXgYAWWym/kjr3MFOeYwJ+rgigaDoF0s3AOf/vKuh5C79ZoRHyUVqGAu9jop5xODf22iBqM76y5r76y4eXXJWeXEe4DBwPtKVBGQEolJGY6C2dKpDa4oDb4OYsZPdOSHqpsL3B2Pkh/zxQWaW1AMxjSAT+Huz7gR+a55k1qFEgN/wXvk9DTtsAq4sIXD4tsNO1pGicFfF1llPh+2FlH+8pi7kCjZNfz0TFw== 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 stub for Ceph. This does the inode shutdown check before proceeding and jumps to copy_splice_read() if the file has inline data or is a synchronous file. We try and get FILE_RD and either FILE_CACHE and/or FILE_LAZYIO caps and hold them across filemap_splice_read(). If we fail to get FILE_CACHE or FILE_LAZYIO capabilities, we use copy_splice_read() instead. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Xiubo Li cc: Ilya Dryomov cc: Jeff Layton cc: ceph-devel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Xiubo Li --- Notes: ver #21) - Need to drop the caps ref. - O_DIRECT is handled by the caller. fs/ceph/file.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f4d8bf7dec88..4285f6cb5d3b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1745,6 +1745,69 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +/* + * Wrap filemap_splice_read with checks for cap bits on the inode. + * Atomically grab references, so that those bits are not released + * back to the MDS mid-read. + */ +static ssize_t ceph_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct ceph_file_info *fi = in->private_data; + struct inode *inode = file_inode(in); + struct ceph_inode_info *ci = ceph_inode(inode); + ssize_t ret; + int want = 0, got = 0; + CEPH_DEFINE_RW_CONTEXT(rw_ctx, 0); + + dout("splice_read %p %llx.%llx %llu~%zu trying to get caps on %p\n", + inode, ceph_vinop(inode), *ppos, len, inode); + + if (ceph_inode_is_shutdown(inode)) + return -ESTALE; + + if (ceph_has_inline_data(ci) || + (fi->flags & CEPH_F_SYNC)) + return copy_splice_read(in, ppos, pipe, len, flags); + + ceph_start_io_read(inode); + + want = CEPH_CAP_FILE_CACHE; + if (fi->fmode & CEPH_FILE_MODE_LAZY) + want |= CEPH_CAP_FILE_LAZYIO; + + ret = ceph_get_caps(in, CEPH_CAP_FILE_RD, want, -1, &got); + if (ret < 0) + goto out_end; + + if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) == 0) { + dout("splice_read/sync %p %llx.%llx %llu~%zu got cap refs on %s\n", + inode, ceph_vinop(inode), *ppos, len, + ceph_cap_string(got)); + + ceph_put_cap_refs(ci, got); + ceph_end_io_read(inode); + return copy_splice_read(in, ppos, pipe, len, flags); + } + + dout("splice_read %p %llx.%llx %llu~%zu got cap refs on %s\n", + inode, ceph_vinop(inode), *ppos, len, ceph_cap_string(got)); + + rw_ctx.caps = got; + ceph_add_rw_context(fi, &rw_ctx); + ret = filemap_splice_read(in, ppos, pipe, len, flags); + ceph_del_rw_context(fi, &rw_ctx); + + dout("splice_read %p %llx.%llx dropping cap refs on %s = %zd\n", + inode, ceph_vinop(inode), ceph_cap_string(got), ret); + + ceph_put_cap_refs(ci, got); +out_end: + ceph_end_io_read(inode); + return ret; +} + /* * Take cap references to avoid releasing caps to MDS mid-write. * @@ -2593,7 +2656,7 @@ const struct file_operations ceph_file_fops = { .lock = ceph_lock, .setlease = simple_nosetlease, .flock = ceph_flock, - .splice_read = generic_file_splice_read, + .splice_read = ceph_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = ceph_ioctl, .compat_ioctl = compat_ptr_ioctl, From patchwork Sat May 20 00:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248998 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 CB933C7EE2A for ; Sat, 20 May 2023 00:01:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F3EB28000E; Fri, 19 May 2023 20:01:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57DE8280001; Fri, 19 May 2023 20:01:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D04F28000E; Fri, 19 May 2023 20:01:55 -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 220FC280001 for ; Fri, 19 May 2023 20:01:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F132A1C79C5 for ; Sat, 20 May 2023 00:01:54 +0000 (UTC) X-FDA: 80808680148.21.D0AAC74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 392701A001F for ; Sat, 20 May 2023 00:01:52 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqZ8/zFW"; spf=pass (imf19.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=1684540912; 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=zZb+7DwI4egZIrF5pxcV1ZQbliPAo6greLJudpvGjhA=; b=ynQcK69naYr5KMTLKZeCdcmJV8rno7LaelawoSWdghvHmI3VyQYVTx61bIHEsG21+X/+1A HmFxEzkLe17YYDC/WMnNyJToWP8p0jXpgKuvvKQlll2EZtEle8tMY5He/dYTmGP56/eU2J 2TwF8TRUOWPrgsdrGT0DxhTvSm+Bjuw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqZ8/zFW"; spf=pass (imf19.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=1684540912; a=rsa-sha256; cv=none; b=AWQxKaVLFOO2sLHiSVb3szBNP06LKvhs+IaPN97lPcuMIo+OhD6OkA66tbkf973OjOeFGI NdMvvmIr/jjiIaiPg3AsgL44F8sPkjEY/p58OyzV9jdfaMzf3rmGYs83/l4ycczs8Pa5EK RDUw2WnKrYmpZEnEU8BOgXxoFV8PEBs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540911; 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=zZb+7DwI4egZIrF5pxcV1ZQbliPAo6greLJudpvGjhA=; b=hqZ8/zFWUuZlxZRMLFVe1W/DDXBoLSAtvS1R6Ao1dWFt0hpObVLSAH2O0XWeaq49HaruNV +GPN8KjMBFmZNXjT5RYIbqXPsqAE9O+lRheQUwHc+FNS7XQcxhqLzSSiGz1t9k9xFxN1NQ ZUAglNQEDypmuF5sA0Vn2C/blX2Ck+E= 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-513-G93-k9ToPbKP465srY7iiw-1; Fri, 19 May 2023 20:01:48 -0400 X-MC-Unique: G93-k9ToPbKP465srY7iiw-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 2F2AC85A5A8; Sat, 20 May 2023 00:01:47 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00F7E4F2DE0; Sat, 20 May 2023 00:01:44 +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 , Tyler Hicks , ecryptfs@vger.kernel.org Subject: [PATCH v21 17/30] ecryptfs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:36 +0100 Message-Id: <20230520000049.2226926-18-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 392701A001F X-Rspam-User: X-Stat-Signature: hb97e5y3txa9xkepd5sz76irpodft9yi X-Rspamd-Server: rspam01 X-HE-Tag: 1684540912-22014 X-HE-Meta: U2FsdGVkX19Iv2Ds+Updko7DNSmdTh2kwF7McZe4yg6GrvdUi06LMcNcfMEhFdjxkPx1aPWJ7jmUhfkBHDqgJofXXZH3cu8tLLT9LwkGCgXdQ1B/0tvkcwTdbjKZ3Esg9sVFsVdJaQ1ddSSsqOXbQdZh/pbd8QAg9v2+ASPqaxvVlj7kmsYZjckVs+5YOpYPW4FZ9efPiMu8AJSC2rYIgWxKkM7O31yi3HDNwog0P3MARb/gMakXE7vmSr8AnEt4tlpTdbqsyWi47kjHPCSpzM4rIML+wEII4B8X1rPCHI71zpldUym+ralysdUqqDVGr4Hc6vAT/BxfAQ6/qswjjoYqA57LTcSX9EQ+qX12smPN/vsGB/H2tX9c0czaM25KLxppVY7KOad5CZoeGz2jaXnrOeMiisYNImilCrKUPT1CYNcdSPY4SKHjiALZaqWyYQ2iUIe00iMNwiBWt4YyhbXGiuvOYKvSaEVxVG8cyuAu4tdaU1sf2OgO5wnOU54Kn1PIw0Pi3UUYSdXkoqQXkTbnEcBt8PPNejmUQEaL/EOdjEwRQ7p9MOkOEzZLXNQcmpztmUP4zfw0xqO/vuLeW8ie/FyF/bWWoEsj3VDUl1dSMKZAnT/f6Pdew7FcMet0vepounktlAe1CRlOjh/lSiB+pbDYINrWuDGHAQmJUpnesYUekO05rhhAvWWiGTYHRwYqvaF62m2zl4gEC/iCBxem6MjytyhmH1EkKqHKjUfN5nnf+AigZPRgA4kQTW7Bf9X5uuVxOLkLi+81qM3VcB0Z3ZukvK4GC+NP2QkfVzAPnSG0A4KA5nWe5kX0yuhFn8t0+mHgpiHuTXiB7p0+IiYFuS2ItxRxcHt6EG/325AtjSDGAKLjoGN80ibTxNN8IybV+uoIxS8t4zWHMyhlmeR7bB3rDE05vFN2ihPWY8UkqhgP/Rf3ibrjMiYj7fU4APV4BdvpOv95/irgIGc QgvzTU5P rwIO+CWjqtnPM9GhwNmCu7jWNCqG2Y295Zxa2mkr+8XbzjI/Qsa9SqPdou15HGwu9CS+8Cc6jKr5g6jX4dg8VXMMxtAo0H+WjpERk+EcI7Ia4xS8xsR1L5M3kCbomqqV1zRzMH6FKY3xkALUBUZUg815rihTHubdQVLXCeXDp2z2TlKVnbXPwIk1yGWx9FC6pUCXjHBq5Vf+CHDm4QgIHUPU2MdW/IvvrH7yQKmogYk/nUXAeG4n7bmbAxtzeUBNt+yqL89ksq7khSBoestMbas1fwcEX+SdwhL3v+/Sf5hZHXzNVAkjaN8kTwe8MIhkHIloAkZv9J5DsNm85sdd9USygAVm23Wy1WwFy8Nz7w6qLn9h+joJdzPkNtFVOZTdNHLy09i1/W7qh3hnt89mKeqJexy9rm73hNe84 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 stub for ecryptfs to update the access time on the lower file after the operation. Splicing from a direct I/O fd will update the access time when ->read_iter() is called. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Tyler Hicks cc: ecryptfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ecryptfs/file.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 268b74499c28..284395587be0 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -44,6 +44,31 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, return rc; } +/* + * ecryptfs_splice_read_update_atime + * + * generic_file_splice_read updates the atime of upper layer inode. But, it + * doesn't give us a chance to update the atime of the lower layer inode. This + * function is a wrapper to generic_file_read. It updates the atime of the + * lower level inode if generic_file_read returns without any errors. This is + * to be used only for file reads. The function to be used for directory reads + * is ecryptfs_read. + */ +static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + ssize_t rc; + const struct path *path; + + rc = generic_file_splice_read(in, ppos, pipe, len, flags); + if (rc >= 0) { + path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); + touch_atime(path); + } + return rc; +} + struct ecryptfs_getdents_callback { struct dir_context ctx; struct dir_context *caller; @@ -414,5 +439,5 @@ const struct file_operations ecryptfs_main_fops = { .release = ecryptfs_release, .fsync = ecryptfs_fsync, .fasync = ecryptfs_fasync, - .splice_read = generic_file_splice_read, + .splice_read = ecryptfs_splice_read_update_atime, }; From patchwork Sat May 20 00:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248999 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 0FE1AC77B7A for ; Sat, 20 May 2023 00:02:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EB67900007; Fri, 19 May 2023 20:01:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9755A900004; Fri, 19 May 2023 20:01:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE23900007; Fri, 19 May 2023 20:01:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6A1A0900004 for ; Fri, 19 May 2023 20:01:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3A7A4160B89 for ; Sat, 20 May 2023 00:01:59 +0000 (UTC) X-FDA: 80808680358.07.5C73AF5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 859E3A0004 for ; Sat, 20 May 2023 00:01:57 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvGybMym; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684540917; 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=qie1g7ABANTtTR0bfsI5jgl8Vmls/curDgoBmVrj5jE=; b=8huWAvcVHsO+FJzfLgoaaSwtD0bb/YBWzokU/QYHfnib7jXNfqhOZ3nFh+p8zjgj/LqGw7 pPNDAeXH5GVxxIBbrMy24+RfX6vBnkpS/zdGm757oWsTq9YsOvmEb/FXsg+x5gby6icODC sBDSClN9Zw7B7Mgw16qu2yJhX5Jur1k= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvGybMym; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684540917; a=rsa-sha256; cv=none; b=zOOhugo7sPamnuVOwLhOwStY3AQApcCPJpbNVJj1CZHsztQM5Vo0XmvQdJUfRjPivfykWf HHXZXZ3HOW4KljrZKa2rom5TEKqEVikU1JsnCvr/DYhZhmM1dutLu2hU1kTqKzeo37jX0M fzB7LMZh4EDmwFP4xY1Ys1yKIAvxDZM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540916; 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=qie1g7ABANTtTR0bfsI5jgl8Vmls/curDgoBmVrj5jE=; b=fvGybMymbrRhCRj1V3kTz+24RuywchDAyLnfzxzIA/dOZ3+256YNGl08FIlnTxFrxBDNW7 zn4/6lhBgdecjSq8KurnAUS7Osnu0H38iDZNZ6hUTvAaqnltD/hIHW/LTtxBRpuBGupzho O+ngdA5WjUnzFdDc1AYsjnfC5cigVAo= 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-561-EBYUT5fsO6CFgP7kQK6tFw-1; Fri, 19 May 2023 20:01:51 -0400 X-MC-Unique: EBYUT5fsO6CFgP7kQK6tFw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84FD7296A609; Sat, 20 May 2023 00:01:50 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D757CC154D1; Sat, 20 May 2023 00:01:47 +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 , "Theodore Ts'o" , Andreas Dilger , linux-ext4@vger.kernel.org Subject: [PATCH v21 18/30] ext4: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:37 +0100 Message-Id: <20230520000049.2226926-19-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 859E3A0004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pjmh6uehsx65n3833muuja8u4d5e4rei X-HE-Tag: 1684540917-526770 X-HE-Meta: U2FsdGVkX1+O4b6UqWGzPUDxlKrbzpHAHwSKAyPh333PJfcDYxTLYLSuWJ8w5kv6bp2pCnB2dhQuohs0kyLepuD7SO791i+xroIxwAUdtMMWtEB0T1w8/IeY8OuzOxLB904uxDDYB6i6cGsFtVx8NJGioGFCAKcti8M8hgou7SCN0SvNww3iaQfNMMz7WT7+4J9MPRQNfWrSMdTrBVwcemdKVHXQ2mQM2IkvNz/kiAQzLIjIOXxupXpmLOKI7fN4rQ+uegoVVKX8i3eaAGCBDk4Gffc5Wk8p6ryBwqB2UyYncgxC6Wz2/G32/WLgc/eO5kxawli1CLOnsUcEXxIxsixYQFpD1iYi+NgfClMFeK8ZPn6Wj32zbofI72ObLRlIA8zcSBkzlRRIVbhyXP8T25X6QT8TsB36PL6Z8VTXiMzj/Ao295BpmfW8EFguDkrFGU0qql1pvQkvwaR/D8VKH8zC/9kfbmbSD2d72//gKIn6bw7fhsziHXkY+3QDkqguBjFPc5/RfwmXfJJPZIrq646Q0HgIxJAcjjLZjy5WZyPMQXibmyBGpN/UivXg4u/Dwcrr62FDwrRycv4A8JSThNHVfQWTESyxT2GIaWI5JPBNYKujkc9SKOPfpLwdwlHpK7pcFm3iaoI2bft7gYC7nCg4u/M5PU3yQcvNH9gJh7LwHv5TydJZJJK6dXq2Bt3ftVqaifrA1P7XCY8MBFP5mJMiRrQK0kUCsRmAkEr5UyayG7bK9/mDqtC4xQvW1fc3YyjEI+lGWApQue6sHxF2F9gXuJIllNet/iehgWvYNNSaIOWUF70Av1N019j1aQKd0NaddB9bTJWI/IcuYwMxz0mOCMp0t7eZ6PRFl9AZ1FhilzLUwJqZXMjC5rJ7d4P3RW7ZmV4Oula9zgd+bMKTwukVPQ81i5rdPLy29vmbGZM+SgulDUHjJoDCYDu2P6xgiw+9vtlHb+hTlTGmk6T 7BFNCXgj eKeDhbaArgkLf7lr8MRILWp8xo9vWBpCJ4A/smA8ZKjbrgucgnn70/zUVHLF08UFgaj4bPhtHHstRDMAC5Hb+rcY3jOUHVRA3pcPtRL6+AIoK3DUDuWiKpEBGXwZsysoD2A+N4UOnSh90CEWQPuWHFpA56ZsOjqn+lVZAakT7Xd/xXAmWYxxw8ZuuJknCfpUiM3R15BVzHI/NrBwa+tcrjVJr9gUBUwA+7o+INaWsPWhKd9Q+oYI1q2+Dp+np9EYJigHQDfPQLbVEHJS/sNJtUu3zTLyErQrzPzc2AfwuARx4zRbNwW5S5GDS/lIO6F7uS8PFz5mBCz5VNWQEA75av88+TmEB3G4WjrawFWk9RnwoxPLO+k0YRK/ujWgcSsigXO06hXUtj1ZJDSEMSHzLLX/+rjUJShd87rf/ 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 stub for Ext4. This does the inode shutdown check before proceeding. Splicing from DAX files and O_DIRECT fds is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: "Theodore Ts'o" cc: Andreas Dilger cc: linux-ext4@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christoph Hellwig Acked-by: Theodore Ts'o --- fs/ext4/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index d101b3b0c7da..9f8bbd9d131c 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -147,6 +147,17 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return generic_file_read_iter(iocb, to); } +static ssize_t ext4_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); + + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) + return -EIO; + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * Called when an inode is released. Note that this is different * from ext4_file_open: open gets called at every open, but release @@ -957,7 +968,7 @@ const struct file_operations ext4_file_operations = { .release = ext4_release_file, .fsync = ext4_sync_file, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, + .splice_read = ext4_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ext4_fallocate, }; From patchwork Sat May 20 00:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249002 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 EAF3DC77B7A for ; Sat, 20 May 2023 00:02:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AF8A900004; Fri, 19 May 2023 20:02:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1381D280001; Fri, 19 May 2023 20:02:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7E77900005; Fri, 19 May 2023 20:02:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D1CB2900004 for ; Fri, 19 May 2023 20:02:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A6DBDAD9E0 for ; Sat, 20 May 2023 00:02:07 +0000 (UTC) X-FDA: 80808680694.03.0704C03 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id D8CE440011 for ; Sat, 20 May 2023 00:02:05 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nmq4+4pP; spf=pass (imf11.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=1684540925; 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=CaLAYOqJ2Anmir2KAA5gHQHUMXRYNU8ZFt/DqT/DIIs=; b=4oK1ZQ0UKDTtsIc6cZ3YnCYRFZY/u/sxIqjYgF/oN741h0eVBCrhA+QHwR3hV74kuDyMve RGYJzEXEzUOuBVPTCGttxV95GZCvDSaMuCmgcnT2dVWFbLdES3wjoN1f5oGXURUNEyhnQl MQGLXG85itIqOy/L82hTcHQkXYFLrAs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nmq4+4pP; spf=pass (imf11.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=1684540925; a=rsa-sha256; cv=none; b=NuZ8OC++wbG5QFx3T9ZD/WnnDTIjsEjVMa+yd3z/VWIOeu4rwOs6V9f27Xq/jMwbHPBF0M lpWlxfH1/cfdQdlw8ZjZOqL5CcX+9PsUBSwYlyVKGsKadIOm+8joZa4h2z5BuWKwlFUIzT gxG44f646yU0tTwztjSHoB23hAVAqHA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540925; 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=CaLAYOqJ2Anmir2KAA5gHQHUMXRYNU8ZFt/DqT/DIIs=; b=Nmq4+4pPjTe9jBRNdoDrN2641Y7aYlSgxiUqzluDv8z8XrNvv6Ic4IiLG7vWEWgm6lEpXt kl1LafeflJONaz00VUUSqHGIQ/6npyxSDY7qgyXKH3ILz5KMPgcNUiLLfD1BPWyaJWmm5M 8eDqf7DVy0KzztSG2ZLiNyv81CXWd2E= 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-403-eV0FIEGwNWuHo-kvCpFXaA-1; Fri, 19 May 2023 20:01:54 -0400 X-MC-Unique: eV0FIEGwNWuHo-kvCpFXaA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D6021C05AE3; Sat, 20 May 2023 00:01:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DFDE2026D49; Sat, 20 May 2023 00:01:51 +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 , Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v21 19/30] f2fs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:38 +0100 Message-Id: <20230520000049.2226926-20-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: D8CE440011 X-Rspam-User: X-Stat-Signature: jmxdfgz9rf8d9d579ea4qxug8u5x3h98 X-Rspamd-Server: rspam01 X-HE-Tag: 1684540925-349275 X-HE-Meta: U2FsdGVkX1/LDvvbZkvFlPFEwKD9Am02UgDNeJVj/LkOaQmUSmj/Z4a5u6N3vO32Oja6M0UnhYt0cfi4IrqZuzleC935u6IpiwhiAN1NNYBrqqTHdT+HhEx7AzRKeBI8SaRT1zQ3jSQ+/vysrilR980LvbrNWOC9zIvwaIjipc7auCo9FMPkKlgzyy8EY2kspU4Wq8okMqbsLp17cn+N9aer1HbrpRmmPPytxRio33LvnnubfFrTsNIcjDMEhdTMP6yOe2TQS2yGDVOETvITsVDVYjuHYqdtTIQmUJM09vnLPAjX/t/sZfPm1GN+ah6LrShlQ1FmjuRYivm3QVE/eO+5fM2KqiU/un7faHqQmT455LLdBM3cTC7DUCGBpFVmx9H82rKvurjYavONSWQsH6lzY+VOeczwIxrvqwrm3DLSFZDePEd4ILmmhoEKXkRgtCgp6tFehe9mfbDg7xL/JU+cdiz5pUhE/VdxEI3A5eZQ0TpFHXbBH5GS8ncQSbRCCbq8TmHpVtamNvNjfD0dTIMJSTVo58krOyvMnozj/Visr29p3TAec3E3WCTznidKlz3HU0UnjsTs1EWuW0WhpNCVIdos8WRPNC2+t18z50UGZIb0EJYmAescyqJVSsDxROlHKqt+qoyJudHjR61lqE0yweOua5cyfonWMzodmksD54AcYCVWcklw2A8WgCMjZzy/Tq4AchBBEoHOrweQjFSoTXGe4Sp07Pn6w5PRtwWGleKtpcquKp66amWJGAu7Hk7IV6JkXE3ldIuYM4fD+CBlItBiugL08EGaojtQ+fzdJZpJl/R/Adw1sJucB8QhmZBPFChRiK6Lomo/b8LAAXCY/JlqvQUslZOZHGozjtL82qcyBG2htk8SM6qZJvDyvcBKLnnic7BNZKoVJoj17EEPLp7EllFuIkp0pJspnRlnOvVFPEommVvMXbwoC7ZuwboAjZpNCt0jNXusj7J tHmvW9Ma G1nn41ud4gtY5iroqrg9EVVck8KgDSYJl9Y/WRiKVqtzbEgnuLhCH6PCsuaaBSghJQnI3BKbu+PNjNEDLYbAonQUODJFnS/UZKODXJYKS96dBXxHrHVsSNDMsipuY1yhi8G4LRSqysTu4M6CBpudnWYyOLfQX3c2cUfp5T4AyqXFkWQyTSDiGyRMsyf01VMI6/wiSkjAv61CcmZLhqzdmuDpY1w+AKe5qSC6x4fFsiJK3/uZqY9vSERolUifP8Aue2GX4s96IeJMV6a4SDZ4414hXUzZhcSpksLxHSR5LZFBhaU+rfiA4EFIeMfmjShakcuxPskOxPw6MLvXx4I70zVt3J2Hg5oDIukAg8lXtQSfbBWixOVsq1ioQsQ== 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 stub for f2fs. This does some checks and tracing before calling filemap_splice_read() and will update the iostats afterwards. Direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Jaegeuk Kim cc: Chao Yu cc: linux-f2fs-devel@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/f2fs/file.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 5ac53d2627d2..3fce122997ca 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4367,22 +4367,23 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } -static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw) +static void f2fs_trace_rw_file_path(struct file *file, loff_t pos, size_t count, + int rw) { - struct inode *inode = file_inode(iocb->ki_filp); + struct inode *inode = file_inode(file); char *buf, *path; buf = f2fs_getname(F2FS_I_SB(inode)); if (!buf) return; - path = dentry_path_raw(file_dentry(iocb->ki_filp), buf, PATH_MAX); + path = dentry_path_raw(file_dentry(file), buf, PATH_MAX); if (IS_ERR(path)) goto free_buf; if (rw == WRITE) - trace_f2fs_datawrite_start(inode, iocb->ki_pos, count, + trace_f2fs_datawrite_start(inode, pos, count, current->pid, path, current->comm); else - trace_f2fs_dataread_start(inode, iocb->ki_pos, count, + trace_f2fs_dataread_start(inode, pos, count, current->pid, path, current->comm); free_buf: f2fs_putname(buf); @@ -4398,7 +4399,8 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return -EOPNOTSUPP; if (trace_f2fs_dataread_start_enabled()) - f2fs_trace_rw_file_path(iocb, iov_iter_count(to), READ); + f2fs_trace_rw_file_path(iocb->ki_filp, iocb->ki_pos, + iov_iter_count(to), READ); if (f2fs_should_use_dio(inode, iocb, to)) { ret = f2fs_dio_read_iter(iocb, to); @@ -4413,6 +4415,30 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t f2fs_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); + const loff_t pos = *ppos; + ssize_t ret; + + if (!f2fs_is_compress_backend_ready(inode)) + return -EOPNOTSUPP; + + if (trace_f2fs_dataread_start_enabled()) + f2fs_trace_rw_file_path(in, pos, len, READ); + + ret = filemap_splice_read(in, ppos, pipe, len, flags); + if (ret > 0) + f2fs_update_iostat(F2FS_I_SB(inode), inode, + APP_BUFFERED_READ_IO, ret); + + if (trace_f2fs_dataread_end_enabled()) + trace_f2fs_dataread_end(inode, pos, ret); + return ret; +} + static ssize_t f2fs_write_checks(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -4714,7 +4740,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = preallocated; } else { if (trace_f2fs_datawrite_start_enabled()) - f2fs_trace_rw_file_path(iocb, orig_count, WRITE); + f2fs_trace_rw_file_path(iocb->ki_filp, iocb->ki_pos, + orig_count, WRITE); /* Do the actual write. */ ret = dio ? @@ -4919,7 +4946,7 @@ const struct file_operations f2fs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = f2fs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = f2fs_file_splice_read, .splice_write = iter_file_splice_write, .fadvise = f2fs_file_fadvise, }; From patchwork Sat May 20 00:00:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249000 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 E7E01C77B7F for ; Sat, 20 May 2023 00:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83E6128000F; Fri, 19 May 2023 20:02:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C9DD280001; Fri, 19 May 2023 20:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 619C828000F; Fri, 19 May 2023 20:02:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4F2F7280001 for ; Fri, 19 May 2023 20:02:03 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2A601160B85 for ; Sat, 20 May 2023 00:02:03 +0000 (UTC) X-FDA: 80808680526.22.538162D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 50107A000A for ; Sat, 20 May 2023 00:02:01 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c4z8XQR1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684540921; 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=PdOrKy/29l/SlwbCKOhyqi9HADxRQvEqQAvIRhlpyNk=; b=1rGa+YfAR7z+Udt4JQUtj+xBKo4Zx4uV1YFqJqJLjIwWhRvevKJDuvxOxtPGGhiOIv1fJw ZX8dToQ9OwLo6Bm6kcrlRyfpAsmCdtiF3suuus0Uuzk9WueE2yPfT7oX6z7cC6TWxH38HX IL51m34opbiNv3UN+82jUTlAdcKfeJo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c4z8XQR1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684540921; a=rsa-sha256; cv=none; b=OqDvy0hto3yUAtJg6HxAeQk/P0YEN6yR2BeSnSu9jtcO2D/0zIosXxfJOoMzOb3D9PWMmz ldqXxIFxDtnSyxzeVsNWBCrKQkfJU/UA9sbe57tqM5Ih2J8gSD6EgpQYgStU2KU4ppMiWf cUrObVbDlOnfJQM+4iHmySne2ckfvZE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540920; 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=PdOrKy/29l/SlwbCKOhyqi9HADxRQvEqQAvIRhlpyNk=; b=c4z8XQR1KBOu2rlC4F+WBWXkByQGsyawgj1bjbPIPi3Vv2/LZDgHjKxn6eoNHU177slM+K KtnGAXpO8it8h/CCKztvY3bILAhsaJ73oJdLXrKLkGeHJRHYkgdOKhVi+4m6+PZPjoKPmg EtHTi4CnyRHBYxQgAsaVcs/F1WRgdlQ= 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-623-PE7fRENvO1etq4VF1XE3og-1; Fri, 19 May 2023 20:01:57 -0400 X-MC-Unique: PE7fRENvO1etq4VF1XE3og-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69DAE80120A; Sat, 20 May 2023 00:01:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15A20492B0A; Sat, 20 May 2023 00:01: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 , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v21 20/30] nfs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:39 +0100 Message-Id: <20230520000049.2226926-21-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 50107A000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ne7z6prqwzstxxer93abxfbcfnfmjdju X-HE-Tag: 1684540921-110865 X-HE-Meta: U2FsdGVkX1/t5+VtKh5dHQbajtVBae0SdjKEe59dNJFirPRDhVH0IZhDtefx0j/CZZsrJtBE+RU7B+c66vguDsukpqRKQKx8UpD7bLkaAPne6NnqHtCra42PGBydh0tQzdmLpa6wjeywRANmo6+nGh3jCMWkUmy1GQ1oYrMXUcQ49MrO/COgZkpqVg+kwFDUoNY08c73J5lrhl/7tvsSTkw7bxIrRrcLCWbHga+mK7x6of+3a7AylZ5QpUNq+JGztFFV1CZxVeL4LFhxDH5nmRq1nQjdnoGpc1Qj2rW1lGlH4VhdZFzrfHnS7OK/aWHHcNwCegGj3QqI1urGkVMgsqrG+vLc6quyZrPnUZ8y+T4fYw0iolOw8Cntry2G3Bx+yFG3Y8PywS+p+2JVDcZfUoIgU/TS14bKLPeqFWfm2Yz+Vvthd1MKyCWW0Vid/jYpr5MRqCMTKU0jiNM/UKGH2voWdrIDifHIbjZy/ZZEF7uwZIqynkbipAZNyLrAPtA1Y0M0c5RI3TNztscwYRp1fmHleyUfqXzVlM2gBhN2YYOOKERZvC8yTUXMrUINCQ5ZAy2A2s//hWQuI6TKPRsRQ6cZmlNznroX5fS6gcoWxes2GZz9tw2H1hXE2SWfyIaws8J33JnRSbXZLwt63mL8KnoRGaGpPOEJEKEeeQlRvX6vDVJb0/7RdzvOyHs5jud9NwtN1VntKq0NA4Atet6qB7l9j2KiKa/FZsYP2iySrlg6tqGrUYXM3HMstVxOQta2+UUQiPWsiohqh9DsM7w9I3OrbiOhCGr0CGai8ODY7JAZIhMc8FX+5KWZKUW4YkcICUQYvtHMeEfVv48WHxDuGjRsji1pKCCjOLXQcqELQJk0fwLwf31qfVWvZsLI5hB7HHdKPiWvQ46BE24C2ZgvkpPkCxwohLsEH8r7gKV6Yi1OyeSkypAOxwm9Wm155Z+woacwyLIu38HYjLG3yYY 2VY8vKLH L+XD/HXkt44JpleKMkHDvB4Te8GkBlMhyHG4j55eiIiMB7274MkvYHeOA9YNhv5VhfzQV9rF0vKGlOxfMsOm7UQ6PcdBCG8XchmRIuMUqc1BZSo/T0Y2OAPuIa1tKPLKUdUOaLgFlkG8Xq9HRyb6vI7CjM8hBReVi2FvnlY0ZusNnGxMlYQ6LScXM+t6QASYt8PkFQf4eYOgyxtSctg5zzxA2xjGxUHQsppLbgUcrTL7ior6Ih8Pi2D6CZIqI16/zLVzSi0Y9GrvLWyL4aZYuGXRD92YX2cn5C1uPXCQ3tSObeiFreqKKsv4s2rrS4Twxg47B/LtBz7TFb2FVPPq8pP0Vs0iHLMN9f2F864uTnPexVLQw7K2VhmoHCp/yrwCu64jB7UoxuWvUreT7vVjsxUwIl4+PswXbj6P7 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 stub for NFS. This locks the inode around filemap_splice_read() and revalidates the mapping. Splicing from direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Trond Myklebust cc: Anna Schumaker cc: linux-nfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #21) - Fix pos -> ppos in dprintk(). fs/nfs/file.c | 23 ++++++++++++++++++++++- fs/nfs/internal.h | 2 ++ fs/nfs/nfs4file.c | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index f0edf5a36237..f5615fdaa9ed 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -178,6 +178,27 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to) } EXPORT_SYMBOL_GPL(nfs_file_read); +ssize_t +nfs_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 result; + + dprintk("NFS: splice_read(%pD2, %zu@%lu)\n", in, len, *ppos); + + nfs_start_io_read(inode); + result = nfs_revalidate_mapping(inode, in->f_mapping); + if (!result) { + result = filemap_splice_read(in, ppos, pipe, len, flags); + if (result > 0) + nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result); + } + nfs_end_io_read(inode); + return result; +} +EXPORT_SYMBOL_GPL(nfs_file_splice_read); + int nfs_file_mmap(struct file * file, struct vm_area_struct * vma) { @@ -879,7 +900,7 @@ const struct file_operations nfs_file_operations = { .fsync = nfs_file_fsync, .lock = nfs_lock, .flock = nfs_flock, - .splice_read = generic_file_splice_read, + .splice_read = nfs_file_splice_read, .splice_write = iter_file_splice_write, .check_flags = nfs_check_flags, .setlease = simple_nosetlease, diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 3cc027d3bd58..b5f21d35d30e 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -416,6 +416,8 @@ static inline __u32 nfs_access_xattr_mask(const struct nfs_server *server) int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync); loff_t nfs_file_llseek(struct file *, loff_t, int); ssize_t nfs_file_read(struct kiocb *, struct iov_iter *); +ssize_t nfs_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, + size_t len, unsigned int flags); int nfs_file_mmap(struct file *, struct vm_area_struct *); ssize_t nfs_file_write(struct kiocb *, struct iov_iter *); int nfs_file_release(struct inode *, struct file *); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 2563ed8580f3..4aeadd6e1a6d 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -454,7 +454,7 @@ const struct file_operations nfs4_file_operations = { .fsync = nfs_file_fsync, .lock = nfs_lock, .flock = nfs_flock, - .splice_read = generic_file_splice_read, + .splice_read = nfs_file_splice_read, .splice_write = iter_file_splice_write, .check_flags = nfs_check_flags, .setlease = nfs4_setlease, From patchwork Sat May 20 00:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249001 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 EBFCFC7EE2A for ; Sat, 20 May 2023 00:02:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86538900003; Fri, 19 May 2023 20:02:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EF8C280001; Fri, 19 May 2023 20:02:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64102900004; Fri, 19 May 2023 20:02:06 -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 50A88900003 for ; Fri, 19 May 2023 20:02:06 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1CE601A0B75 for ; Sat, 20 May 2023 00:02:06 +0000 (UTC) X-FDA: 80808680652.22.503D3DD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 6F67740002 for ; Sat, 20 May 2023 00:02:04 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XsZpY2s+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540924; a=rsa-sha256; cv=none; b=Bkhk0DcjzfhTEaZJ2ijf66pmvUWeQgmfIERRn+guwpJlBQFSFYCv2/ybAIAfciw89L5jqE JPnnW7Z6y9GgeACK4A9jgLFbTsL31RdSgPjwT3jK0GdeH53rViW6qh25kIGy1FX44EmULb cG5mA9RABLoWsrCRgwwf5eKOVgyawdg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XsZpY2s+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540924; 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=6eCSJNH8vHFST21uMhvhB9UZGjvTsMZCtNRoglPFw+I=; b=tv+l42KcVi9nt6qw58FnaGq/B5Oroib7qnoxJwY9Lj0ucfq7HVTQfyJv0l5rTBJCYzSn4o olhy93BEOHAPBqh2+GSEAKybquZ63dZ0Ro+XHwY2waNI3aJGcJIzkWIw6n+ghbLXRqS7Oa qnZfIeNXnp9LaazOMblUYfONAq4uWHk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540923; 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=6eCSJNH8vHFST21uMhvhB9UZGjvTsMZCtNRoglPFw+I=; b=XsZpY2s+bYCk7gTkC0L1myawAtQ9tysgTggM3ayY18SwlMAc2t/Tyk3li6obc7Byu/0MGH K3mKslobLEy+9B+YUERW+LBwL3XK+MaKP+G8A7tBFKyIkAbBv/ejInEONNRscpEyHyDdu5 EynGHrGsUxg21o23l/o7l0i9wN5bYK4= 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-518-Vi3VpzDTNn22brcNxkPP8Q-1; Fri, 19 May 2023 20:02:00 -0400 X-MC-Unique: Vi3VpzDTNn22brcNxkPP8Q-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 3A4411C05AEB; Sat, 20 May 2023 00:01:59 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C7A94F2DE2; Sat, 20 May 2023 00:01:56 +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 , Konstantin Komarov , ntfs3@lists.linux.dev Subject: [PATCH v21 21/30] ntfs3: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:40 +0100 Message-Id: <20230520000049.2226926-22-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6F67740002 X-Stat-Signature: jntbxseyykhhuatf8fpdq5qs33agpjaa X-HE-Tag: 1684540924-74011 X-HE-Meta: U2FsdGVkX1+vbZzCLe4KMLUtMfq1t209T+2g9gTyeWPg3ozdvDcSmBYrmb/eDUdei/sVSb8vzGRWYzlSiTdjO6gUcwJZPwy08QOvVToi3MuTLQBjteW8pU+qhQFJVunPAjQJscY1l9v2BE8LLxLFsYEqF7s92P9tvMk+cIz2wPh26H3CrFzRwuG/HOjvQSH9Xa6nzqinqAvoEaojiz/Dy1GWntUtkIoxJvd2NofTUpW3aXQYmzGmt4pxHiomhgOUXuIUCwa3MsvVEUwMRzS5f5PShgXVz3nLxYuITdHsmiJ8/Nhw/ZxS5dRCiPDLi/Hr71iYeubgl8DMeItlAwsBFVoud9fQvhNnleX8wMlppeRqsdUhIZ38xMqf00RDK7/8CEb/7gpYuQqDnJsGNdZ5ZllwJmmj5m6eRZJRd8II1Lg9CkvMMIs1K2r+QdFCa813sxivb+y23P5cLYKruqDZg3/hoZvVQZqu4Rr0TwXkI8oSlBhapuFXi8+6gR6IaMjHxGtkTZ3Ft7jdKa8NRYZkscJuuTa+K4GgKMfPngy1bd4Rob28Nhaqm8sE/S9I8MIwRX0HBKBr94rWgEMBVFrDwtJlDngP0mLzcbPuEpInfo12OpOA5WiZjGId8bPnTGe6esY2LObLLJSHBcJsLVwgWijTvB1AtP0bEwzFKGEp09vR/r3ZXcM3Yxl9jZfIf5AIhIynWqw4UfoDg54PGhoMXLz1WkFbILs4D0DXntjtfhx/USmERUj0wY+ZeLGt8i89So81dtfg0H3lG+vrJKnqjyfh40p2rP0+4MyuUZ+XFD4y4EUCuqKI2yMrMrhZF1eRq1Mh8x3f3Up3xWbBu+kb/F5lB2D9NtWd1LYZiX8VPouoqr6U4LEwrWxyRn1plp3FGX5l4rwol4O9X6DEXcwKxVxaXxvV6xL83rAP+9JQpoK/BOOVtGv0XpJPAeXM1duxmAw7rnxhxocXIgBb/2V d5vEtYza ECHDgtfgLTRQGOlgDnT/JdrpmKF/MiqVTcxp0qxiPifRYYOCDJHPVWXePeEmVqTuQLSgMCYCU2nMq+1HkwYjyZj8W4P3A/Cnx1cZt6LRNuJhLH+8Dbt37l68P4RBwFmrxpaet1t/UDgD+nipLOupVv/+wXy0GiSgMdYeNCc+SzdyxW9QKkUH/ebJFuSds4711FDvtZh3X9cvtJVjrhN3c8+rY5CoBS6Iq6NN4BUuvr+s68V2iekCMl5DF3mkzKcKZWLDEdJeVTSftQHEvIu9RHOTJyZ5GltBRHyilzxUbrUD1jWBPGTIm3mtIUMRRHrbgbZeX0FPt29pBbmvsjsJ0n/FCrKrq8d511aVMsBf1RZLvT5wfKzDdB+noCr2SqfdqODAtkXuFUvv+VndoVrXUaA6EszIhj6E8IaAP 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 stub for NTFS3 to perform various checks before allowing the operation to proceed. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Konstantin Komarov cc: ntfs3@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ntfs3/file.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 9a3d55c367d9..667c9dc68b58 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -744,6 +744,35 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) return generic_file_read_iter(iocb, iter); } +static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = in->f_mapping->host; + struct ntfs_inode *ni = ntfs_i(inode); + + if (is_encrypted(ni)) { + ntfs_inode_warn(inode, "encrypted i/o not supported"); + return -EOPNOTSUPP; + } + +#ifndef CONFIG_NTFS3_LZX_XPRESS + if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { + ntfs_inode_warn( + inode, + "activate CONFIG_NTFS3_LZX_XPRESS to read external compressed files"); + return -EOPNOTSUPP; + } +#endif + + if (is_dedup(ni)) { + ntfs_inode_warn(inode, "read deduplicated not supported"); + return -EOPNOTSUPP; + } + + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * ntfs_get_frame_pages * @@ -1159,7 +1188,7 @@ const struct file_operations ntfs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = ntfs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = ntfs_file_splice_read, .mmap = ntfs_file_mmap, .open = ntfs_file_open, .fsync = generic_file_fsync, From patchwork Sat May 20 00:00:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249005 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 62442C77B7A for ; Sat, 20 May 2023 00:02:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8850280011; Fri, 19 May 2023 20:02:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C440280001; Fri, 19 May 2023 20:02:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81668280011; Fri, 19 May 2023 20:02:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 63995280001 for ; Fri, 19 May 2023 20:02:17 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3EA0A12083C for ; Sat, 20 May 2023 00:02:17 +0000 (UTC) X-FDA: 80808681114.20.7E8B3A4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 8A96816001F for ; Sat, 20 May 2023 00:02:14 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Zol/mVEi"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1684540934; 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=+ZeMoJ3W4+8Si0O+3M8rAaXW1eupuLZDs/fqA89KAPE=; b=2do0shLPbdcGaE/TAgoLiy7pV6Na8BdFxu2Gg8mNQ3T6FxU4rU1KSTjc6Z5XC5r0EZ3l14 n8ev97rTYFbZp8THb3aqB8qhnDWQFEXrgCLz+dKI6bf33rLdo0nmhvW4mIWnvddk+cRyEi h+7ptrLtSfvQ7yrYPpzau+mfVBPNxf0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Zol/mVEi"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1684540934; a=rsa-sha256; cv=none; b=lSfUx/MJmMaBYgDvPGL+Ne9UJA5xuIZPDdnztUZQYDXAmtKHQ/xWGcV6VjWdFiZKXPrQBN pKWcMwpQruqCnnKCJBwwBM1dw/Qb+ln58zu3B+S927sxQ82WxK8Nf7hJIcx1emw6nzSP/1 S0Y8o+pZJEtfzKnTYGYUc8vIm6OM7yE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540933; 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=+ZeMoJ3W4+8Si0O+3M8rAaXW1eupuLZDs/fqA89KAPE=; b=Zol/mVEiDADTmjnfvCryYdUK9m3cV8zkVhiISKvYPoxCCt5aEAhVKGvqH4VBIxdRNIMagn LluxyngyAytUhCXX66J4QwrAv7OP6iIK+GHJaGEl5doiwUzg5OioA8PDZx6417OgTgtCYF jdokBsNAvQV2N4TGcn3Tbwp6ZVPpFjA= 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-411-v3noG5lZOjuaP3G1f6efug-1; Fri, 19 May 2023 20:02:03 -0400 X-MC-Unique: v3noG5lZOjuaP3G1f6efug-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8752C38035AA; Sat, 20 May 2023 00:02:02 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0ED440C6CD3; Sat, 20 May 2023 00:01:59 +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 , Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH v21 22/30] ocfs2: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:41 +0100 Message-Id: <20230520000049.2226926-23-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspam-User: X-Stat-Signature: sijuhdtrptnz7gekjpuizqsu1jadeywf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8A96816001F X-HE-Tag: 1684540934-431502 X-HE-Meta: U2FsdGVkX1/iXCx9BViy26h6c51F47pgMHydEk8tR/DQwYlLeOUU9a/9taqFigI/+N+x2kVFoQb3SHxsOnZXQ9PC4kNBGCswU3247F58SuTEHrVlx78yazUxw07QrB3Fv8iMBCa/1rnHFSueWR+UAtpCZ+C0vHfIzlpuJmOQEEiApQ0ojT25cywxnCQs6TWxVN8D4W7HdnB857KlQ6851JyN9J/njVTGBeFqyXoIrkH3Jjq4NX/TXzHXT/NleG/f/CRSObUfLnAuRPYDCj3/FuC7chJd8sMv4j9JcCPApxMbgCNSH2Q5RhMcT1d0RPoxRpUITGODiyUWMxkk5AKPiHchQirr24T2Q1vEA4Bl5wXcD2Ad9/OEEeBEjfBkfjpNxm1bV7aAEM8AMlCNvIoLQEdK1FG46Gguna0KWySCw3tYueRu+Qu4PG2TQ7SUmDG+byOboC1hKMM68c5iuBiBQ6GkR4kfm4DXRPJBQzoi5gcFC0RQvBaCt/TLuDH7j6rvY2e8373TP0GRSjg0G6aRdE5sgQ4IU9mIdOJDCQnxvsqfYp+Dg8LrCKalCOOriqow1AYhXj5o2ukGWG/RIOteUU8Ol9xAFVwirwq9chL0in2S9o3N24Zi6Ccv65UOZPogNbttBPJvPADIfebBsUeVk4tjzyYq3Is2iPYygvXCn2+r0wyn7xMWZX5Y91QYKMMifrAX6KAacANp8vKIoXaN09AwlvsfE4FKD/clOwNDYHy7jEBX5X90MYUUhoDXmhYmOBW56wXn4Gkw2/1dpD47cuF/3RsNoDqmuttgQv1/fEebqqmNAR9KcGv+HNjtUBfZ0uSTY2V8x+QHOkSCm8r+3USLOquK2vXGpd/M3X5/F89+VdRAGUnu8RFB/cjssYKgOLCPOKZKffmYAUlge9548hoRNNgtpaFbaSP+dWbdIxd1tzJcndQ0pDoWhkowUuuukmwq8mQCygS/UbZic2j 8lz1Lakr wjDGL+CSPu/uZwuSiHHDDbjFoEuR98Is6sSpkBUK7uA+rb31H9luI3GPy3vqFsB5i3esjbo+vtRqxMwzqqqxzauNLvn7OEJd/YhwHSAIvZIAD4D3Ora5z7nTZYoBW1YHb3yPZdtUEa/6aAy6Xac6Dmg2BVizudWdoSWHrW+PhSwu9ECNQIiNYI6TQYMGGGLtJXsZGUbXi+InxgwUjc7sDu4ABwtzY0ETOkog8khNpOXKTsGduiYIjuSVJCjp9o0gnVNNZI3zo1Kp46volnQ7mW44DTzwul8gzJv7ihG2t/532yjQj3BiPDIg0cK1gE3TTQcB0pe6T08n1ubNezYgN/Jz+SO96pTggvoXlkzMu/9TgFsHJ4w5xDaG7xeWC0eusQyEvqNbY74N+WUv+3Q8cLmhepUuwohvIZ0qQunDFtmBt6e8Pra2qQ8N1tei2sdngdaIpAtAyNKtwEH7gKt1XeZGlWqMtfnePDiD3Wk5c5VqJiYLJ658VE4J8FNCTzo/RT+Bmqc5Yeaz6v5Y= 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 stub for ocfs2. This emits trace lines and does an atime lock/update before calling filemap_splice_read(). Splicing from direct I/O is handled by the caller. A couple of new tracepoints are added for this purpose. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Mark Fasheh cc: Joel Becker cc: Joseph Qi cc: ocfs2-devel@oss.oracle.com cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Joseph Qi --- fs/ocfs2/file.c | 39 ++++++++++++++++++++++++++++++++++++++- fs/ocfs2/ocfs2_trace.h | 3 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index efb09de4343d..f7e00b5689d5 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2581,6 +2581,43 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb, return ret; } +static ssize_t ocfs2_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 = 0; + int lock_level = 0; + + trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry, + (unsigned long long)OCFS2_I(inode)->ip_blkno, + in->f_path.dentry->d_name.len, + in->f_path.dentry->d_name.name, + 0); + + /* + * We're fine letting folks race truncates and extending writes with + * read across the cluster, just like they can locally. Hence no + * rw_lock during read. + * + * Take and drop the meta data lock to update inode fields like i_size. + * This allows the checks down below generic_file_splice_read() a + * chance of actually working. + */ + ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level, true); + if (ret < 0) { + if (ret != -EAGAIN) + mlog_errno(ret); + goto bail; + } + ocfs2_inode_unlock(inode, lock_level); + + ret = filemap_splice_read(in, ppos, pipe, len, flags); + trace_filemap_splice_read_ret(ret); +bail: + return ret; +} + /* Refer generic_file_llseek_unlocked() */ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) { @@ -2744,7 +2781,7 @@ const struct file_operations ocfs2_fops = { #endif .lock = ocfs2_lock, .flock = ocfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = ocfs2_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, diff --git a/fs/ocfs2/ocfs2_trace.h b/fs/ocfs2/ocfs2_trace.h index dc4bce1649c1..b8c3d1702076 100644 --- a/fs/ocfs2/ocfs2_trace.h +++ b/fs/ocfs2/ocfs2_trace.h @@ -1319,6 +1319,8 @@ DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_write); DEFINE_OCFS2_FILE_OPS(ocfs2_file_read_iter); +DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_read); + DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_truncate_file); DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_truncate_file_error); @@ -1470,6 +1472,7 @@ TRACE_EVENT(ocfs2_prepare_inode_for_write, ); DEFINE_OCFS2_INT_EVENT(generic_file_read_iter_ret); +DEFINE_OCFS2_INT_EVENT(filemap_splice_read_ret); /* End of trace events for fs/ocfs2/file.c. */ From patchwork Sat May 20 00:00:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249003 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 F2103C77B7F for ; Sat, 20 May 2023 00:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86523280002; Fri, 19 May 2023 20:02:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EE62280001; Fri, 19 May 2023 20:02:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66863280002; Fri, 19 May 2023 20:02:14 -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 51A78280001 for ; Fri, 19 May 2023 20:02:14 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2DB6B80B84 for ; Sat, 20 May 2023 00:02:14 +0000 (UTC) X-FDA: 80808680988.28.47801EF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 763C640010 for ; Sat, 20 May 2023 00:02:12 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fJtM7YFA; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540932; 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=Kng/NpyyP/9HUThEsQ3KFbnP3O5VwICNL8GAUfOxY8E=; b=rlBZGmTsmWzwbHRVUBJuGl7kKHjyCcoRQc/eTlAerfzfF+lyQNcEgjpt8WOPqGv/B//oQF /o8O1H1BOhnjbRqgUdUN8sVgvw4WYDDCdZVgdEtSpYOkEGXd+Q9zMMjk7GmdAEAp0ui20S kW1T/DlvCqjoTI9/bb6s3m3RoWyaPxg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fJtM7YFA; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540932; a=rsa-sha256; cv=none; b=3MBcQiCgNgPu9a+GCDDLsbw9qeNPSR3sBNp1/2S9eGRaoDGv7XJ0JNUxeI3J6yFQG1i7In OmFVDXvBIO3XLTp0b8OB+HTgQRtPDEDigQuJ9C+9lM1OX1mM9QPfJPw8oun8yXx5OqGEaw CxRHa4Ja4H1pEpyEytQQjPBwQyAYbgo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540931; 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=Kng/NpyyP/9HUThEsQ3KFbnP3O5VwICNL8GAUfOxY8E=; b=fJtM7YFAwnjWNHMhCizFxtDv+dDjio40eAowusfEyEVd22e1woVkSeNNd0qJ4MIKAB/Ukt p+vDghX8bu6YyY45BTs2aTsGiC6iTBF4RARVyjbOhvZe0rDLn9s5BRlmkKB4R80Gg0MnLo 9pGO/tq/LtT0NiL5zqZ9bsm4R1TYMcQ= 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-410-R98rrHZxPWqxxp4SboXMEg-1; Fri, 19 May 2023 20:02:06 -0400 X-MC-Unique: R98rrHZxPWqxxp4SboXMEg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F212296A609; Sat, 20 May 2023 00:02:05 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2587640C6CD3; Sat, 20 May 2023 00:02:03 +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 v21 23/30] orangefs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:42 +0100 Message-Id: <20230520000049.2226926-24-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 763C640010 X-Stat-Signature: jwkp8xe3h9ddx9hhys8x6z4kdiqjd364 X-Rspam-User: X-HE-Tag: 1684540932-690901 X-HE-Meta: U2FsdGVkX18YN04S6FVW2shPuK9y5r1NPEltSTBVWdBMi5o0vnbDcpiNM4zLhbnAYDo7c/R8nn5wF/mN1pPz9fJE7jo7BDqgDByDSh9g5NUlNRCjBs9e6qci3tOLukKfMi4vGdlNDeNvhURxwdfLG4Gxp0wdZrQX38me3gE3AmyiyNzf5csAmvYBHTX9Uc+J3VP7x6f0doPRzw4ZPxdY12jdqW+/8dKzEwQuv3yPtK4YArYtxPG2iroJkb/OLaZ3sFNbYGxZVUD6bqeQqX8DEPQeLxAB+kePa4osnylA4YGOi6RcMIGNSrFa2m2XLv+zxFV9ICCFYYiGLDH34PrlZCux5esIt2Vh3Q3WroaWfIkAroBxXH6HU3j4EKRzGwFOdWvukhXXMghCoIB/jqLSHdwp338KhD493HnLS1UMz1H/cM1FyJ3r7mDY5jvxzsq5shExuK/Td2HJiGWI4xHs9x3s41CyVDsF5a1K/IS1cYzrEALB/m6VVqLIdDPp5fTAdCkQGdgw+mEpdhMOc5tZ8dspft2RuCT5P+Gjlh7Il0gFMYtmr2uYbjAxKZhBYEGy/7Po51o8vO+5XBFNWpC/3/WXoZ1DCstudwFdsp/PWUHY/sWoD0mL7ueHXGuHd/tm1OMQIJAr5kMVn+U4ON9kFX/iFXbIw6fqEOmjQZH0qn3me6olWff1x0IOyaYK9jEU2Wsob/OuZN27/+rU1kawfEARWSMqFcyqDPFYkQcfG0j9VKqcQHuCKVQJCrk4Mw1t9g7jHFasio8JD3aYrG4SHGN384g/ajOQRyrYXAykf/G8MMv6O8GAtB9sh84iW0G3QQNG6KJtZ31z3g2Dsrr6IbR/p45BuLrZEVKRY2Sy5KEUBilAMSPSnMyF33NSPoB8CKJPmIodcRfRqO6G5CYF36TzjimOX5g5q3PHOxLKvJ/kkKIqAB0Mg30gMu+HQZSkPBvwuqi5ZQp6geGU2xb UKdjkR37 LrvMcWcu12Z0cG/AeOLqTljSwfnTKHu5lpbEZqZlru4s3j1KooD0C/aDij2C24FahbyWOcZSVFwMx3PuKsDfEUeCCzWDgr7bYMqNAnzr+9jB562bDAcO0Z8u/PQyENIpIer8YKVbpQRtTPxn1xsIBOtq8ORxsW0K9tXQ9yTRN4zGD1n8pQVTQv4lkokNg8LA9Wmtv/aNNt1YNd8y3qDJPPYx8HKdkQAsUwVhGQrsN2ziXRnSaz5I9cv2xJqzGvW0j+YiseYciilqqUJHFCnuM2Qx2XoXHsA4JJJa0x5Us5M/boL4H8ZnaBD1tRxIdZxg2ZN9l503as5dJf58z/IyDyDF9kDuiPj/HVmDfmi2BetkNPcQ07/bInXYq3NGo1soqroroy434BeeL60ajSnlgB3W+PASl5wsGTM/tuFS3RhKRxeYXTJuqY8M8qMbVAFpN5jQ0paoPpxsE+2lr0W+bv41I2w== 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 stub 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, From patchwork Sat May 20 00:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249004 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 E4559C77B7A for ; Sat, 20 May 2023 00:02:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A29F280010; Fri, 19 May 2023 20:02:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72A6E280001; Fri, 19 May 2023 20:02:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52FBE280010; Fri, 19 May 2023 20:02:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 38BEF280001 for ; Fri, 19 May 2023 20:02:15 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 10D9AA0982 for ; Sat, 20 May 2023 00:02:15 +0000 (UTC) X-FDA: 80808681030.14.DC0932D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 5347040019 for ; Sat, 20 May 2023 00:02:13 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fqGiAR5L; spf=pass (imf11.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=1684540933; 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=xweayQ6b4+yKTogEWKPvOcFVzWq2Z7yytw9vgW43n8c=; b=wSr6Yl2vj9ofDgjtStPTp3TLSiwmC5LoV/ouxepJb7wAO4YAgTZx9za6myE8AGXX+P8oWv 9bkjpYIp6Ua0biUOek9+cmeUaDyp87/IQ9BhZXFalghXqQqWuB4IqJo7UGC2H7e5ap5xCG DK4/QZ4u84eOhYBoWOebvmoc4qaXHOs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fqGiAR5L; spf=pass (imf11.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=1684540933; a=rsa-sha256; cv=none; b=CwlA/eu2ZPxIkJ3bny+X637eLJY48eGkjQjjJjGl02+NmLsRFVWvwk/bxkMIy/7t9yZRF/ 8nVcccjEOvAT4ACJm+XiomvYI6g6ICGfNZZAyuyxBYW5iy7trT5aW/mHYufrxmN0EFH82s HWmF78r6/e+YvE/rFzHnhGaeW+l4T4s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540932; 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=xweayQ6b4+yKTogEWKPvOcFVzWq2Z7yytw9vgW43n8c=; b=fqGiAR5LxDOn7Oyq0CHvwKYEtcuqzcspw/TDWa8KIk2iEx+q/JcvEGd+eaHpHq4qq/3Uex 5lCBPUW6Z4sImfUDPiFPtMXlOIHO6iWQguQb7zuHFHGEacX4tRtWDzDYtAjTwrOltc2io8 sJmBer7Cos42mYkvebdfEPxsf5AxTsk= 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-241-5lqrDGK7M6yCYGGKczU41Q-1; Fri, 19 May 2023 20:02:09 -0400 X-MC-Unique: 5lqrDGK7M6yCYGGKczU41Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 72A7438035AA; Sat, 20 May 2023 00:02:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43E827C52; Sat, 20 May 2023 00:02:06 +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 , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH v21 24/30] xfs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:43 +0100 Message-Id: <20230520000049.2226926-25-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 5347040019 X-Rspam-User: X-Stat-Signature: wd55rzhab1fbcq9zeh5udojkmkace7y7 X-Rspamd-Server: rspam01 X-HE-Tag: 1684540933-941373 X-HE-Meta: U2FsdGVkX19OjcvXREmHh9DwHJ95id2iHlPSepC2+x4vggtIxFFD/01vDjjUeRHPnzimylHpg6XZlWwsgJqTC5gkhVatbOCTaNRrtnyLSquRUyOmhOaoLeJEVO7rqTq7sXhB4ahhw4b+g5Uje3rVyBr8Ndnl4dMhX0FQY+yl6sR4GDz5hq0mSv7QeBTAQgh95ovpb+XZT54dOvytmxIhWqDTQU2gtZbiESiwZX+ZS8L5aHQgykj6VfmpV/1TLJRs6Sk4mrRfWneC2AU+GuOyUwJvQZnEhpq62k59CSyUzq1MeEEWHWQtXKlFq32mgFwy8vT0ZEqcO5AJFINB7nfET1xBp57hqpXeX7FS31CHUQeoUAckZ+AvNhc9NqxpgvqOMEvCRHtxCLJID2AFmk0iZrn+7PMWBktodrJewDZVlPRxkWIiwOD8Idwznd18tY53TovhuTPCnUXnRNy9TahhbqXqRMvymdIWl3ompnzH5I95yAmqWqDcs6i2yOhXsGsNCE4K2P0JaQJUR8MRHykKxc1MLu4RiE8/5Yq6xRjTvg0I2natdvuJ0GQUTqpjXMi5mRVac43bZllwEJ0aYYANDBEM/zid2I284OzpsfCbxXe8nJjw9q8eALaYj1winfgMHIKEVYKNB0IaJz+Rx4ROkJJwDB+mhVJ2jVWppdfDzR6BLV1N+M2PcHfA0RrT64ar+TXTirwDnXyos43sMz81DjbK+rHkbXQXScSZjAk6VPAE29CZ30Ml4Jm2z6qIl6FwENxRforcFYLGiXRhWh8I/Mlzw5hosJyWFqYaN7fgYKcaMgCURvulWYAREGHMNsDKkbVnZqWpnFRVf/NWlcnhYwwup2A8CO2TnTRtS3crMCP1Er1PKMohpi+Lfuq4gv0hro2qHQ+i0Em/lvVGBw+AtqtwHrswpXEg01cVApY5PIUaMJqy0+7jBnLaAlAHUerpkLGkEW24Kp4fTHpGN5+ jfSEaZ8L AaEVURiXZfQTKLX501mmmLUw5Gu939j8Gv8I9JhI8QvqbwjbgZiJk2W8EMDCq2/QtQ/YzTRdtiuHHeZaBIob0+Mdf1A4ZHpALoc3laJjVx1ty7eCEXxEi7eMNS/PRXnz6KLZWHZkGRi90EehIwYHslkzRhYJpQGAzSSeQvbd4sssAxxVfgBG3zvqJHRtTEJb9RjNrQkCNq/bdf3Dxw+1fOOX8Uqa8h9mm7EFqX2R8g+4iyhn6HgCOFR/nqVyo6Ark44OspuqjvKF2OFPBpRPyXlQkyyEcxQRAUH7c0iP2o66+tAQSJ0d+CFwhebrURHzZWziRjoeE7De5ZqDZ8T6aQPJ+bbJeEYuNF6K2 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 stub for XFS. This does a stat count and a shutdown check before proceeding, then emits a new trace line and locks the inode across the call to filemap_splice_read() and adds to the stats afterwards. Splicing from direct I/O or DAX is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Darrick J. Wong cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 30 +++++++++++++++++++++++++++++- fs/xfs/xfs_trace.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index aede746541f8..08d632668e94 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -306,6 +306,34 @@ xfs_file_read_iter( return ret; } +STATIC ssize_t +xfs_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); + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + ssize_t ret = 0; + + XFS_STATS_INC(mp, xs_read_calls); + + if (xfs_is_shutdown(mp)) + return -EIO; + + trace_xfs_file_splice_read(ip, *ppos, len); + + xfs_ilock(ip, XFS_IOLOCK_SHARED); + ret = filemap_splice_read(in, ppos, pipe, len, flags); + xfs_iunlock(ip, XFS_IOLOCK_SHARED); + if (ret > 0) + XFS_STATS_ADD(mp, xs_read_bytes, ret); + return ret; +} + /* * Common pre-write limit and setup checks. * @@ -1423,7 +1451,7 @@ const struct file_operations xfs_file_operations = { .llseek = xfs_file_llseek, .read_iter = xfs_file_read_iter, .write_iter = xfs_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = xfs_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iocb_bio_iopoll, .unlocked_ioctl = xfs_file_ioctl, diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index cd4ca5b1fcb0..4db669203149 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1445,7 +1445,6 @@ DEFINE_RW_EVENT(xfs_file_direct_write); DEFINE_RW_EVENT(xfs_file_dax_write); DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write); - DECLARE_EVENT_CLASS(xfs_imap_class, TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, int whichfork, struct xfs_bmbt_irec *irec), @@ -1535,6 +1534,7 @@ DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append); +DEFINE_SIMPLE_IO_EVENT(xfs_file_splice_read); DECLARE_EVENT_CLASS(xfs_itrunc_class, TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), From patchwork Sat May 20 00:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249006 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 8CE76C77B7F for ; Sat, 20 May 2023 00:02:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24DAA280012; Fri, 19 May 2023 20:02:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E2D6280001; Fri, 19 May 2023 20:02:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1A7B280012; Fri, 19 May 2023 20:02:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D84A6280001 for ; Fri, 19 May 2023 20:02:20 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A6EF8120BCD for ; Sat, 20 May 2023 00:02:20 +0000 (UTC) X-FDA: 80808681240.14.9241AC9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id E061010000A for ; Sat, 20 May 2023 00:02:18 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ittkGr+e; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540939; 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=fg25eeUYeYYdZ/6VEaLafGCYFAO2kBY9m762euh7YIo=; b=nEMMCbYLwp67p05y2DAc4zJndmyCvbp7BLWhWgDT354vRgjWlg8Xm3djFhE4HoJVH1ObLc LwjN681vwrGocHwDbSUWZiraRYHac3bpotPIDW4AMcFZWXwFZEuQP9fPxfNaWaR8D7mqL+ SUkxbVXmZow+XwCNIgExVXdRpEgVSIM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ittkGr+e; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540939; a=rsa-sha256; cv=none; b=qfGP3zA4mA7o35xtNlPpftHsz59xzOgBfe98BXmrdqcj79VZh/25YH4wuZHFbo2j4MMKRu 0vMniTxpJNee1Aetat/eyZ8+VerCkU2dW79kRKFB6Iv8WJEzIS+yZlUWXdBud0vQEHCqRz cy4rDKXzl5g0Rh6eDZ6wLHjypjZEja8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540938; 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=fg25eeUYeYYdZ/6VEaLafGCYFAO2kBY9m762euh7YIo=; b=ittkGr+eqDit6O3SHoFqk8Be6YScrmwzYWPofvkZJOi0N1h8IWsCw/9RiO1ULukICqrtoj ll8JeBAz9Kobwc6O/h1VwuGyRPVW+lruAh+GxhHwhpS0t9ctgHs4LzsUNpx9seVb/n+JKo yaXuLvzMd5RNc+RZVLl6XmSTBoxam2g= 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-54-C8zFKqYaNZCOViPhzBCcFA-1; Fri, 19 May 2023 20:02:12 -0400 X-MC-Unique: C8zFKqYaNZCOViPhzBCcFA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 368B3800969; Sat, 20 May 2023 00:02:11 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 142E040CFD46; Sat, 20 May 2023 00:02:08 +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 , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH v21 25/30] zonefs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:44 +0100 Message-Id: <20230520000049.2226926-26-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E061010000A X-Stat-Signature: os6e4os84qx6gbsq68mntm5ayb3t6rzh X-HE-Tag: 1684540938-458097 X-HE-Meta: U2FsdGVkX18O02vgmNKxrfI6Ft9ePDJMNxqM7+jl55bzT5AYsOfTx+0eMSKEVNts6UbDbbF6uaL0APHpwLk8y0WJlKX8PRtsaQSXKeYVjfAxmgctPUvn4ZIviDKstx+oDsRa7FOtkin+zbC30XneBOAhLQroXDqu2SfIk2YLddFbS6DJLdQqhohXjVjz0YRQKAXXERFkKgIRIoLrlsnDhqQYpujdBpNozyPqUhpg4f1j2oGJU/WtZNG1swk4hddrGTqB6S7k4AHwn7vK295Ou97FiiYUWP5w6ESgHXU7hI9VrFCUXINzdTQKF5Y6KAgjkbe88MuoWvqJGr6kA5umWcR/G2z1SsYi/P2RPxtn5i/sMX+v7NaMuHlwe8fYcZjC8/WPjh5JaBNpSMfCBJimrNOBlFs2x9uBf9nJ/ljo7n5LE6PxZUpzHcIQyjU/XK+lvtG0t0HnPua2my2FsuB5dT1TUSdUd8oHyBh48HVwJqh0rB3VFmVaqrJQOMX/yTQuTisIXgTXhH4atuUMeXy7DILqX5o743tCCXq5pEGHPpTUlZFvk+gn6qGhAQbLAVkK0WN18eXjI5VlKdLbyl9JSP+hMxBAt8BwhE1/Z3YImBD4sWLNsUDR0/FWTbkTmeTBxSuYeJwF56IBaRjC3AWlz141rPCsKJq2jVN+iZYkvsZy8fQ0+Im+yYd7Ibe4GFGeHu8sqwXSOSqlVLY/CXFuFsykbmfsIGQd9vAPZrWv4Oqgs2+1/V0jt2/cJYO6Dx2t+V/58JCHu6dor+3GgM+Sbu5QIAgXmmWC8Fb6xmWlrKZk+qv+GULPu53AYNOAzH2sCSvAJdWCCdc7DmWrSGqgTOGjp9FxINVuc2GXFk1pqM1NuuWGnZAlUoxSo2mwLLlbW4/FMVjKo1IjmlnDG3Vx7QgtIjniHr9q0OSbKjsvHJtBW0FjwzwedK0PWCxopPBjpw/WGlF9en9GiejMQge Q7ffsW41 1cEkwDC+LAjYfMz7//dL9+j2g04cf0VwmPn3yQ404xMkecedsTrhyQWovYaJa0G7WUW/QZVeyQCv8yfun2mpDr+gIyUagmo1KYBtCTXdGnvN/7IAGbibo1AL+GcSe2yfElmp3GUNRx4rpWRbbtHyHq4mYPNuDDgNyTUfb4d0jeHsGYpV6qno+9TDwvSF5bqzNqDHYNaPbscGLba2wS8ceGsB97S04puSlhjrUftCmCIyi25Qn63MgKlOkZu6ONGXFj4BBg/Jm4WWcG9TduYkpq7Oi0+vi7dHyal7Sl648VN+3j4v60LqlvJtTFX8dpcMDxS5GBzMxx9DR5w7DtWPq5bJtHXmQj/q1f8v9 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 stub for zonefs. This does some checks before proceeding and locks the inode across the call to filemap_splice_read() and a size check in case of truncation. Splicing from direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Darrick J. Wong cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/zonefs/file.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 132f01d3461f..65d4c4fe6364 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -752,6 +752,44 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t zonefs_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); + struct zonefs_inode_info *zi = ZONEFS_I(inode); + struct zonefs_zone *z = zonefs_inode_zone(inode); + loff_t isize; + ssize_t ret = 0; + + /* Offline zones cannot be read */ + if (unlikely(IS_IMMUTABLE(inode) && !(inode->i_mode & 0777))) + return -EPERM; + + if (*ppos >= z->z_capacity) + return 0; + + inode_lock_shared(inode); + + /* Limit read operations to written data */ + mutex_lock(&zi->i_truncate_mutex); + isize = i_size_read(inode); + if (*ppos >= isize) + len = 0; + else + len = min_t(loff_t, len, isize - *ppos); + mutex_unlock(&zi->i_truncate_mutex); + + if (len > 0) { + ret = filemap_splice_read(in, ppos, pipe, len, flags); + if (ret == -EIO) + zonefs_io_error(inode, false); + } + + inode_unlock_shared(inode); + return ret; +} + /* * Write open accounting is done only for sequential files. */ @@ -896,7 +934,7 @@ const struct file_operations zonefs_file_operations = { .llseek = zonefs_file_llseek, .read_iter = zonefs_file_read_iter, .write_iter = zonefs_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = zonefs_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iocb_bio_iopoll, }; From patchwork Sat May 20 00:00:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249007 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 21872C77B7F for ; Sat, 20 May 2023 00:02:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 581B8280013; Fri, 19 May 2023 20:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 507E2280001; Fri, 19 May 2023 20:02:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30D3F280013; Fri, 19 May 2023 20:02:23 -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 1CB8E280001 for ; Fri, 19 May 2023 20:02:23 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E69611A0A8F for ; Sat, 20 May 2023 00:02:22 +0000 (UTC) X-FDA: 80808681324.21.CA19EA9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 143D6C000D for ; Sat, 20 May 2023 00:02:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=alx87H68; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540941; 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=HfMcLqK7SdZvPGZvy5b2RGzipVUrB/qFQK+4kiqdRos=; b=tht2OsWiKVLlnWKWvcKWWf0XrgSLfxkxMIb49q7XAIqy9/eOrvGekokg4t/jTR2gX6l91F kMkjQKdpUZrro08AbnRfOwy7ElFdwJtX4JzCJ260b2OHnnGyyZaqe5dF6ecZ6bl5DAZbNT NM1a/MlUzbIEnq2dEX3XT0GFVl8EMfQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=alx87H68; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540941; a=rsa-sha256; cv=none; b=Q1/AnsDQNiq/DvtjKkBKwzbwey25Lg53DnTLgqqDcILmc9llAAcHHAYKd6IztOkK48bsIp Q44j/SCfcYr8ijFuxgYxl4diEuGhm/5vPoxqGupXMUiQnx8+coSwz4XpHlaj8sLRqtZ/Os uvFciVLaftmtD2GLRHBUlRiDdfNopPo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540940; 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=HfMcLqK7SdZvPGZvy5b2RGzipVUrB/qFQK+4kiqdRos=; b=alx87H68eZJK6XpZww3vALmUAFA8/FeftuqTBKFheS89v/drgUzGvLE5+0FQiCkLASm+uh kiXtwndQrNX3OKreGndjIxMXCE+BmtszJg2kSPG44XQoco0kkbTu0L1VTB2FoT/UIEBL/O lCc4sQ79qMV7qXiMpZF2kF1hUBONKtI= 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-146-uJgBlECTNdOvDKp9eNps_A-1; Fri, 19 May 2023 20:02:15 -0400 X-MC-Unique: uJgBlECTNdOvDKp9eNps_A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35A573C02521; Sat, 20 May 2023 00:02:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id E51177C2A; Sat, 20 May 2023 00:02:11 +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 , Steven Rostedt , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Subject: [PATCH v21 26/30] splice: Convert trace/seq to use copy_splice_read() Date: Sat, 20 May 2023 01:00:45 +0100 Message-Id: <20230520000049.2226926-27-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 143D6C000D X-Stat-Signature: us63ez6khkm88jqkg5bnqmx5emrgdin3 X-Rspam-User: X-HE-Tag: 1684540940-962234 X-HE-Meta: U2FsdGVkX1+l9eDmD1Tw3/nKt5P7luDpK+tYNVvY5rE8FApsofHGJhgdKG4lXVSBA6qcJvdtgWtzANGMGOiNYI9bepOF0U4p2oC51sdQ4Dnk0prCbU83vIy2GfmTetkKja9cwBnhf6MmCQWs6XnrP9hXCOXar8otkCdTTCPCSUTqL5se35nna5Li6ZYD4QrD7OV124tNh1SIaiOhELxvFsxzjFxpVn7ImwMuqu6MOCPbXv4iDfN1/h17ZPZD0DXDtwj9DRbMkMqXVOuZ5l+AbilLxSs6wnv9RzTVYO5ttIDnuFyNloC9v6UrUg8dV1Dyu8ymAzvi0dx8oTXyS5RE0Uewr13TrxwYuWJi1WWWvqTAed8bK2hl4eu2F1NqbZW7XVZwsAMaUs6DE/ba/zeeiODb/AzOUF8MXI2U2jw465uX5WMu1327A1+bR4G7qHjidNbfVirdkWqqdk8Pa+b8eHIvZOIqDxGjQsrtf0KrWHG2xP3+0sHiRaWJvvaEqSDX/4tq4KJez1PuovdB9IPsfDrI+nx6Pj6CIJO22GoPFyn7IzEc8XG0UxyJbYpZl56atbIQilEFivjRWH6XR4HD4VyS+C73qHTFYNqBh268ILqfkYu4APQqyFv9wwonYyePB2vuJ9G3h3q5zqZdxUv1npmgkpW2Jho2Ep8tIyXOrZ3PWo1cRhl5W1h2EO5eA0n01k1/EU/8W2khUyLjxLSwlFYn00wIc+eaCAHt7zV88M17ktTFN4jbqU06D0qp4Z/N5E6fp7wKjGLi4PFUhBFCPVU9Ssy+rZPCP8slTl7hT7llCpzK09U+OBuHFal+A9WP5ZAP+WVx2O3eINNfIUcp/OCdIWlMVZb+MV7+Tex7llIHvOMsOHwqPd9qo5HDoX6p5p/GZU3x9vy9hJGyPerN3AYDYbb4wg+Jj8e7GUN+36LUJeDcoW8t2K0eCNDohUS/ojltp5Oe+Itw/9Hi+gk gGu2CH0T wNS6ivpX/Mr3Fp7/sVHy+GmU83gYVfNfkw5V8LysrBKZjetIQ461KXHjhNMy2k4rHrxQ/v8cGP4Y5u8Jd+5UPuOjFf5ed7P6EnC7KWP4iE9k2w+62+Gf2E/QN3nw8sBn6WSX9KDEv2Ty8AcGUDg4rh7pptUDuekNdUwNJfAy4AD/8mwJ6r5xJXMgaFCHknFMukn82p8iwFct4cOZT3Ve+yXpoyVizaRnQu2Q2p5ia8ThzUKUkGV/Q3aoSvUbGGFxnVzszpYzixJ8XwIDj/EUjk7i2kAURfP88oSk087Z+xt6y/oEbNka2ZYNOWDQC8X8+fWaBcEWdsVqOt1Pt0K2FnPm48rBvTYUwvh+S2QJCppwZ2+TSkjkjDCw7V5kdoxjlhSApwBEO+1nT9ayvUYroYumHkpebsB570/8rBIKVyE8V2qTG+HE34zoDVobUG8Lx9ynlyFhmtKbiRJs= 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: For the splice from the trace seq buffer, just use copy_splice_read(). In the future, something better can probably be done by gifting pages from seq->buf into the pipe, but that would require changing seq->buf into a vmap over an array of pages. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Steven Rostedt cc: Masami Hiramatsu cc: linux-kernel@vger.kernel.org cc: linux-trace-kernel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Acked-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebc59781456a..c210d02fac97 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5171,7 +5171,7 @@ static const struct file_operations tracing_fops = { .open = tracing_open, .read = seq_read, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .write = tracing_write_stub, .llseek = tracing_lseek, .release = tracing_release, From patchwork Sat May 20 00:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249008 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 4A18CC7EE23 for ; Sat, 20 May 2023 00:02:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99E73280014; Fri, 19 May 2023 20:02:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92889280001; Fri, 19 May 2023 20:02:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 779E5280014; Fri, 19 May 2023 20:02:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5F348280001 for ; Fri, 19 May 2023 20:02:26 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3CA4AAE538 for ; Sat, 20 May 2023 00:02:26 +0000 (UTC) X-FDA: 80808681492.17.44EC7E9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 758C716001D for ; Sat, 20 May 2023 00:02:24 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ea8kMN8G; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1684540944; 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=KS9sZ9kcl+UmAh/rrU1AUBhdO0vlEMJjBaa07cCJK5s=; b=SMTA84HFPYiqnuNNEGSDsHRTH+ztDkjRQJzjxDtb0AMqHDGvBfiHbuKgdCKotsB+jeZPrE wmjr0G7TKbJ46kAMRPhgmA55HiC83VEm3DIQ6sXmdj0LLuDco6/Xd2FG3beakb2NoxNEfF jRn+WB4kEFYISGSd+JzLDJA4PJmNJ2k= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ea8kMN8G; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1684540944; a=rsa-sha256; cv=none; b=avno6Qye05E9YIN/TfQUHbqjLhLL4NlJF9E39f3SkylJc4q8JW9r8S1Ni76ZIc0Xfe6tDP qKByXL1W1n6cKpCYzdCkodnaI7sNyFof3Jkn+K2OsrKSklSIHbWWeRHJUpReAoTUIgxllK zkCeFXsIQB9Nrlth5ELMJGLemMAz3OQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540943; 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=KS9sZ9kcl+UmAh/rrU1AUBhdO0vlEMJjBaa07cCJK5s=; b=ea8kMN8GIV10ipsMAeiEnQW1pU88+Lv+f8CTzN4DeNtDxJgyad8j65J10ya4CC9I6kjRb6 TiBCKuw4QoKrm1HERuRj/Um6szVMyD4pRyA/OYu4In+NHm7oRChTmRSpMqrTSWaGBFv9bS lEYzs9fN9NfYikk8vYVkj3AVkAsvmrM= 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-231-r_htSqC2OBidCEEBrjvtAw-1; Fri, 19 May 2023 20:02:18 -0400 X-MC-Unique: r_htSqC2OBidCEEBrjvtAw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4832938035AA; Sat, 20 May 2023 00:02:17 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46A240CFD45; Sat, 20 May 2023 00:02:14 +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 , Paulo Alcantara , Steve French , John Hubbard , linux-cifs@vger.kernel.org Subject: [PATCH v21 27/30] cifs: Use filemap_splice_read() Date: Sat, 20 May 2023 01:00:46 +0100 Message-Id: <20230520000049.2226926-28-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 758C716001D X-Stat-Signature: enmjp4f5q1e7wp9f9k6qkjkeza6w5uki X-HE-Tag: 1684540944-740107 X-HE-Meta: U2FsdGVkX18BGver+wGq1j7rNvtF3DWQhewRloY46n3QeLpkuYJ8+VcMFi8TNuPZcHoe6sq5C9N/e4LTbpjcWx9hx1vdwKnXWjNitV94nV3C2s1hEv1XsPJg5lf2jvhrd4/YpkQgMTKBjOEC0B1pmIcMQFIoShLgN7SgW/STFleqfjstp+cHtfOBwHZk5YbHzzOffVm7cEddOtQfIZktZV9W3Ud0P5Ykm0i2kj5npuNVjZ2bZgIlqVDj3LNDmxYtld6V1nQB6q825xpO1nV3htMc281bIxNFBVZXouYmiC3k4yEnmqfmFpF018nevos3BmexQXjMWzXkT3zlBfDpGir9rnCdXsC5YChl2Ha8zgjNYlxHT0JXrp66Z01/eqC5fD03u3sZYAU7Okff0AUxlyoicERm8yr3Ah0WMSH/sqJnQTuzI1g3cZEbC969StfhhOkpcl/4lZUc1PMDXJbUYxytyMx1WQxNBfKRIUHWUd9SCOFpgCVJWkrg6ZZBojtp5fYyhWWQn4dVCHHzNNWaY7JU+W5QnFu4VVkQrKYG9jQJzJS0RPnvdaSvWyj6EGpuDyujfjbYF5Be0qj2a1YtlXhiUREcD22yffwmVsRuVKP6XCwNY+/nVirFn6kzV9YT/tMsEKAh2cUe56mVD5WYbzPKRwfixTzKwxaZ+y1QH9stDJUT22455Gvyd4SYVC+6ftYP7LQCSPgJdA3DY348wTw9+/U+UAvEJqQ6w1dyb0N9tHWNHYlxGXix3GByjO6geJHzkuu/RW1afmDQQpTr48HqEQ0U/DqicrQ5QCtdVHMWI200jKuGQ//t/XA9PcJZILN+PccMq8Z9K3O1mn3DO8mWkvVIkAiXaGqkrVTVM+MPj3CPmt0XHQFlsoeOpNCsoiJVqpFdWFBemC75CuAawpp/AW/rv89EJNJA8DPvcmmri0kG8xeSd+3oZAkbwsOBnTQI6+XwUf3pnfNCK86 AB0lWYcY OP5UoK1VrlqzwBKfzqAF4mV5076fIFphihRNKsMODImlgtxvfvnjvUVfGUHhttLTZi+A10VuWFn3yBZhJJk05Ndljez06hMj+u1RiHw6IdfNLPCdZ/6uJe6JtkLlUme7/GtorA/QIv87cLi4HQf5iFki14LEPC2qa5brbD5WUNUQD7Sv5QnVBjItzMIZmfPxmrAh7RuROZ5k0EAArojgD9SCbVkdlB6xnR4Eo4DP/OJC/iYYaWa+80yVMOsEjnl0hYgIvvZveAWtTsdBuKtSO9+QM6T9g4RdHkfhZe+YaxgdR3k8MX8BdjXWu9fmC83LxAO7JqOkt0oZ+L2n7t9EM0l+Ugm5i10M3AWDVUJJnrCakFe0aJc1PNA7qQxb1/gsln+paYg8e/3/H4E3fqCPBxbR9y5rt4GCmRjOv+Z64ZgAYltYZgF60DU7ywcslC5Oa7W9zZTJ5GZkZJ2JvKLNtcz7UgFPKP2gwSx5I3JiYgfJsRBMkZzKajIhbA4JkBuSR8TV+ 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: Make cifs use filemap_splice_read() rather than doing its own version of generic_file_splice_read(). Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Paulo Alcantara (SUSE) cc: Jens Axboe cc: Steve French cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #21) - Switch to filemap_splice_read() rather than generic_file_splice_read(). ver #20) - Don't remove the export of filemap_splice_read(). ver #18) - Split out from change to generic_file_splice_read(). fs/cifs/cifsfs.c | 8 ++++---- fs/cifs/cifsfs.h | 3 --- fs/cifs/file.c | 16 ---------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index fa2477bbcc86..4f4492eb975f 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1376,7 +1376,7 @@ const struct file_operations cifs_file_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1396,7 +1396,7 @@ const struct file_operations cifs_file_strict_ops = { .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1434,7 +1434,7 @@ const struct file_operations cifs_file_nobrl_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1452,7 +1452,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = { .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 74cd6fafb33e..d7274eefc666 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -100,9 +100,6 @@ extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from); -extern ssize_t cifs_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags); extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock); extern int cifs_lock(struct file *, int, struct file_lock *); extern int cifs_fsync(struct file *, loff_t, loff_t, int); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 023496207c18..375a8037a3f3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -5078,19 +5078,3 @@ const struct address_space_operations cifs_addr_ops_smallbuf = { .launder_folio = cifs_launder_folio, .migrate_folio = filemap_migrate_folio, }; - -/* - * Splice data from a file into a pipe. - */ -ssize_t cifs_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) -{ - if (unlikely(*ppos >= file_inode(in)->i_sb->s_maxbytes)) - return 0; - if (unlikely(!len)) - return 0; - if (in->f_flags & O_DIRECT) - return copy_splice_read(in, ppos, pipe, len, flags); - return filemap_splice_read(in, ppos, pipe, len, flags); -} From patchwork Sat May 20 00:00:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249009 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 E7ECFC77B7F for ; Sat, 20 May 2023 00:02:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFA14280015; Fri, 19 May 2023 20:02:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8822280001; Fri, 19 May 2023 20:02:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3A85280015; Fri, 19 May 2023 20:02:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7E320280001 for ; Fri, 19 May 2023 20:02:27 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 555F8AE66F for ; Sat, 20 May 2023 00:02:27 +0000 (UTC) X-FDA: 80808681534.07.6FB3FF3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 7DA43180010 for ; Sat, 20 May 2023 00:02:25 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hr33qBN9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540945; 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=hIC3yd7DKVBGin918YKNfB7K339xENufY6jpJZIP3yE=; b=PuBGqzCjm8B4gVKk3iVSbsJrDmbRbWw7XqqOk1cnFGsKi26Z+o1F9laMIUW+/3GrOWMHBj TegMuHJ1rZR1gA3oUtHYe28BVrT4WkNuXwPURxEljcorMivjyMY34HqFus0U+V/rrQjxHt sF/i1C88SzCCJMubR8oJDCeO50ZxGvc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hr33qBN9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540945; a=rsa-sha256; cv=none; b=1UaQMNWsabB0TkNLdHm7Px/NH/mZobS9TF/P5jm4NlLUNtDGBWHArAyB7PsHzgkKAI/vQx z+uho0dQf6cF4qPQ3o+MFDeGrtjehZSBbEVpw4hgwV+lRXqcJktwjeg6kTYVFG7YbF3n+7 CPekDuuaLoXTiz4WJK4p2FCYL3nPfpY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540944; 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=hIC3yd7DKVBGin918YKNfB7K339xENufY6jpJZIP3yE=; b=Hr33qBN9BFgPaCk+S20543FE2dM1MBiSw5OxHAYcojhSq2L+LnPmefWAfNtqRKbG1tBFc+ iOb+/WsHHu9Voz/4i9WR0Jay/7DDAwRKW7BzTLEa96x7CnSveS/3V6oKBmE57qU/V7X6nV 2BUdmey3jKcF6+9lAzhah/q63EXqYAE= 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-502-VJvqJAuGPtejclpAZ8tMKQ-1; Fri, 19 May 2023 20:02:21 -0400 X-MC-Unique: VJvqJAuGPtejclpAZ8tMKQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AF0E185A78F; Sat, 20 May 2023 00:02:20 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1081C154D1; Sat, 20 May 2023 00:02:17 +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 , John Hubbard Subject: [PATCH v21 28/30] splice: Use filemap_splice_read() instead of generic_file_splice_read() Date: Sat, 20 May 2023 01:00:47 +0100 Message-Id: <20230520000049.2226926-29-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 7DA43180010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: o6s6em59r1x4d34j5snbpcoqsqbbkdej X-HE-Tag: 1684540945-344684 X-HE-Meta: U2FsdGVkX1/OefPn9Do7ZC+UEdY4TKYeJ9LLZ5mgH45GPvz0COlniITJMGyiLHKlADNHIAHogSPKv5brzymWp98IBuMSmwrRHLlyF5/0F+xDdRB3LOcXB0cSpF9a8tludKGeVWZZRrpC8QYdhKFXaFGMKxf1afFV6OjeI5yf8nDwCn56d/WysgtKIe1EDQCgM6UuKX55mCj+3l6Ucdip27rAvWi0AEZwHtVdk9IHinNuiF2tYuewsvtcsuX2luLN02SVvWNrOFPxXZJqXLuCtH9bfk9YWLB6jU7t+ZV/BBuRAhO7MAtl4SGPNwyNQ3eg0Hm3VgKX9+/gFva00rBnHVjU9n7E/bTNmtWujg/LwoQ6TOS5Eq/XXW8BYRUrMPECrHFth5bSxxXi3dxs6bTXo4HElUVt0SkIEyIehDcUN7BjUKFZxloNG+SuwldNQCmpSu49Lt1waX8BpgxSm8an4RbRVpwj1zVMUhAgq52YK5TXCWucQMj3U9a8Us14ppw/UCrMgNNvB1L2WSu7VuKvzf3vTI4QhwNq9A+Ie6tFE0NoRGqdmIdXWXzyvUqprpniAudgYqEpRenXxNW5AOJwGLS3oqEimIfTRfaHJmG6wTpgTNtkIEUGfQpLS44QrVox7WSnSEcxJS0vNcdR8ld1nKEQsl9yVoSv7lf16L8rCzRbKIZzQl0H5iaKDYEn6+4F0elvosa815VwK73Df9pBUaQb/0lMNCxRKfgE+y+dxCMttlaEnQCdm2UtCVRSdQdveI6DFkCHtdhD5HT7adO3TttGpQVLqQ/GEstihszYGUz0jU7eOUJCX+6EUHAZWkWHKFVFlUM6ZbmWgxbmWuRqEIsLw1nIYGF5I8/Ei/VVcIJg58a/qNFuKPdyufxiLbsTFGwPZV/bfEvmI1CosoAk17kewXwqM0j0v9dN2Lwrd/V5C+zw3+xRk2nLUskr147lS1puQxnwj0bZF943Dzq UApFDMqz gMYxZvf9ik2sFJuQGh7T3NgWGfwQUqHtpyacyEH6t1Tpwc9rrzzF+unBowctmUiOn3GBRscaqMAk+sHdI1XsXdz+izUz/mkZmGP40WhMfDZzFlCSD7h+fUUtDgHatIZ7ef0F0NwMwDzIpKVgaJjXJO9q3N/zBVu+exnwSkX1+p+NLPHlxN1NNBRxQL/ic6asW8VVr7VItlLwIECEUu5pS/hn7ftDOf1VRwQTDMOli0JNra2WqOtUZI7+7envkXIXPb9BIW6nJVl2txgHSECh8jzFuQ/5DWD2JhK6ki+fmSRKH7Lp3g2+E7G3yrYCw/aNVkydg08RWB/nUZZ8IGxVmnbKZ+tNbha35z3MHgc6++M3TMLKfPL1zKx+WhyIKyCp2sQ0+CBjGrzkVIXP637/rpfFXqQ8JY99HDdKis0hiOdeeSeE= 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: Replace pointers to generic_file_splice_read() with calls to filemap_splice_read(). Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- block/fops.c | 2 +- fs/adfs/file.c | 2 +- fs/affs/file.c | 2 +- fs/afs/file.c | 2 +- fs/bfs/file.c | 2 +- fs/btrfs/file.c | 2 +- fs/cramfs/inode.c | 2 +- fs/ecryptfs/file.c | 4 ++-- fs/erofs/data.c | 2 +- fs/exfat/file.c | 2 +- fs/ext2/file.c | 2 +- fs/ext4/file.c | 2 +- fs/fat/file.c | 2 +- fs/fuse/file.c | 2 +- fs/gfs2/file.c | 4 ++-- fs/hfs/inode.c | 2 +- fs/hfsplus/inode.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/file.c | 2 +- fs/jffs2/file.c | 2 +- fs/jfs/file.c | 2 +- fs/minix/file.c | 2 +- fs/nilfs2/file.c | 2 +- fs/ntfs/file.c | 2 +- fs/ntfs3/file.c | 2 +- fs/ocfs2/file.c | 4 ++-- fs/omfs/file.c | 2 +- fs/ramfs/file-mmu.c | 2 +- fs/ramfs/file-nommu.c | 2 +- fs/read_write.c | 2 +- fs/reiserfs/file.c | 2 +- fs/romfs/mmap-nommu.c | 2 +- fs/sysv/file.c | 2 +- fs/ubifs/file.c | 2 +- fs/udf/file.c | 2 +- fs/ufs/file.c | 2 +- fs/vboxsf/file.c | 2 +- 37 files changed, 40 insertions(+), 40 deletions(-) diff --git a/block/fops.c b/block/fops.c index d2e6be4e3d1c..6c9aa028af6e 100644 --- a/block/fops.c +++ b/block/fops.c @@ -691,7 +691,7 @@ const struct file_operations def_blk_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = compat_blkdev_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, }; diff --git a/fs/adfs/file.c b/fs/adfs/file.c index 754afb14a6ff..ee80718aaeec 100644 --- a/fs/adfs/file.c +++ b/fs/adfs/file.c @@ -28,7 +28,7 @@ const struct file_operations adfs_file_operations = { .mmap = generic_file_mmap, .fsync = generic_file_fsync, .write_iter = generic_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations adfs_file_inode_operations = { diff --git a/fs/affs/file.c b/fs/affs/file.c index 8daeed31e1af..e43f2f007ac1 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -1001,7 +1001,7 @@ const struct file_operations affs_file_operations = { .open = affs_file_open, .release = affs_file_release, .fsync = affs_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations affs_file_inode_operations = { diff --git a/fs/afs/file.c b/fs/afs/file.c index d8a6b09dadf7..d37dd201752b 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -603,5 +603,5 @@ static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, if (ret < 0) return ret; - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 57ae5ee6deec..adc2230079c6 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c @@ -27,7 +27,7 @@ const struct file_operations bfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int bfs_move_block(unsigned long from, unsigned long to, diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index f649647392e0..71426c6408fa 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3825,7 +3825,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) const struct file_operations btrfs_file_operations = { .llseek = btrfs_file_llseek, .read_iter = btrfs_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .write_iter = btrfs_file_write_iter, .splice_write = iter_file_splice_write, .mmap = btrfs_file_mmap, diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 006ef68d7ff6..27c6597aa1be 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -473,7 +473,7 @@ static unsigned int cramfs_physmem_mmap_capabilities(struct file *file) static const struct file_operations cramfs_physmem_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .mmap = cramfs_physmem_mmap, #ifndef CONFIG_MMU .get_unmapped_area = cramfs_physmem_get_unmapped_area, diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 284395587be0..ce0a3c5ed0ca 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -47,7 +47,7 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, /* * ecryptfs_splice_read_update_atime * - * generic_file_splice_read updates the atime of upper layer inode. But, it + * filemap_splice_read updates the atime of upper layer inode. But, it * doesn't give us a chance to update the atime of the lower layer inode. This * function is a wrapper to generic_file_read. It updates the atime of the * lower level inode if generic_file_read returns without any errors. This is @@ -61,7 +61,7 @@ static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, ssize_t rc; const struct path *path; - rc = generic_file_splice_read(in, ppos, pipe, len, flags); + rc = filemap_splice_read(in, ppos, pipe, len, flags); if (rc >= 0) { path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); touch_atime(path); diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 6fe9a779fa91..db5e4b7636ec 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -448,5 +448,5 @@ const struct file_operations erofs_file_fops = { .llseek = generic_file_llseek, .read_iter = erofs_file_read_iter, .mmap = erofs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; diff --git a/fs/exfat/file.c b/fs/exfat/file.c index e99183a74611..3cbd270e0cba 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -389,7 +389,7 @@ const struct file_operations exfat_file_operations = { #endif .mmap = generic_file_mmap, .fsync = exfat_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 6b4bebe982ca..d1ae0f0a3726 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -192,7 +192,7 @@ const struct file_operations ext2_file_operations = { .release = ext2_release_file, .fsync = ext2_fsync, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 9f8bbd9d131c..e8261900f4f3 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -155,7 +155,7 @@ static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos, if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } /* diff --git a/fs/fat/file.c b/fs/fat/file.c index 795a4fad5c40..456477946dd9 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -209,7 +209,7 @@ const struct file_operations fat_file_operations = { .unlocked_ioctl = fat_generic_ioctl, .compat_ioctl = compat_ptr_ioctl, .fsync = fat_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = fat_fallocate, }; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 89d97f6188e0..4553124f5406 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3252,7 +3252,7 @@ static const struct file_operations fuse_file_operations = { .lock = fuse_file_lock, .get_unmapped_area = thp_get_unmapped_area, .flock = fuse_file_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 300844f50dcd..0f5ad5165361 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1568,7 +1568,7 @@ const struct file_operations gfs2_file_fops = { .fsync = gfs2_fsync, .lock = gfs2_lock, .flock = gfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = gfs2_file_splice_write, .setlease = simple_nosetlease, .fallocate = gfs2_fallocate, @@ -1599,7 +1599,7 @@ const struct file_operations gfs2_file_fops_nolock = { .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = gfs2_file_splice_write, .setlease = generic_setlease, .fallocate = gfs2_fallocate, diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 1f7bd068acf0..441d7fc952e3 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c @@ -694,7 +694,7 @@ static const struct file_operations hfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .fsync = hfs_file_fsync, .open = hfs_file_open, .release = hfs_file_release, diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index b21660475ac1..7d1a675e037d 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -372,7 +372,7 @@ static const struct file_operations hfsplus_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .fsync = hfsplus_file_fsync, .open = hfsplus_file_open, .release = hfsplus_file_release, diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 28b4f15c19eb..87998df499f4 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -381,7 +381,7 @@ static int hostfs_fsync(struct file *file, loff_t start, loff_t end, static const struct file_operations hostfs_file_fops = { .llseek = generic_file_llseek, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index 88952d4a631e..1bb8d97cd9ae 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c @@ -259,7 +259,7 @@ const struct file_operations hpfs_file_ops = .mmap = generic_file_mmap, .release = hpfs_file_release, .fsync = hpfs_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .unlocked_ioctl = hpfs_ioctl, .compat_ioctl = compat_ptr_ioctl, }; diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 96b0275ce957..2345ca3f09ee 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -56,7 +56,7 @@ const struct file_operations jffs2_file_operations = .unlocked_ioctl=jffs2_ioctl, .mmap = generic_file_readonly_mmap, .fsync = jffs2_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 2ee35be49de1..01b6912e60f8 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -144,7 +144,7 @@ const struct file_operations jfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fsync = jfs_fsync, .release = jfs_release, diff --git a/fs/minix/file.c b/fs/minix/file.c index 0dd05d47724a..906d192ab7f3 100644 --- a/fs/minix/file.c +++ b/fs/minix/file.c @@ -19,7 +19,7 @@ const struct file_operations minix_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int minix_setattr(struct mnt_idmap *idmap, diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a265d391ffe9..a9eb3487efb2 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -140,7 +140,7 @@ const struct file_operations nilfs_file_operations = { .open = generic_file_open, /* .release = nilfs_release_file, */ .fsync = nilfs_sync_file, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index c481b14e4fd9..e5e0ed58670b 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -1992,7 +1992,7 @@ const struct file_operations ntfs_file_ops = { #endif /* NTFS_RW */ .mmap = generic_file_mmap, .open = ntfs_file_open, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations ntfs_file_inode_ops = { diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 667c9dc68b58..036efd85f60c 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -770,7 +770,7 @@ static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, return -EOPNOTSUPP; } - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } /* diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index f7e00b5689d5..ff673c882816 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2601,7 +2601,7 @@ static ssize_t ocfs2_file_splice_read(struct file *in, loff_t *ppos, * rw_lock during read. * * Take and drop the meta data lock to update inode fields like i_size. - * This allows the checks down below generic_file_splice_read() a + * This allows the checks down below filemap_splice_read() a * chance of actually working. */ ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level, true); @@ -2827,7 +2827,7 @@ const struct file_operations ocfs2_fops_no_plocks = { .compat_ioctl = ocfs2_compat_ioctl, #endif .flock = ocfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, diff --git a/fs/omfs/file.c b/fs/omfs/file.c index 0101f1f87b56..de8f57ee39ec 100644 --- a/fs/omfs/file.c +++ b/fs/omfs/file.c @@ -334,7 +334,7 @@ const struct file_operations omfs_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int omfs_setattr(struct mnt_idmap *idmap, diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c index 12af0490322f..c7a1aa3c882b 100644 --- a/fs/ramfs/file-mmu.c +++ b/fs/ramfs/file-mmu.c @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, .get_unmapped_area = ramfs_mmu_get_unmapped_area, diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 9fbb9b5256f7..efb1b4c1a0a4 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/read_write.c b/fs/read_write.c index a21ba3be7dbe..b07de77ef126 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -29,7 +29,7 @@ const struct file_operations generic_ro_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; EXPORT_SYMBOL(generic_ro_fops); diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index b54cc7048f02..8eb3ad3e8ae9 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -247,7 +247,7 @@ const struct file_operations reiserfs_file_operations = { .fsync = reiserfs_sync_file, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c index 4578dc45e50a..4520ca413867 100644 --- a/fs/romfs/mmap-nommu.c +++ b/fs/romfs/mmap-nommu.c @@ -78,7 +78,7 @@ static unsigned romfs_mmap_capabilities(struct file *file) const struct file_operations romfs_ro_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .mmap = romfs_mmap, .get_unmapped_area = romfs_get_unmapped_area, .mmap_capabilities = romfs_mmap_capabilities, diff --git a/fs/sysv/file.c b/fs/sysv/file.c index 50eb92557a0f..c645f60bdb7f 100644 --- a/fs/sysv/file.c +++ b/fs/sysv/file.c @@ -26,7 +26,7 @@ const struct file_operations sysv_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int sysv_setattr(struct mnt_idmap *idmap, diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 979ab1d9d0c3..6738fe43040b 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1669,7 +1669,7 @@ const struct file_operations ubifs_file_operations = { .mmap = ubifs_file_mmap, .fsync = ubifs_fsync, .unlocked_ioctl = ubifs_ioctl, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .open = fscrypt_file_open, #ifdef CONFIG_COMPAT diff --git a/fs/udf/file.c b/fs/udf/file.c index 8238f742377b..29daf5d5cb67 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -209,7 +209,7 @@ const struct file_operations udf_file_operations = { .write_iter = udf_file_write_iter, .release = udf_release_file, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/ufs/file.c b/fs/ufs/file.c index 7e087581be7e..6558882a89ef 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -41,5 +41,5 @@ const struct file_operations ufs_file_operations = { .mmap = generic_file_mmap, .open = generic_file_open, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c index 572aa1c43b37..2307f8037efc 100644 --- a/fs/vboxsf/file.c +++ b/fs/vboxsf/file.c @@ -217,7 +217,7 @@ const struct file_operations vboxsf_reg_fops = { .open = vboxsf_file_open, .release = vboxsf_file_release, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations vboxsf_reg_iops = { From patchwork Sat May 20 00:00:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249010 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 BCAD8C7EE23 for ; Sat, 20 May 2023 00:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3A86280016; Fri, 19 May 2023 20:02:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBEB7280001; Fri, 19 May 2023 20:02:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99BE9280016; Fri, 19 May 2023 20:02:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7D758280001 for ; Fri, 19 May 2023 20:02:30 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E6EF140B07 for ; Sat, 20 May 2023 00:02:30 +0000 (UTC) X-FDA: 80808681660.30.1429408 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 7AE9E40021 for ; Sat, 20 May 2023 00:02:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cUImny7l; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540948; 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=rmUg21oqbgLRKa8Xmc9rYZI7yR2ltYVW2UHU8B7zCB0=; b=jZ5VSintkiR91ZVFmn1M1gWoLei9ZslC0ulTlim9uXcoc3leEJY9//O1RPdW7Wert/eurN T8h7of0jPLkuUNOkiKX4ypjZT+Y/BnJu8sr52r3WCRBIyJW+cWgLTOdZTfdvqf2GfMlP4Z 1vVxHPUV3q1OnFIb9Gm/aAvTcOvf8Lw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540948; a=rsa-sha256; cv=none; b=RF9eyJ6zEUlduSI99UWBde6TMYa9x8VwSC88kqy5IYl/Q5XF8aAWozSzZEW/lTUcIRZz6c 0Edtvkm3KbvynWhYe5coetAet4VnZnzeyhrgD2WKtPB8yFKFxmidBiyUWJL8dbPySm0Dbe DtZlhzOah1AjVCHqVOpYpMiknFuuaBw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cUImny7l; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540947; 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=rmUg21oqbgLRKa8Xmc9rYZI7yR2ltYVW2UHU8B7zCB0=; b=cUImny7lzYiVC2HTPe25U2MbIqLkacpwMDuYakT/FPuLGjsq6Bl9zcJWClhLokqv94Gwib jpovP+4ORLfZk5XC5xSJFUHcFk6aL60vsfoZo2JJMITPQhqTdTWDGgRZcP6jo1YX++CY5s tjUUwKDjCew2Y0t1yf3r2iUCuVlOurE= 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-416-JpVDmfLpP9q6slSFpg2Hww-1; Fri, 19 May 2023 20:02:24 -0400 X-MC-Unique: JpVDmfLpP9q6slSFpg2Hww-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6209238035AA; Sat, 20 May 2023 00:02:23 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB668492B0A; Sat, 20 May 2023 00:02:20 +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 , Steve French , John Hubbard , linux-cifs@vger.kernel.org Subject: [PATCH v21 29/30] splice: Remove generic_file_splice_read() Date: Sat, 20 May 2023 01:00:48 +0100 Message-Id: <20230520000049.2226926-30-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 7AE9E40021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: btinqjpdynua94gpu4eaqazcayrtfk6t X-HE-Tag: 1684540948-762135 X-HE-Meta: U2FsdGVkX19ViVSHc8Kh1QvjGjFGI6yoUsRAhRXZF1vvH2dX02HmzyzmMH+LhFQz25Ixn+jeTzzsLFMLB8RQLUgU4Tpt0D+HiPPkTMO5VCI4b+HV+xK+G2OpwpAmdCpUOxuF9oEvzCSH71TlerJgLcgHq1rEkG7V5qY6DAlDuHvOmF49moV35AxcaFi0bpZ09RDUSPkNufoLFhFG8rkadeIsHDFwiFuy+ZaN3h/o/Zzc/A3Y06OzvPJrKCCAMbAYZ8meE3wym3EeTmPdbdz2808b9x8irhUc9XkeStWgz/KsrVARAKj2gVhhPAdYSIaPrUgx0L3Mc+iAguXSRHbVnQhmA27RhBe9STFiMcwnyT+pBeHZLK4kQifXi7JFdp4GfTX2Hppqk0urDqvVQJda90A9y7D22JkCId5YvMkRnrTzxdIBKZxr0nyGyDmIlyMRNjE+WuimSlZPlASh06llEIB+Brp6+XNZznR3kehSNsvBxVJeO+lJtKxRaP7z2hkfoRg2WK+uCealW4Zuir1YKl24MaHm/Om05KG4DRlLG4KrDmBGzdtDJfApKqXqa3kwkELctFXI81e2g/xgW4wpZC3k5SdA6we4mJz2xO1AvHlAnuwM4yErTa7CTlMswD3/eZMgy8lZPd/YIYomu1Cn5eg/OLMsa/Pnv7kTOKrez8VeiV28NcrD7gx2CYvbq9iBsLa+UOz6Vv2UCd2TUvs51hoYJZyhVpE8qu/96s4dbHxAkEDBFsKrji+BJPPk7d7JUgT682H3rzR5rzt+/wcJGm8szUzjVdDFJBG+tG6iVbbu+TUAIrm/kTAtlDWXRGXkcFr+Y4dkwi/a0lqRRI2ApH7tQS+2b1gTBsIsQJDBnjVZy2LbTluMqcKRgWUeAZznP9y6/M/8nRd/wTaiSMPTzJl3RkNza3Zxhl4VWkNfb+rQYINsBZGchAAQSojhMU9YWU2Jsm7VLkeU39DB+up 4nH17xST WchM1y0O1JN0zqUc1CQ2zAWOD29U0wDNAfiOncooXJ0BqPLYH+YgQXyQ5Ur2e52kphFO3XUnVVsjLX6KX/U3I/HASTqawqHb9h+piu5bTKdT1ed0X7Vgwn1lg4LkMmh4Y7zGE5/NhlqHba1NLY3X1wLSCYaeKaccubjalvBS2qgUkukufOAlslGvxJSQAbYsy6S8s82mHde0k44NgqMt+xpBPoL738HIGrCn6zv8toqLNneGf+WGVO7Bf0jiebqyQAtX4COKTlBxvyFVdhL9DrqwKU+viR5a72H93D8jdXNOQA4MX1JqP4XgONGQKhbi0slngYfQweZ7us3crI1CiKtSlfR+OzOL6mnYSa6KoZ2gFIKQoKWhN1Eiax9j618N6+Nqs+x6CmySyoEAR4WVv1HutI+V6NN6ljN/ArFmMqCJqhcVvUFKOr2pH00TeuMNyST+z 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: Remove generic_file_splice_read() as it has been replaced with calls to filemap_splice_read() and copy_splice_read(). With this, ITER_PIPE is no longer used. Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Steve French cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- Notes: ver #21) - Move zero-len check to vfs_splice_read(). - Move s_maxbytes check to filemap_splice_read(). - DIO (and DAX) are handled by vfs_splice_read(). ver #20) - Use s_maxbytes from the backing store (in->f_mapping), not the front inode (especially for a blockdev). ver #18) - Split out the change to cifs to make it use generic_file_splice_read(). - Split out the unexport of filemap_splice_read() (still needed by cifs). fs/splice.c | 43 ------------------------------------------- include/linux/fs.h | 2 -- 2 files changed, 45 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 8268248df3a9..9be4cb3b9879 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -386,49 +386,6 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, } EXPORT_SYMBOL(copy_splice_read); -/** - * generic_file_splice_read - splice data from file to a pipe - * @in: file to splice from - * @ppos: position in @in - * @pipe: pipe to splice to - * @len: number of bytes to splice - * @flags: splice modifier flags - * - * Description: - * Will read pages from given file and fill them into a pipe. Can be - * used as long as it has more or less sane ->read_iter(). - * - */ -ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) -{ - struct iov_iter to; - struct kiocb kiocb; - int ret; - - iov_iter_pipe(&to, ITER_DEST, pipe, len); - init_sync_kiocb(&kiocb, in); - kiocb.ki_pos = *ppos; - ret = call_read_iter(in, &kiocb, &to); - if (ret > 0) { - *ppos = kiocb.ki_pos; - file_accessed(in); - } else if (ret < 0) { - /* free what was emitted */ - pipe_discard_from(pipe, to.start_head); - /* - * callers of ->splice_read() expect -EAGAIN on - * "can't put anything in there", rather than -EFAULT. - */ - if (ret == -EFAULT) - ret = -EAGAIN; - } - - return ret; -} -EXPORT_SYMBOL(generic_file_splice_read); - const struct pipe_buf_operations default_pipe_buf_ops = { .release = generic_pipe_buf_release, .try_steal = generic_pipe_buf_try_steal, diff --git a/include/linux/fs.h b/include/linux/fs.h index e3c22efa413e..08ba2ae1d3ce 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2755,8 +2755,6 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); -extern ssize_t generic_file_splice_read(struct file *, loff_t *, - struct pipe_inode_info *, size_t, unsigned int); extern ssize_t iter_file_splice_write(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, From patchwork Sat May 20 00:00:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13249011 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 51535C77B7A for ; Sat, 20 May 2023 00:02:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD8BB280017; Fri, 19 May 2023 20:02:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6096280001; Fri, 19 May 2023 20:02:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B1A6280017; Fri, 19 May 2023 20:02:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 753B9280001 for ; Fri, 19 May 2023 20:02:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5650C1C797C for ; Sat, 20 May 2023 00:02:33 +0000 (UTC) X-FDA: 80808681786.02.0DFCBEA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 8A6658000D for ; Sat, 20 May 2023 00:02:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TB5aqd+W; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1684540951; 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=SfZQbtaDoEyq71QPI9lrXKjWo2dYCC1nxqhi0xjsBUU=; b=hOcwa/UU3RNs7Inq+DSXw2SaiDmzLw/NDgcgV2W3NA54UKhJ8lP2rEBfCUVs98rtrMrSoT ZhAdQnwSd2uOZkQMBQ+cGL6HcktwNSmoeab3euOsvjxGvz8uKjdFdzfLwy+AOduC375UhF dJdSU9gkKwOm8OdAPSbVuUnCqTID+Ss= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TB5aqd+W; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1684540951; a=rsa-sha256; cv=none; b=Dg5tP79Tdgerv9nva+BBhlqmmHgdTCndTJc4IaU6b5FLulhg3/VbtJIvVJGUiLUYAE0Va5 fhPHTm2mJQBIrgvP+6aXrbzc8VWBENyEGMIY4a8NNQj5kzbBGpG4SpsdK2PVckG+gYLTDJ LoV34+kCpm2rNa/JCWJIPbInsq60EXE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540950; 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=SfZQbtaDoEyq71QPI9lrXKjWo2dYCC1nxqhi0xjsBUU=; b=TB5aqd+W8wmKCH+fhUM/pXqT/bhW5ugOX1PWVxBs6pZR1M+nFTtQz27SwdU0Wt7kK8ZB8D XtBn8vFpwhBBwDadbNTzHBF9Tu5RNyEuie7Un+BE3/k3F6sXcDAjYGBAUlVod+yKVIba+P DttKTxPPU8uziFlR0eVHhLlO5iNE7ls= 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-553-B9oAsgJHNiK1nkdU_1LuSg-1; Fri, 19 May 2023 20:02:27 -0400 X-MC-Unique: B9oAsgJHNiK1nkdU_1LuSg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DDD0185A794; Sat, 20 May 2023 00:02:26 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FEDA40CFD45; Sat, 20 May 2023 00:02:24 +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 , John Hubbard Subject: [PATCH v21 30/30] iov_iter: Kill ITER_PIPE Date: Sat, 20 May 2023 01:00:49 +0100 Message-Id: <20230520000049.2226926-31-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8A6658000D X-Stat-Signature: gc499osrt11wskhjp1ambupm3qrtwxi7 X-HE-Tag: 1684540951-560502 X-HE-Meta: U2FsdGVkX1/B1nOCU8HrVGWIjSi0iDZB5aKZ1zyyyE7yZ2yDdCvGe9igb0ff3fV7W7gTgjBEurVvQqchlRjlKm9GysuvFrudn2fifWWxKieg5ogxK9p4Z6G5SXaOevGqjTuwdIIfOwt0lvdyj2eyNGCvOiJtNoduQqXox0ljq+x1CjW1mpkcr2BY6Y1TGY6Bx5zPeE6C9hbw6aDmsJGH+sGiC0+LYgztR8bIY+viUTUsgvYLkr6kOE+Xg48cFtk9u/QJDHT3JMGnwCs/0KEasWP/SASvy306g9n3maa0JFo6N56tXGNkcGISjz2AmGS0nNbO/yYwLS6bXCIi0qnXSWshENOWy+9Hjlits6qSrCwbkwa+xdWKzAjSL++QAbaAq8sn3pGo4b155/k3jrSlKswg2wG05zrxp3fpqQ0fmvZRUqO0KTD3KDpC07YLyHNA2R8M6xedJ6TlKhvkyLTn4k0aNlfr6L2FgptZzMiK+xBSxjHLr1a2EBTqh9XAJFc03xbOqh47BnDXitGPtKf1wy6YMSgXNH4VdZxUsfjtWqoVvt7M9eedGG6TcE4+kLUdLU8nifN9q8NYr1hy1ypV+tDhIDd1hAxKwuGR06vXztlIsIHUSfdPaf0AXVfORgXF0kLdxU6AVLI4cln3iGjk0MiSXb8IZRTKHChpD+Vkg9MtjYlfP0QC46FGsvwUt+ca6gWmNV0bKpu1tf8mR9gRb1WjRe1gmaz+jH1Dd95TN9pj2DYLlTzKQhV/AC+BrAfvrQXg10qeTG2xpgbTQDY/g2KqXxUiNI7Ehod821JPBVn+WM7CIQIyhXX33cytoSI/r/bJMfVbBLHfT3nFFSvjm9HvXTbQ/LLUCUq9U7hNJrkSCzlDrx7SwTOVuilhasWyX4cv5XmP9BHFI9ejUDTsDNphMyeMBN5K/yeI9q9IoBDw8mkhcM4wld6PLAhrxKCvlKpYXBOAaU2F+mEA/6f eVqL+aWE VE7P9Su28aef5JjbosdggvYUJ5jCCIZOqvN/9pUae3E8y2J+ji15AHVrWiDh5DDOC78EH2fz+oD9Sp4Px/bhBfMmb4wlOrjvgsNNggAAdLemgz9ExUwvKAbnCRsHk4QEUzSnAyeCeyjsSOIsAMAh+jw9DF5YHEqwcZaS0V1qGuDWO6ywxjP+2/gBKxdO/Q8GWNlwmXtuvQd36Sfj/KoyTov/S5DsFtMDJKUOdGBmg7vvDdncAPKtU+V1QY72y4drF+EN43MSVHi0PENPs+/vT+7NFrzG9OJ0RdTdp63mMXgz1yTiVfl3jlb2c+5p8byXSkrb/WsrhkH/bp1QiDqBphmUTtBSwNuOuMI3BqVGpVTnBajqs4uoZZi8N6K2bLKIqD327zx0MkBUn2/pwyY27atHiJHOKvnfxQ9t2DiV0sDV08fw= 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: The ITER_PIPE-type iterator was only used by generic_file_splice_read() and that has been replaced and removed. This leaves ITER_PIPE unused - so remove it too. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- Notes: ver #20) - Rebase and remove additional pipe reference. include/linux/uio.h | 14 -- lib/iov_iter.c | 431 +------------------------------------------- mm/filemap.c | 3 +- 3 files changed, 4 insertions(+), 444 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 044c1d8c230c..60c342bb7ab8 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -11,7 +11,6 @@ #include struct page; -struct pipe_inode_info; typedef unsigned int __bitwise iov_iter_extraction_t; @@ -25,7 +24,6 @@ enum iter_type { ITER_IOVEC, ITER_KVEC, ITER_BVEC, - ITER_PIPE, ITER_XARRAY, ITER_DISCARD, ITER_UBUF, @@ -74,7 +72,6 @@ struct iov_iter { const struct kvec *kvec; const struct bio_vec *bvec; struct xarray *xarray; - struct pipe_inode_info *pipe; void __user *ubuf; }; size_t count; @@ -82,10 +79,6 @@ struct iov_iter { }; union { unsigned long nr_segs; - struct { - unsigned int head; - unsigned int start_head; - }; loff_t xarray_start; }; }; @@ -133,11 +126,6 @@ static inline bool iov_iter_is_bvec(const struct iov_iter *i) return iov_iter_type(i) == ITER_BVEC; } -static inline bool iov_iter_is_pipe(const struct iov_iter *i) -{ - return iov_iter_type(i) == ITER_PIPE; -} - static inline bool iov_iter_is_discard(const struct iov_iter *i) { return iov_iter_type(i) == ITER_DISCARD; @@ -286,8 +274,6 @@ void iov_iter_kvec(struct iov_iter *i, unsigned int direction, const struct kvec unsigned long nr_segs, size_t count); void iov_iter_bvec(struct iov_iter *i, unsigned int direction, const struct bio_vec *bvec, unsigned long nr_segs, size_t count); -void iov_iter_pipe(struct iov_iter *i, unsigned int direction, struct pipe_inode_info *pipe, - size_t count); void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count); void iov_iter_xarray(struct iov_iter *i, unsigned int direction, struct xarray *xarray, loff_t start, size_t count); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 960223ed9199..f18138e0292a 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -14,8 +14,6 @@ #include #include -#define PIPE_PARANOIA /* for now */ - /* covers ubuf and kbuf alike */ #define iterate_buf(i, n, base, len, off, __p, STEP) { \ size_t __maybe_unused off = 0; \ @@ -198,150 +196,6 @@ static int copyin(void *to, const void __user *from, size_t n) return res; } -#ifdef PIPE_PARANOIA -static bool sanity(const struct iov_iter *i) -{ - struct pipe_inode_info *pipe = i->pipe; - unsigned int p_head = pipe->head; - unsigned int p_tail = pipe->tail; - unsigned int p_occupancy = pipe_occupancy(p_head, p_tail); - unsigned int i_head = i->head; - unsigned int idx; - - if (i->last_offset) { - struct pipe_buffer *p; - if (unlikely(p_occupancy == 0)) - goto Bad; // pipe must be non-empty - if (unlikely(i_head != p_head - 1)) - goto Bad; // must be at the last buffer... - - p = pipe_buf(pipe, i_head); - if (unlikely(p->offset + p->len != abs(i->last_offset))) - goto Bad; // ... at the end of segment - } else { - if (i_head != p_head) - goto Bad; // must be right after the last buffer - } - return true; -Bad: - printk(KERN_ERR "idx = %d, offset = %d\n", i_head, i->last_offset); - printk(KERN_ERR "head = %d, tail = %d, buffers = %d\n", - p_head, p_tail, pipe->ring_size); - for (idx = 0; idx < pipe->ring_size; idx++) - printk(KERN_ERR "[%p %p %d %d]\n", - pipe->bufs[idx].ops, - pipe->bufs[idx].page, - pipe->bufs[idx].offset, - pipe->bufs[idx].len); - WARN_ON(1); - return false; -} -#else -#define sanity(i) true -#endif - -static struct page *push_anon(struct pipe_inode_info *pipe, unsigned size) -{ - struct page *page = alloc_page(GFP_USER); - if (page) { - struct pipe_buffer *buf = pipe_buf(pipe, pipe->head++); - *buf = (struct pipe_buffer) { - .ops = &default_pipe_buf_ops, - .page = page, - .offset = 0, - .len = size - }; - } - return page; -} - -static void push_page(struct pipe_inode_info *pipe, struct page *page, - unsigned int offset, unsigned int size) -{ - struct pipe_buffer *buf = pipe_buf(pipe, pipe->head++); - *buf = (struct pipe_buffer) { - .ops = &page_cache_pipe_buf_ops, - .page = page, - .offset = offset, - .len = size - }; - get_page(page); -} - -static inline int last_offset(const struct pipe_buffer *buf) -{ - if (buf->ops == &default_pipe_buf_ops) - return buf->len; // buf->offset is 0 for those - else - return -(buf->offset + buf->len); -} - -static struct page *append_pipe(struct iov_iter *i, size_t size, - unsigned int *off) -{ - struct pipe_inode_info *pipe = i->pipe; - int offset = i->last_offset; - struct pipe_buffer *buf; - struct page *page; - - if (offset > 0 && offset < PAGE_SIZE) { - // some space in the last buffer; add to it - buf = pipe_buf(pipe, pipe->head - 1); - size = min_t(size_t, size, PAGE_SIZE - offset); - buf->len += size; - i->last_offset += size; - i->count -= size; - *off = offset; - return buf->page; - } - // OK, we need a new buffer - *off = 0; - size = min_t(size_t, size, PAGE_SIZE); - if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) - return NULL; - page = push_anon(pipe, size); - if (!page) - return NULL; - i->head = pipe->head - 1; - i->last_offset = size; - i->count -= size; - return page; -} - -static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t bytes, - struct iov_iter *i) -{ - struct pipe_inode_info *pipe = i->pipe; - unsigned int head = pipe->head; - - if (unlikely(bytes > i->count)) - bytes = i->count; - - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - if (offset && i->last_offset == -offset) { // could we merge it? - struct pipe_buffer *buf = pipe_buf(pipe, head - 1); - if (buf->page == page) { - buf->len += bytes; - i->last_offset -= bytes; - i->count -= bytes; - return bytes; - } - } - if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) - return 0; - - push_page(pipe, page, offset, bytes); - i->last_offset = -(offset + bytes); - i->head = head; - i->count -= bytes; - return bytes; -} - /* * fault_in_iov_iter_readable - fault in iov iterator for reading * @i: iterator @@ -446,46 +300,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, } EXPORT_SYMBOL(iov_iter_init); -// returns the offset in partial buffer (if any) -static inline unsigned int pipe_npages(const struct iov_iter *i, int *npages) -{ - struct pipe_inode_info *pipe = i->pipe; - int used = pipe->head - pipe->tail; - int off = i->last_offset; - - *npages = max((int)pipe->max_usage - used, 0); - - if (off > 0 && off < PAGE_SIZE) { // anon and not full - (*npages)++; - return off; - } - return 0; -} - -static size_t copy_pipe_to_iter(const void *addr, size_t bytes, - struct iov_iter *i) -{ - unsigned int off, chunk; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - for (size_t n = bytes; n; n -= chunk) { - struct page *page = append_pipe(i, n, &off); - chunk = min_t(size_t, n, PAGE_SIZE - off); - if (!page) - return bytes - n; - memcpy_to_page(page, off, addr, chunk); - addr += chunk; - } - return bytes; -} - static __wsum csum_and_memcpy(void *to, const void *from, size_t len, __wsum sum, size_t off) { @@ -493,44 +307,10 @@ static __wsum csum_and_memcpy(void *to, const void *from, size_t len, return csum_block_add(sum, next, off); } -static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes, - struct iov_iter *i, __wsum *sump) -{ - __wsum sum = *sump; - size_t off = 0; - unsigned int chunk, r; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - while (bytes) { - struct page *page = append_pipe(i, bytes, &r); - char *p; - - if (!page) - break; - chunk = min_t(size_t, bytes, PAGE_SIZE - r); - p = kmap_local_page(page); - sum = csum_and_memcpy(p + r, addr + off, chunk, sum, off); - kunmap_local(p); - off += chunk; - bytes -= chunk; - } - *sump = sum; - return off; -} - size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_pipe_to_iter(addr, bytes, i); if (user_backed_iter(i)) might_fault(); iterate_and_advance(i, bytes, base, len, off, @@ -552,42 +332,6 @@ static int copyout_mc(void __user *to, const void *from, size_t n) return n; } -static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, - struct iov_iter *i) -{ - size_t xfer = 0; - unsigned int off, chunk; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - while (bytes) { - struct page *page = append_pipe(i, bytes, &off); - unsigned long rem; - char *p; - - if (!page) - break; - chunk = min_t(size_t, bytes, PAGE_SIZE - off); - p = kmap_local_page(page); - rem = copy_mc_to_kernel(p + off, addr + xfer, chunk); - chunk -= rem; - kunmap_local(p); - xfer += chunk; - bytes -= chunk; - if (rem) { - iov_iter_revert(i, rem); - break; - } - } - return xfer; -} - /** * _copy_mc_to_iter - copy to iter with source memory error exception handling * @addr: source kernel address @@ -607,9 +351,8 @@ static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, * alignment and poison alignment assumptions to avoid re-triggering * hardware exceptions. * - * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies. - * Compare to copy_to_iter() where only ITER_IOVEC attempts might return - * a short copy. + * * ITER_KVEC and ITER_BVEC can return short copies. Compare to + * copy_to_iter() where only ITER_IOVEC attempts might return a short copy. * * Return: number of bytes copied (may be %0) */ @@ -617,8 +360,6 @@ size_t _copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_mc_pipe_to_iter(addr, bytes, i); if (user_backed_iter(i)) might_fault(); __iterate_and_advance(i, bytes, base, len, off, @@ -732,8 +473,6 @@ size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, return 0; if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_page_to_iter_pipe(page, offset, bytes, i); page += offset / PAGE_SIZE; // first subpage offset %= PAGE_SIZE; while (1) { @@ -764,8 +503,6 @@ size_t copy_page_to_iter_nofault(struct page *page, unsigned offset, size_t byte return 0; if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_page_to_iter_pipe(page, offset, bytes, i); page += offset / PAGE_SIZE; // first subpage offset %= PAGE_SIZE; while (1) { @@ -818,36 +555,8 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes, } EXPORT_SYMBOL(copy_page_from_iter); -static size_t pipe_zero(size_t bytes, struct iov_iter *i) -{ - unsigned int chunk, off; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - for (size_t n = bytes; n; n -= chunk) { - struct page *page = append_pipe(i, n, &off); - char *p; - - if (!page) - return bytes - n; - chunk = min_t(size_t, n, PAGE_SIZE - off); - p = kmap_local_page(page); - memset(p + off, 0, chunk); - kunmap_local(p); - } - return bytes; -} - size_t iov_iter_zero(size_t bytes, struct iov_iter *i) { - if (unlikely(iov_iter_is_pipe(i))) - return pipe_zero(bytes, i); iterate_and_advance(i, bytes, base, len, count, clear_user(base, len), memset(base, 0, len) @@ -878,32 +587,6 @@ size_t copy_page_from_iter_atomic(struct page *page, unsigned offset, size_t byt } EXPORT_SYMBOL(copy_page_from_iter_atomic); -static void pipe_advance(struct iov_iter *i, size_t size) -{ - struct pipe_inode_info *pipe = i->pipe; - int off = i->last_offset; - - if (!off && !size) { - pipe_discard_from(pipe, i->start_head); // discard everything - return; - } - i->count -= size; - while (1) { - struct pipe_buffer *buf = pipe_buf(pipe, i->head); - if (off) /* make it relative to the beginning of buffer */ - size += abs(off) - buf->offset; - if (size <= buf->len) { - buf->len = size; - i->last_offset = last_offset(buf); - break; - } - size -= buf->len; - i->head++; - off = 0; - } - pipe_discard_from(pipe, i->head + 1); // discard everything past this one -} - static void iov_iter_bvec_advance(struct iov_iter *i, size_t size) { const struct bio_vec *bvec, *end; @@ -955,8 +638,6 @@ void iov_iter_advance(struct iov_iter *i, size_t size) iov_iter_iovec_advance(i, size); } else if (iov_iter_is_bvec(i)) { iov_iter_bvec_advance(i, size); - } else if (iov_iter_is_pipe(i)) { - pipe_advance(i, size); } else if (iov_iter_is_discard(i)) { i->count -= size; } @@ -970,26 +651,6 @@ void iov_iter_revert(struct iov_iter *i, size_t unroll) if (WARN_ON(unroll > MAX_RW_COUNT)) return; i->count += unroll; - if (unlikely(iov_iter_is_pipe(i))) { - struct pipe_inode_info *pipe = i->pipe; - unsigned int head = pipe->head; - - while (head > i->start_head) { - struct pipe_buffer *b = pipe_buf(pipe, --head); - if (unroll < b->len) { - b->len -= unroll; - i->last_offset = last_offset(b); - i->head = head; - return; - } - unroll -= b->len; - pipe_buf_release(pipe, b); - pipe->head--; - } - i->last_offset = 0; - i->head = head; - return; - } if (unlikely(iov_iter_is_discard(i))) return; if (unroll <= i->iov_offset) { @@ -1079,24 +740,6 @@ void iov_iter_bvec(struct iov_iter *i, unsigned int direction, } EXPORT_SYMBOL(iov_iter_bvec); -void iov_iter_pipe(struct iov_iter *i, unsigned int direction, - struct pipe_inode_info *pipe, - size_t count) -{ - BUG_ON(direction != READ); - WARN_ON(pipe_full(pipe->head, pipe->tail, pipe->ring_size)); - *i = (struct iov_iter){ - .iter_type = ITER_PIPE, - .data_source = false, - .pipe = pipe, - .head = pipe->head, - .start_head = pipe->head, - .last_offset = 0, - .count = count - }; -} -EXPORT_SYMBOL(iov_iter_pipe); - /** * iov_iter_xarray - Initialise an I/O iterator to use the pages in an xarray * @i: The iterator to initialise. @@ -1224,19 +867,6 @@ bool iov_iter_is_aligned(const struct iov_iter *i, unsigned addr_mask, if (iov_iter_is_bvec(i)) return iov_iter_aligned_bvec(i, addr_mask, len_mask); - if (iov_iter_is_pipe(i)) { - size_t size = i->count; - - if (size & len_mask) - return false; - if (size && i->last_offset > 0) { - if (i->last_offset & addr_mask) - return false; - } - - return true; - } - if (iov_iter_is_xarray(i)) { if (i->count & len_mask) return false; @@ -1307,14 +937,6 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) if (iov_iter_is_bvec(i)) return iov_iter_alignment_bvec(i); - if (iov_iter_is_pipe(i)) { - size_t size = i->count; - - if (size && i->last_offset > 0) - return size | i->last_offset; - return size; - } - if (iov_iter_is_xarray(i)) return (i->xarray_start + i->iov_offset) | i->count; @@ -1367,36 +989,6 @@ static int want_pages_array(struct page ***res, size_t size, return count; } -static ssize_t pipe_get_pages(struct iov_iter *i, - struct page ***pages, size_t maxsize, unsigned maxpages, - size_t *start) -{ - unsigned int npages, count, off, chunk; - struct page **p; - size_t left; - - if (!sanity(i)) - return -EFAULT; - - *start = off = pipe_npages(i, &npages); - if (!npages) - return -EFAULT; - count = want_pages_array(pages, maxsize, off, min(npages, maxpages)); - if (!count) - return -ENOMEM; - p = *pages; - for (npages = 0, left = maxsize ; npages < count; npages++, left -= chunk) { - struct page *page = append_pipe(i, left, &off); - if (!page) - break; - chunk = min_t(size_t, left, PAGE_SIZE - off); - get_page(*p++ = page); - } - if (!npages) - return -EFAULT; - return maxsize - left; -} - static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa, pgoff_t index, unsigned int nr_pages) { @@ -1547,8 +1139,6 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, } return maxsize; } - if (iov_iter_is_pipe(i)) - return pipe_get_pages(i, pages, maxsize, maxpages, start); if (iov_iter_is_xarray(i)) return iter_xarray_get_pages(i, pages, maxsize, maxpages, start); return -EFAULT; @@ -1638,9 +1228,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate, } sum = csum_shift(csstate->csum, csstate->off); - if (unlikely(iov_iter_is_pipe(i))) - bytes = csum_and_copy_to_pipe_iter(addr, bytes, i, &sum); - else iterate_and_advance(i, bytes, base, len, off, ({ + iterate_and_advance(i, bytes, base, len, off, ({ next = csum_and_copy_to_user(addr + off, base, len); sum = csum_block_add(sum, next, off); next ? 0 : len; @@ -1725,15 +1313,6 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages) return iov_npages(i, maxpages); if (iov_iter_is_bvec(i)) return bvec_npages(i, maxpages); - if (iov_iter_is_pipe(i)) { - int npages; - - if (!sanity(i)) - return 0; - - pipe_npages(i, &npages); - return min(npages, maxpages); - } if (iov_iter_is_xarray(i)) { unsigned offset = (i->xarray_start + i->iov_offset) % PAGE_SIZE; int npages = DIV_ROUND_UP(offset + i->count, PAGE_SIZE); @@ -1746,10 +1325,6 @@ EXPORT_SYMBOL(iov_iter_npages); const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) { *new = *old; - if (unlikely(iov_iter_is_pipe(new))) { - WARN_ON(1); - return NULL; - } if (iov_iter_is_bvec(new)) return new->bvec = kmemdup(new->bvec, new->nr_segs * sizeof(struct bio_vec), diff --git a/mm/filemap.c b/mm/filemap.c index 0fcb0b80c2e2..603b562d69b1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2687,8 +2687,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, if (unlikely(iocb->ki_pos >= i_size_read(inode))) break; - error = filemap_get_pages(iocb, iter->count, &fbatch, - iov_iter_is_pipe(iter)); + error = filemap_get_pages(iocb, iter->count, &fbatch, false); if (error < 0) break;