[Devel] [RFC PATCH vz9 v6 07/62] dm-ploop: convert wait_list and wb_batch_llist to use lockless lists

Alexander Atanasov alexander.atanasov at virtuozzo.com
Tue Jan 14 19:00:11 MSK 2025


On 9.01.25 6:44, Pavel Tikhomirov wrote:
> 
> 
> On 12/6/24 05:55, Alexander Atanasov wrote:
>> Convert to lockless lists - intermix with regular list due to
>> that next pointer in both list_head and llist_head is the first
>> field, and prev is not used. Do this so we can make babysteps
>> forward.
>>
>> https://virtuozzo.atlassian.net/browse/VSTOR-91820
>> Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
>> ---
>>   drivers/md/dm-ploop-bat.c    |  3 +--
>>   drivers/md/dm-ploop-map.c    | 49 ++++++++++++++++++++----------------
>>   drivers/md/dm-ploop-target.c |  2 +-
>>   drivers/md/dm-ploop.h        |  6 ++---
>>   4 files changed, 32 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
>> index 886a05cdd23a..655d0e4c91ab 100644
>> --- a/drivers/md/dm-ploop-bat.c
>> +++ b/drivers/md/dm-ploop-bat.c
>> @@ -80,8 +80,7 @@ static struct md_page *ploop_alloc_md_page(u32 id)
>>       page = alloc_page(GFP_KERNEL);
>>       if (!page)
>>           goto err_page;
>> -    INIT_LIST_HEAD(&md->wait_list);
>> -    INIT_LIST_HEAD(&md->wb_link);
>> +    init_llist_head(&md->wait_llist);
>>       md->status = 0;
>>       md->bat_levels = levels;
>> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
>> index a0fe92a592a1..fb49dc7bd7b0 100644
>> --- a/drivers/md/dm-ploop-map.c
>> +++ b/drivers/md/dm-ploop-map.c
>> @@ -382,13 +382,14 @@ static bool ploop_delay_if_md_busy(struct ploop 
>> *ploop, struct md_page *md,
>>       WARN_ON_ONCE(!list_empty(&pio->list));
>> -    write_lock_irqsave(&ploop->bat_rwlock, flags);
>> +    /* lock protects piwb */
> 
> Should we have similar readlock around the use of md->piwb in 
> ploop_submit_cow_index_wb, ploop_process_one_discard_pio, 
> ploop_submit_metadata_writeback and ploop_prepare_reloc_index_wb? Else 
> it can be freed concurrently in ploop_break_bat_update or "protected" in 
> ploop_advance_local_after_bat_wb.


ploop_md_make_dirty should protect piwb until completion wrt:
- ploop_submit_metadata_writeback
- ploop_process_one_discard_pio
- ploop_submit_cow_index_wb

when page is dirty next requests end up in wait list.
on completion it is freed no other requests possible.

- ploop_break_bat_update is a cleanup on error , no one else have access 
to piwb yet.


- ploop_prepare_reloc_index_wb - is tricky

it is used by grow and resize operations

new md pages are made available at the end of operation.

so until it is finished no one else can use them

-- 
Regards,
Alexander Atanasov



More information about the Devel mailing list