[Devel] [PATCH RHEL8 COMMIT] ploop: Make ploop_check_delta_length() return file_fize

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 24 12:57:20 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 803efbfa55c1fc1150b2e913e78a43f41d754a24
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 24 12:57:19 2021 +0300

    ploop: Make ploop_check_delta_length() return file_fize
    
    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-bat.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index e21eb98fcd2b..ffdd82cbc98e 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -498,14 +498,14 @@ static void apply_delta_mappings(struct ploop *ploop, struct ploop_delta *deltas
 }
 
 static int ploop_check_delta_length(struct ploop *ploop, struct file *file,
-				    u32 *size_in_clus)
+				    loff_t *file_size)
 {
 	loff_t loff = i_size_read(file->f_mapping->host);
 	unsigned int cluster_log = ploop->cluster_log;
 
 	if (loff & ((1 << (cluster_log + SECTOR_SHIFT)) - 1))
 		return -EPROTO;
-	*size_in_clus = loff >> (cluster_log + SECTOR_SHIFT);
+	*file_size = loff;
 	return 0;
 }
 
@@ -515,12 +515,13 @@ static int ploop_check_delta_length(struct ploop *ploop, struct file *file,
  */
 int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_raw)
 {
+	u32 size_in_clus, cluster_log = ploop->cluster_log;
 	struct ploop_delta *deltas = ploop->deltas;
 	struct ploop_pvd_header *hdr = NULL;
-	u32 size_in_clus;
+	loff_t file_size;
 	int ret;
 
-	ret = ploop_check_delta_length(ploop, file, &size_in_clus);
+	ret = ploop_check_delta_length(ploop, file, &file_size);
 	if (ret)
 		goto out;
 
@@ -529,6 +530,8 @@ int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_r
 		if (ret)
 			goto out;
 		size_in_clus = le32_to_cpu(hdr->m_Size);
+	} else {
+		size_in_clus = to_sector(file_size) >> cluster_log;
 	}
 
 	ret = -EBADSLT;


More information about the Devel mailing list