Re: [PATCH v4 07/19] liveupdate: Add helpers to track the files that LUO manages
From: Pratyush Yadav
Date: Tue Nov 24 2026 - 10:03:21 EST
On Mon, Nov 23 2026, David Matlack wrote:
> On Fri Nov 20, 2026 at 3:15 AM PST, Pratyush Yadav wrote:
>> On Wed, Nov 11 2026, David Matlack wrote:
>>> @@ -788,8 +797,7 @@ int luo_file_finish(struct luo_file_set *file_set)
>>> luo_file_finish_one(file_set, luo_file);
>>>
>>> if (luo_file->file) {
>>> - xa_erase(&luo_preserved_files,
>>> - luo_get_id(luo_file->fh, luo_file->file));
>>> + luo_untrack_file(luo_file->fh, luo_file->file);
>>
>> This looks dangerous.
>>
>> Since the previous patch set luo_file->file when xa_insert() failed,
>> this will trigger in a failed retrieve. Except, the file was never
>> tracked to begin with.
>>
>> While I don't see anything that actually breaks because of this today,
>> I think it is a bug in the making.
>>
>> I think the below is a bit better. Although this change probably makes
>> more sense in the previous patch, since that introduced the problem.
>> This patch should just replace the xa_erase() with luo_untrack_file().
>>
>> if (luo_file->file)
>> fput(luo_file->file);
>>
>> if (luo_file->retrieve_status > 0)
>> luo_untrack_file(luo_file->fh, luo_file->file);
>
> Good catch, I'll fix this in the previous patch in v5.
>
> (But luo_untrack_file() needs to be called before fput() in case the
> latter drops the last reference.)
>
> So:
>
> if (luo_file->retrieve_status > 0)
> luo_untrack_file(luo_file->fh, luo_file->file);
>
> if (luo_file->file)
> fput(luo_file->file);
Right, makes sense. Thanks!
--
Regards,
Pratyush Yadav