]>
Commit | Line | Data |
---|---|---|
bfcc224e AV |
1 | /* |
2 | * Write logging blk driver based on blkverify and blkdebug. | |
3 | * | |
4 | * Copyright (c) 2017 Tuomas Tynkkynen <[email protected]> | |
5 | * Copyright (c) 2018 Aapo Vienamo <[email protected]> | |
6 | * Copyright (c) 2018 Ari Sundholm <[email protected]> | |
7 | * | |
8 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
9 | * See the COPYING file in the top-level directory. | |
10 | */ | |
11 | ||
12 | #include "qemu/osdep.h" | |
13 | #include "qapi/error.h" | |
14 | #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ | |
15 | #include "block/block_int.h" | |
16 | #include "qapi/qmp/qdict.h" | |
17 | #include "qapi/qmp/qstring.h" | |
18 | #include "qemu/cutils.h" | |
19 | #include "qemu/option.h" | |
20 | ||
21 | /* Disk format stuff - taken from Linux drivers/md/dm-log-writes.c */ | |
22 | ||
23 | #define LOG_FLUSH_FLAG (1 << 0) | |
24 | #define LOG_FUA_FLAG (1 << 1) | |
25 | #define LOG_DISCARD_FLAG (1 << 2) | |
26 | #define LOG_MARK_FLAG (1 << 3) | |
0878b3c1 AS |
27 | #define LOG_FLAG_MASK (LOG_FLUSH_FLAG \ |
28 | | LOG_FUA_FLAG \ | |
29 | | LOG_DISCARD_FLAG \ | |
30 | | LOG_MARK_FLAG) | |
bfcc224e AV |
31 | |
32 | #define WRITE_LOG_VERSION 1ULL | |
33 | #define WRITE_LOG_MAGIC 0x6a736677736872ULL | |
34 | ||
35 | /* All fields are little-endian. */ | |
36 | struct log_write_super { | |
37 | uint64_t magic; | |
38 | uint64_t version; | |
39 | uint64_t nr_entries; | |
40 | uint32_t sectorsize; | |
41 | } QEMU_PACKED; | |
42 | ||
43 | struct log_write_entry { | |
44 | uint64_t sector; | |
45 | uint64_t nr_sectors; | |
46 | uint64_t flags; | |
47 | uint64_t data_len; | |
48 | } QEMU_PACKED; | |
49 | ||
50 | /* End of disk format structures. */ | |
51 | ||
52 | typedef struct { | |
53 | BdrvChild *log_file; | |
54 | uint32_t sectorsize; | |
55 | uint32_t sectorbits; | |
56 | uint64_t cur_log_sector; | |
57 | uint64_t nr_entries; | |
1dce698e | 58 | uint64_t update_interval; |
bfcc224e AV |
59 | } BDRVBlkLogWritesState; |
60 | ||
61 | static QemuOptsList runtime_opts = { | |
62 | .name = "blklogwrites", | |
63 | .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | |
64 | .desc = { | |
0878b3c1 AS |
65 | { |
66 | .name = "log-append", | |
67 | .type = QEMU_OPT_BOOL, | |
68 | .help = "Append to an existing log", | |
69 | }, | |
bfcc224e AV |
70 | { |
71 | .name = "log-sector-size", | |
72 | .type = QEMU_OPT_SIZE, | |
73 | .help = "Log sector size", | |
74 | }, | |
1dce698e AS |
75 | { |
76 | .name = "log-super-update-interval", | |
77 | .type = QEMU_OPT_NUMBER, | |
78 | .help = "Log superblock update interval (# of write requests)", | |
79 | }, | |
bfcc224e AV |
80 | { /* end of list */ } |
81 | }, | |
82 | }; | |
83 | ||
84 | static inline uint32_t blk_log_writes_log2(uint32_t value) | |
85 | { | |
86 | assert(value > 0); | |
87 | return 31 - clz32(value); | |
88 | } | |
89 | ||
0878b3c1 AS |
90 | static inline bool blk_log_writes_sector_size_valid(uint32_t sector_size) |
91 | { | |
92 | return sector_size < (1ull << 24) && is_power_of_2(sector_size); | |
93 | } | |
94 | ||
95 | static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log, | |
96 | uint32_t sector_size, | |
97 | uint64_t nr_entries, | |
98 | Error **errp) | |
99 | { | |
100 | uint64_t cur_sector = 1; | |
101 | uint64_t cur_idx = 0; | |
102 | uint32_t sector_bits = blk_log_writes_log2(sector_size); | |
103 | struct log_write_entry cur_entry; | |
104 | ||
105 | while (cur_idx < nr_entries) { | |
106 | int read_ret = bdrv_pread(log, cur_sector << sector_bits, &cur_entry, | |
107 | sizeof(cur_entry)); | |
108 | if (read_ret < 0) { | |
109 | error_setg_errno(errp, -read_ret, | |
110 | "Failed to read log entry %"PRIu64, cur_idx); | |
111 | return (uint64_t)-1ull; | |
112 | } | |
113 | ||
114 | if (cur_entry.flags & ~cpu_to_le64(LOG_FLAG_MASK)) { | |
115 | error_setg(errp, "Invalid flags 0x%"PRIx64" in log entry %"PRIu64, | |
116 | le64_to_cpu(cur_entry.flags), cur_idx); | |
117 | return (uint64_t)-1ull; | |
118 | } | |
119 | ||
120 | /* Account for the sector of the entry itself */ | |
121 | ++cur_sector; | |
122 | ||
123 | /* | |
124 | * Account for the data of the write. | |
125 | * For discards, this data is not present. | |
126 | */ | |
127 | if (!(cur_entry.flags & cpu_to_le64(LOG_DISCARD_FLAG))) { | |
128 | cur_sector += le64_to_cpu(cur_entry.nr_sectors); | |
129 | } | |
130 | ||
131 | ++cur_idx; | |
132 | } | |
133 | ||
134 | return cur_sector; | |
135 | } | |
136 | ||
bfcc224e AV |
137 | static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, |
138 | Error **errp) | |
139 | { | |
140 | BDRVBlkLogWritesState *s = bs->opaque; | |
141 | QemuOpts *opts; | |
142 | Error *local_err = NULL; | |
143 | int ret; | |
2dacaf7c | 144 | uint64_t log_sector_size; |
0878b3c1 | 145 | bool log_append; |
bfcc224e AV |
146 | |
147 | opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); | |
148 | qemu_opts_absorb_qdict(opts, options, &local_err); | |
149 | if (local_err) { | |
150 | ret = -EINVAL; | |
151 | error_propagate(errp, local_err); | |
152 | goto fail; | |
153 | } | |
154 | ||
155 | /* Open the file */ | |
156 | bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, | |
157 | &local_err); | |
158 | if (local_err) { | |
159 | ret = -EINVAL; | |
160 | error_propagate(errp, local_err); | |
161 | goto fail; | |
162 | } | |
163 | ||
bfcc224e AV |
164 | /* Open the log file */ |
165 | s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false, | |
166 | &local_err); | |
167 | if (local_err) { | |
168 | ret = -EINVAL; | |
169 | error_propagate(errp, local_err); | |
170 | goto fail; | |
171 | } | |
172 | ||
0878b3c1 AS |
173 | log_append = qemu_opt_get_bool(opts, "log-append", false); |
174 | ||
175 | if (log_append) { | |
176 | struct log_write_super log_sb = { 0, 0, 0, 0 }; | |
177 | ||
178 | if (qemu_opt_find(opts, "log-sector-size")) { | |
179 | ret = -EINVAL; | |
180 | error_setg(errp, "log-append and log-sector-size are mutually " | |
181 | "exclusive"); | |
182 | goto fail_log; | |
183 | } | |
184 | ||
185 | /* Read log superblock or fake one for an empty log */ | |
186 | if (!bdrv_getlength(s->log_file->bs)) { | |
187 | log_sb.magic = cpu_to_le64(WRITE_LOG_MAGIC); | |
188 | log_sb.version = cpu_to_le64(WRITE_LOG_VERSION); | |
189 | log_sb.nr_entries = cpu_to_le64(0); | |
190 | log_sb.sectorsize = cpu_to_le32(BDRV_SECTOR_SIZE); | |
191 | } else { | |
192 | ret = bdrv_pread(s->log_file, 0, &log_sb, sizeof(log_sb)); | |
193 | if (ret < 0) { | |
194 | error_setg_errno(errp, -ret, "Could not read log superblock"); | |
195 | goto fail_log; | |
196 | } | |
197 | } | |
198 | ||
199 | if (log_sb.magic != cpu_to_le64(WRITE_LOG_MAGIC)) { | |
200 | ret = -EINVAL; | |
201 | error_setg(errp, "Invalid log superblock magic"); | |
202 | goto fail_log; | |
203 | } | |
204 | ||
205 | if (log_sb.version != cpu_to_le64(WRITE_LOG_VERSION)) { | |
206 | ret = -EINVAL; | |
207 | error_setg(errp, "Unsupported log version %"PRIu64, | |
208 | le64_to_cpu(log_sb.version)); | |
209 | goto fail_log; | |
210 | } | |
211 | ||
212 | log_sector_size = le32_to_cpu(log_sb.sectorsize); | |
213 | s->cur_log_sector = 1; | |
214 | s->nr_entries = 0; | |
215 | ||
216 | if (blk_log_writes_sector_size_valid(log_sector_size)) { | |
217 | s->cur_log_sector = | |
218 | blk_log_writes_find_cur_log_sector(s->log_file, log_sector_size, | |
219 | le64_to_cpu(log_sb.nr_entries), &local_err); | |
220 | if (local_err) { | |
221 | ret = -EINVAL; | |
222 | error_propagate(errp, local_err); | |
223 | goto fail_log; | |
224 | } | |
225 | ||
226 | s->nr_entries = le64_to_cpu(log_sb.nr_entries); | |
227 | } | |
228 | } else { | |
229 | log_sector_size = qemu_opt_get_size(opts, "log-sector-size", | |
230 | BDRV_SECTOR_SIZE); | |
231 | s->cur_log_sector = 1; | |
232 | s->nr_entries = 0; | |
233 | } | |
234 | ||
235 | if (!blk_log_writes_sector_size_valid(log_sector_size)) { | |
236 | ret = -EINVAL; | |
237 | error_setg(errp, "Invalid log sector size %"PRIu64, log_sector_size); | |
238 | goto fail_log; | |
239 | } | |
240 | ||
241 | s->sectorsize = log_sector_size; | |
242 | s->sectorbits = blk_log_writes_log2(log_sector_size); | |
1dce698e AS |
243 | s->update_interval = qemu_opt_get_number(opts, "log-super-update-interval", |
244 | 4096); | |
245 | if (!s->update_interval) { | |
246 | ret = -EINVAL; | |
247 | error_setg(errp, "Invalid log superblock update interval %"PRIu64, | |
248 | s->update_interval); | |
249 | goto fail_log; | |
250 | } | |
0878b3c1 | 251 | |
bfcc224e | 252 | ret = 0; |
0878b3c1 AS |
253 | fail_log: |
254 | if (ret < 0) { | |
255 | bdrv_unref_child(bs, s->log_file); | |
256 | s->log_file = NULL; | |
257 | } | |
bfcc224e AV |
258 | fail: |
259 | if (ret < 0) { | |
260 | bdrv_unref_child(bs, bs->file); | |
261 | bs->file = NULL; | |
262 | } | |
263 | qemu_opts_del(opts); | |
264 | return ret; | |
265 | } | |
266 | ||
267 | static void blk_log_writes_close(BlockDriverState *bs) | |
268 | { | |
269 | BDRVBlkLogWritesState *s = bs->opaque; | |
270 | ||
271 | bdrv_unref_child(bs, s->log_file); | |
272 | s->log_file = NULL; | |
273 | } | |
274 | ||
275 | static int64_t blk_log_writes_getlength(BlockDriverState *bs) | |
276 | { | |
277 | return bdrv_getlength(bs->file->bs); | |
278 | } | |
279 | ||
280 | static void blk_log_writes_refresh_filename(BlockDriverState *bs, | |
281 | QDict *options) | |
282 | { | |
283 | BDRVBlkLogWritesState *s = bs->opaque; | |
284 | ||
285 | /* bs->file->bs has already been refreshed */ | |
286 | bdrv_refresh_filename(s->log_file->bs); | |
287 | ||
288 | if (bs->file->bs->full_open_options | |
289 | && s->log_file->bs->full_open_options) | |
290 | { | |
291 | QDict *opts = qdict_new(); | |
292 | qdict_put_str(opts, "driver", "blklogwrites"); | |
293 | ||
294 | qobject_ref(bs->file->bs->full_open_options); | |
295 | qdict_put_obj(opts, "file", QOBJECT(bs->file->bs->full_open_options)); | |
296 | qobject_ref(s->log_file->bs->full_open_options); | |
297 | qdict_put_obj(opts, "log", | |
298 | QOBJECT(s->log_file->bs->full_open_options)); | |
299 | qdict_put_int(opts, "log-sector-size", s->sectorsize); | |
300 | ||
301 | bs->full_open_options = opts; | |
302 | } | |
303 | } | |
304 | ||
305 | static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c, | |
306 | const BdrvChildRole *role, | |
307 | BlockReopenQueue *ro_q, | |
308 | uint64_t perm, uint64_t shrd, | |
309 | uint64_t *nperm, uint64_t *nshrd) | |
310 | { | |
311 | if (!c) { | |
312 | *nperm = perm & DEFAULT_PERM_PASSTHROUGH; | |
313 | *nshrd = (shrd & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHANGED; | |
314 | return; | |
315 | } | |
316 | ||
317 | if (!strcmp(c->name, "log")) { | |
318 | bdrv_format_default_perms(bs, c, role, ro_q, perm, shrd, nperm, nshrd); | |
319 | } else { | |
320 | bdrv_filter_default_perms(bs, c, role, ro_q, perm, shrd, nperm, nshrd); | |
321 | } | |
322 | } | |
323 | ||
324 | static void blk_log_writes_refresh_limits(BlockDriverState *bs, Error **errp) | |
325 | { | |
326 | BDRVBlkLogWritesState *s = bs->opaque; | |
327 | bs->bl.request_alignment = s->sectorsize; | |
328 | } | |
329 | ||
330 | static int coroutine_fn | |
331 | blk_log_writes_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | |
332 | QEMUIOVector *qiov, int flags) | |
333 | { | |
334 | return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); | |
335 | } | |
336 | ||
337 | typedef struct BlkLogWritesFileReq { | |
338 | BlockDriverState *bs; | |
339 | uint64_t offset; | |
340 | uint64_t bytes; | |
341 | int file_flags; | |
342 | QEMUIOVector *qiov; | |
343 | int (*func)(struct BlkLogWritesFileReq *r); | |
344 | int file_ret; | |
345 | } BlkLogWritesFileReq; | |
346 | ||
347 | typedef struct { | |
348 | BlockDriverState *bs; | |
349 | QEMUIOVector *qiov; | |
350 | struct log_write_entry entry; | |
351 | uint64_t zero_size; | |
352 | int log_ret; | |
353 | } BlkLogWritesLogReq; | |
354 | ||
355 | static void coroutine_fn blk_log_writes_co_do_log(BlkLogWritesLogReq *lr) | |
356 | { | |
357 | BDRVBlkLogWritesState *s = lr->bs->opaque; | |
358 | uint64_t cur_log_offset = s->cur_log_sector << s->sectorbits; | |
359 | ||
360 | s->nr_entries++; | |
361 | s->cur_log_sector += | |
362 | ROUND_UP(lr->qiov->size, s->sectorsize) >> s->sectorbits; | |
363 | ||
364 | lr->log_ret = bdrv_co_pwritev(s->log_file, cur_log_offset, lr->qiov->size, | |
365 | lr->qiov, 0); | |
366 | ||
367 | /* Logging for the "write zeroes" operation */ | |
368 | if (lr->log_ret == 0 && lr->zero_size) { | |
369 | cur_log_offset = s->cur_log_sector << s->sectorbits; | |
370 | s->cur_log_sector += | |
371 | ROUND_UP(lr->zero_size, s->sectorsize) >> s->sectorbits; | |
372 | ||
373 | lr->log_ret = bdrv_co_pwrite_zeroes(s->log_file, cur_log_offset, | |
374 | lr->zero_size, 0); | |
375 | } | |
376 | ||
1dce698e AS |
377 | /* Update super block on flush or every update interval */ |
378 | if (lr->log_ret == 0 && ((lr->entry.flags & LOG_FLUSH_FLAG) | |
379 | || (s->nr_entries % s->update_interval == 0))) | |
380 | { | |
bfcc224e AV |
381 | struct log_write_super super = { |
382 | .magic = cpu_to_le64(WRITE_LOG_MAGIC), | |
383 | .version = cpu_to_le64(WRITE_LOG_VERSION), | |
384 | .nr_entries = cpu_to_le64(s->nr_entries), | |
385 | .sectorsize = cpu_to_le32(s->sectorsize), | |
386 | }; | |
387 | void *zeroes = g_malloc0(s->sectorsize - sizeof(super)); | |
388 | QEMUIOVector qiov; | |
389 | ||
390 | qemu_iovec_init(&qiov, 2); | |
391 | qemu_iovec_add(&qiov, &super, sizeof(super)); | |
392 | qemu_iovec_add(&qiov, zeroes, s->sectorsize - sizeof(super)); | |
393 | ||
394 | lr->log_ret = | |
395 | bdrv_co_pwritev(s->log_file, 0, s->sectorsize, &qiov, 0); | |
396 | if (lr->log_ret == 0) { | |
397 | lr->log_ret = bdrv_co_flush(s->log_file->bs); | |
398 | } | |
399 | qemu_iovec_destroy(&qiov); | |
400 | g_free(zeroes); | |
401 | } | |
402 | } | |
403 | ||
404 | static void coroutine_fn blk_log_writes_co_do_file(BlkLogWritesFileReq *fr) | |
405 | { | |
406 | fr->file_ret = fr->func(fr); | |
407 | } | |
408 | ||
409 | static int coroutine_fn | |
410 | blk_log_writes_co_log(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | |
411 | QEMUIOVector *qiov, int flags, | |
412 | int (*file_func)(BlkLogWritesFileReq *r), | |
413 | uint64_t entry_flags, bool is_zero_write) | |
414 | { | |
415 | QEMUIOVector log_qiov; | |
416 | size_t niov = qiov ? qiov->niov : 0; | |
417 | BDRVBlkLogWritesState *s = bs->opaque; | |
418 | BlkLogWritesFileReq fr = { | |
419 | .bs = bs, | |
420 | .offset = offset, | |
421 | .bytes = bytes, | |
422 | .file_flags = flags, | |
423 | .qiov = qiov, | |
424 | .func = file_func, | |
425 | }; | |
426 | BlkLogWritesLogReq lr = { | |
427 | .bs = bs, | |
428 | .qiov = &log_qiov, | |
429 | .entry = { | |
430 | .sector = cpu_to_le64(offset >> s->sectorbits), | |
431 | .nr_sectors = cpu_to_le64(bytes >> s->sectorbits), | |
432 | .flags = cpu_to_le64(entry_flags), | |
433 | .data_len = 0, | |
434 | }, | |
435 | .zero_size = is_zero_write ? bytes : 0, | |
436 | }; | |
437 | void *zeroes = g_malloc0(s->sectorsize - sizeof(lr.entry)); | |
438 | ||
439 | assert((1 << s->sectorbits) == s->sectorsize); | |
440 | assert(bs->bl.request_alignment == s->sectorsize); | |
441 | assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); | |
442 | assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); | |
443 | ||
444 | qemu_iovec_init(&log_qiov, niov + 2); | |
445 | qemu_iovec_add(&log_qiov, &lr.entry, sizeof(lr.entry)); | |
446 | qemu_iovec_add(&log_qiov, zeroes, s->sectorsize - sizeof(lr.entry)); | |
447 | if (qiov) { | |
448 | qemu_iovec_concat(&log_qiov, qiov, 0, qiov->size); | |
449 | } | |
450 | ||
451 | blk_log_writes_co_do_file(&fr); | |
452 | blk_log_writes_co_do_log(&lr); | |
453 | ||
454 | qemu_iovec_destroy(&log_qiov); | |
455 | g_free(zeroes); | |
456 | ||
457 | if (lr.log_ret < 0) { | |
458 | return lr.log_ret; | |
459 | } | |
460 | ||
461 | return fr.file_ret; | |
462 | } | |
463 | ||
464 | static int coroutine_fn | |
465 | blk_log_writes_co_do_file_pwritev(BlkLogWritesFileReq *fr) | |
466 | { | |
467 | return bdrv_co_pwritev(fr->bs->file, fr->offset, fr->bytes, | |
468 | fr->qiov, fr->file_flags); | |
469 | } | |
470 | ||
471 | static int coroutine_fn | |
472 | blk_log_writes_co_do_file_pwrite_zeroes(BlkLogWritesFileReq *fr) | |
473 | { | |
474 | return bdrv_co_pwrite_zeroes(fr->bs->file, fr->offset, fr->bytes, | |
475 | fr->file_flags); | |
476 | } | |
477 | ||
478 | static int coroutine_fn blk_log_writes_co_do_file_flush(BlkLogWritesFileReq *fr) | |
479 | { | |
480 | return bdrv_co_flush(fr->bs->file->bs); | |
481 | } | |
482 | ||
483 | static int coroutine_fn | |
484 | blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq *fr) | |
485 | { | |
486 | return bdrv_co_pdiscard(fr->bs->file->bs, fr->offset, fr->bytes); | |
487 | } | |
488 | ||
489 | static int coroutine_fn | |
490 | blk_log_writes_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | |
491 | QEMUIOVector *qiov, int flags) | |
492 | { | |
493 | return blk_log_writes_co_log(bs, offset, bytes, qiov, flags, | |
494 | blk_log_writes_co_do_file_pwritev, 0, false); | |
495 | } | |
496 | ||
497 | static int coroutine_fn | |
498 | blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, | |
499 | BdrvRequestFlags flags) | |
500 | { | |
501 | return blk_log_writes_co_log(bs, offset, bytes, NULL, flags, | |
502 | blk_log_writes_co_do_file_pwrite_zeroes, 0, | |
503 | true); | |
504 | } | |
505 | ||
506 | static int coroutine_fn blk_log_writes_co_flush_to_disk(BlockDriverState *bs) | |
507 | { | |
508 | return blk_log_writes_co_log(bs, 0, 0, NULL, 0, | |
509 | blk_log_writes_co_do_file_flush, | |
510 | LOG_FLUSH_FLAG, false); | |
511 | } | |
512 | ||
513 | static int coroutine_fn | |
514 | blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) | |
515 | { | |
516 | return blk_log_writes_co_log(bs, offset, count, NULL, 0, | |
517 | blk_log_writes_co_do_file_pdiscard, | |
518 | LOG_DISCARD_FLAG, false); | |
519 | } | |
520 | ||
521 | static BlockDriver bdrv_blk_log_writes = { | |
522 | .format_name = "blklogwrites", | |
523 | .instance_size = sizeof(BDRVBlkLogWritesState), | |
524 | ||
525 | .bdrv_open = blk_log_writes_open, | |
526 | .bdrv_close = blk_log_writes_close, | |
527 | .bdrv_getlength = blk_log_writes_getlength, | |
528 | .bdrv_refresh_filename = blk_log_writes_refresh_filename, | |
529 | .bdrv_child_perm = blk_log_writes_child_perm, | |
530 | .bdrv_refresh_limits = blk_log_writes_refresh_limits, | |
531 | ||
532 | .bdrv_co_preadv = blk_log_writes_co_preadv, | |
533 | .bdrv_co_pwritev = blk_log_writes_co_pwritev, | |
534 | .bdrv_co_pwrite_zeroes = blk_log_writes_co_pwrite_zeroes, | |
535 | .bdrv_co_flush_to_disk = blk_log_writes_co_flush_to_disk, | |
536 | .bdrv_co_pdiscard = blk_log_writes_co_pdiscard, | |
537 | .bdrv_co_block_status = bdrv_co_block_status_from_file, | |
538 | ||
539 | .is_filter = true, | |
540 | }; | |
541 | ||
542 | static void bdrv_blk_log_writes_init(void) | |
543 | { | |
544 | bdrv_register(&bdrv_blk_log_writes); | |
545 | } | |
546 | ||
547 | block_init(bdrv_blk_log_writes_init); |