git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/4] reftable/stack: move list lock to `struct reftable_stack`

From
Karthik Nayak <karthik.188@gmail.com>
Date
Aug 26, 2026, 09:46 UTC
Message-ID
<CAOLa=ZSbOFmsNUfhsEESsD5rBqUq0iX=Ls_TgfRkeo5FQpamtQ@mail.gmail.com>
In-Reply-To
<ao1uqpCxFHlOyTV-@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 32 quoted lines
> On Mon, Aug 24, 2026 at 11:31:01AM +0200, Karthik Nayak wrote:
>> 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

I agree, I couldn't find another solution. The alternative being, we move the bitfield to the 'reftable_stack', but that is more fragile since there are more touch fields. So I think this is okay too.

Thanks
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 6 of 9 in “reftable/stack: avoid reloading the stack when locked”
  1. 0/4 reftable/stack: avoid reloading the stack when lockedKarthik Nayak, Aug 24, 2026
  2. 1/4 reftable/stack: remove `REFTABLE_STACK_NEW_ADDITION_RELOAD`Karthik Nayak, Aug 24, 2026
  3. 2/4 reftable/stack: rename reftable_stack_new_addition()Karthik Nayak, Aug 24, 2026
  4. 3/4 reftable/stack: move list lock to `struct reftable_stack`Karthik Nayak, Aug 24, 2026
  5. Patrick SteinhardtAug 25, 2026
  6. Karthik NayakAug 26, 2026
  7. 4/4 reftable/stack: avoid reloading the stack when already lockedKarthik Nayak, Aug 24, 2026
  8. Jeff KingAug 24, 2026
  9. Karthik NayakAug 26, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.