[Devel] [PATCH 1/1] ploop: remove unnecessary flushes from ploop/dm-ploop code
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Sep 10 13:25:55 MSK 2024
LGTM
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
On 9/9/24 19:47, Denis V. Lunev wrote:
> This patch drops vfs_flush just once the image has been fallocated.
> This is not required as fallocate returns once all internal checks
> are done and the file has been properly enlarged.
>
> In general, this follows userspace pattern. We should flush when and
> only when the guest sends barrier. It is ready to loose this data
> if something will go wrong due to the guest filesystem facilities
> like journal.
>
> Signed-off-by: Denis V. Lunev <den at openvz.org>
> CC: Alexey Kuznetsov <kuznet at virtuozzo.com>
> CC: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
> CC: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
> ---
> drivers/md/dm-ploop-map.c | 17 -----------------
> drivers/md/dm-qcow2-map.c | 17 +----------------
> 2 files changed, 1 insertion(+), 33 deletions(-)
>
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> index 33aac1a69fdf..0809867ebd3a 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -1020,12 +1020,6 @@ static int ploop_truncate_prealloc_safe(struct ploop *ploop,
> return ret;
> }
>
> - ret = vfs_fsync(file, 0);
> - if (ret) {
> - PL_ERR("%s->fsync(): %d", func, ret);
> - return ret;
> - }
> -
> delta->file_size = new_len;
> delta->file_preallocated_area_start = len;
> return 0;
> @@ -1071,17 +1065,6 @@ static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu)
> ret = ploop_truncate_prealloc_safe(ploop, top, end, __func__);
> if (ret)
> return ret;
> - } else if (pos < top->file_preallocated_area_start) {
> - /*
> - * Flush punch_hole()/zero_range() modifications.
> - * TODO: track recentry unused blocks and do that
> - * in background.
> - */
> - ret = vfs_fsync(file, 0);
> - if (ret) {
> - PL_ERR("fsync: %d", ret);
> - return ret;
> - }
> }
>
> if (end > top->file_preallocated_area_start)
> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
> index 137fb9a270cd..992a962d8eaf 100644
> --- a/drivers/md/dm-qcow2-map.c
> +++ b/drivers/md/dm-qcow2-map.c
> @@ -2141,13 +2141,7 @@ static loff_t find_unused_cluster(struct qcow2 *qcow2, struct qio **qio,
>
> int qcow2_truncate_safe(struct file *file, loff_t new_len)
> {
> - int ret;
> -
> - ret = vfs_truncate2(&file->f_path, new_len, file);
> - if (ret)
> - return ret;
> -
> - return vfs_fsync(file, 0);
> + return vfs_truncate2(&file->f_path, new_len, file);
> }
>
> static int truncate_prealloc_safe(struct qcow2 *qcow2, loff_t len, const char *func)
> @@ -2416,15 +2410,6 @@ static loff_t allocate_cluster(struct qcow2 *qcow2, struct qio *qio,
> ret = truncate_prealloc_safe(qcow2, end, __func__);
> if (ret)
> return ret;
> - } else if (pos < qcow2->file_preallocated_area_start) {
> - /*
> - * Flush punch_hole() modifications.
> - * TODO: track recentry unused blocks
> - * and punch holes in background.
> - */
> - ret = vfs_fsync(file, 0);
> - if (ret)
> - return ret;
> }
>
> if (end > qcow2->file_preallocated_area_start)
More information about the Devel
mailing list