Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp377200pxu; Fri, 11 Dec 2020 04:38:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM+dSn+I4Y+baeCk5dXmHsjRg+3ZN52BYl6ZFw9OdcVKfyFAHJJq1vh0qciGQX31cZB636 X-Received: by 2002:aa7:df91:: with SMTP id b17mr11848794edy.272.1607690332630; Fri, 11 Dec 2020 04:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607690332; cv=none; d=google.com; s=arc-20160816; b=UvP0YQfnXUfNLFUywIFf6u6RbautRO9IcfmEBzSEbHiGkLW8dQFozkFhqUirwKFrqf D7kVQsIDq1AlfB7+5muPZDf7Oz6gaoRW17hs1+2HxH75a3kQkeQMn9AL7rXAL5e8gM0d mRdR/PAfLI5Wh+h3Qez46c+BKf7d0gNwevNYSAOt5xa/77BapNAUw6eIZ9MD6lVchoQZ 6ouFmiJWiQXGj4fs1xZakUeb4xG3UgB+NnffV1sZv5tOy5qdhn1kjZLRnxxyLrCd+VNp +T6qMdOHwJOZw4RRtBbyUUX+g1vq5Np0VvjH6M6ayudz5taYESSva/w84RsJD7KUbBOr MWhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Rj1vcfLqePUUlfq7nqOeH8Fm78abBXaKWQgBWRoed4A=; b=Awc97POihKrORhp2Oh4bW8WNjosFSAYxlvOO1fLDzFg8KCNmNpZfXfRDlAp2Zm8U0X 8SF9afdz8uEKq1UL4dlwOFW+QD4F9cftowUiszz10Fonu69DJP6pvqheumKKAMrWyjMR mj4x2p565Cc+q8FO95d9juicUXim1zK/WQVvKCvyS/4JYzfQkNeU/5v4i4lJk5UPSEl1 E9XMBH2CsixtH0fmmST5kUOnYqLcFO5W6Pnai1j9oza/+c75BP30rluyLAwB7adXEptw NKX7mnOqkl4aCtH5YrADLPRIueDHLkjTzPNpTYUHb6OGZQD14ScT7NXsq2enwbRs4ew+ SnXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dl7l0wi5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si4548866edw.300.2020.12.11.04.38.29; Fri, 11 Dec 2020 04:38:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dl7l0wi5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2392502AbgLKIoE (ORCPT + 99 others); Fri, 11 Dec 2020 03:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390924AbgLKInI (ORCPT ); Fri, 11 Dec 2020 03:43:08 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 451C9C0613CF; Fri, 11 Dec 2020 00:42:28 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id n4so8676572iow.12; Fri, 11 Dec 2020 00:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Rj1vcfLqePUUlfq7nqOeH8Fm78abBXaKWQgBWRoed4A=; b=dl7l0wi5jZN6XN7c6BYUXRKxvPj9p3GLxvbbZ2NMLxZYHf74FV7iUH72JnoFuugKv7 r+j4eW81uTT36YVTgbawKBSSdgIIZOoCYc5h4KnLJIg1cBtqCR1QYVm60D4cCl26oURr 8AoT9wYTy3YutSRlHGHBcE+bjh5VrQlBU5i/RUygv0DqxTm20HPZ+kseOfcaowuYWLVj 2oA1BbrBziMh15/eQ54OWxSR135CxJC41UrTHPihzuKnwdRmr1zjBcfepE+vIVz0fo0E uD3nTp3WHPKNzi/JadBV8wneE3k56qJK5/wRAyd3Zmq87SFwoakrwiCGFKS6T6n5pwD8 bv+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Rj1vcfLqePUUlfq7nqOeH8Fm78abBXaKWQgBWRoed4A=; b=Fht6IWs9VvUWBKZr0L7EGWrLqMwjxeiTaAUaUIuNzNczUslMvZzy3vuorlN+IQvqRr 0kgb7iZRCqHLmDo3iCoyDP5aSp1NeMpSfdLYcYL7w+uf3h93JBKckk5vQm0b6+ZmGHfz x5yTsghUxp2KVX05lYhfncfT6UIAOHvSmlIiUuebZt/z7va4jEn3QmNg+PG6+tTWgGLv rCTbUOkKWVquvlF6tVSdTvNLqP+pGCtYg3p15K4wYNcmXeiZ61VcRw+ttQdmA7GNZVQM +9kuZ6j3DvkKnGoTf96yrqG7671FPEKbhUZ3lab7sjr/Mo5XDq9e44bl0T9r/Amz37jD /RRA== X-Gm-Message-State: AOAM531+phuo4nmXK0XUTtTduTftu5ZS0L3jaG8zHqVfXaW6L+xnbGSm eNr543Wv9rLyx/X81H90yRbkD5OwJuTAFb7yvtVkr35Gzpg= X-Received: by 2002:a02:a60a:: with SMTP id c10mr14200928jam.123.1607676147492; Fri, 11 Dec 2020 00:42:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Amir Goldstein Date: Fri, 11 Dec 2020 10:42:16 +0200 Message-ID: Subject: Re: linux-next fsnotify mod breaks tail -f To: Hugh Dickins Cc: Jan Kara , linux-fsdevel , linux-kernel Content-Type: multipart/mixed; boundary="000000000000afb1d705b62c45d3" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000afb1d705b62c45d3 Content-Type: text/plain; charset="UTF-8" On Fri, Dec 11, 2020 at 1:45 AM Hugh Dickins wrote: > > Hi Jan, Amir, > > There's something wrong with linux-next commit ca7fbf0d29ab > ("fsnotify: fix events reported to watching parent and child"). > > If I revert that commit, no problem; > but here's a one-line script "tailed": > > for i in 1 2 3 4 5; do date; sleep 1; done & > > Then if I run that (same result doing ./tailed after chmod a+x): > > sh tailed >log; tail -f log > > the "tail -f log" behaves in one of three ways: > > 1) On a console, before graphical screen, no problem, > it shows the five lines coming from "date" as you would expect. > 2) From xterm or another tty, shows just the first line from date, > but after I wait and Ctrl-C out, "cat log" shows all five lines. > 3) From xterm or another tty, doesn't even show that first line. > > The before/after graphical screen thing seems particularly weird: > I expect you'll end up with a simpler explanation for what's > causing that difference. > > tailed and log are on ext4, if that's relevant; > ah, I just tried on tmpfs, and saw no problem there. Nice riddle Hugh :) Thanks for this early testing! I was able to reproduce this. The outcome does not depend on the type of terminal or filesystem it depends on the existence of a watch on the parent dir of the log file. Running ' inotifywait -m . &' will stop tail from getting notifications: echo > log tail -f log & sleep 1 echo "can you see this?" >> log inotifywait -m . & sleep 1 echo "how about this?" >> log kill $(jobs -p) I suppose with a graphical screen you have systemd or other services in the system watching the logs/home dir in your test env. Attached fix patch. I suppose Jan will want to sqhash it. We missed a subtle logic change in the switch from inode/child marks to parent/inode marks terminology. Before the change (!inode_mark && child_mark) meant that name was not NULL and should be discarded (which the old code did). After the change (!parent_mark && inode_mark) is not enough to determine if name should be discarded (it should be discarded only for "events on child"), so another check is needed. Thanks, Amir. --000000000000afb1d705b62c45d3 Content-Type: text/plain; charset="US-ASCII"; name="fsnotify-fix-for-fix-events-reported-to-watching-parent-and-child.patch.txt" Content-Disposition: attachment; filename="fsnotify-fix-for-fix-events-reported-to-watching-parent-and-child.patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kik0jqhf0 RnJvbSBjN2VhNTdjNjZjOGM5Zjk2MDc5MjhiZjdjNTVmYzQwOWVlY2MzZTU3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbWlyIEdvbGRzdGVpbiA8YW1pcjczaWxAZ21haWwuY29tPgpE YXRlOiBGcmksIDExIERlYyAyMDIwIDEwOjE5OjM2ICswMjAwClN1YmplY3Q6IFtQQVRDSF0gZnNu b3RpZnk6IGZpeCBmb3IgZml4IGV2ZW50cyByZXBvcnRlZCB0byB3YXRjaGluZyBwYXJlbnQgYW5k CiBjaGlsZAoKVGhlIGNoaWxkIHdhdGNoIGlzIGV4cGVjdGluZyBhbiBldmVudCB3aXRob3V0IGZp bGUgbmFtZSBhbmQgd2l0aG91dAp0aGUgT05fQ0hJTEQgZmxhZy4KClJlcG9ydGVkLWJ5OiBIdWdo IERpY2tpbnMgPGh1Z2hkQGdvb2dsZS5jb20+ClNpZ25lZC1vZmYtYnk6IEFtaXIgR29sZHN0ZWlu IDxhbWlyNzNpbEBnbWFpbC5jb20+Ci0tLQogZnMvbm90aWZ5L2Zzbm90aWZ5LmMgfCA1ICsrKysr CiAxIGZpbGUgY2hhbmdlZCwgNSBpbnNlcnRpb25zKCspCgpkaWZmIC0tZ2l0IGEvZnMvbm90aWZ5 L2Zzbm90aWZ5LmMgYi9mcy9ub3RpZnkvZnNub3RpZnkuYwppbmRleCBhMGRhOWU3NjY5OTIuLjMw ZDQyMmI4YzBmYyAxMDA2NDQKLS0tIGEvZnMvbm90aWZ5L2Zzbm90aWZ5LmMKKysrIGIvZnMvbm90 aWZ5L2Zzbm90aWZ5LmMKQEAgLTI5MS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