[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 65/69] qemu-io: Add 'write -z -u' to test MAY_UNMAP f
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 65/69] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag |
Date: |
Thu, 12 May 2016 16:35:45 +0200 |
From: Eric Blake <address@hidden>
Make it easier to control whether the BDRV_REQ_MAY_UNMAP flag
can be passed through a write_zeroes command, by adding the '-u'
flag to qemu-io 'write -z' and 'aio_write -z'. To be useful,
the device has to be opened with BDRV_O_UNMAP (done by default
in qemu-io, but can be made explicit with '-d unmap').
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
qemu-io-cmds.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 71ae8d0..4a00bc6 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -943,6 +943,7 @@ static void write_help(void)
" -P, -- use different pattern to fill file\n"
" -C, -- report statistics in a machine parsable format\n"
" -q, -- quiet mode, do not show I/O statistics\n"
+" -u, -- with -z, allow unmapping\n"
" -z, -- write zeroes using blk_co_write_zeroes\n"
"\n");
}
@@ -955,7 +956,7 @@ static const cmdinfo_t write_cmd = {
.cfunc = write_f,
.argmin = 2,
.argmax = -1,
- .args = "[-bcCfqz] [-P pattern] off len",
+ .args = "[-bcCfquz] [-P pattern] off len",
.oneline = "writes a number of bytes at a specified offset",
.help = write_help,
};
@@ -974,7 +975,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
int64_t total = 0;
int pattern = 0xcd;
- while ((c = getopt(argc, argv, "bcCfpP:qz")) != -1) {
+ while ((c = getopt(argc, argv, "bcCfpP:quz")) != -1) {
switch (c) {
case 'b':
bflag = true;
@@ -1001,6 +1002,9 @@ static int write_f(BlockBackend *blk, int argc, char
**argv)
case 'q':
qflag = true;
break;
+ case 'u':
+ flags |= BDRV_REQ_MAY_UNMAP;
+ break;
case 'z':
zflag = true;
break;
@@ -1023,6 +1027,11 @@ static int write_f(BlockBackend *blk, int argc, char
**argv)
return 0;
}
+ if ((flags & BDRV_REQ_MAY_UNMAP) && !zflag) {
+ printf("-u requires -z to be specified\n");
+ return 0;
+ }
+
if (zflag && Pflag) {
printf("-z and -P cannot be specified at the same time\n");
return 0;
@@ -1561,6 +1570,7 @@ static void aio_write_help(void)
" -C, -- report statistics in a machine parsable format\n"
" -f, -- use Force Unit Access semantics\n"
" -q, -- quiet mode, do not show I/O statistics\n"
+" -u, -- with -z, allow unmapping\n"
" -z, -- write zeroes using blk_aio_write_zeroes\n"
"\n");
}
@@ -1572,7 +1582,7 @@ static const cmdinfo_t aio_write_cmd = {
.cfunc = aio_write_f,
.argmin = 2,
.argmax = -1,
- .args = "[-Cfqz] [-P pattern] off len [len..]",
+ .args = "[-Cfquz] [-P pattern] off len [len..]",
.oneline = "asynchronously writes a number of bytes",
.help = aio_write_help,
};
@@ -1596,6 +1606,9 @@ static int aio_write_f(BlockBackend *blk, int argc, char
**argv)
case 'q':
ctx->qflag = true;
break;
+ case 'u':
+ flags |= BDRV_REQ_MAY_UNMAP;
+ break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
@@ -1623,6 +1636,11 @@ static int aio_write_f(BlockBackend *blk, int argc, char
**argv)
return 0;
}
+ if ((flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) {
+ printf("-u requires -z to be specified\n");
+ return 0;
+ }
+
if (ctx->zflag && ctx->Pflag) {
printf("-z and -P cannot be specified at the same time\n");
g_free(ctx);
--
1.8.3.1
- [Qemu-devel] [PULL 55/69] iotests: fix the redirection order in 083, (continued)
- [Qemu-devel] [PULL 55/69] iotests: fix the redirection order in 083, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 64/69] qemu-io: Add 'write -f' to test FUA flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 67/69] block: add support for encryption secrets in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 41/69] sd: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 56/69] qemu-img: check block status of backing file when converting., Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 53/69] block: Drop superfluous invalidating bs->file from drivers, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 57/69] Add new block driver interface to add/delete a BDS's child, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 54/69] block: Inactivate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 65/69] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag,
Kevin Wolf <=
- [Qemu-devel] [PULL 62/69] qemu-io: Use bool for command line flags, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 58/69] quorum: implement bdrv_add_child() and bdrv_del_child(), Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 61/69] qemu-io: Make 'open' subcommand more like command line, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 60/69] qemu-io: Add missing option documentation, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 68/69] block: enable testing of LUKS driver with block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 63/69] qemu-io: Allow unaligned access by default, Kevin Wolf, 2016/05/12
- Re: [Qemu-devel] [PULL 00/69] Block layer patches, Peter Maydell, 2016/05/12