[Devel] [PATCH RH8 04/11] ploop: Make ploop_check_delta_length() return file_fize
Kirill Tkhai
ktkhai at virtuozzo.com
Fri May 21 11:46:23 MSK 2021
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