version 1.1.1.5, 2018/04/24 18:56:49
|
version 1.1.1.6, 2018/04/24 19:17:56
|
Line 596 static int readv_f(int argc, char **argv
|
Line 596 static int readv_f(int argc, char **argv
|
|
|
nr_iov = argc - optind; |
nr_iov = argc - optind; |
buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab); |
buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab); |
|
if (buf == NULL) { |
|
return 0; |
|
} |
|
|
gettimeofday(&t1, NULL); |
gettimeofday(&t1, NULL); |
cnt = do_aio_readv(&qiov, offset, &total); |
cnt = do_aio_readv(&qiov, offset, &total); |
Line 850 static int writev_f(int argc, char **arg
|
Line 853 static int writev_f(int argc, char **arg
|
|
|
nr_iov = argc - optind; |
nr_iov = argc - optind; |
buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern); |
buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern); |
|
if (buf == NULL) { |
|
return 0; |
|
} |
|
|
gettimeofday(&t1, NULL); |
gettimeofday(&t1, NULL); |
cnt = do_aio_writev(&qiov, offset, &total); |
cnt = do_aio_writev(&qiov, offset, &total); |
Line 880 static void multiwrite_help(void)
|
Line 886 static void multiwrite_help(void)
|
" in a batch of requests that may be merged by qemu\n" |
" in a batch of requests that may be merged by qemu\n" |
"\n" |
"\n" |
" Example:\n" |
" Example:\n" |
" 'multiwrite 512 1k 1k ; 4k 1k' \n" |
" 'multiwrite 512 1k 1k ; 4k 1k'\n" |
" writes 2 kB at 512 bytes and 1 kB at 4 kB into the open file\n" |
" writes 2 kB at 512 bytes and 1 kB at 4 kB into the open file\n" |
"\n" |
"\n" |
" Writes into a segment of the currently open file, using a buffer\n" |
" Writes into a segment of the currently open file, using a buffer\n" |
Line 950 static int multiwrite_f(int argc, char *
|
Line 956 static int multiwrite_f(int argc, char *
|
} |
} |
} |
} |
|
|
reqs = qemu_malloc(nr_reqs * sizeof(*reqs)); |
reqs = g_malloc0(nr_reqs * sizeof(*reqs)); |
buf = qemu_malloc(nr_reqs * sizeof(*buf)); |
buf = g_malloc0(nr_reqs * sizeof(*buf)); |
qiovs = qemu_malloc(nr_reqs * sizeof(*qiovs)); |
qiovs = g_malloc(nr_reqs * sizeof(*qiovs)); |
|
|
for (i = 0; i < nr_reqs; i++) { |
for (i = 0; i < nr_reqs && optind < argc; i++) { |
int j; |
int j; |
|
|
/* Read the offset of the request */ |
/* Read the offset of the request */ |
offset = cvtnum(argv[optind]); |
offset = cvtnum(argv[optind]); |
if (offset < 0) { |
if (offset < 0) { |
printf("non-numeric offset argument -- %s\n", argv[optind]); |
printf("non-numeric offset argument -- %s\n", argv[optind]); |
return 0; |
goto out; |
} |
} |
optind++; |
optind++; |
|
|
if (offset & 0x1ff) { |
if (offset & 0x1ff) { |
printf("offset %lld is not sector aligned\n", |
printf("offset %lld is not sector aligned\n", |
(long long)offset); |
(long long)offset); |
return 0; |
goto out; |
} |
} |
|
|
if (i == 0) { |
if (i == 0) { |
Line 985 static int multiwrite_f(int argc, char *
|
Line 991 static int multiwrite_f(int argc, char *
|
nr_iov = j - optind; |
nr_iov = j - optind; |
|
|
/* Build request */ |
/* Build request */ |
|
buf[i] = create_iovec(&qiovs[i], &argv[optind], nr_iov, pattern); |
|
if (buf[i] == NULL) { |
|
goto out; |
|
} |
|
|
reqs[i].qiov = &qiovs[i]; |
reqs[i].qiov = &qiovs[i]; |
buf[i] = create_iovec(reqs[i].qiov, &argv[optind], nr_iov, pattern); |
|
reqs[i].sector = offset >> 9; |
reqs[i].sector = offset >> 9; |
reqs[i].nb_sectors = reqs[i].qiov->size >> 9; |
reqs[i].nb_sectors = reqs[i].qiov->size >> 9; |
|
|
optind = j + 1; |
optind = j + 1; |
|
|
offset += reqs[i].qiov->size; |
|
pattern++; |
pattern++; |
} |
} |
|
|
|
/* If there were empty requests at the end, ignore them */ |
|
nr_reqs = i; |
|
|
gettimeofday(&t1, NULL); |
gettimeofday(&t1, NULL); |
cnt = do_aio_multiwrite(reqs, nr_reqs, &total); |
cnt = do_aio_multiwrite(reqs, nr_reqs, &total); |
gettimeofday(&t2, NULL); |
gettimeofday(&t2, NULL); |
Line 1015 static int multiwrite_f(int argc, char *
|
Line 1027 static int multiwrite_f(int argc, char *
|
out: |
out: |
for (i = 0; i < nr_reqs; i++) { |
for (i = 0; i < nr_reqs; i++) { |
qemu_io_free(buf[i]); |
qemu_io_free(buf[i]); |
qemu_iovec_destroy(&qiovs[i]); |
if (reqs[i].qiov != NULL) { |
|
qemu_iovec_destroy(&qiovs[i]); |
|
} |
} |
} |
qemu_free(buf); |
g_free(buf); |
qemu_free(reqs); |
g_free(reqs); |
qemu_free(qiovs); |
g_free(qiovs); |
return 0; |
return 0; |
} |
} |
|
|
Line 1186 static int aio_read_f(int argc, char **a
|
Line 1200 static int aio_read_f(int argc, char **a
|
|
|
nr_iov = argc - optind; |
nr_iov = argc - optind; |
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab); |
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab); |
|
if (ctx->buf == NULL) { |
|
free(ctx); |
|
return 0; |
|
} |
|
|
gettimeofday(&ctx->t1, NULL); |
gettimeofday(&ctx->t1, NULL); |
acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov, |
acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov, |
Line 1249 static int aio_write_f(int argc, char **
|
Line 1267 static int aio_write_f(int argc, char **
|
case 'P': |
case 'P': |
pattern = parse_pattern(optarg); |
pattern = parse_pattern(optarg); |
if (pattern < 0) { |
if (pattern < 0) { |
|
free(ctx); |
return 0; |
return 0; |
} |
} |
break; |
break; |
Line 1280 static int aio_write_f(int argc, char **
|
Line 1299 static int aio_write_f(int argc, char **
|
|
|
nr_iov = argc - optind; |
nr_iov = argc - optind; |
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern); |
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern); |
|
if (ctx->buf == NULL) { |
|
free(ctx); |
|
return 0; |
|
} |
|
|
gettimeofday(&ctx->t1, NULL); |
gettimeofday(&ctx->t1, NULL); |
acb = bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov, |
acb = bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov, |
Line 1582 static const cmdinfo_t map_cmd = {
|
Line 1605 static const cmdinfo_t map_cmd = {
|
|
|
static int close_f(int argc, char **argv) |
static int close_f(int argc, char **argv) |
{ |
{ |
bdrv_close(bs); |
bdrv_delete(bs); |
bs = NULL; |
bs = NULL; |
return 0; |
return 0; |
} |
} |
Line 1611 static int openfile(char *name, int flag
|
Line 1634 static int openfile(char *name, int flag
|
|
|
if (bdrv_open(bs, name, flags, NULL) < 0) { |
if (bdrv_open(bs, name, flags, NULL) < 0) { |
fprintf(stderr, "%s: can't open device %s\n", progname, name); |
fprintf(stderr, "%s: can't open device %s\n", progname, name); |
|
bdrv_delete(bs); |
bs = NULL; |
bs = NULL; |
return 1; |
return 1; |
} |
} |
Line 1834 int main(int argc, char **argv)
|
Line 1858 int main(int argc, char **argv)
|
qemu_aio_flush(); |
qemu_aio_flush(); |
|
|
if (bs) { |
if (bs) { |
bdrv_close(bs); |
bdrv_delete(bs); |
} |
} |
return 0; |
return 0; |
} |
} |