[Devel] [PATCH vz9 v2 33/65] dm-ploop: convert high_prio to status

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov convert bool high prio to status bit - reduce size and gain atomicity https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in

[Devel] [PATCH vz9 v2 62/65] dm-ploop: dm-ploop: simplify discard completion

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov ploop_advance_local_after_bat_wb is handling only one md page, so it is possible do simplify discard completion done in ploop_piwb_discard_completed. initialization overlaps and there is an extra md page lookup which can be avoided. remove the function and integrate it i

[Devel] [PATCH vz9 v2 13/65] dm-ploop: move preparations of pios into the caller from worker

2025-02-12 Thread Konstantin Khorenko
Prepare pios earlier in preparation to try to execute them earlier. Convert more places to use lock less lists. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a diffe

[Devel] [PATCH vz9 v2 63/65] dm-ploop: use GFP_ATOMIC instead of GFP_NOIO

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov GFP_NOIO can sleep so we can not use it while we are called from block layer and device mapper in interrupt context. It is also invalid under rcu_nesting which happens too. (traces in the issue) https://virtuozzo.atlassian.net/browse/VSTOR-98291 Signed-off-by: Alexander

[Devel] [PATCH vz9 v2 65/65] dm-ploop: fix how current flags are managed inside threads

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov currently threads do old_flags = current->flags; current->flags |= ploop flags; ... current->flags = old_flags; this can break process flags To fix this use current_restore_flags(..) macro which only removes our flags and it preserves any other flags. https://virtuoz

[Devel] [PATCH vz9 v2 25/65] dm-ploop: add delay for metadata writeback

2025-02-12 Thread Konstantin Khorenko
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] [PATCH vz9 v2 18/65] dm-ploop: introduce per-md page locking

2025-02-12 Thread Konstantin Khorenko
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] [PATCH vz9 v2 58/65] dm-ploop: rework logic in pio processing

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov improve how and when we wait for pios to complete before proceeding with next pios. force writing of pending md pages in case we have a sync pios. remove now unused functions. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == P

[Devel] [PATCH vz9 v2 51/65] dm-ploop: catch if we try to advance pio past bio end

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Do not advance pio past bio end - this should not happen but try to catch and log it as an error. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requs

[Devel] [PATCH vz9 v2 22/65] dm-ploop: make new allocations immediately visible in BAT

2025-02-12 Thread Konstantin Khorenko
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_ALLOC apply metadata changes immediately. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko

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

2025-02-12 Thread Konstantin Khorenko
Use llist and remove deferred_lock around pio dispatching. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which results

[Devel] [PATCH vz9 v2 46/65] dm-ploop: use lockless lists for data ready pios

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov reduce locking for data ready pios chained to bat updates https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel wh

[Devel] [PATCH vz9 v2 28/65] dm-ploop: do not use a wrapper for set_bit to make a page writeback

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov unify how MD_WRITEBACK bit is set across the code - one of the files is using a wrapper the rest of the code directly sets the bit. To avoid confusion remove the wrapper. Remove the lock and rely on atmoic bitops to make a further lock reorganization easier. https://virt

[Devel] [PATCH vz9 v2 24/65] dm-ploop: do not wait for BAT update for non-FUA requests

2025-02-12 Thread Konstantin Khorenko
From: Andrey Zhadchenko https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in perf

[Devel] [PATCH vz9 v2 64/65] dm-ploop: fix locks used in mixed context

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov These locks are used in both interrupt and user context so we must preserve interrupts state. https://virtuozzo.atlassian.net/browse/VSTOR-98471 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts i

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
On 12.02.25 11:02, Pavel Tikhomirov wrote: On 2/12/25 14:38, Alexander Atanasov wrote: On 12.02.25 7:54, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: With the locking reduced it opened windows for races between running updates, pending and new updates. Current logic

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
On 12.02.25 13:12, Pavel Tikhomirov wrote: On 2/12/25 17:42, Alexander Atanasov wrote: On 12.02.25 11:02, Pavel Tikhomirov wrote: On 2/12/25 14:38, Alexander Atanasov wrote: On 12.02.25 7:54, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: With the locking reduced i

[Devel] [PATCH vz9 v2 08/65] dm-ploop: convert enospc handling to use lockless lists

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in pe

