[Devel] [PATCH RH8 02/22] ploop: Add md and piwb cross pointers
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 30 13:33:02 MSK 2021
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 1 +
drivers/md/dm-ploop-map.c | 14 +++++++++++++-
drivers/md/dm-ploop.h | 2 ++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 602842b2440c..b445663c8be6 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -81,6 +81,7 @@ static struct md_page * alloc_md_page(unsigned int id)
INIT_LIST_HEAD(&md->wait_list);
md->bat_levels = levels;
+ md->piwb = NULL;
md->page = page;
md->id = id;
return md;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index a2737e9beac3..8b2fc152eb77 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -44,6 +44,7 @@ void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop)
piwb->ploop = ploop;
init_completion(&piwb->comp);
spin_lock_init(&piwb->lock);
+ piwb->md = NULL;
piwb->bat_page = NULL;
piwb->bi_status = 0;
INIT_LIST_HEAD(&piwb->ready_data_pios);
@@ -642,8 +643,8 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
struct ploop_index_wb *piwb,
bool success)
{
- struct md_page *md = md_page_find(ploop, piwb->page_id);
unsigned int i, last, *bat_entries;
+ struct md_page *md = piwb->md;
map_index_t *dst_clu, off;
unsigned long flags;
LIST_HEAD(list);
@@ -778,6 +779,11 @@ static int ploop_prepare_bat_update(struct ploop *ploop, unsigned int page_id,
BUG_ON(!md);
bat_entries = kmap_atomic(md->page);
+ write_lock_irq(&ploop->bat_rwlock);
+ md->piwb = piwb;
+ piwb->md = md;
+ write_unlock_irq(&ploop->bat_rwlock);
+
piwb->page_id = page_id;
to = kmap_atomic(page);
memcpy((void *)to, bat_entries, PAGE_SIZE);
@@ -816,6 +822,12 @@ static int ploop_prepare_bat_update(struct ploop *ploop, unsigned int page_id,
void ploop_reset_bat_update(struct ploop_index_wb *piwb)
{
struct ploop *ploop = piwb->ploop;
+ unsigned long flags;
+
+ write_lock_irqsave(&ploop->bat_rwlock, flags);
+ piwb->md->piwb = NULL;
+ piwb->md = NULL;
+ write_unlock_irqrestore(&ploop->bat_rwlock, flags);
put_page(piwb->bat_page);
ploop_index_wb_init(piwb, ploop);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 698da3f887e4..879d7c5b25e7 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -96,6 +96,7 @@ struct ploop_index_wb {
struct completion comp;
enum piwb_type type;
spinlock_t lock;
+ struct md_page *md;
struct page *bat_page;
struct list_head ready_data_pios;
struct list_head cow_list;
@@ -112,6 +113,7 @@ struct md_page {
struct page *page;
u8 *bat_levels;
struct list_head wait_list;
+ struct ploop_index_wb *piwb;
};
enum {
More information about the Devel
mailing list