From patchwork Mon Jun 26 23:09:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13293593 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F72EB64D7 for ; Mon, 26 Jun 2023 23:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbjFZXJG (ORCPT ); Mon, 26 Jun 2023 19:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjFZXJG (ORCPT ); Mon, 26 Jun 2023 19:09:06 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A77FD1701; Mon, 26 Jun 2023 16:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687820942; bh=sub/f/fHhbhbOWVCyd50R46uZcOKsIBrfjQMG/W+FCw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HxqwL28g71pwu+IzMPEwCvy41NJdhiKG+zYcdx2zjgKQ91pOvlul3YCIP+DzvVLKG f6IEv3xbPmNa28JVA/k1ED8XGqkXTn0qniqHcv3n68NlNyYcV4BwDq1lBVdOEh/FIf 3bK5xwypKzuEqZ2REhkXsk1H3B0PYfqdQXB/M+4chFeS+ETdxatb1RXAnpN85AYBJi SEU0yauqTvLue95Rq252Ihl1kM7pT7uR3Q7zOFH/n0slXtIvHuXq3c1CPkyzYszmXM n0Efd7R1qXXshbGFMj1l4aJDkJW/joG6HztqM6DRXyTk4iPo2Ir12J/IQVsP1OCNKp Lh+dcGejjbOSw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id EA355CFE; Tue, 27 Jun 2023 01:09:01 +0200 (CEST) Date: Tue, 27 Jun 2023 01:09:00 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: Amir Goldstein Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Chung-Chiang Cheng Subject: [PATCH v2 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't. This affected userspace which used inotify, like coreutils tail -f. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Signed-off-by: Ahelenia Ziemiańska Reviewed-by: Amir Goldstein --- No changes since v1 (except in the message). fs/splice.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 3e06611d19ae..94fae24f9d54 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1154,7 +1154,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, if ((in->f_flags | out->f_flags) & O_NONBLOCK) flags |= SPLICE_F_NONBLOCK; - return splice_pipe_to_pipe(ipipe, opipe, len, flags); + ret = splice_pipe_to_pipe(ipipe, opipe, len, flags); + goto notify; } if (ipipe) { @@ -1182,15 +1183,12 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); - if (ret > 0) - fsnotify_modify(out); - if (!off_out) out->f_pos = offset; else *off_out = offset; - return ret; + goto notify; } if (opipe) { @@ -1209,18 +1207,23 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = splice_file_to_pipe(in, opipe, &offset, len, flags); - if (ret > 0) - fsnotify_access(in); - if (!off_in) in->f_pos = offset; else *off_in = offset; - return ret; + goto notify; } return -EINVAL; + +notify: + if (ret > 0) { + fsnotify_access(in); + fsnotify_modify(out); + } + + return ret; } static long __do_splice(struct file *in, loff_t __user *off_in, From patchwork Mon Jun 26 23:09:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13293594 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C5D9EB64D7 for ; Mon, 26 Jun 2023 23:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbjFZXJT (ORCPT ); Mon, 26 Jun 2023 19:09:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjFZXJO (ORCPT ); Mon, 26 Jun 2023 19:09:14 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F77E1701; Mon, 26 Jun 2023 16:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687820951; bh=+Yr5r5tG9lNpcgAHvStT9mCUIkD4YLaRJRy3M3c4Tqg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hxU83TaBoEaA02pAlqIgCfA16dHrOofbg/dUHxRm+2un6Yumd2364qaq5EXEWuAij 632S4cpDA3idsBq2OkWgVzcdLx0NLSFfFLqV4JLRbW4sRySMe0cxU9B+DABZJt+3Yi crgWARtpmWtnl0jjDkWNrTd3APkR8P4cuSRusIiLNDtMdjE2z2PlDEJLLtWcEjnIZS b1+17vzZ6LmLyx8prL6gS0LNg/Bouspz32sLX4IcYx+30+PwCXhOmVxKu063ltZFXo TcF12OEfXHCrHAO2sK3pdaXjrZOwHFewL4oQfa2GfPldDWwlcOraU0lJiTIjDQPNwe gWc8+LPpbST1A== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 70917EEE; Tue, 27 Jun 2023 01:09:11 +0200 (CEST) Date: Tue, 27 Jun 2023 01:09:10 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: Amir Goldstein Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Chung-Chiang Cheng Subject: [PATCH v2 2/3] splice: fsnotify_modify(fd) in vmsplice Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Same logic applies here: this can fill up the pipe and pollers that rely on getting IN_MODIFY notifications never wake up. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Signed-off-by: Ahelenia Ziemiańska --- fs/splice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index 94fae24f9d54..a18274209dc1 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1447,6 +1447,9 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov, else error = vmsplice_to_user(f.file, &iter, flags); + if (error > 0) + fsnotify_modify(f.file); + kfree(iov); out_fdput: fdput(f); From patchwork Mon Jun 26 23:09:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13293595 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A89EB64DC for ; Mon, 26 Jun 2023 23:09:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbjFZXJb (ORCPT ); Mon, 26 Jun 2023 19:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjFZXJ2 (ORCPT ); Mon, 26 Jun 2023 19:09:28 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D5BE173A; Mon, 26 Jun 2023 16:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687820960; bh=ahR55X1tMPjwCkeOkwkz+mlJGXSwvA70sfFtKUTZ6Ss=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aKRjZtezVd/LhdXkFG54SEwZN9ryQa8wFlxFxLBNvRD7v+XexIoRNNaWsxwWiD7KK SfwbA9gGZk/Wbd6xAEEM7d4ympWN90GKQOKfqcc7gQx1v1O0rD8m3ShhrlCO6w0GKt Lf331rDdyp1lrpT4cwdlSw/Ubf4bRQ2aUIUUtWNKetPOwUsVukkO5CzuuXxQy+BhlU qxDF3gIzlTk67ee5x01nR6CsDA9jHF0y2Jzd5fa7KIHTo4SVvZOP+Mx06mY+C5Z95p lH/WmXllzukRrcycICxqvzp4yqNy4iNX1UthdMYk4NEL5yL792W8QKb4uaHHsicrZl 3AS76GIikN2Pw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 591DF179A; Tue, 27 Jun 2023 01:09:20 +0200 (CEST) Date: Tue, 27 Jun 2023 01:09:19 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: Amir Goldstein Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Chung-Chiang Cheng Subject: [PATCH v2 3/3] splice: fsnotify_access(in), fsnotify_modify(out) on success in tee Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Same logic applies here: this can fill up the pipe, and pollers that rely on getting IN_MODIFY notifications never wake up. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Signed-off-by: Ahelenia Ziemiańska Reviewed-by: Amir Goldstein --- fs/splice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index a18274209dc1..3234aaa6e957 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1819,6 +1819,11 @@ long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags) } } + if (ret > 0) { + fsnotify_access(in); + fsnotify_modify(out); + } + return ret; }