[Devel] [PATCH vz9 v2 01/65] dm-ploop: md_pages map all pages at creation time

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov md_page is always present in memory. In that case md_page->page could be always be mapped and we would not need to perform kmap_atomic/kunmap_atomic during each lookup Convert bat updates to use kmap_local_page/kunmap_local. https://virtuozzo.atlassian.net/browse/VSTOR-

[Devel] [PATCH vz9 v2 09/65] dm-ploop: convert suspended_pios list to use lockless list

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in pe

[Devel] [PATCH vz9 v2 02/65] dm-ploop: Use READ_ONCE/WRITE_ONCE to access md page data

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Prepare to reduce locking by using atomic 32 bit access to the fields. To ensure this we need to use the _ONCE macros. https://virtuozzo.atlassian.net/browse/VSTOR-91659 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling

[Devel] [PATCH vz9 v2 05/65] dm-ploop: drop md_page.wb_link initialization

2025-02-12 Thread Konstantin Khorenko
md_page.wb_link is never a listhead, it's a list node => no list initialization is needed, list_add() will correctly initialize the data. Signed-off-by: Konstantin Khorenko --- drivers/md/dm-ploop-bat.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-

[Devel] [PATCH vz9 v2 03/65] dm-ploop: fsync after all pios are sent

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Currently there are two workers one to handle pios, one to handle flush (via vfs_fsync). This workers are created unbound which means they are run whenever there is a free CPU. When ploop sends pios (via ploop_dispatch_pios) it checks if there are data and if there are fl

[Devel] [PATCH vz9 v2 00/65] ploop optimistations and scalling

2025-02-12 Thread Konstantin Khorenko
Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in performance and makes further optimistations possible. v1: - addressed feedback, i've left a few requests to merge changes into bigger patches out, as to keep changes in smal

[Devel] [PATCH vz9 v2 04/65] dm-ploop: move md status to use proper bitops

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Fix direct bitops to use set_bit/clear_bit which are atomic - this is required since there are some places in code that do not use locking when operating on that bits. this is also a preparation to relax locking. https://virtuozzo.atlassian.net/browse/VSTOR-91820 Signed-

[Devel] [PATCH vz9 v2 06/65] dm-ploop: introduce pio.llist

2025-02-12 Thread Konstantin Khorenko
We are going to move most of pio lists to llists, so while we have in parallel situations when a pio can be added to a list or to a llist, let's have a union of both "list" and "llist". Once we remove all pio.list users, we will remove the "list" field. Signed-off-by: Konstantin Khorenko --- dr

[Devel] [PATCH vz9 v2 26/65] dm-ploop: submit all postponed metadata on REQ_OP_FLUSH

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: optimistations and sca

[Devel] [PATCH vz9 v2 42/65] dm-ploop: process pios via runners

2025-02-12 Thread Konstantin Khorenko
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] [PATCH vz9 v2 47/65] dm-ploop: give runner threads better name

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Encode device minor number into thread name. If we use dm-ploop as prefix since name gets truncated so shorten it to ploop. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scall

[Devel] [PATCH vz9 v2 54/65] dm-ploop: fix locking and improve error handling when submitting pios

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov The difference between hlist_unhashed_lockless and hlist_unhashed is that _lockless version uses READ_ONCE to do the check. Since it is used without locks we must switch to the _lockless variant. Also make locking clusters and adding to inflight_pios return result so we

[Devel] [PATCH vz9 v2 50/65] dm-ploop: use filp per thread

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov For some reason this fixed xfs issues . I do not know why yet. To be investigated. And probably reverted. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop process

[Devel] [PATCH vz9 v2 53/65] dm-ploop: proplerly access nr_bat_entries

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov nr_bat_entries are updated while resizing, some places read it without holding the bat_lock, to ensure a good value is read use READ_ONCE and WRITE_ONCE when updating. During grow/resize and shrink pios are suspended and code waits for all active inflight pios to complete

[Devel] [PATCH vz9 v2 07/65] dm-ploop: convert wait_list and wb_batch_llist to use lockless lists

2025-02-12 Thread Konstantin Khorenko
From: 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: Alexande

[Devel] [PATCH vz9 v2 41/65] dm-ploop: add pio list ids to be used when passing pios to runners

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Add specific list ids for writeback and flush pios, and process them inside the runners. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a d

