[Devel] [RFC PATCH vz9 v5 36/49] dm-ploop: debug patch , keep on top of stack
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Mon Nov 18 09:25:03 MSK 2024
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
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/drivers/md/dm-ploop-map.c
index 574ed9045c2d..4587b2c19df9 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -71,6 +71,7 @@ void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop)
piwb->flush_pio = NULL;
}
+static unsigned long pio_seqno;
void ploop_init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio)
{
pio->ploop = ploop;
@@ -91,6 +92,7 @@ void ploop_init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio)
/* FIXME: assign real clu? */
pio->clu = UINT_MAX;
pio->level = BAT_LEVEL_INVALID;
+ pio->seqno = pio_seqno++;
}
/* Check that rq end byte is not behind end of device */
@@ -216,13 +218,15 @@ static void ploop_do_pio_endio(struct pio *pio)
void *endio_cb_data = pio->endio_cb_data;
bool free_on_endio = pio->free_on_endio;
+ // if (free_on_endio) printk(KERN_ERR "pend:%ld rem:%d\n", pio->seqno, atomic_read(&pio->remaining));
if (!atomic_dec_and_test(&pio->remaining))
return;
endio_cb(pio, endio_cb_data, pio->bi_status);
-
- if (free_on_endio)
+ if (free_on_endio) {
+ // printk(KERN_ERR "fpio:%ld\n", pio->seqno);
ploop_free_pio(pio->ploop, pio);
+ }
}
void ploop_pio_endio(struct pio *pio)
@@ -241,6 +245,7 @@ static void ploop_pio_chain_endio(struct pio *pio, void *parent_ptr,
if (unlikely(bi_status))
parent->bi_status = bi_status;
+ // printk(KERN_ERR "chain endio:%ld\n", pio->seqno);
ploop_do_pio_endio(parent);
}
@@ -252,6 +257,7 @@ static void ploop_pio_chain(struct pio *pio, struct pio *parent)
pio->endio_cb_data = parent;
pio->endio_cb = ploop_pio_chain_endio;
atomic_inc(&parent->remaining);
+ // printk(KERN_ERR "chain:%ld rem:%d\n", pio->seqno, atomic_read(&parent->remaining));
}
/* Clone of bio_advance_iter() */
@@ -345,6 +351,7 @@ ALLOW_ERROR_INJECTION(ploop_split_pio_to_list, ERRNO);
static void ploop_schedule_work(struct ploop *ploop)
{
#ifndef USE_KTHREAD
+#warning Need to flush delayed md pages
queue_work(ploop->wq, &ploop->worker);
#else
wake_up_process(ploop->kt_worker->task);
@@ -361,6 +368,7 @@ static void ploop_dispatch_pio(struct ploop *ploop, struct pio *pio)
if (pio->queue_list_id == PLOOP_LIST_FLUSH)
list = (struct llist_head *)&ploop->pios[PLOOP_LIST_PREPARE];
+ // printk(KERN_ERR "disp: %ld q:%d", pio->seqno, pio->queue_list_id);
llist_add((struct llist_node *)(&pio->list), list);
}
@@ -392,6 +400,7 @@ static bool ploop_delay_if_md_busy(struct ploop *ploop, struct md_page *md,
if (piwb && (piwb->type != type || test_bit(MD_WRITEBACK, &md->status))) {
llist_add((struct llist_node *)(&pio->list), &md->wait_llist);
busy = true;
+ printk(KERN_ERR "p:%ld delay\n", pio->seqno);
}
read_unlock_irqrestore(&md->lock, flags);
@@ -835,21 +844,29 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
wait_llist_pending = llist_del_all(&md->wait_llist);
if (wait_llist_pending) {
+ printk(KERN_ERR "mdwb:mlist");
llist_for_each_safe(pos, t, wait_llist_pending) {
pio = list_entry((struct list_head *)pos, typeof(*pio), list);
list_add(&pio->list, &list);
+ printk(KERN_ERR "resume:%ld\n", pio->seqno);
}
}
- if (!list_empty(&list))
+ if (!list_empty(&list)) {
+ printk(KERN_ERR "mdwb:slist");
ploop_dispatch_pios(ploop, NULL, &list);
+ }
}
static void ploop_free_piwb(struct ploop_index_wb *piwb)
{
- kunmap(piwb->kmpage);
+ WARN_ON(!piwb);
+ if (!piwb) return;
+ if (piwb->kmpage)
+ kunmap(piwb->kmpage);
ploop_free_pio(piwb->ploop, piwb->pio);
- put_page(piwb->bat_page);
+ if (piwb->bat_page)
+ put_page(piwb->bat_page);
kfree(piwb);
}
@@ -918,8 +935,13 @@ static void ploop_bat_write_complete(struct pio *pio, void *piwb_ptr,
}
if (flush_pio) {
- if (atomic_dec_and_test(&flush_pio->md_inflight))
+ if (atomic_dec_and_test(&flush_pio->md_inflight)) {
+ printk(KERN_ERR "fl rdy:%ld\n", flush_pio->seqno);
ploop_dispatch_pios(ploop, flush_pio, NULL);
+ } else {
+ printk(KERN_ERR "fl %ld seqno:%ld\n", atomic_read(&flush_pio->md_inflight), flush_pio->seqno);
+ }
+
piwb->flush_pio = NULL;
}
@@ -1792,10 +1814,12 @@ static void ploop_process_one_discard_pio(struct ploop *ploop, struct pio *pio)
ploop_md_make_dirty(ploop, md);
ploop_md_up_prio(ploop, md);
out:
+ // printk(KERN_ERR "disc:2:%ld\n", pio->seqno);
return;
err:
if (bat_update_prepared)
ploop_break_bat_update(ploop, md);
+ // printk(KERN_ERR "disc:3:%ld\n", pio->seqno);
ploop_pio_endio(pio);
}
@@ -1857,6 +1881,7 @@ static void ploop_submit_metadata_writeback(struct ploop *ploop)
clear_bit(MD_HIGHPRIO, &md->status);
ploop_index_wb_submit(ploop, md->piwb);
} else {
+ printk(KERN_ERR "abwbl\n");
llist_add((struct llist_node *)&md->wb_link, &ploop->wb_batch_llist);
}
}
@@ -1869,6 +1894,7 @@ static void process_ploop_fsync_work(struct ploop *ploop, struct llist_node *llf
int ret;
struct llist_node *pos, *t;
+ // printk(KERN_ERR "ploop:vfs_sync\n");
file = ploop_top_delta(ploop)->file;
/* All flushes are done as one */
ret = vfs_fsync(file, 0);
@@ -2025,6 +2051,7 @@ static int ploop_prepare_flush(struct ploop *ploop, struct pio *pio)
atomic_set(&flush_pio->md_inflight, md_inflight);
write_unlock_irq(&ploop->bat_rwlock);
+ if (md_inflight) printk(KERN_ERR "md_inf:%d\n", md_inflight);
return md_inflight;
}
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index d2dfc4389050..eff445e2dd95 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -20,6 +20,8 @@
#include <linux/vmalloc.h>
#include <linux/uio.h>
#include <linux/error-injection.h>
+#include <linux/llist.h>
+#include <linux/hashtable.h>
#include "dm-ploop.h"
#define DM_MSG_PREFIX "ploop"
@@ -159,10 +161,30 @@ static bool ploop_empty_htable(struct hlist_head head[])
return true;
}
+static void print_ploop_lists(struct ploop *ploop)
+{
+#ifdef PLOOP_DEBUG
+ int i;
+
+ for (i = 0; i < PLOOP_LIST_COUNT; i++) {
+ printk(KERN_ERR "list:%d %d\n", i, !!llist_empty(&ploop->pios[i]));
+ }
+ printk(KERN_ERR "lk_list: %d\n", !!list_empty(&ploop->cluster_lk_list));
+ printk(KERN_ERR "susp: %d\n", !!llist_empty(&ploop->llsuspended_pios));
+ printk(KERN_ERR "nospcs: %d\n", !!llist_empty(&ploop->enospc_pios));
+ if (ploop->inflight_pios)
+ printk(KERN_ERR "inflht: %d\n", !!ploop_empty_htable(ploop->exclusive_pios));
+ if (ploop->exclusive_pios)
+ printk(KERN_ERR "excls: %d\n", !!ploop_empty_htable(ploop->inflight_pios));
+#endif
+}
+
+
static void ploop_destroy(struct ploop *ploop)
{
int i;
+ print_ploop_lists(ploop);
if (ploop->wq) {
flush_workqueue(ploop->wq);
destroy_workqueue(ploop->wq);
@@ -189,6 +211,7 @@ static void ploop_destroy(struct ploop *ploop)
// TODO: check if any pios left and end them with error
kfree(ploop->kt_worker);
}
+ print_ploop_lists(ploop);
for (i = 0; i < 2; i++)
percpu_ref_exit(&ploop->inflight_bios_ref[i]);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index e369d223da91..b605d37196dc 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -305,6 +305,8 @@ struct pio {
void *data;
atomic_t md_inflight;
+
+ unsigned long seqno;
};
/* Delta COW private */
--
2.43.0
More information about the Devel
mailing list