[Devel] [RFC PATCH vz9 v6 40/62] dm-ploop: make ploop_bat_write_complete ready for parallel pio completion

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Jan 17 13:16:27 MSK 2025


On 17.01.25 10:09, Pavel Tikhomirov wrote:
> 
>> --- a/drivers/md/dm-ploop-map.c
>> +++ b/drivers/md/dm-ploop-map.c
>> @@ -893,35 +893,47 @@ static void ploop_bat_write_complete(struct pio 
>> *pio, void *piwb_ptr,
>>       struct ploop_cow *cow;
>>       struct pio *data_pio;
>>       unsigned long flags;
>> -
>> -    if (!bi_status) {
>> -        /*
>> -         * Success: now update local BAT copy. We could do this
>> -         * from our delayed work, but we want to publish new
>> -         * mapping in the fastest way. This must be done before
>> -         * data bios completion, since right after we complete
>> -         * a bio, subsequent read wants to see written data
>> -         * (ploop_map() wants to see not zero bat_entries[.]).
>> -         */
>> -        ploop_advance_local_after_bat_wb(ploop, piwb, true);
>> +    LIST_HEAD(lready_pios);
>> +    LIST_HEAD(lcow_pios);
>> +    int completed = atomic_read(&piwb->count) == 1;
> 
> Maybe we can use this construct:
> 
> if (atomic_dec_and_test(&piwb->count)) {do}

I've rewritten the logic, whomever is last does all the updates.

-- 
Regards,
Alexander Atanasov



More information about the Devel mailing list