From nobody Mon Jun 8 08:28:38 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B516142AA9 for ; Sun, 31 May 2026 01:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189343; cv=none; b=QVFqv7rxv66Yn41WJKrxvpf6mVyuah2VE6AdpOKNsyEbgnetX8/Nu7N4IM0nd4wLUelzcQV+h8rHH5iMak9VeOGDu+1lMdE+QA6FkPjlwEr6dcplclsxIUSiIOt+MapYEqVZ2PLNDcM4gTOFxr9viK+evz+DYvPSSUcbrkyIGNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189343; c=relaxed/simple; bh=vsb+QThfs2Jw6QSiFQtsk0PMTT4LF7TO2lj9pLcB1Gc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qp3vPB7kdsx8ewuoft7h5MAcIdNJRnM3KSOwBucAneoLvDhhQ9/j/M96v/rFwIDx3et9owYztHj9fC0nJVTMDXdNP4wq1SgK9PkzIcqvRFrQTXhLTZCMVOE2I3OsYnsOkUghCqzR5uh9bbI4XM6jO1+nObUYMTQAvvWXmSb3Nmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YAvMMyEJ; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YAvMMyEJ" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so68627925e9.0 for ; Sat, 30 May 2026 18:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780189340; x=1780794140; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BcbBqWTkzkDxwNMdgJ7xVJp7N/TN/+GdHi920u4savY=; b=YAvMMyEJ51N9vhC53xnEEhMm64qQqG1nVXXeYsDkF8PoTdCjhLyZnmzfCSYThtdoy1 xQsUDvOWfjZEmUxZMrd9oIqvRZNrBe6DS3VWZlDIMcgXjpn2cJcdJNnFBr/XqhB96PJU HBSmZ6TBf4E9VdaAhL/aQODtYVa6xsf9T38CbwVsI4S3+2yt0zjO8SndLk/jA/1OffH2 ZaVds/eSQ4VuDx11SuHsFijcAuRxyQ4YsPRgmLwekBU/X7ylJBNUFqTSL0pxA7dPhDq3 +oBnDHnZnJl5UV9B+7sXOzS0EcMnC8BefxAnlSrPj8VyAxLHQjRV3k3PD5oBoLo4cQgo GZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780189340; x=1780794140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BcbBqWTkzkDxwNMdgJ7xVJp7N/TN/+GdHi920u4savY=; b=NVqjIwCy3REFqkLpkk7kji2KEhysFuyNRBIswnlg2wksCQ0wYSgur43z6NX34PGvZ7 vMpVoUEq/8SHVjDeODQ3npSe2zHWqKpTZ/dopyAr1QkOp2nIIqhn0eLWsEYuNMrBydIH rAjV0gaXU1YUz+uhniUBNMMAt1SgqxphOerxGmmhtgetY07MowhLg2o36bSBc9ummghp CDNq9Ael2Bu4P373aBEf92WJK1nLMOQEMVTfE6MdxlbIouyBegDx2Hz9WsNMPVCewqqr rRIbO8MYd+4Ppg4EuhQ9aTmYaypL/Dj9cuvk8QVp0Aan80JOJ0hxKK2OrV7Pf+i+/cNK eADw== X-Gm-Message-State: AOJu0Yw02jOOaP3E3zyKTKg2ZnAverrbHRNAt0mJmWrmZI1YmsTkDmRZ iuArHcJzz8Ac1scrNCpieMqRwShOjnBMvtLN+dPZtLaqs8CqYhYjna1/ X-Gm-Gg: Acq92OGcy2SJRYAMXLHzPag7xW4bOLXqOw40BIfpms+mwzO2/1tEvqRvbu5zn91DQ+f op/jS7RGek/sQpUAcNlEWz8SWQnN58NwX81/xpJ29OicgRgiyFXkySL/okKrmlKAnkPzkjFwOf7 07vEfv9IYnrVl5O+POj9+WOstCKiVlEJbr1lJxKUqlEhrZj+UF3qvO9MqzLvycHGFWddYN6RLo7 g7uF9eAlihFXnW6nnXPvjt8uxlBssbImCJnxBkgfF8VHrOKUlViCXd5Gks7SlYHxbfonmPUnSGU 3Ra7BjyNc6s8b66sA9eGQ0+l3wvVjWIkTF8hxf1BqaFxs/8v9JvzVp4eLz/5QshH/m3Xd0dzV8Z 5yuyWIfiAyfH0xmr1M2ACP7IYYzUnXQvJZEd5qvKzZTH2JaMmsi2kY9vTQOIDKkWThj7EIvWmA+ dGPPKzmzRVbZ6Z703pQqO03p448vesRg== X-Received: by 2002:a05:600d:8648:20b0:490:9d5c:a3e0 with SMTP id 5b1f17b1804b1-490a29215ebmr71216825e9.9.1780189339981; Sat, 30 May 2026 18:02:19 -0700 (PDT) Received: from localhost ([212.73.77.104]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4909c103908sm45297445e9.22.2026.05.30.18.02.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2026 18:02:19 -0700 (PDT) From: Askar Safin To: linux-fsdevel@vger.kernel.org, Christian Brauner , Alexander Viro , Jan Kara Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, netdev@vger.kernel.org, Linus Torvalds , Matthew Wilcox , Jens Axboe , Christoph Hellwig , David Howells , Andrew Morton , David Hildenbrand , Pedro Falcato , Miklos Szeredi , patches@lists.linux.dev Subject: [PATCH 1/3] tee: fs/splice.c: remove unused parameter "flags" from "link_pipe" Date: Sun, 31 May 2026 01:01:05 +0000 Message-ID: <20260531010107.1953702-2-safinaskar@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260531010107.1953702-1-safinaskar@gmail.com> References: <20260531010107.1953702-1-safinaskar@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove unused parameter "flags" from "link_pipe". Signed-off-by: Askar Safin Tested-by: Willy Tarreau --- fs/splice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 9d8f63e2fd1a..59adbc2fa4d6 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1849,7 +1849,7 @@ static int splice_pipe_to_pipe(struct pipe_inode_info= *ipipe, */ static ssize_t link_pipe(struct pipe_inode_info *ipipe, struct pipe_inode_info *opipe, - size_t len, unsigned int flags) + size_t len) { struct pipe_buffer *ibuf, *obuf; unsigned int i_head, o_head; @@ -1962,7 +1962,7 @@ ssize_t do_tee(struct file *in, struct file *out, siz= e_t len, if (!ret) { ret =3D opipe_prep(opipe, flags); if (!ret) - ret =3D link_pipe(ipipe, opipe, len, flags); + ret =3D link_pipe(ipipe, opipe, len); } } =20 --=20 2.47.3 From nobody Mon Jun 8 08:28:38 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 942EB1509AB for ; Sun, 31 May 2026 01:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189366; cv=none; b=mwofpJ7iHTmz00PftnWd3XAjB9GvIp6w/Hvfff8CYBYRpYGewmbn9e0YnLxvPT/0nXD05F5+OT5cLBgOhMm2ofquN/sxCzswO7+ya6PdODhPnQKsp1sogq8Nvj9crepC588Cz+9EV+z3Yd1pGH30uPe5NfdnvnbHtkQOFW2Wpzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189366; c=relaxed/simple; bh=vUJD/5u6kCUr8KTYSWHaD9vjocEHmK/li6avZTPmLtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ogcBI4jEN1u07MlrHyp/gbitlpBUBqDyj20V/K8sJ0P+BwI1hTUaPqt9wQVBQOieMQUrkZvD3jWOmpuPUDbm1ZbCn/QXJUE2hzrEJ0+WFR/MxRu/j4sR3+hvC/bMeDSD5accq8S/HjGXeemO0RKh3KYBJJnDPnemFX8GM2lVOfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R+BLq0J2; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R+BLq0J2" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49039a8851fso92833535e9.2 for ; Sat, 30 May 2026 18:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780189363; x=1780794163; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rY9xqu8l7Va76QXZ+E4mFY8QOJNQ9i1JD1YVgseayQc=; b=R+BLq0J2w381bFRKFyzrU+hqNJJPVTY7d7VsekKBtYm2lA7bJQVZe3AMJE5yVJ9/it g50g4EL1SB1WnQCwPCqL87AoXk9JMoCEgo972LohIYWq60LxoyRwzJjr254rTvgyq+Xs PNxDwU6GjN0nm1jwAIr4s+IIFTW1zmDeJ9U/5yqC9KFx4IufSiPRpLmwbrKPgmULiNGf RjnVXDNGaHi3pNBD/2GW6RadBuI7zlRy1zn8XjbIqP6y2xrDYKiMms5F4+iBWXlMAjtW DtrP5KV2Oq9PPjiZX4wD0ViM1Z+usKZ+vFk0Nkjjk9jCqY14VKN47Vhb2U2cGARs62Fj 3CWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780189363; x=1780794163; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rY9xqu8l7Va76QXZ+E4mFY8QOJNQ9i1JD1YVgseayQc=; b=Y1H3B1qr8O84m6373wXk4PWYD3IyZwF5iMDHNWlpuP0JaxTrWJl5eSoRgCgT+TsoCK HgW6Rw9OoQP1jJknjh4sBn1aRebktfJeyOFYBEJZ1b/HhOw1jXj2RjwdWBr6nWwALQZL YgweZy62UkeMQlyxhgjaiBdyArlmNklX1DD2ylvxj04QoJc94tgZRMmcPlIZ29Z0XRK7 J7876y0hCMdpdQalyRPtXw/PUOrxyUkybF2gtsKvkVaLzwCDbyB4d6Mi/7t5unfb62D2 sDI208lgajykDGkQnQY1h5njVFqBxYjCcn56sTDVdU+zAuDPHoNNKbDuOF4+OKk3NqAd DxlQ== X-Gm-Message-State: AOJu0YzDYNujqHmlTiPaqVx7L/wS7lO6hcaj1t28hLiAo/6X5xblgE/L dO0iZEBEt1yTydovB/CTm6tooTFEl8iT/ZcSK6T5EzZb7Cj0UXYBg/SA X-Gm-Gg: Acq92OEOVbqXTlk9eFxIPPrSquMtIqlCEzFnjKQsMmKYZIcNae83jZ4c6fPl9z87TOu /O5wyaajGY9LziFpJeGv1Solw9AChS+EABkE1ZYmjZANhtcGa2jsOo9W4UjDt1A2WV2KTwKVU17 BkxQWYPpAOrU0emZOGwSeqtXzTUkTjR/kDCj60b+eJVVaf8fwjSeJbIjoK3fe41lozVAajUMv2a MhoGhJI/RCghD2h6jeL9cnFdZx7g5Y7IoElYRupUvpTYE/1EIs38GVibmsdYq6OlDqmdZ5u5sof ihH6coDihd+MeUNNQejt2cIAdN+WUGtqGO5IGJDw3zXHxe+jiWZetMxaeWnN7o/6JNu9z4NnXkU YgV07XgzbWQ5zTpCb/JlmpM22ZxifHhFqy455UoXts1eJbQEGj5LyMoxAKuMENygBxgsoV/eqv2 lYyM/t3j7/p/3eO4w7/DwbfNk74hb5cB3VzNpKUpfl X-Received: by 2002:a05:600d:844a:10b0:48a:5565:ec3d with SMTP id 5b1f17b1804b1-490a294935bmr71684235e9.22.1780189362730; Sat, 30 May 2026 18:02:42 -0700 (PDT) Received: from localhost ([212.73.77.104]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4909d68a925sm219356085e9.2.2026.05.30.18.02.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2026 18:02:42 -0700 (PDT) From: Askar Safin To: linux-fsdevel@vger.kernel.org, Christian Brauner , Alexander Viro , Jan Kara Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, netdev@vger.kernel.org, Linus Torvalds , Matthew Wilcox , Jens Axboe , Christoph Hellwig , David Howells , Andrew Morton , David Hildenbrand , Pedro Falcato , Miklos Szeredi , patches@lists.linux.dev Subject: [PATCH 2/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2 Date: Sun, 31 May 2026 01:01:06 +0000 Message-ID: <20260531010107.1953702-3-safinaskar@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260531010107.1953702-1-safinaskar@gmail.com> References: <20260531010107.1953702-1-safinaskar@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" vmsplice behavior on writable pipe became equivalent to pwritev2. vmsplice behavior on readable pipe already was nearly equivalent to preadv2, but I made this explicit. I. e. I made it obvious from code that vmsplice now is equivalent to preadv2/pwritev2. Also I moved vmsplice to fs/read_write.c, because now it arguably belongs there. Note that SPLICE_F_NONBLOCK behavior slightly changed: previously vmsplice ignored whether the pipe was opened with O_NONBLOCK, and mode of operation depended on whether SPLICE_F_NONBLOCK was passed only. Now the operation will be non-blocking if O_NONBLOCK was passed when opening *or* SPLICE_F_NONBLOCK was passed to vmsplice. Previous behavior was arguably buggy, and new behavior is arguably better. Now SPLICE_F_GIFT is always ignored by all 3 syscalls: splice, tee and vmsplice. Signed-off-by: Askar Safin Tested-by: Willy Tarreau --- fs/read_write.c | 23 +++++ fs/splice.c | 192 +-------------------------------------- include/linux/skbuff.h | 4 +- include/linux/splice.h | 2 +- include/linux/syscalls.h | 4 +- 5 files changed, 29 insertions(+), 196 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 50bff7edc91f..1e5444f4dab3 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1213,6 +1213,29 @@ SYSCALL_DEFINE6(pwritev2, unsigned long, fd, const s= truct iovec __user *, vec, return do_pwritev(fd, vec, vlen, pos, flags); } =20 +/* + * Legacy preadv2/pwritev2 wrapper. + */ +SYSCALL_DEFINE4(vmsplice, unsigned long, fd, const struct iovec __user *, = vec, + unsigned long, vlen, unsigned int, flags) +{ + if (unlikely(flags & ~SPLICE_F_ALL)) + return -EINVAL; + + CLASS(fd, f)(fd); + if (fd_empty(f)) + return -EBADF; + + /* We do do_writev/do_readv, so it is okay to pass "false" here */ + if (!get_pipe_info(fd_file(f), /* for_splice =3D */ false)) + return -EBADF; + + if (fd_file(f)->f_mode & FMODE_WRITE) + return do_writev(fd, vec, vlen, (flags & SPLICE_F_NONBLOCK) ? RWF_NOWAIT= : 0); + else + return do_readv(fd, vec, vlen, (flags & SPLICE_F_NONBLOCK) ? RWF_NOWAIT = : 0); +} + /* * Various compat syscalls. Note that they all pretend to take a native * iovec - import_iovec will properly treat those as compat_iovecs based on diff --git a/fs/splice.c b/fs/splice.c index 59adbc2fa4d6..b1a4e3713bd6 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -159,22 +159,6 @@ const struct pipe_buf_operations page_cache_pipe_buf_o= ps =3D { .get =3D generic_pipe_buf_get, }; =20 -static bool user_page_pipe_buf_try_steal(struct pipe_inode_info *pipe, - struct pipe_buffer *buf) -{ - if (!(buf->flags & PIPE_BUF_FLAG_GIFT)) - return false; - - buf->flags |=3D PIPE_BUF_FLAG_LRU; - return generic_pipe_buf_try_steal(pipe, buf); -} - -static const struct pipe_buf_operations user_page_pipe_buf_ops =3D { - .release =3D page_cache_pipe_buf_release, - .try_steal =3D user_page_pipe_buf_try_steal, - .get =3D generic_pipe_buf_get, -}; - static void wakeup_pipe_readers(struct pipe_inode_info *pipe) { smp_mb(); @@ -589,8 +573,7 @@ static void splice_from_pipe_end(struct pipe_inode_info= *pipe, struct splice_des * Description: * This function does little more than loop over the pipe and call * @actor to do the actual moving of a single struct pipe_buffer to - * the desired destination. See pipe_to_file, pipe_to_sendmsg, or - * pipe_to_user. + * the desired destination. See pipe_to_file or pipe_to_sendmsg. * */ ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_des= c *sd, @@ -1440,179 +1423,6 @@ static ssize_t __do_splice(struct file *in, loff_t = __user *off_in, return ret; } =20 -static ssize_t iter_to_pipe(struct iov_iter *from, - struct pipe_inode_info *pipe, - unsigned int flags) -{ - struct pipe_buffer buf =3D { - .ops =3D &user_page_pipe_buf_ops, - .flags =3D flags - }; - size_t total =3D 0; - ssize_t ret =3D 0; - - while (iov_iter_count(from)) { - struct page *pages[16]; - ssize_t left; - size_t start; - int i, n; - - left =3D iov_iter_get_pages2(from, pages, ~0UL, 16, &start); - if (left <=3D 0) { - ret =3D left; - break; - } - - n =3D DIV_ROUND_UP(left + start, PAGE_SIZE); - for (i =3D 0; i < n; i++) { - int size =3D umin(left, PAGE_SIZE - start); - - buf.page =3D pages[i]; - buf.offset =3D start; - buf.len =3D size; - ret =3D add_to_pipe(pipe, &buf); - if (unlikely(ret < 0)) { - iov_iter_revert(from, left); - // this one got dropped by add_to_pipe() - while (++i < n) - put_page(pages[i]); - goto out; - } - total +=3D ret; - left -=3D size; - start =3D 0; - } - } -out: - return total ? total : ret; -} - -static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *= buf, - struct splice_desc *sd) -{ - int n =3D copy_page_to_iter(buf->page, buf->offset, sd->len, sd->u.data); - return n =3D=3D sd->len ? n : -EFAULT; -} - -/* - * For lack of a better implementation, implement vmsplice() to userspace - * as a simple copy of the pipe's pages to the user iov. - */ -static ssize_t vmsplice_to_user(struct file *file, struct iov_iter *iter, - unsigned int flags) -{ - struct pipe_inode_info *pipe =3D get_pipe_info(file, true); - struct splice_desc sd =3D { - .total_len =3D iov_iter_count(iter), - .flags =3D flags, - .u.data =3D iter - }; - ssize_t ret =3D 0; - - if (!pipe) - return -EBADF; - - pipe_clear_nowait(file); - - if (sd.total_len) { - pipe_lock(pipe); - ret =3D __splice_from_pipe(pipe, &sd, pipe_to_user); - pipe_unlock(pipe); - } - - if (ret > 0) - fsnotify_access(file); - - return ret; -} - -/* - * vmsplice splices a user address range into a pipe. It can be thought of - * as splice-from-memory, where the regular splice is splice-from-file (or - * to file). In both cases the output is a pipe, naturally. - */ -static ssize_t vmsplice_to_pipe(struct file *file, struct iov_iter *iter, - unsigned int flags) -{ - struct pipe_inode_info *pipe; - ssize_t ret =3D 0; - unsigned buf_flag =3D 0; - - if (flags & SPLICE_F_GIFT) - buf_flag =3D PIPE_BUF_FLAG_GIFT; - - pipe =3D get_pipe_info(file, true); - if (!pipe) - return -EBADF; - - pipe_clear_nowait(file); - - pipe_lock(pipe); - ret =3D wait_for_space(pipe, flags); - if (!ret) - ret =3D iter_to_pipe(iter, pipe, buf_flag); - pipe_unlock(pipe); - if (ret > 0) { - wakeup_pipe_readers(pipe); - fsnotify_modify(file); - } - return ret; -} - -/* - * Note that vmsplice only really supports true splicing _from_ user memory - * to a pipe, not the other way around. Splicing from user memory is a sim= ple - * operation that can be supported without any funky alignment restrictions - * or nasty vm tricks. We simply map in the user memory and fill them into - * a pipe. The reverse isn't quite as easy, though. There are two possible - * solutions for that: - * - * - memcpy() the data internally, at which point we might as well just - * do a regular read() on the buffer anyway. - * - Lots of nasty vm tricks, that are neither fast nor flexible (it - * has restriction limitations on both ends of the pipe). - * - * Currently we punt and implement it as a normal copy, see pipe_to_user(). - * - */ -SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov, - unsigned long, nr_segs, unsigned int, flags) -{ - struct iovec iovstack[UIO_FASTIOV]; - struct iovec *iov =3D iovstack; - struct iov_iter iter; - ssize_t error; - int type; - - if (unlikely(flags & ~SPLICE_F_ALL)) - return -EINVAL; - - CLASS(fd, f)(fd); - if (fd_empty(f)) - return -EBADF; - if (fd_file(f)->f_mode & FMODE_WRITE) - type =3D ITER_SOURCE; - else if (fd_file(f)->f_mode & FMODE_READ) - type =3D ITER_DEST; - else - return -EBADF; - - error =3D import_iovec(type, uiov, nr_segs, - ARRAY_SIZE(iovstack), &iov, &iter); - if (error < 0) - return error; - - if (!iov_iter_count(&iter)) - error =3D 0; - else if (type =3D=3D ITER_SOURCE) - error =3D vmsplice_to_pipe(fd_file(f), &iter, flags); - else - error =3D vmsplice_to_user(fd_file(f), &iter, flags); - - kfree(iov); - return error; -} - SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 2bcf78a4de7b..2961fee3e5cc 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -505,7 +505,7 @@ enum { SKBFL_ZEROCOPY_ENABLE =3D BIT(0), =20 /* This indicates at least one fragment might be overwritten - * (as in vmsplice(), sendfile() ...) + * (as in sendfile(), ...) * If we need to compute a TX checksum, we'll need to copy * all frags to avoid possible bad checksum */ @@ -4017,7 +4017,7 @@ static inline int skb_linearize(struct sk_buff *skb) * @skb: buffer to test * * Return: true if the skb has at least one frag that might be modified - * by an external entity (as in vmsplice()/sendfile()) + * by an external entity (as in sendfile()) */ static inline bool skb_has_shared_frag(const struct sk_buff *skb) { diff --git a/include/linux/splice.h b/include/linux/splice.h index 9dec4861d09f..fb4f035aae83 100644 --- a/include/linux/splice.h +++ b/include/linux/splice.h @@ -19,7 +19,7 @@ /* we may still block on the fd we splice */ /* from/to, of course */ #define SPLICE_F_MORE (0x04) /* expect more data */ -#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ +#define SPLICE_F_GIFT (0x08) /* ignored */ =20 #define SPLICE_F_ALL (SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE= _F_GIFT) =20 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index f5639d5ac331..a86a88207956 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -514,8 +514,8 @@ asmlinkage long sys_ppoll_time32(struct pollfd __user *= , unsigned int, struct old_timespec32 __user *, const sigset_t __user *, size_t); asmlinkage long sys_signalfd4(int ufd, sigset_t __user *user_mask, size_t = sizemask, int flags); -asmlinkage long sys_vmsplice(int fd, const struct iovec __user *iov, - unsigned long nr_segs, unsigned int flags); +asmlinkage long sys_vmsplice(unsigned long fd, const struct iovec __user *= vec, + unsigned long vlen, unsigned int flags); asmlinkage long sys_splice(int fd_in, loff_t __user *off_in, int fd_out, loff_t __user *off_out, size_t len, unsigned int flags); --=20 2.47.3 From nobody Mon Jun 8 08:28:38 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD7AF1509AB for ; Sun, 31 May 2026 01:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189388; cv=none; b=vGfC98tvHBmugP5T2cWtLG/JVEgCooYqsDNl+C89P7R4YGz2SS/tZSPpo0OuqCMVZ6UWoFVYzYeIeihlVu21KrOGtTSHGFqy5YbCH6Xx5qpwdceM5jvFEHPAzSXS/Enfja4CqdQLygFvvXZdXB684a68wlY0lTkIq15nAVmZDVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780189388; c=relaxed/simple; bh=APiFWZXTnRfbG+HwF1DJ9n4FtfK50FyeJSRq8kImSmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vw1rLOboOHFCMxiQbSu65WmXwC14YAdLLF3MyQbqq4jbG69ZvEXV9mvOQ07QJKLZPvWuFvZLDg1j19B8DQGofKDXZMZp0etNUpRjXAdhg0fPAmdLupHb+OZ9jk6/G7lEY+x+q8vPm9w/je4tkqGrqOuJJbbPAHStG/XyI0vwzZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jCfvO7qB; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jCfvO7qB" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4906869f0cbso77859685e9.1 for ; Sat, 30 May 2026 18:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780189385; x=1780794185; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+xcR4llDLZ21dX5aGAHoZFyM5vQ6lE/uFW6fHX8pUaI=; b=jCfvO7qBVVXKTcOlfUa6tSZO8/gjbdh1BF6NE9G3o80DPXyDhMitwi1hSC20yG73Zr Di/I9DSUSzgUkdD/Xnhme2MNWHgw679ZK6z8dT+WEPR/B6Mxgfsnu20MZpLqQjLgDz20 lzbSB6VVmc/BvsDeK7tPSK90BaGVhabvFMQNyQtoWPVYdbeqUoU6o27XN/xwFNFEwywD dSshlovJ0vlIZaUjuAlnMnrkeUlMmj29U0pB/x3rI0wtn83yzuIWa/d8O8Vwt8IkYmq6 jSgQ4EJ+MK+Ie+hCNmf32BtZmbr3w+6rszUuUOCGPtkXRAhjEx+ggatc0Wwe6X+pu3x0 U3fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780189385; x=1780794185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+xcR4llDLZ21dX5aGAHoZFyM5vQ6lE/uFW6fHX8pUaI=; b=RGpCUdIBwR076PW212PeFOR4NoVTCQCuoaq4kNmqlifhkBFMKewI/pFOKlKShC5T1H ZDyVI2fsHMBxJS23EJq5QaGDbMADcF/a+8N3kthG/EgAXHr0RKOrwWF7XbXwb8bEFB6/ X4wbaxU224viagb4YMcR9jVSUrA9JzpCyreRE2rRCzOBVPKwcF/vl8kwhA+sV4Za0RfQ +4Rh2dZvqR2AgJtJwwobzm4JbiXCTHUtRjXVS5BoslG+LtlhH6enx1nAy/umZfPVXKCj r8es3sD62G273M980/6zxOyT/fcPae0NHcEPmxjkdfc7fatpry6zJQ2DFDSSRblXuW+4 CeNg== X-Gm-Message-State: AOJu0YyWTeX5ADx/ywBojvaBxA4TlQDijEhxMosci8kXY2YVHCXZuo6L lv6Xj9dseojzcxJ45dwblsI9qoltMLVLoVh/249bxRi19hD6sGMX5W/v X-Gm-Gg: Acq92OEXbBCIlGD7eM6IeG5pEwB0hZNlWEPGpiT9wSBgYaB0VzZDtO06ic8O5d5HOf5 N9t9AW2820Vvmz8kYEK6sLeLZGFu1O/RH7etHsFq101w9CP21Y0hCtFVvTe3wWXsbYGyIfFC8dB nMplz4WixLVJ9Ao3E8jvoQn90Kzz9vdMiFW6azqZ2KS3LKQ5Ov++uhtfo6as+RjjpbG0+xlwGQB k4BS8ouFcFyEBF2ycPw8UotroZ3PQUbqgQoLGNQbD+PdU05io1lw3SaS2LdneJdk0M7x2lSz0Nx nqV6Meb9LIBQiT8KerCYM9k/RzDOA3R3kbkRoDsivGfUYWJAGE4z+9Xx/xgIhlJOkEc0R2JySxv hdkdhsm/NgIZQpd8xmHezpsEs8XSzOyXQe1hBTKf5HZwjZAKDBpTftV9WTRlOysbhpL7/MeMfe+ 30hDyt8BLn1iWsNwPIL0V9z0Kte9yDqA== X-Received: by 2002:a05:600c:e489:20b0:490:467e:a3d7 with SMTP id 5b1f17b1804b1-490a2952798mr65855195e9.30.1780189385274; Sat, 30 May 2026 18:03:05 -0700 (PDT) Received: from localhost ([212.73.77.104]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4909ca6575csm218111405e9.4.2026.05.30.18.03.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2026 18:03:04 -0700 (PDT) From: Askar Safin To: linux-fsdevel@vger.kernel.org, Christian Brauner , Alexander Viro , Jan Kara Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, netdev@vger.kernel.org, Linus Torvalds , Matthew Wilcox , Jens Axboe , Christoph Hellwig , David Howells , Andrew Morton , David Hildenbrand , Pedro Falcato , Miklos Szeredi , patches@lists.linux.dev Subject: [PATCH 3/3] splice: remove PIPE_BUF_FLAG_GIFT Date: Sun, 31 May 2026 01:01:07 +0000 Message-ID: <20260531010107.1953702-4-safinaskar@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260531010107.1953702-1-safinaskar@gmail.com> References: <20260531010107.1953702-1-safinaskar@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It is unused now. Signed-off-by: Askar Safin Tested-by: Willy Tarreau --- fs/fuse/dev.c | 1 - fs/splice.c | 6 ++---- include/linux/pipe_fs_i.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 5dda7080f4a9..fb8fe0c96692 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2352,7 +2352,6 @@ static ssize_t fuse_dev_splice_write(struct pipe_inod= e_info *pipe, goto out_free; =20 *obuf =3D *ibuf; - obuf->flags &=3D ~PIPE_BUF_FLAG_GIFT; obuf->len =3D rem; ibuf->offset +=3D obuf->len; ibuf->len -=3D obuf->len; diff --git a/fs/splice.c b/fs/splice.c index b1a4e3713bd6..6ddf7dd72f7b 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1622,10 +1622,9 @@ static int splice_pipe_to_pipe(struct pipe_inode_inf= o *ipipe, *obuf =3D *ibuf; =20 /* - * Don't inherit the gift and merge flags, we need to + * Don't inherit the merge flag, we need to * prevent multiple steals of this page. */ - obuf->flags &=3D ~PIPE_BUF_FLAG_GIFT; obuf->flags &=3D ~PIPE_BUF_FLAG_CAN_MERGE; =20 obuf->len =3D len; @@ -1711,10 +1710,9 @@ static ssize_t link_pipe(struct pipe_inode_info *ipi= pe, *obuf =3D *ibuf; =20 /* - * Don't inherit the gift and merge flag, we need to prevent + * Don't inherit the merge flag, we need to prevent * multiple steals of this page. */ - obuf->flags &=3D ~PIPE_BUF_FLAG_GIFT; obuf->flags &=3D ~PIPE_BUF_FLAG_CAN_MERGE; =20 if (obuf->len > len) diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index 7f6a92ac9704..a1eeed800669 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -6,7 +6,6 @@ =20 #define PIPE_BUF_FLAG_LRU 0x01 /* page is on the LRU */ #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */ -#define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */ #define PIPE_BUF_FLAG_PACKET 0x08 /* read() as a packet */ #define PIPE_BUF_FLAG_CAN_MERGE 0x10 /* can merge buffers */ #define PIPE_BUF_FLAG_WHOLE 0x20 /* read() must return entire buffer or er= ror */ --=20 2.47.3