[Devel] [RFC PATCH vz9 v6 34/62] dm-ploop: convert high_prio to status
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Dec 6 00:56:07 MSK 2024
convert bool high prio to status bit - reduce size and gain atomicity
https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 1 -
drivers/md/dm-ploop-map.c | 9 ++++-----
drivers/md/dm-ploop.h | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 1171294841a7..a6202720927f 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -88,7 +88,6 @@ static struct md_page *ploop_alloc_md_page(u32 id)
md->page = page;
md->kmpage = kmap(page);
md->id = id;
- md->high_prio = false;
rwlock_init(&md->lock);
return md;
err_page:
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 722a1fbf499e..ad500df411c7 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -573,10 +573,9 @@ static void ploop_md_up_prio(struct ploop *ploop, struct md_page *md)
write_lock_irqsave(&ploop->bat_rwlock, flags);
if (test_bit(MD_WRITEBACK, &md->status))
goto out;
- if (md->high_prio)
+ if (test_and_set_bit(MD_HIGHPRIO, &md->status))
goto out;
- md->high_prio = true;
WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
out:
write_unlock_irqrestore(&ploop->bat_rwlock, flags);
@@ -1846,14 +1845,14 @@ static void ploop_submit_metadata_writeback(struct ploop *ploop)
llist_for_each_safe(pos, t, ll_wb_batch) {
md = list_entry((struct list_head *)pos, typeof(*md), wb_link);
INIT_LIST_HEAD(&md->wb_link);
- if (md->high_prio || ktime_after(md->dirty_time, ktimeout)
+ if (test_bit(MD_HIGHPRIO, &md->status) || ktime_after(md->dirty_time, ktimeout)
|| ploop->force_md_writeback) {
/* L1L2 mustn't be redirtyed, when wb in-flight! */
WARN_ON_ONCE(!test_bit(MD_DIRTY, &md->status));
WARN_ON_ONCE(test_bit(MD_WRITEBACK, &md->status));
- md->high_prio = false;
set_bit(MD_WRITEBACK, &md->status);
clear_bit(MD_DIRTY, &md->status);
+ clear_bit(MD_HIGHPRIO, &md->status);
ploop_index_wb_submit(ploop, md->piwb);
} else {
llist_add((struct llist_node *)&md->wb_link, &ploop->wb_batch_llist);
@@ -2018,7 +2017,7 @@ static int ploop_prepare_flush(struct ploop *ploop, struct pio *pio)
md = list_entry((struct list_head *)pos, typeof(*md), wb_link);
md_inflight++;
md->piwb->flush_pio = flush_pio;
- md->high_prio = true;
+ set_bit(MD_HIGHPRIO, &md->status);
}
atomic_set(&flush_pio->md_inflight, md_inflight);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 1ecd51f2ac3a..8dfd75e97845 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -118,6 +118,7 @@ struct md_page {
u32 id; /* Number of this page starting from hdr */
#define MD_DIRTY (1U << 1) /* Page contains changes and wants writeback */
#define MD_WRITEBACK (1U << 2) /* Writeback was submitted */
+#define MD_HIGHPRIO (1U << 3) /* High priority writeback */
unsigned long status;
struct page *page;
void *kmpage;
@@ -129,7 +130,6 @@ struct md_page {
rwlock_t lock;
- bool high_prio;
ktime_t dirty_time;
};
--
2.43.0
More information about the Devel
mailing list