🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1046

Re: [PATCH 2/4] odb/source-files: reload alternates on retry

#1046
From: Christian Couder
Date: Wed, 21 Oct 2026 14:32
92 lines
15520 bytes
On Tue, Oct 20, 2026 at 11:01 AM Patrick Steinhardt <ps@pks.im> wrote:

> diff --git a/odb/source-files.c b/odb/source-files.c
> index d31da6e5d9..86f3fd1136 100644
> --- a/odb/source-files.c
> +++ b/odb/source-files.c
> @@ -425,6 +425,7 @@ static enum odb_read_status odb_source_files_read_object_info(struct odb_source
>                                                               struct strbuf *errmsg)
>  {
>         struct odb_source_files *files = odb_source_files_downcast(source);
> +       struct odb_files_dir **tail = NULL;
>         enum odb_read_status status = ODB_READ_NOT_FOUND;
>         enum odb_read_status ret;
>         bool retry = false;
> @@ -448,10 +449,11 @@ static enum odb_read_status odb_source_files_read_object_info(struct odb_source
>                         status = ret;
>         }
>
> -       for (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) {
> -               if (retry)
> -                       break;
> -
> +       /*
> +        * When we have reprepared alternates then we only re-scan directories
> +        * that were newly added.
> +        */
> +       for (struct odb_files_dir *dir = tail ? *tail : files->dirs; dir; dir = dir->next) {
>                 ret = odb_source_read_object_info(&dir->loose->base, oid, oi, flags,
>                                                   status == ODB_READ_NOT_FOUND ? errmsg : NULL);
>                 if (!ret)
> @@ -461,6 +463,8 @@ static enum odb_read_status odb_source_files_read_object_info(struct odb_source
>         }
>
>         if (!retry && !(flags & OBJECT_INFO_QUICK)) {
> +               tail = files->dirs_tail;
> +               prepare_alternates(files, NULL);

This calls `read_alternates(files->dirs->abspath, ...)`, but when we
use a temporary primary directory, `files->dirs` is that temporary
primary directory. The prepare_alternates() call will then quietly
find nothing new because temporary primary directories have no
alternates.

Before 5946a564cd (odb/source: make `read_object_info()` function
pluggable, 2026-03-05), when there was a temporary primary directory,
reloading the alternates also found nothing new for the same reason
(no alternates).

So we could think that there is no behavior change, but in the
meantime there was bdee7b3013 (builtin/receive-pack: stage incoming
objects via ODB transactions, 2026-07-10) which made the quarantine
the temporary primary directory in receive-pack. Before that commit,
receive-pack only passed its quarantine to child processes through
environment variables, so its own lookups reloaded the repository's
real alternates.

I wonder if it would be better to always reload the repository's real
alternates, instead of `files->dirs`'s alternates. This way, objects
that moved to an alternate would still be found, not only during a
receive-pack like before 5946a564cd, but whenever a temporary primary
directory is used.

It looks like with your 4/4 patch this improvement would add no extra cost.

Then `files->dirs` should also likely be replaced by the repository's
own object directory in the following places inside
odb_files_dir_is_usable():

- in the hashmap_entry_init() call that seeds the duplicate map, and
- in strbuf_realpath() when we are supposed to compare against the
resolved path of the primary.

These are not reachable today when a temporary primary directory is
installed, as no alternates are read then. But they would become
reachable if we reload the repository's real alternates, instead of
`files->dirs`'s alternates.

>                 retry = true;
>                 goto retry;
>         }
Technical Details
Message-ID: <CAP8UFD0woTHVqy0cXtWJCL9Pt_jqWXT3m0bN=LufOQ_zJaKeAA@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72730-linux-kernel-git=dewy.ru
References: <20261020-pks-odb-files-reload-alternates-v1-0-d9e156323836@pks.im> <20261020-pks-odb-files-reload-alternates-v1-2-d9e156323836@pks.im>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72730-linux-kernel-git=dewy.ru
From: christian.couder@gmail.com (Christian Couder)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 2/4] odb/source-files: reload alternates on retry
Date: Wed, 21 Oct 2026 16:32:34 +0200
Organization: Usenet Network
Message-ID: <CAP8UFD0woTHVqy0cXtWJCL9Pt_jqWXT3m0bN=LufOQ_zJaKeAA@mail.gmail.com>
References: <20261020-pks-odb-files-reload-alternates-v1-0-d9e156323836@pks.im>
 <20261020-pks-odb-files-reload-alternates-v1-2-d9e156323836@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="4168839"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6RyuDdmJRGcSpu99gFDYaiI+bjE= sha256:iCN8MMHf+1em0mOfrVeKZNzbovNw0pMyoc8FER4x2yY=
	sha1:+HQwVHLu/HU5FjrpQJbhNClz0Ec= sha256:GJZAoy7Wty0M0i6S3jeMwlV++zYQFsuVpKilnXcOkZU=
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 A8BF811103A; Wed, 21 Oct 2026 17:38:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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.25,
	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 PqU4c9vtzskK;
	Wed, 21 Oct 2026 17:38:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-72730-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 9C77B11102D; Wed, 21 Oct 2026 17:38:13 +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 645D43ED33; Wed, 21 Oct 2026 14:32:49 +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=1792593168;
	b=dbtCUEXAilLlbkB4u4jFMSq2Mwl004fe+F9SuyoX20y8VEHqWkxpOiSxhsdnHkzHpYE/
	 c9u2dlyX86/1WLMxrtp+ECAK0aqHirQs0mIIFZVLRIVKMH+IzJlz+hYGXiJ0rIpLncHoI
	 22C8JfKjtsIPt8H/5bN4DPPJhwq4fqAyX19OiSeExn78/i8su83LDzpzhV/mwC+lQHOw7
	 DiXcN3OtqSPmElYi4vB9c/2p8GS2mzroZKzaeWw1oyadjCDEQ9cKULgeYPXE+HZiZ4+NR
	 Pt0SOHQnYt23zXWYiyiW9c2Jh+QIgWcUgAtWtN8fUgWhvwG/X2StjPaAkA3IqQMIwpA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792593168;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature: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=FVTgtHTrRi6tdoklZ5DEITdo+2m6NZ+IebXrN7tlaMQ=;
	b=JiDJi8Lfrl0aPjq9QXREAVUKU4ojN1TornnoY8ijXV0NEg1sHIWFoOVibIKTN9r/mfXZ
	 IPV0q4iL8ITiELtCPu4+Dr6UMQ1OPzIZk9xmFTRC82gKgkI1gBvaU2qW98RuVpLFwOVEk
	 qCyGfNr+l7aBaIJq8thGj4JWfHrsg1uSsBRYn70uYKDp5u76n4MCIcyRhz5A/RrJc2T2z
	 BGl1Zp16UGv/4wyr7ZfPwQKOBNIVtwCxCCiz5IHhlHWVuG2U9/gdWXiomecmX594QsqhK
	 LnnNf3e6qU/ctTRKFKvHWU/K5jRkbuDW6hJlFUhCpa7xA/vRWqVwBb5mvW5gTH7Vbwg==
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=20251104 header.b=Dv+5hpRs;
	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 96958606A322;
	Wed, 21 Oct 2026 14:32:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Dv+5hpRs
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.82.54
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792593167;
	b=2nLlGr4hmGsNNwdTsoqUdTBNBJ9K+vRWjoa52P9fs/ve52BO56/SSMLQQmlO9DC0bHoT
	 dp/t/V/qZYOLhhsfxuWEX4RAGklA478Ujlf6hVXy8zv7YxTEL1SkGx5Dq14syejVNUo8O
	 VrvkbL4DJFika2ZEcaqZIl6sk+wCJ9Vfgu+mc3jIla/IslaQj8qqzSXnJ/B1oQjNeGOgp
	 uyuLslFr5/oWE9tnBLKTgykAP/J+W1YW7DDQY1SwdrJQzVbooqT+cDbPEErtXfF5LH7hS
	 QXcPNOuAGf1eqRS5t3R9cUj/mHr/Gs0ORrIzH9uyIBLbo9u8gBrBdnj5bFYvMhGIdMQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792593167;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 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=FVTgtHTrRi6tdoklZ5DEITdo+2m6NZ+IebXrN7tlaMQ=;
	b=ZioNtF1HZSPyMNKw38j3GhF+flTPSiyCGAp7v2RTwhRQWmSkZ1QUspqmXvot70pWcO+8
	 FfJqQatEhgPf7i00BwJVSN6WDeoylW56Vx2RdaaYNUdv19FGd3mWT77GbY6uD6KQ+CBjb
	 9ldEkZAsAhJBOwMqUwETmXnNznei6hLTvm6GGYLs4U/MCY+O7Wndxl8Nb3KEE4T1l88HT
	 iYIgbkFUH62y0efSTln/BoisGW9Fp6jaTllREnPUuC2uuRWFh/rYXYd+08U0+Gm5CHhEw
	 28aKf3yDhjVSNiCVE75YrcsqiaTFAORCmOwmYhljhfnV+w0/WwFcb1ZtP2QTx0jskKg==
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=20251104 header.b=Dv+5hpRs;
	arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.82.54
X-Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54])
	(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 62194606A31A
	for <git@vger.kernel.org>; Wed, 21 Oct 2026 14:32:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 62194606A31A
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-dl1-f54.google.com with SMTP id a92af1059eb24-157fe9d771bso1019115c88.0
        for <git@vger.kernel.org>; Wed, 21 Oct 2026 07:32:47 -0700 (PDT)
X-ARC-Seal: i=1; a=rsa-sha256; t=1792593166; cv=none;
        d=google.com; s=arc-20260327;
        b=f6P3LO4nxurLI1Yii2yrU1eSAoY+evBp8F+ip4EXXEP1DAbHldwSUeiNGYFxPqdzms
         h4VA9YFvuwgvElMmhUK42KkijyCtN9aTzCN5PEcxZCQU8LB1RKzcfVcQ4j9pUf0hPXeA
         WXOVBGMpKZQg2LWCwcZhIlcMlyOOJrN+aurKizzGLZFVDXsuEr2TdUJNwxipA7cD+TGC
         tTz2MymRt8slyaN341hWp/aGx8ezhdiSRuqXTpPw5I3Vu3XUIEIqOre11Urfhrzig4X8
         dRBm8p8tdJtjBSkcy1nbeFKGAI96SCE8NWj7NpFw5WthT75T3+VHtNJYpJ4ksFs1305D
         0fOg==
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=FVTgtHTrRi6tdoklZ5DEITdo+2m6NZ+IebXrN7tlaMQ=;
        fh=4hRD6dug9K2dA8/Qy44rHfFMnlFofhUgf7dxeZXl9E8=;
        b=JywpUQLOiyRabJ9A06R5snfhd82JKxi+zxkmC9jQiTxVo6blPE7gaBERyIsiGAPcQk
         Be91W4g8NyoZMx+00ml+nRxARnRLeATkHu+wWBzVk8KD4Z2ucLalhj2gZioHeYw9lS4u
         8eaV19S5N6ouq7WVizI8rJuKe8rUSriG6SDaGlq6B2Cg15zLVIugc0m758QC/DanEhLf
         vIP7WessHBCNdJ5MW94tLH0hFC4BoIzRYXWOKnvvFXq+H3epcoovZma40utNPoC23pjf
         L16d7VyIMIhJAz1rfd7rdQD84Vc5S5JE+p1Qkl8trpg/ZzgIfoHf48rRQK+Gdhldxq48
         S7Sg==;
        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=20251104; t=1792593166; x=1793197966; 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=FVTgtHTrRi6tdoklZ5DEITdo+2m6NZ+IebXrN7tlaMQ=;
        b=Dv+5hpRsyfIjL2cC6xNCAjZKj7aV7bDgP73vQJIcmrqK6xSt1FUD36+xcawtic6CXL
         Oe2Jd3OyVx/g4MZgu0JNk4WGbo0B+h50NFT07uIxKfkjXnOhzA+J3YTTAxw/uAfFPWd9
         xb7By0jVDWFk/0Z496v+R4Vqps7W3Y6cp+qT7MlxT6FCGtqMbRm9L+UufJMk2ErXhu6V
         N1HFXAB4iv5ooWMGiqKzSL3TQI+91vMSesattwmQqALT9X4XOsFtKFMPfTFyESWMAcym
         T681IhzKSIUPrk1MpIgV4fv42s/liUrHIM8G3S4qCFOmtwBmqJfQ/iVSnNbnCXurX9h7
         SFFA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792593166; x=1793197966;
        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=FVTgtHTrRi6tdoklZ5DEITdo+2m6NZ+IebXrN7tlaMQ=;
        b=AvAWS1GxRYqiZiFCRlqXcJkdgoqgtK/KPN/IrM+cGThXTIEXV8FXtAg/HSJJybMb2A
         ST5S3C7FBfmk6Hc4Xh60KuopTb3hql9Yc4HgwkDmCT794vyH/uTESqNZ+zC576+fkS2S
         z01DZiqGIBgWId5Urxwu6MOur31tZaNvS05jHH+5UkR2xU3DsJ3HaHnEs1nQw7GZ8cPy
         itd2/NJSbDgKgSagogDFprujI3CKJSv57nFKuNvkBYzXzSQy7dp7kWpQJKkoaXP3gJ+s
         TWuli4mmjx3RsF/V/L44qkp8OACWyJlULrRQ68edpxhkiUveteH2FLeIA76krH8Arv7Q
         Z+jA==
X-Gm-Message-State: AFq9FYJkjK694iEwDt8PJf9/Oz7pocwIS4Gs3agR3ixryF/GUUpl8r7W
	Qz33uJVMxpKW0gwkP/2jDk78vsmAU9wNGEggaPeDlaLo1LvYukS6IcjzazWOMmnRf3SDbwMP62M
	MdYq+Jz2lh0jrHDrsAdksMuRtteVCvvNZtyj9
X-Gm-Gg: AYBFou0hp0vMps3UKzJGF2YXxjYrA+z0IFjqEy5LEl2d1krct083xf6QhNHSsv5mg4J
	Zv4tYe/Iwuaz91ba0Otr+kqR4q/GTanayOPTej0m4dvhKMFx9ZkbxVHPwfphjId3srNRkYIOKqO
	hfmnvF3L0aXxlP0Fs8k233u6wBO7mTaY0fm4Z3iU7klmZEoYW7lHZkZQbVXHf59X39Mh7GxXzOQ
	iy6uJ1R+rEVC+UzDIBQCVrYEsy7o8eImRvE2OWHAnerlNwMn5qhMZnUZrUFgF+AxgyUX3pIuo0O
	mx6Af9jUyvGtGge/TCkxBVYdIfmvexfQmkDU3tC9GrDommoWn1M4FUx9AKK5sitjrnjJ1BdWBWl
	pTpwV1uxSiyz/eYpZ4kj22tHCr442IRgrDiLR3k2qEjEGh7JFjtrsX45qOdsDgBK+0DAeLqhSxs
	sSiTpmWOUcuxjvxZFVvCayR8H3PcxPqwCjZ2ahyY4RQkQdGhKztO3IB1I61s208tosPQ8lNuAlO
	H/OQT8DWFrmuh1yDJaQ9S6L
X-Received: by 2002:a05:7022:2507:b0:151:ece6:b16b with SMTP id
 a92af1059eb24-190a4c1fa2emr3920852c88.7.1792593166128; Wed, 21 Oct 2026
 07:32:46 -0700 (PDT)
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: <20261020-pks-odb-files-reload-alternates-v1-2-d9e156323836@pks.im>
X-Gm-Features: AclHuK-il5Y2O4RlC_w2D75UpHTnNO0RcFc5_oZwM0L4fYfn_zEgg97gQujh7TQ
X-Cc: git@vger.kernel.org