From patchwork Thu Jul 27 16:10:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13330339 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 60E13C0015E for ; Thu, 27 Jul 2023 16:10:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D621E6B0074; Thu, 27 Jul 2023 12:10:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D121E6B0075; Thu, 27 Jul 2023 12:10:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDA946B0078; Thu, 27 Jul 2023 12:10:31 -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 A64A96B0074 for ; Thu, 27 Jul 2023 12:10:31 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7FD921C926D for ; Thu, 27 Jul 2023 16:10:31 +0000 (UTC) X-FDA: 81057879462.13.B032BC3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 8DD73A0010 for ; Thu, 27 Jul 2023 16:10:28 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ZOxAp/Cq"; spf=pass (imf15.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=1690474228; 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=6riGtniLbVW/0RUbKJK18+ZXuUEMwjT27R+MDiLMQAI=; b=uw+GShRYBxf/SBoUo56naz8Ej2IMuAHN4KrznAzpr1UBb/jF5s5ZQ7zW15p94n9sat+xnb PCZfy52uzxle/Ro+c9fwoCjg95VzoUh7E938ek3/RAdy75EVSaNIkwtial0i1DpsBEnVSZ 7DfGwAVvKh4aN4He6a3rFMg8HxONGKs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690474228; a=rsa-sha256; cv=none; b=Js9PR/H1fbEi4dghl199rF5t0mvKGP72LaYTf0ie4gi8eFeVkUQCf8N0MS4BE4198C80Xg XanH7+OPEW5qen1CI1cRafjeu+PQG0zcdxwwTj36/pr9rFHrkwLN4Xr/ObK7H5zMi+Q0Nx +sgFzFDxyVhcZdEUHGfYI8QefjU6Yi8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ZOxAp/Cq"; spf=pass (imf15.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=1690474227; 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=6riGtniLbVW/0RUbKJK18+ZXuUEMwjT27R+MDiLMQAI=; b=ZOxAp/CqDyg8aN6mT/r3jqFdkPwIWlcN6XksL6GN0YnQrMN5iemQe6I9DdIyQtnr9zu6ML XxrNkipo6f6+aJAVW5NOrF/VvLXF1TF4hxuHiS0nmAOE4X6El1GqmVtdGywWPxsb0eqeJ5 Ai0lXV4Z8sia0JEO134hiD8OJSYq5TY= 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-498-nOoNmV6EMre8aO0nn0whDw-1; Thu, 27 Jul 2023 12:10:24 -0400 X-MC-Unique: nOoNmV6EMre8aO0nn0whDw-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 6BE30185A7A5; Thu, 27 Jul 2023 16:10:23 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC402C57964; Thu, 27 Jul 2023 16:10:21 +0000 (UTC) From: David Howells To: Hugh Dickins Cc: David Howells , Andrew Morton , Christoph Hellwig , Jens Axboe , Al Viro , John Hubbard , David Hildenbrand , Matthew Wilcox , Chuck Lever , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/2] shmem: Fix splice of a missing page Date: Thu, 27 Jul 2023 17:10:15 +0100 Message-ID: <20230727161016.169066-2-dhowells@redhat.com> In-Reply-To: <20230727161016.169066-1-dhowells@redhat.com> References: <20230727161016.169066-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Stat-Signature: qpiznd4hrsa1o4qs5989fjjsea4po7c9 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8DD73A0010 X-Rspam-User: X-HE-Tag: 1690474228-615448 X-HE-Meta: U2FsdGVkX19A/45q614TaJs5f4HptQCZZzAPO78PtQnsP2e0rL5MoCgdHCFlVFM6Kyr0SlQv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5y0871uXh+wlFfpgG4dXizy+s+f02nut3GFMUlaUoKIAPo3O3Trr7aK6U17G14/z3jyrlwZVKoTjz1kAQyKf1Nk9tQ3GDl76GdKOaMj8D7BBrJnZEFWi+cq5nnkud45yIQCSWmL+J2tgN+MjVbTvc32fExqk8Z90NpnyHq0gL2kB/v3Q6rrM8Z9UrBQLABaJzMJI+10gCRr5pEYsjN/xJTBfpefm/t/Ce2NtWzes20clmzR/HEdkoCNedHAPvEfkdGSTHgUB4DuVWR+a4He6ay9ZclZKnt86w4PZlxX3+enNU6uaDf3qr7Tlbv 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 shmem_splice_read() to splice only part of the partial page at the end of a splice and not all of it. This can be seen by splicing from a tmpfs file that's not a multiple of PAGE_SIZE in size. Without this fix, it splices extra data to round up to PAGE_SIZE. Fixes: bd194b187115 ("shmem: Implement splice-read") Signed-off-by: David Howells cc: Hugh Dickins cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Chuck Lever cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2f2e0e618072..0164cccdcd71 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2841,7 +2841,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, folio_put(folio); folio = NULL; } else { - n = splice_zeropage_into_pipe(pipe, *ppos, len); + n = splice_zeropage_into_pipe(pipe, *ppos, part); } if (!n) From patchwork Thu Jul 27 16:10:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13330340 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 D65A6C04A6A for ; Thu, 27 Jul 2023 16:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 559E86B007D; Thu, 27 Jul 2023 12:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD226B007B; Thu, 27 Jul 2023 12:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 375E56B007D; Thu, 27 Jul 2023 12:10: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 0E4A36B0078 for ; Thu, 27 Jul 2023 12:10:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A1B1E1410B8 for ; Thu, 27 Jul 2023 16:10:32 +0000 (UTC) X-FDA: 81057879504.25.FB258BE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 88A911C0002 for ; Thu, 27 Jul 2023 16:10:30 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WrgIRkUl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1690474230; 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=TLR8tINgbBniZykrMZZb+ehfHyamxexwgaHRKDrxZjA=; b=EhvJMTGP7bT9Vibmz0fUf8M2W1IRzP7B58oho9DoZcQFZvBVIuLH8qOXdpdJK4AuJ8sorq +QMZM0ysDOzdCr46DAj/LvDDwDyg4PpdJZB5ViIGNU1t29IY95D/iIllCnEF/BaV6Ttv6i YFlIzn1Op02lduybbJRwdbM4eN5SY4U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WrgIRkUl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.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=1690474230; a=rsa-sha256; cv=none; b=G793lS4Cl9m4+9yS2s78TWo0rzrEIDAE14gWjK0VXF1s/jWVxFpjbtcbzKLKzQOMrYyMjE vnbCqOKzVR75Cb5eeLMZ5os48N/sLOp2uz1C1htQ8ej8we06VP1eW2XVb3vyET1m8mifV2 v/rpRXSIuDmG2yYlUUYJKWCNCdfXIeE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690474229; 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=TLR8tINgbBniZykrMZZb+ehfHyamxexwgaHRKDrxZjA=; b=WrgIRkUlhEgIcVfBBnruNTC1Z4mDv7HC5bKYmPbQszKce7sh3MhMrrTuzNb0xwb7bPYUe+ HG4qDfuKmZ8etQJEaMu3JsJXFnaU642t8HXUk8gXEOXXlEc4CS1YRFfOijjpVgqEcEQOaj +ArkA/Y2+8JnNvCllvV31CfSljChDQo= 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-500-vm9257bXN52QLdEzJBO93A-1; Thu, 27 Jul 2023 12:10:26 -0400 X-MC-Unique: vm9257bXN52QLdEzJBO93A-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 9DF87858EED; Thu, 27 Jul 2023 16:10:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1000740D2839; Thu, 27 Jul 2023 16:10:23 +0000 (UTC) From: David Howells To: Hugh Dickins Cc: David Howells , Andrew Morton , Christoph Hellwig , Jens Axboe , Al Viro , John Hubbard , David Hildenbrand , Matthew Wilcox , Chuck Lever , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] shmem: Apply a couple of filemap_splice_read() fixes to shmem_splice_read() Date: Thu, 27 Jul 2023 17:10:16 +0100 Message-ID: <20230727161016.169066-3-dhowells@redhat.com> In-Reply-To: <20230727161016.169066-1-dhowells@redhat.com> References: <20230727161016.169066-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 88A911C0002 X-Stat-Signature: 3etmgqf8dg7wuycp98ydami4hjnwk67s X-HE-Tag: 1690474230-305356 X-HE-Meta: U2FsdGVkX1+Ryq4OQSYRHrMWw9eHVE0EnDjrQ2gSKA+RnBD4eZVGy6PyOnjL6Oi+KVnV37SGtkvevhBN2GAcMPsln33s4DpEvyPdXvnMWw4FT0GAKbWbmAICvTDBXR5lA37RHJv+S/2leb03acot1dFKZpBszxoYB2SkzNhytbOujAygZnvSCA/CuVFfP1jaZcbWCJ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vJObDbEWiDCjRiVTGEiuVmDNHOhQHrNxrGAi1exCYJMGMqd8BhJBc1UN3kWQvPjinAvFoQOQqOr7s4zw6OXQV2VT3uiBDRtN/garJU6utnxMTUE92t1Hcph9W7jgy6t2C6DRe/ykJP1WV6cLPG1KNzTinID8gQ+aGEJFjRCdq0SES6d9h23+PAtLjbYuvJVRPUiiKLwA+8vlZHgER1jGEGt1X4orpg4PaBqdUinNGNjHQczDtunw1STO5t7oCP+eQECnpPoi2SfOEvn69xZkA== 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 shmem_splice_read() to use the inode from in->f_mapping->host rather than file_inode(in) and to skip the splice if it starts after s_maxbytes, analogously with fixes to filemap_splice_read(). Fixes: bd194b187115 ("shmem: Implement splice-read") Signed-off-by: David Howells cc: Hugh Dickins cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Chuck Lever cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- mm/shmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 0164cccdcd71..8a16d4c7092b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2780,13 +2780,16 @@ 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 inode *inode = in->f_mapping->host; 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; + if (unlikely(*ppos >= inode->i_sb->s_maxbytes)) + return 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);