[Devel] [PATCH RHEL8 COMMIT] ploop: Reread file size after index update

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 2 22:48:02 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.51
------>
commit ae3e06b5ed9517b01fa41b9aa8f7bb06a7b3ce4b
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Jul 2 22:48:02 2021 +0300

    ploop: Reread file size after index update
    
    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>
    
    ==========================
    ploop: Split pios in kwork
    
    https://jira.sw.ru/browse/PSBM-131208
    
    Kirill Tkhai (10):
          ploop: Remove debug noinline in create_bvec_from_rq()
          ploop: Manage flush pios in generic way
          ploop: Teach dispatch_pios() work with flush pios
          ploop: Make split_pios_to_list() to add initial pio to the list too
          ploop: Introduce embedded_pio_to_prq()
          ploop: Introduce ploop_prq_valid()
          ploop: Move create_bvec_from_rq() up
          ploop: Split pios from kwork context
          ploop: Add sanity check of passed BAT from disk
          ploop: Reread file size after index update
---
 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