[Devel] [RFC PATCH vz9 v5 36/49] dm-ploop: debug patch , keep on top of stack

2024-11-18 Thread Alexander Atanasov
Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c| 39 ++-- drivers/md/dm-ploop-target.c | 23 + drivers/md/dm-ploop.h| 2 ++ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-ploop-map.c b/

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

2024-11-18 Thread Alexander Atanasov
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 --- drivers/md

[Devel] [RFC PATCH vz9 v5 08/49] dm-ploop: convert enospc handling to use lockless lists

2024-11-18 Thread Alexander Atanasov
https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c| 23 --- drivers/md/dm-ploop-target.c | 3 ++- drivers/md/dm-ploop.h| 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers

[Devel] [RFC PATCH vz9 v5 05/49] dm-ploop: remove unneccessary lock

2024-11-18 Thread Alexander Atanasov
now proper bitops are used for status we do not need to lock. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-cmd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c index 8bbb16

[Devel] [RFC PATCH vz9 v5 35/49] dm-ploop: split cow processing into two functions

2024-11-18 Thread Alexander Atanasov
Split ploop_process_delta_cow in two - list iterator and processing functions, unify handling with other pio types. We need this to be able to call pio by pio from threads. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 55 +++

[Devel] [RFC PATCH vz9 v5 00/49] ploop optimistations and scalling

2024-11-18 Thread Alexander Atanasov
Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in performance and makes further optimistations possible. Along with changes in v4: - BAT writeback delay - Lists/Locking moving to lockless lists to reduce locking - Requests are

[Devel] [RFC PATCH vz9 v5 31/49] dm-ploop: make md writeback timeout to be per page

2024-11-18 Thread Alexander Atanasov
Do not bulk write all dirtied bat pages in a common timeout. Instead mark dirty time for each page and delay for each page by the timeout. If page is tried to be redirtied - update the dirty time so for hot page try to accumulate more changes before writeout. https://virtuozzo.atlassian.net/browse

[Devel] [RFC PATCH vz9 v5 42/49] dm-ploop: fix access to batpages to use WRITE_ONCE

2024-11-18 Thread Alexander Atanasov
This was missed in an earlier patch and i've actually had a crash here. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm

[Devel] [RFC PATCH vz9 v5 32/49] dm-ploop: add interface to disable bat writeback delay

2024-11-18 Thread Alexander Atanasov
When doing utility operations we do not want to delay writeout of dirty pages. Add interface to disable delay. Hook it into suspend/resuming of sending pios. Which is done before ops that require it. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Alexander Atanasov --- drivers

[Devel] [RFC PATCH vz9 v5 41/49] dm-ploop: make ploop_bat_write_complete ready for parallel pio completion

2024-11-18 Thread Alexander Atanasov
There are some requirements listed in the comment inside ploop_bat_write_complete * 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

[Devel] [RFC PATCH vz9 v5 06/49] dm-ploop: reduce the time lock is hold, taking it only to protect data

2024-11-18 Thread Alexander Atanasov
Currently lock is taken once for all pios submitted(code block), move it to protect only the list insertion (data). The goal is to reduce lock contention on the deferred lock as it is in the top of lock stats. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --

[Devel] [RFC PATCH vz9 v5 23/49] dm-ploop: make new allocations immediately visible in BAT

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko We are planning to delay metadata writeback, so we want to immediately apply metadata changes to BAT page. Make all request that trigger PIWB_TYPE_RELOC apply metadata changes immediately. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko

Re: [Devel] [PATCH VZ9 0/2] dm-qcow2: add a memory pool for big buffer allocations

2024-11-18 Thread Pavel Tikhomirov
From the third glance it is fine, as for GFP_NOIO kvmalloc only does kmalloc allocation and do not try vmalloc. Series is fine, but I will resend it anyway, cause I found that there is already a patch in mainstream which dublicates my first patch. On 11/18/24 14:20, Pavel Tikhomirov wrote: Oh,

