[Devel] [PATCH RHEL8 COMMIT] ploop: Kill "message snapshot" interface
Konstantin Khorenko
khorenko at virtuozzo.com
Tue May 11 18:31:00 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.27
------>
commit e6ce4cbf8187db5990cb9f6313848fad8d232873
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue May 11 18:30:59 2021 +0300
ploop: Kill "message snapshot" interface
The interface is overkill. We use special message
interfaces instead of reload only in case of userspace
touches metadata on suspended image. But in case
of snapshot this is not so (in case of reload fails,
we just continue with old delta).
https://jira.sw.ru/browse/PSBM-129258
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
ploop: Preparation to kill-loop from dm-ploop (series 4)
Currently, ploop requires underlining loop for top delta. This is overkill,
since we may submit bios directly to fs, without using it.
Initially there was a possibility, we may use device-mapper format snapshots
instead of ploop-based. But we don't do that, so we have to use loop for top
delta and directly submit bios to the rest of deltas. So, these two ways to do
the same actions are wrong.
This is preparations #3 for further series.
Let's this goes to testing earlier.
Kirill Tkhai (8):
ploop: Fix prealloc_md_pages() defaults
ploop: Move alloc wq up
ploop: Pass nr_deltas to parse_bat_entries()
ploop: Pass @ploop to md_page_cluster_is_in_top_delta()
ploop: Kill "message snapshot" interface
ploop: Introduce top_level()
ploop: Do not try to track bios on resize
ploop: Make fields in dm_ploop_endio_hook separate
https://jira.sw.ru/browse/PSBM-123654
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 99 -----------------------------------------------
drivers/md/dm-ploop-map.c | 36 +----------------
drivers/md/dm-ploop.h | 7 ----
3 files changed, 1 insertion(+), 141 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 3961155cf4fd..57ab6a867db1 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -920,99 +920,6 @@ static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
return cmd.retval;
}
-static void process_switch_top_delta(struct ploop *ploop, struct ploop_cmd *cmd)
-{
- unsigned int i, end, size, bat_clusters, *bat_entries, level = ploop->nr_deltas;
- struct rb_node *node;
- struct md_page *md;
- int ret;
-
- force_defer_bio_count_inc(ploop);
- ret = ploop_inflight_bios_ref_switch(ploop, true);
- if (ret)
- goto out;
-
- /* If you add more two-stages-actions, you must cancel them here too */
- cancel_discard_bios(ploop);
- restart_delta_cow(ploop);
-
- write_lock_irq(&ploop->bat_rwlock);
- swap(ploop->origin_dev, cmd->switch_top_delta.origin_dev);
- swap(ploop->deltas, cmd->switch_top_delta.deltas);
- ploop_for_each_md_page(ploop, md, node) {
- init_bat_entries_iter(ploop, md->id, &i, &end);
- bat_entries = kmap_atomic(md->page);
- for (; i <= end; i++) {
- if (md->bat_levels[i] == BAT_LEVEL_TOP)
- md->bat_levels[i] = level;
- }
- }
-
- /* Header and BAT-occupied clusters at start of file */
- size = (PLOOP_MAP_OFFSET + ploop->nr_bat_entries) * sizeof(map_index_t);
- bat_clusters = DIV_ROUND_UP(size, 1 << (ploop->cluster_log + 9));
- for (i = 0; i < ploop->hb_nr; i++) {
- if (i < bat_clusters)
- clear_bit(i, ploop->holes_bitmap);
- else
- set_bit(i, ploop->holes_bitmap);
- }
-
- ploop->nr_deltas++;
- write_unlock_irq(&ploop->bat_rwlock);
-out:
- force_defer_bio_count_dec(ploop);
-
- cmd->retval = ret;
- complete(&cmd->comp); /* Last touch of cmd memory */
-}
-
-/* Switch top delta to new device after userspace has created snapshot */
-static int ploop_switch_top_delta(struct ploop *ploop, int new_ro_fd,
- char *new_dev)
-{
- struct dm_target *ti = ploop->ti;
- struct ploop_cmd cmd = { {0} };
- struct file *file;
- unsigned int size;
- int ret;
-
- cmd.type = PLOOP_CMD_SWITCH_TOP_DELTA;
- cmd.ploop = ploop;
-
- if (ploop->maintaince)
- return -EBUSY;
- if (ploop->nr_deltas == BAT_LEVEL_TOP)
- return -EMFILE;
- if (!(file = fget(new_ro_fd)))
- return -EBADF;
- ret = dm_get_device(ti, new_dev, dm_table_get_mode(ti->table),
- &cmd.switch_top_delta.origin_dev);
- if (ret)
- goto fput;
- ret = -ENOMEM;
- size = (ploop->nr_deltas + 1) * sizeof(struct ploop_delta);
- cmd.switch_top_delta.deltas = kmalloc(size, GFP_NOIO);
- if (!cmd.switch_top_delta.deltas)
- goto put_dev;
- size -= sizeof(struct ploop_delta);
- memcpy(cmd.switch_top_delta.deltas, ploop->deltas, size);
- cmd.switch_top_delta.deltas[ploop->nr_deltas].file = file;
- cmd.switch_top_delta.deltas[ploop->nr_deltas].is_raw = false;
-
- init_completion(&cmd.comp);
- ploop_queue_deferred_cmd(ploop, &cmd);
- wait_for_completion(&cmd.comp);
- ret = cmd.retval;
- kfree(cmd.switch_top_delta.deltas);
-put_dev:
- dm_put_device(ploop->ti, cmd.switch_top_delta.origin_dev);
-fput:
- if (ret)
- fput(file);
- return ret;
-}
-
static void process_flip_upper_deltas(struct ploop *ploop, struct ploop_cmd *cmd)
{
unsigned int i, size, end, bat_clusters, hb_nr, *bat_entries;
@@ -1630,8 +1537,6 @@ void process_deferred_cmd(struct ploop *ploop, struct ploop_index_wb *piwb)
process_merge_latest_snapshot_cmd(ploop, cmd);
} else if (cmd->type == PLOOP_CMD_NOTIFY_DELTA_MERGED) {
process_notify_delta_merged(ploop, cmd);
- } else if (cmd->type == PLOOP_CMD_SWITCH_TOP_DELTA) {
- process_switch_top_delta(ploop, cmd);
} else if (cmd->type == PLOOP_CMD_UPDATE_DELTA_INDEX) {
process_update_delta_index(ploop, cmd);
} else if (cmd->type == PLOOP_CMD_TRACKING_START) {
@@ -1704,10 +1609,6 @@ int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
if (argc != 3 || kstrtou64(argv[1], 10, &val) < 0)
goto unlock;
ret = ploop_update_delta_index(ploop, val, argv[2]);
- } else if (!strcmp(argv[0], "snapshot")) {
- if (argc != 3 || kstrtou64(argv[1], 10, &val) < 0)
- goto unlock;
- ret = ploop_switch_top_delta(ploop, val, argv[2]);
} else if (!strncmp(argv[0], "tracking_", 9)) {
if (argc != 1)
goto unlock;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index bba578e8c219..1e8a0a1561ce 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1102,6 +1102,7 @@ static void queue_or_fail(struct ploop *ploop, int err, void *data)
{
struct bio *bio = data;
+ /* FIXME: do we use BLK_STS_AGAIN? */
if (err && err != BLK_STS_AGAIN) {
bio->bi_status = errno_to_blk_status(err);
bio_endio(bio);
@@ -1230,25 +1231,6 @@ static void process_delta_wb(struct ploop *ploop, struct ploop_index_wb *piwb)
spin_lock_irq(&ploop->deferred_lock);
}
-void restart_delta_cow(struct ploop *ploop)
-{
- struct bio_list cow_list = BIO_EMPTY_LIST;
- struct bio *cluster_bio;
- struct ploop_cow *cow;
-
- spin_lock_irq(&ploop->deferred_lock);
- bio_list_merge(&cow_list, &ploop->delta_cow_action_list);
- bio_list_init(&ploop->delta_cow_action_list);
- spin_unlock_irq(&ploop->deferred_lock);
-
- while ((cluster_bio = bio_list_pop(&cow_list)) != NULL) {
- cow = cluster_bio->bi_private;
- /* This may restart only normal cow */
- WARN_ON_ONCE(cow->end_fn != queue_or_fail);
- complete_cow(cow, BLK_STS_AGAIN);
- }
-}
-
/*
* This allocates a new cluster (if cluster wb is not pending yet),
* or tries to attach a bio to a planned page index wb.
@@ -1505,22 +1487,6 @@ static void process_discard_bios(struct ploop *ploop, struct bio_list *bios,
}
}
-void cancel_discard_bios(struct ploop *ploop)
-{
- struct bio_list bio_list = BIO_EMPTY_LIST;
- struct bio *bio;
-
- spin_lock_irq(&ploop->deferred_lock);
- bio_list_merge(&bio_list, &ploop->discard_bios);
- bio_list_init(&ploop->discard_bios);
- spin_unlock_irq(&ploop->deferred_lock);
-
- while ((bio = bio_list_pop(&bio_list)) != NULL) {
- bio->bi_status = BLK_STS_NOTSUPP;
- bio_endio(bio);
- }
-}
-
/* Remove from tree bio and endio bio chain */
void unlink_postponed_backup_endio(struct ploop *ploop,
struct bio_list *bio_list,
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 3a64522187a8..cee2a962802d 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -42,7 +42,6 @@ struct ploop_cmd {
#define PLOOP_CMD_RESIZE 1
#define PLOOP_CMD_MERGE_SNAPSHOT 3
#define PLOOP_CMD_NOTIFY_DELTA_MERGED 4
-#define PLOOP_CMD_SWITCH_TOP_DELTA 5
#define PLOOP_CMD_UPDATE_DELTA_INDEX 6
#define PLOOP_CMD_TRACKING_START 7
#define PLOOP_CMD_FLIP_UPPER_DELTAS 8
@@ -79,10 +78,6 @@ struct ploop_cmd {
u8 level;
bool forward;
} notify_delta_merged;
- struct {
- struct dm_dev *origin_dev;
- struct ploop_delta *deltas;
- } switch_top_delta;
struct {
u8 level;
const char *map;
@@ -513,8 +508,6 @@ extern int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
extern int submit_cluster_cow(struct ploop *ploop, unsigned int level,
unsigned int cluster, unsigned int dst_cluster,
void (*end_fn)(struct ploop *, int, void *), void *data);
-extern void restart_delta_cow(struct ploop *ploop);
-extern void cancel_discard_bios(struct ploop *ploop);
extern struct bio * alloc_bio_with_pages(struct ploop *ploop);
extern void free_bio_with_pages(struct ploop *ploop, struct bio *bio);
More information about the Devel
mailing list