Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16853474rwd; Mon, 26 Jun 2023 16:31:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63fKMfLsyCHPQKPqRvCR/bEiqu1IUqskLhAzt65XkxAimxU1xqHINRXn7e2Q9rWmG4mkrb X-Received: by 2002:a17:907:2bc4:b0:98e:4ec0:da6a with SMTP id gv4-20020a1709072bc400b0098e4ec0da6amr4129672ejc.0.1687822261684; Mon, 26 Jun 2023 16:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687822261; cv=none; d=google.com; s=arc-20160816; b=RW/OI08jmW/ajsQsPkRxgADHF26ltF0WFUPVPM1DQzrN4paTI6jAEoDhYWdSWss2wp UUbuGCPBVpYAMPQ57uSwaV4FVR+gmMN+669D2BdnLzDt3h1fvihes1CVJnydklGyyzHs pZlT/OQwuXMFoOF0geIRa+zUkQlr355bFOlpcgz8p985LcrK10zOlTDdtLWmnRNJ38wD 7xaN/NAIrr4cRWhlw1NsbNqZI1dOgGQbs68W1lVhOJcvKoq7vGia+V/LAVmNeNZxTfKI RkJyELhoBeX0KCnMrR1Ma2p6C+m/jY+fLdwkS6f+9FuLFEmbM4TJoyU4uwL7MrqrnqK4 yi6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9+UnP4YU/hmPsP6DwYLo5zHvmgpSFBYW3L690x3d9SI=; fh=IHFQlbVsC+DUr5Z3Sb1CE3j8cu6SvNBPXxR31tL4TGQ=; b=sv0HpE+M3qub9aJaexmbFfNjiNy0kZsq+Q9FvdSnBrxCUMe18/Nno9dJOfxIi2kueg P9gcjUfFb8IYVwUz/FLBzZ0wU0L3JdC3c/07yF2g7Nm4qtCiiN55ZYwkZUsyJU3RO7rJ Vuxed97sZfMiS/TCFmfz/8cRqoUDZsUgaBlWpuMhUzeRQllneyUO/L9/RDKTHFdFEtVH XhBhEa1a9ucvDeeUcQT4mhxhC6lc1LyDPUxFKwKCE7r3eOY3TfwGZdxtxdsfeTVGVU4P SCJkMFi2cWAopwCL/ArD3nt42TRsRtZugAcAGSopOiGLOltswCBDvIJT8An67v2iuR8V cbBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=HxqwL28g; 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=NONE dis=NONE) header.from=nabijaczleweli.xyz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a170906340700b0098e05d1a61csi2800756ejb.99.2023.06.26.16.30.34; Mon, 26 Jun 2023 16:31:01 -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=@nabijaczleweli.xyz header.s=202305 header.b=HxqwL28g; 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=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbjFZXJH (ORCPT + 99 others); Mon, 26 Jun 2023 19:09:07 -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-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gryd5vox5utp35lw" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 --gryd5vox5utp35lw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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/jbyihkyk5dtaohdwjyivambb2gffyjs= 3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Signed-off-by: Ahelenia Ziemia=C5=84ska 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, struc= t file *out, if ((in->f_flags | out->f_flags) & O_NONBLOCK) flags |=3D SPLICE_F_NONBLOCK; =20 - return splice_pipe_to_pipe(ipipe, opipe, len, flags); + ret =3D splice_pipe_to_pipe(ipipe, opipe, len, flags); + goto notify; } =20 if (ipipe) { @@ -1182,15 +1183,12 @@ long do_splice(struct file *in, loff_t *off_in, str= uct file *out, ret =3D do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); =20 - if (ret > 0) - fsnotify_modify(out); - if (!off_out) out->f_pos =3D offset; else *off_out =3D offset; =20 - return ret; + goto notify; } =20 if (opipe) { @@ -1209,18 +1207,23 @@ long do_splice(struct file *in, loff_t *off_in, str= uct file *out, =20 ret =3D splice_file_to_pipe(in, opipe, &offset, len, flags); =20 - if (ret > 0) - fsnotify_access(in); - if (!off_in) in->f_pos =3D offset; else *off_in =3D offset; =20 - return ret; + goto notify; } =20 return -EINVAL; + +notify: + if (ret > 0) { + fsnotify_access(in); + fsnotify_modify(out); + } + + return ret; } =20 static long __do_splice(struct file *in, loff_t __user *off_in, --=20 2.39.2 --gryd5vox5utp35lw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmSaGowACgkQvP0LAY0m WPEDSw//ayNYath/dKwG3xqHQEgbQxT/PNnP5LsdRIbTatY1FVLYDWKyI9/6IkGm VYDDQQwBlq4GpCY+jjK8fO+NhoscJB1FtTFcMfGbttzF6b4Nzu4cjYnacgYjGS6B ofEB2uIc7rv0ilUz9Cst+0VsA5EBR0r9geFxGei2lVYLi1UCi3jyN33wtQ0z5c3O b9KjSjuJjbtP3tkxsGa74icXNS3TNUOPtikVxqrWbf+UBAkN1KHom65P2GIqixjS Fi1ic9W+K4koz5Tr7qBCSUZdwVdH2Bnkis4L8725yMfxitjX+VomqnF6ifFClKeu 8wT/iW9P+Gr7Rn4g7DN/0U2BGgvcakStGA3Gtsm9uHy6sj58yAVNEeX62r+IXU9a j/OxUbYzzSwEMY23YFYW0QtmzR5q+TjmJVKVQtJcCOaflqz/OlfceyR2ss78UNQs Yefl9U7FM3LVQoS78fvM4WiFNqlGwDjEeo9FdUJUjf9D4hwQcWqXOjEfXgK4LLdg StKJfk9mOGNofI1sYgBMOZL7lnF9x7ILCdNFGRnemmkilOoWjXmPFmw9n+Dkpc4b SHD8pdFoXCExujyeaxDm4NLZS6cmYUV9w3/l2g48t86Lxe7BpX53Eu4nf03opVF6 nN26aORRZ/Lb/OF1BUIot9VAszPtFBus78vaMxvAd240N6Uym0o= =12tM -----END PGP SIGNATURE----- --gryd5vox5utp35lw--