Re: [PATCH v2 3/4] reftable/stack: move list lock to `struct reftable_stack`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 25, 2026, 10:30 UTC
- Message-ID
- <ao1uqpCxFHlOyTV-@pks.im>
- In-Reply-To
- <20260824-740-optimize-reloading-the-reftable-stack-v2-3-9c9de2eb0af7@gmail.com>
On Mon, Aug 24, 2026 at 11:31:01AM +0200, Karthik Nayak wrote:
Show 22 quoted lines
> diff --git a/reftable/stack.c b/reftable/stack.c
> index 703548417c..c3d4deff29 100644
> --- a/reftable/stack.c
> +++ b/reftable/stack.c
> @@ -628,10 +630,16 @@ int reftable_stack_reload(struct reftable_stack *st)
> }
>
> struct reftable_addition {
> - struct reftable_flock tables_list_lock;
> struct reftable_stack *stack;
> struct reftable_write_options opts;
>
> + /*
> + * While the list lock is acquired on the stack, we need to distinguish
> + * which 'reftable_addition' is responsible for the lock. This avoids
> + * clearing the lock of another 'reftable_addition'.
> + */
> + unsigned int locked : 1;
> +
> char **new_tables;
> size_t new_tables_len, new_tables_cap;
> uint64_t next_update_index;This feels somewhat fragile, as tracking state via a bit is very easy to get wrong. I would have preferred a solution where we didn't have to have this field and instead a more direct proxy. But there's not that many spots where we have to do this, so this may be okay-ish.
Other than that this series looks good to me, thanks!
Patrick