[Devel] [PATCH vz9 v2 34/65] dm-ploop: split cow processing into two functions

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: op

[Devel] [PATCH vz9 v2 23/65] dm-ploop: drop ploop_cluster_is_in_top_delta()

2025-02-12 Thread Konstantin Khorenko
From: Andrey Zhadchenko as all it's users are gone or reworked https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which re

[Devel] [PATCH vz9 v2 16/65] dm-ploop: set IOCB_DSYNC on all FUA requests

2025-02-12 Thread Konstantin Khorenko
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] [PATCH vz9 v2 20/65] dm-ploop: simplify llseek

2025-02-12 Thread Konstantin Khorenko
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. Return EINVAL if it fails to find md page. https://virtuozzo.atlassian.net/bro

[Devel] [PATCH vz9 v2 17/65] dm-ploop: remove extra ploop_cluster_is_in_top_delta()

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel w

[Devel] [PATCH vz9 v2 48/65] dm-ploop: resize operation - add holes bitmap locking

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov lock bitmap in grow update header and disable delayed writeback https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in paral

[Devel] [PATCH vz9 v2 36/65] dm-ploop: convert bat_rwlock to bat_lock spinlock

2025-02-12 Thread Konstantin Khorenko
From: 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 == Patchset description: ploop: optimistat

[Devel] [PATCH vz9 v2 39/65] dm-ploop: make ploop_submit_metadata_writeback return number of requests sent

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov We need to wait for write back to complete to issue pending flushes. To know if we have to wait return numer of pios submitted. Check if we have pending pios blocked by md update. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov

[Devel] [PATCH vz9 v2 38/65] dm-ploop: make ploop_bat_write_complete ready for parallel pio completion

2025-02-12 Thread Konstantin Khorenko
From: 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

[Devel] [PATCH vz9 v2 31/65] dm-ploop: add interface to disable bat writeback delay

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Add conditions that prevent writeback delay: - if we have a pending pios - if doing utility operations we do not want to delay writeout too Add interface to disable delay. Hook it into suspend/resuming of sending pios. Which is done before ops that require it. https://v

[Devel] [PATCH vz9 v2 52/65] dm-ploop: support REQ_FUA for data pios

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov If we see a bio with REQ_FUA set we need to request a sync. https://virtuozzo.atlassian.net/browse/VSTOR-91816 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel

[Devel] [PATCH vz9 v2 49/65] dm-ploop: remove unnecessary operations

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov - no point to sync before write - no point to reverse the list order since it is resubmit and order is lost already https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Pl

[Devel] [PATCH vz9 v2 60/65] dm-ploop: make filespace preallocations async

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Move file space allocation into a separate thread, try to preallocate space in advance. On each cluster allocation check if next allocation will possibly require file space allocation and trigger the allocator thread to perform it in background. In case we try to alloca

[Devel] [PATCH vz9 v2 61/65] dm-ploop: resubmit enospc pios from dispatcher thread

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov When running out of space pios are delayed and retried from a timer. This timer is the only thing that runs in interrupt context and brings requirement to use _irqsave variants, since a complete request processing can be started from the timer. To avoid this set a flag fr

[Devel] [PATCH vz9 v2 21/65] dm-ploop: speed up ploop_prepare_bat_update()

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: optimistations and scalling

[Devel] [PATCH vz9 v2 19/65] dm-ploop: reduce BAT accesses on discard completion

2025-02-12 Thread Konstantin Khorenko
From: Andrey Zhadchenko Drop extra ploop_cluster_is_in_top_delta() as we are planning to access BAT anyway https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different

[Devel] [PATCH vz9 v2 14/65] dm-ploop: fast path execution for reads

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads

[Devel] [PATCH vz9 v2 29/65] dm-ploop: BAT use only one list for writeback

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov remove the wb_batch_list_prio, use only wb_batch_list and use the md high_prio flag for immediate submission. https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop pro

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

2025-02-12 Thread Konstantin Khorenko
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 dependency in the worker. So put both data and flush pios into prepare list. This way worker can get sing

[Devel] [PATCH vz9 v2 59/65] dm-ploop: end fsync pios in parallel

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Send all pios attached to sync operation to runners to call endio. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in pa

