[Devel] [RFC PATCH vz9 v6 22/62] dm-ploop: speed up ploop_prepare_bat_update()
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Mon Jan 20 21:40:49 MSK 2025
On 20.01.25 6:50, Pavel Tikhomirov wrote:
>
>
> On 12/6/24 05:55, Alexander Atanasov wrote:
>> From: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
>>
>> Drop ploop_cluster_is_in_top_delta(), because
>> - it internally searches md on every call
>> - it takes read lock every time
>>
>> https://virtuozzo.atlassian.net/browse/VSTOR-91817
>> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
>> ---
>> drivers/md/dm-ploop-map.c | 15 +++++++++++----
>> 1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
>> index c89e28aa18f9..de885049e3f9 100644
>> --- a/drivers/md/dm-ploop-map.c
>> +++ b/drivers/md/dm-ploop-map.c
>> @@ -899,13 +899,14 @@ static void ploop_bat_write_complete(struct pio
>> *pio, void *piwb_ptr,
>> static int ploop_prepare_bat_update(struct ploop *ploop, struct
>> md_page *md,
>> enum piwb_type type)
>> {
>> - u32 i, off, last, *bat_entries;
>> + u32 i, off, last, *bat_entries, clu;
>> struct ploop_index_wb *piwb;
>> bool is_last_page = true;
>> u32 page_id = md->id;
>> struct page *page;
>> struct pio *pio;
>> map_index_t *to;
>> + u8 level;
>> piwb = kmalloc(sizeof(*piwb), GFP_NOIO);
>> if (!piwb)
>> @@ -928,6 +929,8 @@ static int ploop_prepare_bat_update(struct ploop
>> *ploop, struct md_page *md,
>> piwb->page_id = page_id;
>> to = piwb->kmpage;
>> +
>> + read_lock_irq(&md->lock);
>> memcpy((void *)to, bat_entries, PAGE_SIZE);
>> /* Absolute number of first index in page (negative for page#0) */
>> @@ -946,10 +949,14 @@ static int ploop_prepare_bat_update(struct ploop
>> *ploop, struct md_page *md,
>> /* Copy BAT (BAT goes right after hdr, see .ctr) */
>> for (; i < last; i++) {
>> - if (ploop_cluster_is_in_top_delta(ploop, i + off))
>> - continue;
>> - to[i] = 0;
>> + level = md->bat_levels[i];
>
> Why do we assume that md page will not change when iterating from
> PLOOP_MAP_OFFSET and until (ploop->nr_bat_entries - (page_id * PAGE_SIZE
> / sizeof(map_index_t) - PLOOP_MAP_OFFSET) ? If it's true, we need
> explanation in commit message. If false, we need to update md each time
> as ploop_cluster_is_in_top_delta did.
this can change on grow or shrink - but when such operation is in
progress, there are no pios in flight and pio submission is suspended -
so it can not change. Change is applied at the end of operation.
>
>> + clu = READ_ONCE(bat_entries[i]);
>> +
>> + if (clu == BAT_ENTRY_NONE || level < ploop_top_level(ploop))
>> + to[i] = 0;
>> }
>> + read_unlock_irq(&md->lock);
>> +
>> if (is_last_page) {
>> /* Fill tail of page with 0 */
>> for (i = last; i < PAGE_SIZE / sizeof(map_index_t); i++)
>
--
Regards,
Alexander Atanasov
More information about the Devel
mailing list