[Devel] [PATCH RH8 10/10] ploop: Reread file size after index update
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 30 19:47:02 MSK 2021
Userspace uses this interface to notify us
it makes grow on intermediate delta. This
grow may also result in file size increase,
so here we reread it.
In scope of: https://jira.sw.ru/browse/PSBM-131202
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 3 +--
drivers/md/dm-ploop-cmd.c | 11 +++++++++++
drivers/md/dm-ploop.h | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index b07dc87cf3e9..f55956aab5a7 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -481,8 +481,7 @@ static void apply_delta_mappings(struct ploop *ploop, struct ploop_delta *deltas
write_unlock_irq(&ploop->bat_rwlock);
}
-static int ploop_check_delta_length(struct ploop *ploop, struct file *file,
- loff_t *file_size)
+int ploop_check_delta_length(struct ploop *ploop, struct file *file, loff_t *file_size)
{
loff_t loff = i_size_read(file->f_mapping->host);
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 87517ed7ef1a..64e46d1b39f0 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -866,6 +866,8 @@ static int ploop_get_delta_name_cmd(struct ploop *ploop, u8 level,
static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
const char *map)
{
+ struct ploop_delta *delta;
+ loff_t file_size;
int ret;
if (ploop->maintaince)
@@ -877,8 +879,17 @@ static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
if (ret)
goto out;
+ delta = &ploop->deltas[level];
+ /* Index update may go together with file size increase */
+ ret = ploop_check_delta_length(ploop, delta->file, &file_size);
+ if (ret)
+ goto resume;
+ delta->file_size = file_size;
+ delta->file_preallocated_area_start = file_size;
+
ret = process_update_delta_index(ploop, level, map);
+resume:
ploop_resume_submitting_pios(ploop);
out:
return ret;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 5bc3cb7c78b6..3746443c3325 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -532,6 +532,7 @@ extern bool try_update_bat_entry(struct ploop *ploop, u32 clu,
extern int convert_bat_entries(struct ploop *ploop, u32 *bat_entries, u32 count);
extern int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_raw);
+extern int ploop_check_delta_length(struct ploop *ploop, struct file *file, loff_t *file_size);
extern void dispatch_pios(struct ploop *ploop, struct pio *pio, struct list_head *pio_list);
extern void do_ploop_work(struct work_struct *ws);
extern void do_ploop_fsync_work(struct work_struct *ws);
More information about the Devel
mailing list