qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] prealloc: add truncate mode for prealloc filter


From: Denis V. Lunev
Subject: Re: [PATCH 1/1] prealloc: add truncate mode for prealloc filter
Date: Wed, 29 May 2024 10:34:00 +0200
User-agent: Mozilla Thunderbird

On 5/29/24 04:33, Wang, Lei wrote:
On 5/1/2024 1:05, Denis V. Lunev via wrote:
Preallocate filter allows to implement really interesting setups.

Assume that we have
* shared block device, f.e. iSCSI LUN, implemented with some HW device
* clustered LVM on top of it
* QCOW2 image stored inside LVM volume

This allows very cheap clustered setups with all QCOW2 features intact.
Currently supported setups using QCOW2 with data_file option are not
so cool as snapshots are not allowed, QCOW2 should be placed into some
additional distributed storage and so on.

Though QCOW2 inside LVM volume has a drawback. The image is growing and
in order to accomodate that image LVM volume is to be resized. This
could be done externally using ENOSPACE event/condition but this is
cumbersome.

This patch introduces native implementation for such a setup. We should
just put prealloc filter in between QCOW2 format and file nodes. In that
case LVM will be resized at proper moment and that is done effectively
as resizing is done in chinks.

The patch adds allocation mode for this purpose in order to distinguish
'fallocate' for ordinary file system and 'truncate'.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
  block/preallocate.c | 50 +++++++++++++++++++++++++++++++++++++++++++--
  1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/block/preallocate.c b/block/preallocate.c
index 4d82125036..6d31627325 100644
--- a/block/preallocate.c
+++ b/block/preallocate.c
@@ -33,10 +33,24 @@
  #include "block/block-io.h"
  #include "block/block_int.h"
+typedef enum PreallocateMode {
+    PREALLOCATE_MODE_FALLOCATE = 0,
+    PREALLOCATE_MODE_TRUNCATE = 1,
+    PREALLOCATE_MODE__MAX = 2,
+} PreallocateMode;
+
+static QEnumLookup prealloc_mode_lookup = {
+    .array = (const char *const[]) {
+        "falloc",
+        "truncate",
+    },
+    .size = PREALLOCATE_MODE__MAX,
+};
typedef struct PreallocateOpts {
      int64_t prealloc_size;
      int64_t prealloc_align;
+    PreallocateMode prealloc_mode;
  } PreallocateOpts;
typedef struct BDRVPreallocateState {
@@ -79,6 +93,7 @@ typedef struct BDRVPreallocateState {
#define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align"
  #define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size"
+#define PREALLOCATE_OPT_MODE "mode"
Why not keeping the names consistent, I mean:

#define PREALLOCATE_OPT_PREALLOC_MODE "prealloc-mode"

I have had some thoughts on that, like prealloc-mode
name is already used on the generic level, but obviously
I have mistaken.

Sure thing, I'll rename to "prealloc-mode" and in the
same way in the macro on next submission.

Thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]