Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18079787rwd; Tue, 27 Jun 2023 11:16:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Old0wwkAW4q7rsxCg7h2mFwYwKoL4eQHlsDEe01s+i62go1i2BCq3dk50xI54ay7XroBu X-Received: by 2002:a17:902:e883:b0:1b5:5fd2:4d6e with SMTP id w3-20020a170902e88300b001b55fd24d6emr12760054plg.58.1687889817114; Tue, 27 Jun 2023 11:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687889817; cv=none; d=google.com; s=arc-20160816; b=VBorlogbZ7FQ0fWGQ4nOhvNhE+tujKNiunmyT78oTWvn9qLzklCMDN2QsoIQXcLLB4 OuWC2NxPEU9ys16TXwCgcM0oI+HWg/LOKILWZP+0SCT7yLTRJnra9BzQSlzEktrOvBTN 38iLDh90F0NQrY0U1JJjpEePNZcEKNJoO7y4kdDRWzFAKxrQoQEfKEF9RLkHiK/5nO1k bMWA5DejGlv0s0i7QINW52ReW225Hz3fH5TqmBNig6WyKKKk+M9DSR6K2CsfCB1Cg3Yb C135KEAIFtYqSqr4i0kS9yFSPrGoeWgzHj5zCfqM1Mu6Ew4q7jD3yKEissHdYvG1QKn9 hXlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BxAO7TkpAopVR9RFBa3ieNMWyhRAiu+znyikTlS1Z8c=; fh=tqRbcSzGBk4lpV/pfyPeX4jugtdYu/Oaz8s71R5Kofg=; b=fx6E6Ua7w7BAYmOeH+npDgT4GOqLW1U59i9uaxIY0PxD76EPBfJqsuLVK0sLFLK6JN /qyljIUEe6pUt8/TAE5xy1WPlsEu47+nJtuowsSZbMbbf2SFsu4e1maIi0Nk8f2tr1oG WIsCqeCEX3YxItofGqjpxuYob+EhYUYYCpfero/TIpg2kJKJh+3BWvy+2YWcu1SqTiOj FzObAN5DgQ8MCXKZ0dgNM/NjbwnrHPiVR+NrofyuYfj6/BUOjOqIetNTv790FMUvwXiL JEyUgrLAe89DkdaM1n2WFKjo4/2vRxVBSmlNT8wGIMeQTDtcjXaQzNOrNpSH14JUeivd lZQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=S9BFeKqM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jh1-20020a170903328100b001b3c97a1ea1si7034628plb.162.2023.06.27.11.16.39; Tue, 27 Jun 2023 11:16:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=S9BFeKqM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjF0SK3 (ORCPT + 99 others); Tue, 27 Jun 2023 14:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjF0SK2 (ORCPT ); Tue, 27 Jun 2023 14:10:28 -0400 Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C42D2976; Tue, 27 Jun 2023 11:10:23 -0700 (PDT) Received: by mail-ua1-x92f.google.com with SMTP id a1e0cc1a2514c-783eef15004so1249161241.3; Tue, 27 Jun 2023 11:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687889421; x=1690481421; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BxAO7TkpAopVR9RFBa3ieNMWyhRAiu+znyikTlS1Z8c=; b=S9BFeKqM99KjDoFbnkBHX7/8AHDKJT+eQUCHhBmo31QVx/NLnXo0dWbYVh+wmbA6du NDcGrFkPjA3FHlr4BaU79GX3HeApMPCTZU8A3WofOsB0tlLsG3ogtMVEsgnh6hV7KKSv aXfxUKSTl2imkTZdrS1aDFIsyjs+hyjpUOAvKf1IluqvFAhw99Yvxhd3UDThpu4IKceY N6K438qlgtuQA4AxmOawC6UvSW/gntAHYeq4YrZ6QBtRpP7UmqKXyg2zgYH2lgy4LTWl AqqCUPoFdzGKIuWGt9tYq/cTBX5+SSsFTo9cvgWRxmbwhwyaQ5wsARdDKB2NN7qhu2I4 5SaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687889421; x=1690481421; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BxAO7TkpAopVR9RFBa3ieNMWyhRAiu+znyikTlS1Z8c=; b=VgEz8TXsLD/b+ibNMMgNHrhKI2yIwL3kNhR3ixMPHHQ+gFonsPvF3ktyRrjgsvtJkX CUvWOgGnpZ+7aFY53JacJWrUPzRvsYqdKDRrsmvapAPc8Bjgit7GnRNHjg3mqN1f8Uld BFPfcvAV7TEnlVlfR/RQhKTnK18APeM504Cql8JCuzyC+RPjsKGWehpfKA0c2wIkHiRP phKMR1NTmH/3IUT8WSY0j4lEwmFiZEeCKEtyZHdNQXlDONCpJYzKz2Zx53zVMZK9waYG I6XU9mmI94Rg71UO0QaHN7YVxdqBEP+k/LGB/KdhMMhGKUMRhCkGcwU/ZOJWuNALPdwu T7ew== X-Gm-Message-State: AC+VfDwR+tGx5kC28puG0BDDNBI8CmVN0PTh6N/nse43OlxpYBf4TLlZ k5OjYsZfxiaeMyORS+sD/NxPyJwARhL+/P1loz8= X-Received: by 2002:a67:ff89:0:b0:440:d2dc:fbdf with SMTP id v9-20020a67ff89000000b00440d2dcfbdfmr7661864vsq.9.1687889421090; Tue, 27 Jun 2023 11:10:21 -0700 (PDT) MIME-Version: 1.0 References: <8827a512f0974b9f261887d344c3b1ffde7b21e5.1687884031.git.nabijaczleweli@nabijaczleweli.xyz> In-Reply-To: <8827a512f0974b9f261887d344c3b1ffde7b21e5.1687884031.git.nabijaczleweli@nabijaczleweli.xyz> From: Amir Goldstein Date: Tue, 27 Jun 2023 21:10:09 +0300 Message-ID: Subject: Re: [PATCH v3 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success To: =?UTF-8?Q?Ahelenia_Ziemia=C5=84ska?= Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Chung-Chiang Cheng , ltp@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 27, 2023 at 7:55=E2=80=AFPM Ahelenia Ziemia=C5=84ska wrote: > > 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 uses inotify, most notably coreutils > tail -f, to monitor pipes. > If the pipe buffer had been filled by a splice-family function: > * tail wouldn't know and thus wouldn't service the pipe, and > * all writes to the pipe would block because it's full, > thus service was denied. > (For the particular case of tail -f this could be worked around > with ---disable-inotify.) > > Fixes: 983652c69199 ("splice: report related fsnotify events") > Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffy= js3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u > Link: https://bugs.debian.org/1039488 > Signed-off-by: Ahelenia Ziemia=C5=84ska > Reviewed-by: Amir Goldstein > --- > fs/splice.c | 31 ++++++++++++++----------------- > 1 file changed, 14 insertions(+), 17 deletions(-) > > diff --git a/fs/splice.c b/fs/splice.c > index 3e06611d19ae..e16f4f032d2f 100644 > --- a/fs/splice.c > +++ b/fs/splice.c > @@ -1154,10 +1154,8 @@ long do_splice(struct file *in, loff_t *off_in, st= ruct file *out, > if ((in->f_flags | out->f_flags) & O_NONBLOCK) > flags |=3D SPLICE_F_NONBLOCK; > > - return splice_pipe_to_pipe(ipipe, opipe, len, flags); > - } > - > - if (ipipe) { > + ret =3D splice_pipe_to_pipe(ipipe, opipe, len, flags); > + } else if (ipipe) { > if (off_in) > return -ESPIPE; > if (off_out) { > @@ -1182,18 +1180,15 @@ long do_splice(struct file *in, loff_t *off_in, s= truct file *out, > ret =3D do_splice_from(ipipe, out, &offset, len, flags); > file_end_write(out); > > - if (ret > 0) > - fsnotify_modify(out); > - > if (!off_out) > out->f_pos =3D offset; > else > *off_out =3D offset; > > - return ret; > - } > - > - if (opipe) { > + // splice_write-> already marked out > + // as modified via vfs_iter_write() > + goto noaccessout; > + } else if (opipe) { > if (off_out) > return -ESPIPE; > if (off_in) { > @@ -1209,18 +1204,20 @@ long do_splice(struct file *in, loff_t *off_in, s= truct file *out, > > ret =3D splice_file_to_pipe(in, opipe, &offset, len, flag= s); > > - if (ret > 0) > - fsnotify_access(in); > - > if (!off_in) > in->f_pos =3D offset; > else > *off_in =3D offset; > + } else > + return -EINVAL; > > - return ret; > - } > + if (ret > 0) > + fsnotify_modify(out); > +noaccessout: > + if (ret > 0) > + fsnotify_access(in); > As I wrote, I don't like this special case. I prefer that we generate double IN_MODIFY than having to maintain unreadable code. Let's see what Jan has to say about this. Thanks, Amir.