[Devel] [RFC PATCH vz9 v5 25/49] dm-ploop: do not wait for BAT update for non-FUA requests

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko --- drivers/md/dm-ploop-map.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index 8c02095321c4..25d24f

[Devel] [RFC PATCH vz9 v5 39/49] dm-ploop: convert bat_rwlock to bat_lock spinlock

2024-11-18 Thread Alexander Atanasov
Prepare for threads. Convert rwlock to spin lock. This patch converts existing rwlocks only. In the next one lock is used where required. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-cmd.c| 8 drivers/md/dm-ploop-map.c

[Devel] [RFC PATCH vz9 v5 21/49] dm-ploop: introduce per-md page locking

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko Currently we have single bat_rwlock for the whole ploop. However, runtime locking granularity can be reduced to single metadata page. In this patch, add rwlock to metadata structure, use it when accessing md->levels and md->page at the sime time to protect readers against

[Devel] [RFC PATCH vz9 v5 19/49] dm-ploop: simplify llseek

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko Do not bother with locked clusters. For llseek we can ignore all concurrent operations. Do not call ploop_bat_entries() on every cluster as this is slow. Just remember md and read it directly. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadch

[Devel] [RFC PATCH vz9 v5 49/49] dm-ploop: disable fast path

2024-11-18 Thread Alexander Atanasov
*** JUST FOR TESTING - NOT TO BE APPLIED *** Fast path results in rcu lockups and hangs. The reason is that we got called from fs, then we try to re-enter the fs but fs is not ready for this. There is an idea to investigate - try to skip dispatcher thread and directly execute in a runner thread.

[Devel] [RFC PATCH vz9 v5 26/49] dm-ploop: add delay for metadata writeback

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko Revert llist conversion for metadata writeback. Create new list for priority metadata updates, which are triggered by FUA requests. Write metadata for all other requests in batch after some delay. Add new parameter to specify delay time. Always submit COW and discard io to

[Devel] [RFC PATCH vz9 v5 27/49] dm-ploop: submit all postponed metadata on REQ_OP_FLUSH

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko On every flush request we should submit all accumulated metadata changes, wait for their completion and only then do the flush. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko --- drivers/md/dm-ploop-map.c| 42

[Devel] [RFC PATCH vz9 v5 13/49] dm-ploop: complete conversion of enospc and suspended pios to lockless

2024-11-18 Thread Alexander Atanasov
https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-cmd.c | 12 ++-- drivers/md/dm-ploop-map.c | 12 ++-- drivers/md/dm-ploop.h | 2 +- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/md/dm-ploop

[Devel] [RFC PATCH vz9 v5 40/49] dm-ploop: prepare bat updates under bat_lock

2024-11-18 Thread Alexander Atanasov
Prepare for threads. When preparing bat updates there are two important things to protect - md->status MD_DIRTY bit and holes bitmap. Use bat_lock to protect them. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 83 +++

[Devel] [RFC PATCH vz9 v5 47/49] dm-ploop: process pios via runners

2024-11-18 Thread Alexander Atanasov
Process pios in runner threads while preserving order. Metadata writeback requries all prios pios to be processed, since they can generate updates, so we have to wait before processing writeback. Fsync is yet sequential too. Both can be improved in a next iterration. https://virtuozzo.atlassian.n

[Devel] [RFC PATCH vz9 v5 18/49] dm-ploop: remove extra ploop_cluster_is_in_top_delta()

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko as we already got all info from ploop_bat_entries() earlier. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko --- drivers/md/dm-ploop-map.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-ploop

[Devel] [RFC PATCH vz9 v5 10/49] dm-ploop: convert the rest of the lists to use llist variant

2024-11-18 Thread Alexander Atanasov
pios can get reordered, fix in the next commit. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c| 119 ++- drivers/md/dm-ploop-target.c | 6 +- drivers/md/dm-ploop.h| 4 +- 3 files c

