Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16293974rwd; Mon, 26 Jun 2023 08:09:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6D/Wl2U08Ld4B5NEVj4ZkSeYhmS6bbENsbbsNJTcmTMrWKulKbUzJAV2/5ap97SvxH+JKa X-Received: by 2002:a17:902:f681:b0:1ac:8be5:8787 with SMTP id l1-20020a170902f68100b001ac8be58787mr4317306plg.21.1687792197832; Mon, 26 Jun 2023 08:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687792197; cv=none; d=google.com; s=arc-20160816; b=DEjRelyEYb6eTzDFc0WKK/NkazwWh2G/wFhVGq/9etKtCICJ4hNpzmwAz4RSqpH/5R GEkyDOVHxgUxPmok5CeiTM3sxnZWmY9YTkMY0dvcNijFZmJNRqUwkGJbKR2aom6Io9zQ 4C7YuQ0dwDU+Ft/7ZBYtzAVuqeiWUUZbIYdXRCD8ljW5K6ytfRYOMfih6WQ4oM3e4jh5 KXko/3NOp1LoWG2n2HJ0QzZH6rxH4xwVEN9CcNDZhxtQvqXtprgIbnV42eRMHqx95ARM GIO98RPQkwbelXBkcgdt4CS1PhVCpoIjLsvGSDqQFMOtTQeuTWoWrsX0Ab+iEy12crIh Bggg== 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=upTc9SE8YksMihaSznGHdckB/sO/co9zyMoJyyjNds8=; fh=Tno23T7vtYGL4G/7fCj+ADjttrVfkC4DNwl/8HUB31M=; b=vYJnuB44ZsoAtPKkhFUAKKJg3gEcEVpi05Hp/19tU/W3m1NyNDt0pLQY8szjVPevfG A84gSQaL03DIZFtXiqi7l8g2RkCdp2KbBErG4hDRocfhT7tZdIDzTyYsSthuYbgSAhMT XPWOOmiXgoX1pjUJgsy9CpPV+VcVaIrYd1NgCffVFO/x7U5N6U9AfiyvBC9SHLM24BmK Q1gtjO4AsZzm7XBkamETd6cdsg9NbGGJnFKVSYYEbt5yxVb2QO2t7eV1wFQoPIsgi18z q8T0HY/tXsrItmV20c2HMUktIvQ02AnsprDOl7Ay+G4RuQhvki9SFXixOp84gyqftXP5 1IQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=MK7aSg0D; 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 d17-20020a170902ced100b001ab0d2ca17asi5422186plg.457.2023.06.26.08.09.31; Mon, 26 Jun 2023 08:09: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=@nabijaczleweli.xyz header.s=202305 header.b=MK7aSg0D; 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 S229868AbjFZO0G (ORCPT + 99 others); Mon, 26 Jun 2023 10:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232222AbjFZOZt (ORCPT ); Mon, 26 Jun 2023 10:25:49 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EF9210CB; Mon, 26 Jun 2023 07:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687789543; bh=i6O4ngsx2ktTmVzWSuII1juMQqfsoJmZ03DNRqux+Dw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MK7aSg0DOhBqnDMATrhx4LnQAfYiuRIkAXaws+JXSRgVjDPXkWg9UM85/Xv5HA4c3 oErRkO9aBJGmPlaA6NmKeC8DuxWkWRat8RhrahhzlSnb2Dc4KCaieS9zx8luPkXd03 JCsuRsWSEo7UpqDnFdI4Fw8QFmLyHuwbSeK/l3TsN8HcoNgYhRG5Y0WfKxwCy8v2wh 1jdl1O31BnoLXQff66g/27GL4qkPlresA/8V5fNFBNRlgX2G2xyCrgKobz7rEzkPva zi+ddqXiKew0Zz6t5q3EkTS6sXuS+PXI8vvT4JrqCO4cSGOqpPRnQ4cHmlD929StSE 2yssrBVLjKBng== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 0CADC180C; Mon, 26 Jun 2023 16:25:43 +0200 (CEST) Date: Mon, 26 Jun 2023 16:25:41 +0200 From: Ahelenia =?utf-8?Q?Ziemia=C5=84ska?= To: Jan Kara Cc: Amir Goldstein , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: splice(-> FIFO) never wakes up inotify IN_MODIFY? Message-ID: References: <20230626135159.wzbtjgo6qryfet4e@quack3> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4vndfkeg7aishp6c" Content-Disposition: inline In-Reply-To: <20230626135159.wzbtjgo6qryfet4e@quack3> 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 --4vndfkeg7aishp6c Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 26, 2023 at 03:51:59PM +0200, Jan Kara wrote: > On Mon 26-06-23 14:57:55, Ahelenia Ziemia=C5=84ska wrote: > > On Mon, Jun 26, 2023 at 02:19:42PM +0200, Ahelenia Ziemia=C5=84ska wrot= e: > > > > splice(2) differentiates three different cases: > > > > if (ipipe && opipe) { > > > > ... > > > > if (ipipe) { > > > > ... > > > > if (opipe) { > > > > ... > > > >=20 > > > > IN_ACCESS will only be generated for non-pipe input > > > > IN_MODIFY will only be generated for non-pipe output > > > > > > > > Similarly FAN_ACCESS_PERM fanotify permission events > > > > will only be generated for non-pipe input. > > Sorry, I must've misunderstood this as "splicing to a pipe generates > > *ACCESS". Testing reveals this is not the case. So is it really true > > that the only way to poll a pipe is a sleep()/read(O_NONBLOCK) loop? > So why doesn't poll(3) work? AFAIK it should... poll returns instantly with revents=3DPOLLHUP for pipes that were closed by the last writer. Thus, you're either in a hot loop or you have to explicitly detect this and fall back to sleeping, which defeats the point of polling: -- >8 -- #define _GNU_SOURCE #include #include #include #include #include int main() { char buf[64 * 1024]; struct pollfd pf =3D {.fd =3D 0, .events =3D POLLIN}; size_t consec =3D 0; for (ssize_t rd;;) { while (poll(&pf, 1, -1) <=3D 0) ; if (pf.revents & POLLIN) { while ((rd =3D read(0, buf, sizeof(buf))) =3D=3D -1 && errno =3D=3D E= INTR) ; fprintf(stderr, "\nrd=3D%zd: %m\n", rd); } if (pf.revents & POLLHUP) { if (!consec++) fprintf(stderr, "\n\tPOLLHUPs"); fprintf(stderr, "\r%zu", consec); } else consec =3D 0; } } -- >8 -- And -- >8 -- $ ./rdr < fifo rd=3D12: Success 1779532 POLLHUPs rd=3D5: Success 945087 POLLHUPs rd=3D12: Success ^C -- >8 -- corresponding to -- >8 -- $ cat > fifo abc def ghi ^D $ echo zupa > fifo $ cat > fifo as dsaa asd ^C -- >8 -- --4vndfkeg7aishp6c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmSZn+MACgkQvP0LAY0m WPEtvhAAnoc8iGU5tbBviUj4eAspCbymYYCzvQtpQBWBCevNmprEWYcATNj2tetx 9o1uTLxYRHFil8uIcUnq0/zzwbGNmmVZpZn4WzBszM6rBC81PgtucxzSZ/gdOZia J9WTog/1ZL4ecsVc4tMmm7D++qDYPg5ndm+JCQpp6z9fwxd8l6mwOvdOEO5KTl3h 7YUKtii0OxxrjiNNdT6rIP/yF65Z38wmKO8A5Ab1mjuIfDQ/EhVPeFS9C62+J41H AphKzxg31+1kNyFSYv2oeYMTVLAXuVuGMV6Qq+OYpixkOpanW3RFjYcHd5oIQ/DO 0VUM36xMMh5zXZmuN4cNWX5yJD9cP4XLH36jlt4pOJsoCb8pQBc4DcfFeO83ef4R L6betbH6LnKhycjO5Wfv2forBf5OHtOlripTyM3HCivpfFTOQXBXVTapCbD3huNj kqIQoM23AG7VOJWcf15HsRe/v0VCbOaz/4EY1+keJSqxdlqZvgDAZ3coKOOSvp6i 8yReURg28bDo8jLKRTSJMvbY+K1RqSVFc/e84xgKthPr5zCdTd1sLpfWcrcKjAdf ClOT87YPeXzyWO413vsy37j1bcj8R6CVP1r+frfyujL7ahKDFNxDJfbKnzOJyEH2 9vaOoMe2FX4rFFVqoFp4O2AEwgf8RvJl1RfvgRqTQJhlyXuTPlk= =sIzT -----END PGP SIGNATURE----- --4vndfkeg7aishp6c--