[Devel] [PATCH RHEL8 COMMIT] ploop: Do not use work on resize
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jun 24 14:25:07 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.49
------>
commit 12afd6b614a1513000115abd884229eca5fd934f
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Thu Jun 24 14:25:07 2021 +0300
ploop: Do not use work on resize
Resize is made when there is no inflight reqs,
work is not needed.
Preparation for https://jira.sw.ru/browse/PSBM-124550
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 38 +++++++++-----------------------------
drivers/md/dm-ploop-map.c | 2 --
drivers/md/dm-ploop.h | 1 -
3 files changed, 9 insertions(+), 32 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 44ecdb167857..7f2affd38ca6 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -401,11 +401,8 @@ static void ploop_add_md_pages(struct ploop *ploop, struct rb_root *from)
* of disk after resize. For user they look as already written to disk,
* so be careful(!) and protective. Update indexes only after cluster
* data is written to disk.
- *
- * This is called from deferred work -- the only place we alloc clusters.
- * So, nobody can reallocate clusters updated in ploop_grow_relocate_cluster().
*/
-static void process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
+static int process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
{
struct ploop_index_wb piwb;
unsigned int dst_cluster;
@@ -413,25 +410,17 @@ static void process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
ploop_index_wb_init(&piwb, ploop);
- /*
- * Update memory arrays and hb_nr, but do not update nr_bat_entries.
- * This is noop except first enter to this function.
- */
+ /* Update memory arrays and hb_nr, but do not update nr_bat_entries. */
ploop_advance_holes_bitmap(ploop, cmd);
- if (cmd->resize.dst_cluster <= cmd->resize.end_dst_cluster) {
+ while (cmd->resize.dst_cluster <= cmd->resize.end_dst_cluster) {
ret = ploop_grow_relocate_cluster(ploop, &piwb, cmd);
if (ret)
goto out;
-
- /* Move one cluster per cmd to allow other requests. */
- ploop_queue_deferred_cmd(ploop, cmd);
- return;
- } else {
- /* Update header metadata */
- ret = ploop_grow_update_header(ploop, &piwb, cmd);
}
+ /* Update header metadata */
+ ret = ploop_grow_update_header(ploop, &piwb, cmd);
out:
write_lock_irq(&ploop->bat_rwlock);
if (ret) {
@@ -449,8 +438,7 @@ static void process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
}
write_unlock_irq(&ploop->bat_rwlock);
- cmd->retval = ret;
- complete(&cmd->comp); /* Last touch of cmd memory */
+ return ret;
}
struct pio *alloc_pio_with_pages(struct ploop *ploop)
@@ -504,6 +492,7 @@ void free_pio_with_pages(struct ploop *ploop, struct pio *pio)
}
/* @new_size is in sectors */
+/* TODO: we may delegate this to userspace */
static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
{
unsigned int nr_bat_entries, nr_old_bat_clusters, nr_bat_clusters;
@@ -576,18 +565,11 @@ static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
cmd.resize.new_sectors = new_sectors;
cmd.resize.md0 = md0;
cmd.retval = 0;
- cmd.type = PLOOP_CMD_RESIZE;
cmd.ploop = ploop;
ploop_suspend_submitting_pios(ploop);
- /* FIXME: Avoid using work */
- init_completion(&cmd.comp);
- ploop_queue_deferred_cmd(ploop, &cmd);
- wait_for_completion(&cmd.comp);
-
+ ret = process_resize_cmd(ploop, &cmd);
ploop_resume_submitting_pios(ploop);
-
- ret = cmd.retval;
err:
if (cmd.resize.pio)
free_pio_with_pages(ploop, cmd.resize.pio);
@@ -1192,9 +1174,7 @@ void process_deferred_cmd(struct ploop *ploop)
ploop->deferred_cmd = NULL;
spin_unlock_irq(&ploop->deferred_lock);
- if (cmd->type == PLOOP_CMD_RESIZE) {
- process_resize_cmd(ploop, cmd);
- } else if (cmd->type == PLOOP_CMD_MERGE_SNAPSHOT) {
+ if (cmd->type == PLOOP_CMD_MERGE_SNAPSHOT) {
process_merge_latest_snapshot_cmd(ploop, cmd);
} else {
cmd->retval = -EINVAL;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 6777e51810ac..f519a933b915 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -826,8 +826,6 @@ static int find_dst_cluster_bit(struct ploop *ploop,
{
unsigned int dst_cluster;
- WARN_ON_ONCE(!(current->flags & PF_WQ_WORKER));
-
/* Find empty cluster */
dst_cluster = find_first_bit(ploop->holes_bitmap, ploop->hb_nr);
if (dst_cluster >= ploop->hb_nr)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index ea743cc064ca..70c40a794231 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -48,7 +48,6 @@ struct ploop_delta {
};
struct ploop_cmd {
-#define PLOOP_CMD_RESIZE 1
#define PLOOP_CMD_MERGE_SNAPSHOT 3
struct completion comp;
struct ploop *ploop;
More information about the Devel
mailing list