[Devel] [PATCH RHEL8 COMMIT] ploop: Cleanup in ploop_resize()

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 24 12:57:22 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.31
------>
commit 1536ad05debfee90f72d969c01c75c0406262619
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 24 12:57:22 2021 +0300

    ploop: Cleanup in ploop_resize()
    
    Rename {old,new}_size to fit sectors content.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Truncate top delta from kernel
    
    and refactoring at tail.
    
    https://jira.sw.ru/browse/PSBM-129278
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 24 ++++++++++++------------
 drivers/md/dm-ploop.h     |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 0dd68b1f4f97..56d0de1b9339 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -348,7 +348,7 @@ static int ploop_grow_update_header(struct ploop *ploop,
 	hdr = kmap_atomic(piwb->bat_page);
 	/* TODO: head and cylinders */
 	nr_be = hdr->m_Size = cpu_to_le32(cmd->resize.nr_bat_entries);
-	sectors = hdr->m_SizeInSectors_v2 = cpu_to_le64(cmd->resize.new_size);
+	sectors = hdr->m_SizeInSectors_v2 = cpu_to_le64(cmd->resize.new_sectors);
 	offset = hdr->m_FirstBlockOffset = cpu_to_le32(first_block_off);
 	kunmap_atomic(hdr);
 
@@ -484,15 +484,15 @@ void free_pio_with_pages(struct ploop *ploop, struct pio *pio)
 }
 
 /* @new_size is in sectors */
-static int ploop_resize(struct ploop *ploop, u64 new_size)
+static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
 {
+	unsigned int hb_nr, size, old_size, cluster_log = ploop->cluster_log;
 	unsigned int nr_bat_entries, nr_old_bat_clusters, nr_bat_clusters;
-	unsigned int hb_nr, size, cluster_log = ploop->cluster_log;
 	struct ploop_cmd cmd = { .resize.md_pages_root = RB_ROOT };
 	struct ploop_pvd_header *hdr;
+	sector_t old_sectors;
 	struct md_page *md0;
 	int ret = -ENOMEM;
-	u64 old_size;
 
 	if (ploop->maintaince)
 		return -EBUSY;
@@ -503,23 +503,23 @@ static int ploop_resize(struct ploop *ploop, u64 new_size)
 	if (WARN_ON(!md0))
 		return -EIO;
 	hdr = kmap(md0->page);
-	old_size = le64_to_cpu(hdr->m_SizeInSectors_v2);
+	old_sectors = le64_to_cpu(hdr->m_SizeInSectors_v2);
 	kunmap(md0->page);
 
-	if (old_size == new_size)
+	if (old_sectors == new_sectors)
 		return 0;
-	if (old_size > new_size) {
+	if (old_sectors > new_sectors) {
 		DMWARN("online shrink is not supported");
 		return -EINVAL;
-	} else if ((new_size >> cluster_log) >= UINT_MAX - 2) {
+	} else if ((new_sectors >> cluster_log) >= UINT_MAX - 2) {
 		DMWARN("resize: too large size is requested");
 		return -EINVAL;
-	} else if (new_size & ((1 << cluster_log) - 1)) {
-		DMWARN("resize: new_size is not aligned");
+	} else if (new_sectors & ((1 << cluster_log) - 1)) {
+		DMWARN("resize: new_sectors is not aligned");
 		return -EINVAL;
 	}
 
-	nr_bat_entries = (new_size >> cluster_log);
+	nr_bat_entries = new_sectors >> cluster_log;
 
 	/* Memory for new md pages */
 	if (prealloc_md_pages(&cmd.resize.md_pages_root,
@@ -553,7 +553,7 @@ static int ploop_resize(struct ploop *ploop, u64 new_size)
 	cmd.resize.nr_old_bat_clu = nr_old_bat_clusters;
 	cmd.resize.nr_bat_entries = nr_bat_entries;
 	cmd.resize.hb_nr = hb_nr;
-	cmd.resize.new_size = new_size;
+	cmd.resize.new_sectors = new_sectors;
 	cmd.resize.md0 = md0;
 	cmd.retval = 0;
 	cmd.type = PLOOP_CMD_RESIZE;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index a53abd0a041e..a0faffe2d0e6 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -55,7 +55,7 @@ struct ploop_cmd {
 	int retval;
 	union {
 		struct {
-			u64 new_size;
+			sector_t new_sectors;
 			/* Preallocated data */
 			struct rb_root md_pages_root;
 			struct md_page *md0;


More information about the Devel mailing list