Re: [PATCH 3/7] refs/files: add count field to ref_lock
- From
karthik nayak <karthik.188@gmail.com>
- Date
- Dec 11, 2024, 10:18 UTC
- Message-ID
- <CAOLa=ZRuuS_TW=BPeC36eWfgcYegT5hVKd+pVLG6TDMMjJ7tsg@mail.gmail.com>
- In-Reply-To
- <CAP8UFD0UAWib-GceEQi+ZzbosRcvSRbq-DuMLVVr9xuf8C03ow@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 18 quoted lines
> On Mon, Dec 9, 2024 at 12:11 PM Karthik Nayak <karthik.188@gmail.com> wrote: >> >> When refs are updated in the files-backend, a lock is obtained for the >> corresponding file path. This is the case even for reflogs, i.e. a lock >> is obtained on the reference path instead of the reflog path. This >> works, since generally, reflogs are updated alongside the ref. >> >> The upcoming patches will add support for reflog updates in ref >> transaction. This means, in a particular transaction we want to have ref >> updates and reflog updates. For refs, in a given transaction there can >> only be one update. But, we can theoretically have multiple reflog >> updates in a given transaction. > > Nit: Giving an example might help understand where multiple reflog > updates can happen in a given transaction. Alternatively pointing to > an existing doc that contains such an example or explanations might > help too. >
The use-case is added in the series. I've added a note about how this is needed in reflog migration.
Show 17 quoted lines
>> @@ -2572,18 +2588,25 @@ static int lock_ref_for_update(struct files_ref_store *refs,
>> goto out;
>> }
>>
>> - ret = lock_raw_ref(refs, update->refname, mustexist,
>> - affected_refnames,
>> - &lock, &referent,
>> - &update->type, err);
>> - if (ret) {
>> - char *reason;
>> + lock = strmap_get(&backend_data->ref_locks, update->refname);
>> + if (lock) {
>> + lock->count = lock->count + 1;
>
> Nit:
> lock->count++;
>Will fix, thanks.
[snip]