From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 08/93] gluster: Add support for creating zero-filled image
Date: Fri, 24 Jan 2014 18:20:51 +0100 [thread overview]
Message-ID: <1390584136-24703-9-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1390584136-24703-1-git-send-email-kwolf@redhat.com>
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
GlusterFS supports creation of zero-filled file on GlusterFS volume
by means of an API called glfs_zerofill(). Use this API from QEMU to
create an image that is filled with zeroes by using the preallocation
option of qemu-img.
qemu-img create gluster://server/volume/image -o preallocation=full 10G
The allowed values for preallocation are 'full' and 'off'. By default
preallocation is off and image is not zero-filled.
glfs_zerofill() offloads the writing of zeroes to the server and if
the storage supports SCSI WRITESAME, GlusterFS server can issue
BLKZEROOUT ioctl to achieve the zeroing.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/gluster.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/block/gluster.c b/block/gluster.c
index c11f60c..a009b15 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -354,6 +354,29 @@ out:
g_slice_free(GlusterAIOCB, acb);
return ret;
}
+
+static inline bool gluster_supports_zerofill(void)
+{
+ return 1;
+}
+
+static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
+ int64_t size)
+{
+ return glfs_zerofill(fd, offset, size);
+}
+
+#else
+static inline bool gluster_supports_zerofill(void)
+{
+ return 0;
+}
+
+static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
+ int64_t size)
+{
+ return 0;
+}
#endif
static int qemu_gluster_create(const char *filename,
@@ -362,6 +385,7 @@ static int qemu_gluster_create(const char *filename,
struct glfs *glfs;
struct glfs_fd *fd;
int ret = 0;
+ int prealloc = 0;
int64_t total_size = 0;
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
@@ -374,6 +398,19 @@ static int qemu_gluster_create(const char *filename,
while (options && options->name) {
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
total_size = options->value.n / BDRV_SECTOR_SIZE;
+ } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) {
+ if (!options->value.s || !strcmp(options->value.s, "off")) {
+ prealloc = 0;
+ } else if (!strcmp(options->value.s, "full") &&
+ gluster_supports_zerofill()) {
+ prealloc = 1;
+ } else {
+ error_setg(errp, "Invalid preallocation mode: '%s'"
+ " or GlusterFS doesn't support zerofill API",
+ options->value.s);
+ ret = -EINVAL;
+ goto out;
+ }
}
options++;
}
@@ -383,9 +420,15 @@ static int qemu_gluster_create(const char *filename,
if (!fd) {
ret = -errno;
} else {
- if (glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE) != 0) {
+ if (!glfs_ftruncate(fd, total_size * BDRV_SECTOR_SIZE)) {
+ if (prealloc && qemu_gluster_zerofill(fd, 0,
+ total_size * BDRV_SECTOR_SIZE)) {
+ ret = -errno;
+ }
+ } else {
ret = -errno;
}
+
if (glfs_close(fd) != 0) {
ret = -errno;
}
@@ -560,6 +603,11 @@ static QEMUOptionParameter qemu_gluster_create_options[] = {
.type = OPT_SIZE,
.help = "Virtual disk size"
},
+ {
+ .name = BLOCK_OPT_PREALLOC,
+ .type = OPT_STRING,
+ .help = "Preallocation mode (allowed values: off, full)"
+ },
{ NULL }
};
--
1.8.1.4
next prev parent reply other threads:[~2014-01-24 17:22 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 17:20 [Qemu-devel] [PULL v2 00/93] Block patches Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 01/93] rbd: switch from pipe to QEMUBH completion notification Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 02/93] qemu-iotests: Introduce _unsupported_imgopts Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 03/93] qemu-iotests: Add _unsupported_imgopts for vmdk subformats Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 04/93] qemu-iotests: Clean up all extents for vmdk Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 05/93] block/iscsi: return -ENOMEM if an async call fails immediately Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 06/93] gluster: Convert aio routines into coroutines Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 07/93] gluster: Implement .bdrv_co_write_zeroes for gluster Kevin Wolf
2014-01-24 17:20 ` Kevin Wolf [this message]
2014-01-24 17:20 ` [Qemu-devel] [PULL 09/93] sheepdog: fix clone operation by 'qemu-img create -b' Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 10/93] qtest: Fix the bug about disable vnc causes "make check" fail Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 11/93] docs: qcow2 compat=1.1 is now the default Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 12/93] vmdk: Fix big flat extent IO Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 13/93] readline: decouple readline from the monitor Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 14/93] readline: move readline to a generic location Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 15/93] osdep: add qemu_set_tty_echo() Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 16/93] qemu-io: use readline.c Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 17/93] qemu-io: add command completion Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 18/93] blkdebug: Use errp for read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 19/93] blkdebug: Don't require sophisticated filename Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 20/93] qdict: Add qdict_array_split() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 21/93] qapi: extend qdict_flatten() for QLists Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 22/93] qemu-option: Add qemu_config_parse_qdict() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 23/93] blkdebug: Always call read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 24/93] blkdebug: Use command-line in read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 25/93] block: Allow reference for bdrv_file_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 26/93] block: Pass reference to bdrv_file_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 27/93] block: Allow block devices without files Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 28/93] block: Add bdrv_open_image() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 29/93] block: Use bdrv_open_image() in bdrv_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 30/93] block: Allow recursive "file"s Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 31/93] blockdev: Move "file" to legacy_opts Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 32/93] blkdebug: Allow command-line file configuration Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 33/93] blkverify: Allow command-line configuration Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 34/93] blkverify: Don't require protocol filename Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 35/93] qapi: Add "errno" to the list of polluted words Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 36/93] qapi: QMP interface for blkdebug and blkverify Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 37/93] qemu-io: Make filename optional Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 38/93] tests: Add test for qdict_array_split() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 39/93] tests: Add test for qdict_flatten() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 40/93] iotests: Test new blkdebug/blkverify interface Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 41/93] iotests: Test file format nesting Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 42/93] block: fix backing file segfault Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 43/93] dataplane: fix shadowed return value Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 44/93] qcow2: fix wrong value of L1E_OFFSET_MASK, L2E_OFFSET_MASK and REFT_OFFSET_MASK Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 45/93] vmdk: Check for overhead when opening Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 46/93] qemu-progress: Drop unused include Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 47/93] qemu-progress: Fix progress printing on SIGUSR1 Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 48/93] Documentation: qemu-img: Mention SIGUSR1 progress report Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 49/93] sheepdog: fix 'qemu-img map' Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 50/93] drive mirror:fix memory leak Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 51/93] vmdk: Fix format specific information (create type) for streamOptimized Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 52/93] qapi: Add "backing" to BlockStats Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 53/93] block: Add bs->node_name to hold the name of a bs node of the bs graph Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 54/93] block: Allow the user to define "node-name" option both on command line and QMP Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 55/93] qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 56/93] qmp: Allow to change password on named block driver states Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 57/93] block: Create authorizations mechanism for external snapshot and resize Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 58/93] qmp: Allow block_resize to manipulate bs graph nodes Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 59/93] qmp: Allow to take external snapshots on bs graphs node Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 60/93] block/curl: Implement the libcurl timer callback interface Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 61/93] block: resize backing file image during offline commit, if necessary Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 62/93] block: resize backing image during active layer commit, if needed Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 63/93] block: update block commit documentation regarding image truncation Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 64/93] block: Fix bdrv_commit return value Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 65/93] block: Move initialisation of BlockLimits to bdrv_refresh_limits() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 66/93] block: Inherit opt_transfer_length Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 67/93] block: Update BlockLimits when they might have changed Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 68/93] qemu_memalign: Allow small alignments Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 69/93] block: Detect unaligned length in bdrv_qiov_is_aligned() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 70/93] block: Don't use guest sector size for qemu_blockalign() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 71/93] block: rename buffer_alignment to guest_block_size Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 72/93] raw: Probe required direct I/O alignment Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 73/93] block: Introduce bdrv_aligned_preadv() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 74/93] block: Introduce bdrv_co_do_preadv() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 75/93] block: Introduce bdrv_aligned_pwritev() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 76/93] block: write: Handle COR dependency after I/O throttling Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 77/93] block: Introduce bdrv_co_do_pwritev() Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 78/93] block: Switch BdrvTrackedRequest to byte granularity Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 79/93] block: Allow waiting for overlapping requests between begin/end Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 80/93] block: Make zero-after-EOF work with larger alignment Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 81/93] block: Generalise and optimise COR serialisation Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 82/93] block: Make overlap range for serialisation dynamic Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 83/93] block: Allow wait_serialising_requests() at any point Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 84/93] block: Align requests in bdrv_co_do_pwritev() Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 85/93] block: Assert serialisation assumptions in pwritev Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 86/93] block: Change coroutine wrapper to byte granularity Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 87/93] block: Make bdrv_pread() a bdrv_prwv_co() wrapper Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 88/93] block: Make bdrv_pwrite() " Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 89/93] iscsi: Set bs->request_alignment Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 90/93] blkdebug: Make required alignment configurable Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 91/93] qemu-io: New command 'sleep' Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 92/93] qemu-iotests: Test pwritev RMW logic Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 93/93] block: Switch bdrv_io_limits_intercept() to byte granularity Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1390584136-24703-9-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).