Article View: linux.kernel.git
Article #2733Re: [PATCH] fsmonitor: check the untracked cache after a trivial response
From: Ilia K
Date: Mon, 09 Nov 2026 18:59
Date: Mon, 09 Nov 2026 18:59
109 lines
15615 bytes
15615 bytes
On Thu, Nov 5, 2026 at 4:01 PM Derrick Stolee <stolee@gmail.com> wrote:
>
> > + strbuf_setlen(path, len);
> > + }
> > +
> > + return nr_invalidated;
> > +}
> > +
> > +int untracked_cache_invalidate_stale_dirs(struct index_state *istate)
> > +{
> > + struct strbuf path = STRBUF_INIT;
> > + const char *worktree;
> > + int nr_invalidated;
> > +
> > + if (!istate->untracked || !istate->untracked->root)
> > + return 0;
> > +
> > + /*
> > + * The index is also read and written by commands that do not
> > + * run in the top-level directory of the worktree.
> > + */
> > + worktree = repo_get_work_tree(istate->repo);
> > + if (!worktree)
> > + return 0;
>
> I wonder if this is the right response if we fail to get a worktree. Maybe
> we should invalidate the entire untracked cache in this case, along with a
> warning that we couldn't evaluate the worktree? Or should we return -1 to
> signal an error?
Fixed, thank you!
> > diff --git a/read-cache.c b/read-cache.c
> > index c4cf08a3a3..00c9960c8e 100644
> > --- a/read-cache.c
> > +++ b/read-cache.c
> > @@ -3034,6 +3034,22 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
> > istate->untracked) {
> > strbuf_reset(&sb);
> >
> > + /*
> > + * The monitor could not say what changed (see the trivial
> > + * response in refresh_fsmonitor()), so nothing kept the
> > + * valid bits up to date. Check them before they are saved
> > + * next to the new token, which later commands trust even
> > + * when this command did not look for untracked files.
> > + */
> > + if (write_extensions & WRITE_FSMONITOR_EXTENSION &&
> > + istate->fsmonitor_last_update &&
> > + !istate->untracked->use_fsmonitor) {
> > + int nr = untracked_cache_invalidate_stale_dirs(istate);
> > +
> > + trace2_data_intmax("index", istate->repo,
> > + "extension/untr/invalidated", nr);
> > + }
>
> This surprised me, that you're computing this in do_write_index(). I suppose
> that this avoids doing this computation unless the index is written, but is
> it possible that between refresh_fsmonitor() and do_write_index() that the
> untracked cache is read and used to determine what this index update should
> be?
No, nothing between `refresh_fsmonitor()` and `do_write_index()`
trusts the cache because use_fsmonitor stays 0 until the index is
written.
> > +# After a trivial response ("/") the monitor cannot vouch for the
> > +# untracked cache. Even a command that does not look for untracked
> > +# files must drop the stale entries, or the next "git status" trusts them.
>
> nit: Generally, we don't need these comments because the tests should be
> self-documenting.
Fixed, thank you!
> > + EOF
> > + git status --porcelain >../actual 2>../err &&
> > + test_must_be_empty ../err &&
> > + test_cmp ../expect ../actual
> > + )
> > +'
>
> > +# After a restart the daemon sends a trivial response ("/"), because it
> > +# cannot know what changed while it was down. Even a command that does
> > +# not look for untracked files must then drop the stale untracked cache
> > +# entries, or the next "git status" trusts them.
>
> same nit: comments shouldn't be necessary here.
Fixed, thank you!
--
- Ilia
Technical Details
Message-ID:
<CAMmqxguRpCFL2cRJ_LCXaPd9d91zFb-Yo6MVbhSsi57S14xseA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!git+bounces-74960-linux-kernel-git=dewy.ruReferences:
<pull.2247.git.1791127155614.gitgitgadget@gmail.com> <c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com> <xmqqld77uofw.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!git+bounces-74960-linux-kernel-git=dewy.ru
From: ki.stfu@gmail.com (Ilia K)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] fsmonitor: check the untracked cache after a trivial response
Date: Mon, 9 Nov 2026 19:59:10 +0100
Organization: Usenet Network
Message-ID: <CAMmqxguRpCFL2cRJ_LCXaPd9d91zFb-Yo6MVbhSsi57S14xseA@mail.gmail.com>
References: <pull.2247.git.1791127155614.gitgitgadget@gmail.com>
<c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com> <xmqqld77uofw.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="427748"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:DF/Shak4Il7Njk7imT+7MpFscws= sha256:FoLAu+frabQok5lqMRBnMWnYXHlta4LBheaBVqwBvww=
sha1:by2ikMZWIm+La2191VnIWP7AAyg= sha256:b23gMYDuyet6bn11k3TWn/08GJzonhvRXBbHGaJ9wmA=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 7A0E0113661; Mon, 9 Nov 2026 22:00:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id lKHtMmBpcACr;
Mon, 9 Nov 2026 22:00:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74960-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 3D7F01138D8; Mon, 9 Nov 2026 22:00:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 750AF894AE; Mon, 9 Nov 2026 18:59:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794250764;
b=iLPn8ZZHCZI5VBcWm13KQsa4ruhyj+BBytos2IPI6kt8FbVwMpXGpac+rxLWkHOkCL41
UsbuMChjaE7oIcWKgJWLZ0dics431tF5YFp2rq9QSqYFIepIHPrdbZBIeo2TP2sDH7fep
Sz/PIky6r1TkWnTDoIFvrdn3M7/7YR4cNbSVgU11gCR2Jk1PB25C595j9qzF63ojaPSes
Q5I6GmlKVW3WJSeE6Tqh4DloBTheQc7OJ4q0wlBQHOmK88sPpoRlgiccpSTsL7+j2LhOZ
ujc7RPRYCZjGAC7ivDU3zj9ha1Fdvn3m34A3KrYG30vCL2CmtSPSpm3bW/isEf63yQg==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794250764;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
Cc:Content-Type:Content-Transfer-Encoding;
bh=/COnO9dnKjvbNK9djz5XaFLsfrCcAvuowKtvzFXEA5E=;
b=Ubldr6rax7078Urx3Bg2zIo4U/BRmChqawcMMq/2cc9mdv4noQOQLQcRggRfU085hn+C
lUxBYHjZphSuucHADxiohpD8i6d58mzHNtey/QCNwvR+3AWQLvVtV+VzRZhAs9hWCg7o2
K20xdNELkQLrzf/8HMFwoHwwVbnyg/fKQeUD4bNZkejcBo16doveL7rnQiMI7oVUdl4hp
1W32pXIs/cF/ZqzERLBVtqHzckkWujxFPn/Ufaa0z5LsXOaPcnQJXCAafeGdbesg8Ozmv
RajN9Nzjnb3IBZBs+ZHbSPkQ5DmsBbaoIakm50x0MJXo1laFBihrtKqbyEXiOuzBZrQ==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZP+pxIYH;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E98D606A337;
Mon, 9 Nov 2026 18:59:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZP+pxIYH
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.160.170
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794250763;
b=KhphHIJvGJ+AWf0NLslUnnwI+xoiHtc5HSpR/w+7oPCuagG4yu1ahkMSxPHU38kKZPad
AUFOcawAJLIrRt20PBdmomVAqWeW0AVRWcxcg4OJ7S617mUvDXAjJDg9MFaJDI4lb2HRo
DO92YASLewvURbjErkMOpv2okQQV1QsclupFLVfDmnrGvT/jRAaRsL9t4bH3NkPbIVqqS
krvR6Nudeq/NYxXZpkM2i1BP2vmzGj9hvJ8J9xzc/8ZlJffMc9kWBmOel3RzlyFGK916G
rfOEZxUMM0x4uCggXcpGiZsFSKevRYFNZGU/q65jPZPdpoZofNwy1wxYriHVQ9rAN1A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794250763;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=/COnO9dnKjvbNK9djz5XaFLsfrCcAvuowKtvzFXEA5E=;
b=Eef9kNVEBRUEBnOCrwETAMgIMLa+Aqd4vygn5ctRu90xlPCgrdixj2HDuTCupXWcurf9
FMqSbLpFkMIPHJO4yKcbuNjdb5/g5D9mV2rUt1OGVdrtaK6Lzv0JEjwd1ZHjZKQe1XV8Y
PXMv+JPTT7DjpuYcBvNQDipMCs0Wf/Q10Un2ZWjTVKbA09r5tyEcYv0/QfqsPMgJTTEnR
hzTbZguBk8qZww27gXTy8pbw0wT5HO4lQrzYkcIa98D7jYSaQ1zimEXeIoPPS6FO2q/Lo
coKcZzA1qqf5TaE0srHUwERYT1o1bSO7n0Jd/Kg1xcv0EVmTBbMB0oTx8xh5kKkZQPQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZP+pxIYH;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.160.170
X-Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06B51606A31C
for <git@vger.kernel.org>; Mon, 9 Nov 2026 18:59:22 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06B51606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-5366463571cso14651511cf.3
for <git@vger.kernel.org>; Mon, 09 Nov 2026 10:59:22 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1794250762; cv=none;
d=google.com; s=arc-20260327;
b=AYaULdmVQg6m1abqC8JGUQliHNnyCvX+JnjIZ5H8TMPrw1fNfhSl1TCg97BB8oa/HT
cGw7D+am1TmWxFlpzSLd3TJWGRVARP0+4QegP6B+3BOK1as1UNITHiIyt9ybtf5Mib94
vUe8188XtGvwARMqvLy8WbvRxY1qJZo1O0pU6GOdjvFhOmVh8J41IpQAlq1mDLue6xyL
gEzY4kNR/SE0XPI0FHqYyGfxFqD1vUtEaE2C1taejusgXssR7mEA5aINpcZe2epyTgLO
ruH5jNz6xTCz/6xnUZHjx3bjJDcmb74+wqZss+jOGtb7N1gGYj/6SsxV3iXIN7PTiLKH
db7g==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=/COnO9dnKjvbNK9djz5XaFLsfrCcAvuowKtvzFXEA5E=;
fh=TkCkMTSg7nLsSbRYBdn7vrS7QlHCcgz2mDcBjyLFqNs=;
b=nYXuqW6x5DpFpwKvGIQerTKCmBfYI7laxvGPQ6LK8b+Zn5Xcxy5yhby02kujDyUQJH
KXzqtkrneznTJ9qTZKqNXgWadNKCCgxlyoEjWeR1H9luDewnASbamMvOOftPxBGDBvtr
EjrW/jjXomSNdzR27fPqKGP4T/kUe1Yb3slogBDGoaF3XxihMIcLrjvjDo79FnFLng58
oQ9tqB/t+GnGvL6dOzNDqMfFm5DdTCY1bqPbqzbQDVVB7SnYWuKrJGwlk/r+dKuwwhF8
0wsBPqX1sJz7SNnddXo2oSmkZ+NbRKTCWIAkhWeE6zXUQt6JAak3ppnyxEKAq5JPa8Vx
mUPg==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794250762; x=1794855562; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=/COnO9dnKjvbNK9djz5XaFLsfrCcAvuowKtvzFXEA5E=;
b=ZP+pxIYHByY/yx77qsQMGTiP71HYrRqKEXQ23Yl9R4dKa1tXrvW3ONZUdl/MP+UWgi
z3fZZwMVrt80rbl+BzmJPLPGMvAC6VeiRSGGQzbMDxazzpwWkUj+mI0mUrVHzGAbMr04
kVInu+CuBQrb15kNGLrggzmEDcHAAPs41h0cSnR5b1cEVJJPyWvhKrNRysQ2fZJAzMCX
DhV5zAPJBI5Uh7eZ93mJxHArV3oQhu5yXtCJLJ0I7ofTvNGh0Be7lilL9kNUfpDF3k2B
0LJHuLai4nzzxSmHkGd+c5g74yJcCP0+p7LyLre8QIynURX0Q1ykVIPyu2VZgnfA6d7B
tebw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794250762; x=1794855562;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=/COnO9dnKjvbNK9djz5XaFLsfrCcAvuowKtvzFXEA5E=;
b=JnO+iO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FvJKEkfy7Bb8LM
wzfTNrfEobpxb4SA==
X-Received: by 2002:a05:620a:4593:b0:93e:9834:3863 with SMTP id
af79cd13be357-9479f2b05f0mr65411685a.15.1794250761983; Mon, 09 Nov 2026
10:59:21 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <xmqqld77uofw.fsf@gitster.g>
X-Gm-Features: AclHuK_AJbVafaEGmhEioMpS7EzUgarM9Wqaz3UPstqpnpBlrsAso47LY_PF-XE
X-Cc: Derrick Stolee <stolee@gmail.com>, Ilia via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org