From patchwork Mon May 22 13:49:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250586 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 6A3BEC77B73 for ; Mon, 22 May 2023 13:50:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2DD3280004; Mon, 22 May 2023 09:50:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB6D5280002; Mon, 22 May 2023 09:50:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7EB7280004; Mon, 22 May 2023 09:50:54 -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 BFED5280002 for ; Mon, 22 May 2023 09:50:54 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8EEC21A0327 for ; Mon, 22 May 2023 13:50:54 +0000 (UTC) X-FDA: 80818026828.05.AB1282F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id BD526100015 for ; Mon, 22 May 2023 13:50:52 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VklACMMH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1684763452; 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=OAfj5fBZSZu8a/UyjUmcAHzT3o8yzjmkKwDwGprM6r0=; b=MP4VwHG5Zhby6yZx/r59y06jSmpPDv+J0cxQeBwAiM9WR5IqLqXj+8evqhsloWUFba0Om2 WRKdcME85lLjyRX9GXVLgTX2Jp9LSEkegAYi/irIadyrYdYXiwUPg0lnAqI6X0zzBnevsm QdPCJeniFZ8SNhZZjboPHyva5iLOvVY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VklACMMH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1684763452; a=rsa-sha256; cv=none; b=H1a3pJYFXvguUG/KRkF9SP6nswZp5hxjWNT6Jln/SlM9qahMR0zb+AxooU7MmQ0FhFKkga ST9uiyWY/H5idLUyaj71hnw9dfApR4vfVB3zel/Ff+rf+v333cYhb9dDXA4cArThY1gGCi hPYxBfzSM7Ze/n0nRCYi4uElJ3xAue4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763452; 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=OAfj5fBZSZu8a/UyjUmcAHzT3o8yzjmkKwDwGprM6r0=; b=VklACMMH8QUbz5ndWOQFK65p+yWfpfru3ae58f9Jnf2QLrjTVwgP/SexBjxId+9pyricnA f6wo69ZNXyjCI828RcW6tPaZ0WQR15jCuFo2Sy4+JZ9fw9GlLvAqiGuJIIA5RnYxpYTGUa j6D7sonQWbG7uZ/DnXEOUDCveeacYFE= 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-315-ESFFS34sPvibgfGTGCbRAQ-1; Mon, 22 May 2023 09:50:49 -0400 X-MC-Unique: ESFFS34sPvibgfGTGCbRAQ-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 160012812947; Mon, 22 May 2023 13:50:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0BB8C1ED99; Mon, 22 May 2023 13:50:45 +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 v22 06/31] splice: Check for zero count in vfs_splice_read() Date: Mon, 22 May 2023 14:49:53 +0100 Message-Id: <20230522135018.2742245-7-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BD526100015 X-Stat-Signature: juafubn4snoretwsc563kqqoyyia1xqg X-HE-Tag: 1684763452-767482 X-HE-Meta: U2FsdGVkX19tQ6TFQmINuetGL96v1Jd6pZUW50oQo+n/awhlmVrVn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ydL9aSuNxaVbhpud0X0k3JL2ik19D5IZpL6acFlFnPQl+5wyWh0Nz3/60AQUNucyLLORrTVZM5k4O4wJxm4oFc50QyQk2I05IaYl6kQ4gNHpjkCaGnsMJlGN8eDS6+QnT756mM81ijMaMeFyvpRox9fP983eR2RANxHe2F3TREVmCDSEyTZG31Kf66HxaJ8/08l6VrtUGtB5HrkORndM+ionWYbSO760CEIJR2OdLNHpPas9fot4J72FiP3hRz3BsAFEIIV80TUfwfY= 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- 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);