[Devel] [RFC PATCH vz9 v6 07/62] dm-ploop: convert wait_list and wb_batch_llist to use lockless lists
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Jan 9 08:32:05 MSK 2025
On 12/6/24 05:55, Alexander Atanasov wrote:
> @@ -1758,22 +1767,18 @@ static void ploop_process_resubmit_pios(struct ploop *ploop,
> static void ploop_submit_metadata_writeback(struct ploop *ploop)
> {
> struct md_page *md;
> - while (1) {
> - write_lock_irq(&ploop->bat_rwlock);
> - md = list_first_entry_or_null(&ploop->wb_batch_list,
> - struct md_page, wb_link);
> - if (!md) {
> - write_unlock_irq(&ploop->bat_rwlock);
> - break;
> - }
> - list_del_init(&md->wb_link);
> - /* L1L2 mustn't be redirtyed, when wb in-flight! */
> + struct md_page *t;
> + struct llist_node *wbl;
> +
> + wbl = llist_del_all(&ploop->wb_batch_llist);
> + if (!wbl)
> + return;
> + wbl = llist_reverse_order(wbl);
> + llist_for_each_entry_safe(md, t, wbl, wb_llink) {
Why do we need _safe version here? Noone can delete from wbl at this point.
> WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
> WARN_ON_ONCE(test_bit(MD_WRITEBACK, &md->status));
> set_bit(MD_WRITEBACK, &md->status);
> clear_bit(MD_DIRTY, &md->status);
> - write_unlock_irq(&ploop->bat_rwlock);
> -
> ploop_index_wb_submit(ploop, md->piwb);
> }
> }
--
Best regards, Tikhomirov Pavel
Senior Software Developer, Virtuozzo.
More information about the Devel
mailing list