[Devel] [RFC PATCH vz9 v5 15/49] dm-ploop: fast path execution for reads

2024-11-18 Thread Alexander Atanasov
After a pio is split and prepared try to execute if immediately without going to the worker thread. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 92 --- 1 file changed, 67 insertions(+), 2

[Devel] [RFC PATCH vz9 v5 37/49] dm-ploop: use jiffies when calculating writeback time

2024-11-18 Thread Alexander Atanasov
ktime_* are expnsive functions, we do not need ns precision. using jiffies is fine. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 9 - drivers/md/dm-ploop.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-)

[Devel] [RFC PATCH vz9 v5 11/49] dm-ploop: combine processing of pios thru prepare list and remove fsync worker

2024-11-18 Thread Alexander Atanasov
Currently data pios and fluses are separated into different lists before handled to workqueue. This can lead to executing of flushes before relevant data pios and it is not possible to get that dependancy in the worker. So put both data and flush pios into prepare list. This way worker can get sing

[Devel] [RFC PATCH vz9 v5 45/49] dm-ploop: introduce pio runner threads

2024-11-18 Thread Alexander Atanasov
Create threads to execute pios in parallel - call them pio runners. Use number of CPUs to determine the number of threads started. >From worker each pio is sent to a thread in round-robin fashion thru work_llist. Maintain the number of pios sent so we can wait for them to be processed - NB we only

[Devel] [RFC PATCH vz9 v5 22/49] dm-ploop: speed up ploop_prepare_bat_update()

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko 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 --- drivers/md/dm-ploop-map.c | 15 +++ 1 file chang

[Devel] [RFC PATCH vz9 v5 17/49] dm-ploop: set IOCB_DSYNC on all FUA requests

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko When mapping request, save all flags, rather then only operation type. Use it later to check if the request is FUA or not. Unfortunately there is no REQ_FUA equivalent on IOCB layer, but IOCB_DSYNC is usually translated to it, as can be seen in __iomap_dio_rw(). https://v

[Devel] [RFC PATCH vz9 v5 38/49] dm-ploop: convert md page rw lock to spin lock

2024-11-18 Thread Alexander Atanasov
Prepare locking for threads. Some operations require to lock bat data (see next patch) and in some cases we need to lock md page while hodling bat spin lock but we can not take sleeping lock while holding a spin lock. To address this use a spin lock for md pages instead of rwlock. https://virtuoz

[Devel] [RFC PATCH vz9 v5 28/49] dm-ploop: handle REQ_PREFLUSH

2024-11-18 Thread Alexander Atanasov
From: Andrey Zhadchenko Create new flush pio when we see REQ_PREFLUSH flag. Call original pio after the flush is done. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko --- drivers/md/dm-ploop-map.c | 41 +-- 1 file changed,

[Devel] [RFC PATCH vz9 v5 33/49] dm-ploop: convert wb_batch_list to lockless variant

2024-11-18 Thread Alexander Atanasov
Merging required to back this change, so do it again. Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c| 49 ++-- drivers/md/dm-ploop-target.c | 1 - drivers/md/dm-ploop.h| 1 - 3 files changed, 25 insertions(+), 26 deletions(-) diff -

[Devel] [RFC PATCH vz9 v5 48/49] dm-ploop: disable metadata writeback delay

2024-11-18 Thread Alexander Atanasov
*** JUST FOR TESTING - NOT TO BE APPLIED *** Delayed metadata writeback results in a hang, disable it until it is fixed. Pios end in the waiting list of md and get stuck there never to complete. Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c | 3 ++- 1 file changed, 2 insertio

[Devel] [RFC PATCH vz9 v5 12/49] dm-ploop: WIP move from wq to kthread

2024-11-18 Thread Alexander Atanasov
This is a base for moving to multithreaded model. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov --- drivers/md/dm-ploop-map.c| 65 drivers/md/dm-ploop-target.c | 60 + drivers/md/dm-pl