[Devel] [PATCH vz9 v2 43/65] dm-ploop: disable metadata writeback delay

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov 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 == Patchset description: ploop: optimistations and scalling Ploop processes requ

[Devel] [PATCH vz9 v2 57/65] dm-ploop: rework bat completion logic

2025-02-12 Thread Konstantin Khorenko
a pio may complete after md page update, in that case we must not complete the update but wait for the last data pio and only then complete them all. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalli

[Devel] [PATCH vz9 v2 27/65] dm-ploop: handle REQ_PREFLUSH

2025-02-12 Thread Konstantin Khorenko
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 == Patchset description: ploop: optimistations and scalling Ploop processes requsts in

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 14:38, Alexander Atanasov wrote: On 12.02.25 7:54, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: With the locking reduced it opened windows for races between running updates, pending and new updates. Current logic to deal with them is not correct. Examples

[Devel] [PATCH vz9 v2 35/65] dm-ploop: convert md page rw lock to spin lock

2025-02-12 Thread Konstantin Khorenko
From: 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

[Devel] [PATCH vz9 v2 15/65] dm-ploop: do not flush after metadata writes

2025-02-12 Thread Konstantin Khorenko
From: Andrey Zhadchenko Flushed should be explicitly called by the writer if he really wants it. Drop ploop_md_write_endio() and ploop_md_fsync_endio(). https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko == Patchset description: ploop: optimistations and sc

[Devel] [PATCH vz9 v2 30/65] dm-ploop: make md writeback timeout to be per page

2025-02-12 Thread Konstantin Khorenko
From: 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://vir

[Devel] [PATCH vz9 v2 45/65] dm-ploop: use lockless lists for chained cow updates list

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov reduce locking for cow pios chained to bat updates https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where pos

[Devel] [PATCH vz9 v2 56/65] dm-ploop: sync when suspended or stopping

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov On suspended or stopped sync delta. Enable use of per cpu pool cache for bio allocated from kaio. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requ

[Devel] [PATCH vz9 v2 55/65] dm-ploop: fix how ENOTBLK is handled

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov direct IO write result ENOTBLK or 0(in ext4 case) means retry IO in buffered mode. We wrongly assumed that it is a short write and handled it incorrectly Since we can not retry in buffered mode, code is not ready for it. Take a different route. This error happens if pag

[Devel] [PATCH vz9 v2 32/65] dm-ploop: convert wb_batch_list to lockless variant

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Merging required to back this change, so do it again. Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where possible which results in significant improvement i

[Devel] [PATCH vz9 v2] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
With the locking reduced it opened windows for races between running updates, pending and new updates. Current logic to deal with them is not correct. Current flags are: MD_DIRTY - means md page is dirty and is waiting for writeback MD_WRITEBACK - write back is in progress But we drop the lock aft

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
On 12.02.25 11:52, Alexander Atanasov wrote: On 12.02.25 11:50, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: @@ -2067,21 +2109,46 @@ static inline int ploop_submit_metadata_writeback(struct ploop *ploop, int force    */   llist_for_each_safe(pos, t, ll_wb_batch

[Devel] [PATCH vz9 v2 44/65] dm-ploop: disable fast path

2025-02-12 Thread Konstantin Khorenko
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. Signed-off-by: Alexander Atanasov == Pa

[Devel] [PATCH vz9 v2 37/65] dm-ploop: prepare bat updates under bat_lock

2025-02-12 Thread Konstantin Khorenko
From: 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 == Patchset des

[Devel] [PATCH vz9 v2 40/65] dm-ploop: introduce pio runner threads

2025-02-12 Thread Konstantin Khorenko
From: 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

Re: [Devel] [PATCH vz9 v2 00/65] ploop optimistations and scalling

2025-02-12 Thread Alexander Atanasov
On 12.02.25 11:32, Konstantin Khorenko wrote: Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in performance and makes further optimistations possible. v1: - addressed feedback, i've left a few requests to merge changes i

[Devel] [PATCH vz9 v2 12/65] dm-ploop: move from wq to kthread

2025-02-12 Thread Konstantin Khorenko
From: Alexander Atanasov Move to multithreaded model and remove work queue. https://virtuozzo.atlassian.net/browse/VSTOR-91821 Signed-off-by: Alexander Atanasov == Patchset description: ploop: optimistations and scalling Ploop processes requsts in a different threads in parallel where pos

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Pavel Tikhomirov
On 2/11/25 22:25, Alexander Atanasov wrote: @@ -2067,21 +2109,46 @@ static inline int ploop_submit_metadata_writeback(struct ploop *ploop, int force */ llist_for_each_safe(pos, t, ll_wb_batch) { md = list_entry((struct list_head *)pos, typeof(*md), wb_link); +

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
On 12.02.25 11:50, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: @@ -2067,21 +2109,46 @@ static inline int ploop_submit_metadata_writeback(struct ploop *ploop, int force    */   llist_for_each_safe(pos, t, ll_wb_batch) {   md = list_entry((struct list_hea

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 17:42, Alexander Atanasov wrote: If you really want to read md->piwb to piwb variable BEFORE ploop_write_cluster_sync, you should use READ_ONCE, or other appropriately used memory barrier. READ_ONCE is not a memory barrier - it is a COMPILER BARRIER. https://docs.kernel.org/co

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 17:42, Alexander Atanasov wrote: On 12.02.25 11:02, Pavel Tikhomirov wrote: On 2/12/25 14:38, Alexander Atanasov wrote: On 12.02.25 7:54, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: With the locking reduced it opened windows for races between running u

Re: [Devel] [PATCH vz9 v2 00/65] ploop optimistations and scalling

2025-02-12 Thread Alexander Atanasov
On 13.02.25 7:40, Pavel Tikhomirov wrote: On 2/12/25 17:46, Alexander Atanasov wrote: On 12.02.25 11:32, Konstantin Khorenko wrote: Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in performance and makes further optimistation

Re: [Devel] [PATCH vz9 v2 13/65] dm-ploop: move preparations of pios into the caller from worker

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 17:33, Konstantin Khorenko wrote: @@ -325,17 +322,24 @@ static int ploop_split_pio_to_list(struct ploop *ploop, struct pio *pio, if (!split) goto err; - list_add_tail(&split->list, &list); + llist_add(&split->llist, &llist)

Re: [Devel] [PATCH vz9 v2 10/65] dm-ploop: convert the rest of the lists to use llist variant

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 17:33, Konstantin Khorenko wrote: @@ -1879,20 +1906,15 @@ static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio) worker = &ploop->fsync_worker; } - spin_lock_irqsave(&ploop->deferred_lock, flags); if (unlikely(ploop->stop_sub

Re: [Devel] [PATCH vz9 v2 00/65] ploop optimistations and scalling

2025-02-12 Thread Pavel Tikhomirov
Looks good except one missed hunk. We can handle excess pio->llist.next = NULL and INIT_LIST_HEADs, and list_for_each_ENTRY_safe separately later, as those are not directly connected to this rework. note: Looks like you've accidentally over-wrote original patch authors. Reviewed-by: Pavel Ti

Re: [Devel] [PATCH vz9 v2 00/65] ploop optimistations and scalling

2025-02-12 Thread Pavel Tikhomirov
On 2/12/25 17:46, Alexander Atanasov wrote: On 12.02.25 11:32, Konstantin Khorenko wrote: Ploop processes requsts in a different threads in parallel where possible which results in significant improvement in performance and makes further optimistations possible. v1:    - addressed feedback, i

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Pavel Tikhomirov
On 2/11/25 22:25, Alexander Atanasov wrote: @@ -2607,6 +2674,7 @@ int ploop_prepare_reloc_index_wb(struct ploop *ploop, type = PIWB_TYPE_RELOC; err = -EIO; + spin_lock_irq(&ploop->bat_lock); if (test_bit(MD_DIRTY, &md->status) || test_bit(MD_WRITEBACK, &md

Re: [Devel] [PATCH vz9] dm-ploop: fix and rework md updates

2025-02-12 Thread Alexander Atanasov
On 12.02.25 10:08, Pavel Tikhomirov wrote: On 2/11/25 22:25, Alexander Atanasov wrote: @@ -2607,6 +2674,7 @@ int ploop_prepare_reloc_index_wb(struct ploop *ploop,   type = PIWB_TYPE_RELOC;   err = -EIO; +    spin_lock_irq(&ploop->bat_lock);   if (test_bit(MD_DIRTY, &md->status