uint32_t sectorbits;
uint64_t cur_log_sector;
uint64_t nr_entries;
+ uint64_t update_interval;
} BDRVBlkLogWritesState;
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 */ }
},
};
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);
+ goto fail_log;
+ }
ret = 0;
fail_log:
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),
# @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: