From: Ari Sundholm <ari@tuxera.com>
To: qemu-devel@nongnu.org
Cc: Ari Sundholm <ari@tuxera.com>, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>, Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"open list:blklogwrites" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH 3/3] block/blklogwrites: Add an option for the update interval of the log superblock
Date: Wed, 4 Jul 2018 17:46:37 +0300 [thread overview]
Message-ID: <1530715597-30975-4-git-send-email-ari@tuxera.com> (raw)
In-Reply-To: <1530715597-30975-1-git-send-email-ari@tuxera.com>
This is a way to ensure that the log superblock is periodically
updated. Before, this was only done on flush requests, which may
not be enough if the VM exits abnormally, omitting the final flush.
The default interval is 4096 write requests.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
---
block/blklogwrites.c | 19 +++++++++++++++++--
qapi/block-core.json | 6 +++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 56154e7..963e4dd 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -55,6 +55,7 @@ typedef struct {
uint32_t sectorbits;
uint64_t cur_log_sector;
uint64_t nr_entries;
+ uint64_t update_interval;
} BDRVBlkLogWritesState;
static QemuOptsList runtime_opts = {
@@ -71,6 +72,11 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_SIZE,
.help = "Log sector size",
},
+ {
+ .name = "log-super-update-interval",
+ .type = QEMU_OPT_NUMBER,
+ .help = "Log superblock update interval (# of write requests)",
+ },
{ /* end of list */ }
},
};
@@ -234,6 +240,13 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
s->sectorsize = log_sector_size;
s->sectorbits = blk_log_writes_log2(log_sector_size);
+ s->update_interval = qemu_opt_get_number(opts, "log-super-update-interval",
+ 4096);
+ if (!s->update_interval) {
+ ret = -EINVAL;
+ error_setg(errp, "Invalid log superblock update interval %"PRIu64,
+ s->update_interval);
+ }
ret = 0;
fail_log:
@@ -360,8 +373,10 @@ static void coroutine_fn blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)
lr->zero_size, 0);
}
- /* Update super block on flush */
- if (lr->log_ret == 0 && lr->entry.flags & LOG_FLUSH_FLAG) {
+ /* Update super block on flush or every update interval */
+ if (lr->log_ret == 0 && ((lr->entry.flags & LOG_FLUSH_FLAG)
+ || (s->nr_entries % s->update_interval == 0)))
+ {
struct log_write_super super = {
.magic = cpu_to_le64(WRITE_LOG_MAGIC),
.version = cpu_to_le64(WRITE_LOG_VERSION),
diff --git a/qapi/block-core.json b/qapi/block-core.json
index d1753a2..38b3125 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3057,13 +3057,17 @@
# @log-sector-size: sector size used in logging writes to @file, determines
# granularity of offsets and sizes of writes (default: 512)
#
+# @log-super-update-interval: interval of write requests after which the log
+# super block is updated to disk (default: 4096)
+#
# Since: 3.0
##
{ 'struct': 'BlockdevOptionsBlklogwrites',
'data': { 'file': 'BlockdevRef',
'log': 'BlockdevRef',
'*log-sector-size': 'uint32',
- '*log-append': 'bool' } }
+ '*log-append': 'bool',
+ '*log-super-update-interval': 'uint64' } }
##
# @BlockdevOptionsBlkverify:
--
2.7.4
prev parent reply other threads:[~2018-07-04 14:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 14:46 [Qemu-devel] [PATCH 0/3] blklogwrites improvements Ari Sundholm
2018-07-04 14:46 ` [Qemu-devel] [PATCH 1/3] block/blklogwrites: Change log_sector_size from int64_t to uint64_t Ari Sundholm
2018-07-04 14:46 ` [Qemu-devel] [PATCH 2/3] block/blklogwrites: Add an option for appending to an old log Ari Sundholm
2018-07-04 14:46 ` Ari Sundholm [this message]
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=1530715597-30975-4-git-send-email-ari@tuxera.com \
--to=ari@tuxera.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).