[Devel] [PATCH RH8 2/4] ploop: Pass level directly in ploop_add_delta()
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 5 13:11:15 MSK 2021
Do not manipulate nr_deltas in ploop_add_delta().
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 12 ++++--------
drivers/md/dm-ploop-target.c | 5 ++++-
drivers/md/dm-ploop.h | 2 +-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index fd2b841e540c..135427c759dd 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -410,15 +410,14 @@ int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
}
static int apply_delta_mappings(struct ploop *ploop, struct ploop_delta *deltas,
- void *hdr, u64 size_in_clus)
+ u32 level, void *hdr, u64 size_in_clus)
{
map_index_t *bat_entries, *delta_bat_entries;
- unsigned int i, end, level, dst_cluster;
+ unsigned int i, end, dst_cluster;
struct rb_node *node;
struct md_page *md;
bool is_raw;
- level = ploop->nr_deltas;
/* Points to hdr since md_page[0] also contains hdr. */
delta_bat_entries = (map_index_t *)hdr;
is_raw = deltas[level].is_raw;
@@ -457,8 +456,6 @@ static int apply_delta_mappings(struct ploop *ploop, struct ploop_delta *deltas,
kunmap_atomic(bat_entries);
delta_bat_entries += PAGE_SIZE / sizeof(map_index_t);
}
-
- ploop->nr_deltas++;
write_unlock_irq(&ploop->bat_rwlock);
get_file(ploop->deltas[level].file);
@@ -481,10 +478,9 @@ static int ploop_check_delta_length(struct ploop *ploop, struct file *file,
* @fd refers to a new delta, which is placed right before top_delta.
* So, userspace has to populate deltas stack from oldest to newest.
*/
-int ploop_add_delta(struct ploop *ploop, int fd, bool is_raw)
+int ploop_add_delta(struct ploop *ploop, u32 level, int fd, bool is_raw)
{
struct ploop_delta *deltas = ploop->deltas;
- unsigned int level = ploop->nr_deltas;
struct file *file;
u64 size_in_clus;
void *hdr = NULL;
@@ -509,7 +505,7 @@ int ploop_add_delta(struct ploop *ploop, int fd, bool is_raw)
if (ret)
goto out;
- ret = apply_delta_mappings(ploop, deltas, hdr, size_in_clus);
+ ret = apply_delta_mappings(ploop, deltas, level, hdr, size_in_clus);
out:
vfree(hdr);
fput(file);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 37e581f2997f..4e5f5adba40e 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -120,6 +120,7 @@ static int ploop_add_deltas_stack(struct ploop *ploop, char **argv, int argc)
int i, delta_fd, ret = 0;
const char *arg;
bool is_raw;
+ u32 level;
if (!argc)
goto out;
@@ -146,9 +147,11 @@ static int ploop_add_deltas_stack(struct ploop *ploop, char **argv, int argc)
if (kstrtos32(arg, 10, &delta_fd) < 0)
goto out;
- ret = ploop_add_delta(ploop, delta_fd, is_raw);
+ level = ploop->nr_deltas;
+ ret = ploop_add_delta(ploop, level, delta_fd, is_raw);
if (ret < 0)
goto out;
+ ploop->nr_deltas++;
}
ret = 0;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 54baa1aa0229..1eeac9ca064d 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -487,7 +487,7 @@ extern void free_md_pages_tree(struct rb_root *root);
extern bool try_update_bat_entry(struct ploop *ploop, unsigned int cluster,
u8 level, unsigned int dst_cluster);
-extern int ploop_add_delta(struct ploop *ploop, int fd, bool is_raw);
+extern int ploop_add_delta(struct ploop *ploop, u32 level, int fd, bool is_raw);
extern void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bio_list);
extern void do_ploop_work(struct work_struct *ws);
extern void process_deferred_cmd(struct ploop *ploop,
More information about the Devel
mailing list