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+RnBD4eZVGy6PyOnjL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g0BLk5XxKZUm9tqvch84HRMlKT9Hc0MQxXX4+Y70Jon+ftpYbWyivI+4QHDNQNJ7IzLuVlF6Q/6cq+HZvm8Y5oDgSAUIFxK98GhFeriOmA1gut9ZsOOA+T3Q12FTgxvJObDbEWiDCjRiVTGEiuVmDNHOhQHrNxrGAi1exCYJMGMqd8BhJBc1UN3kWQvPjinAvFoQOQqOr7s4zw6OXQV2VT3uiBDRtN/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);