blob: 6a9261351848ba7e3272de48a51d100345a45a7f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2003 Sistina Software
3 *
4 * This file is released under the LGPL.
5 */
6
7#include <linux/init.h>
8#include <linux/slab.h>
9#include <linux/module.h>
10#include <linux/vmalloc.h>
11
12#include "dm-log.h"
13#include "dm-io.h"
14
Alasdair G Kergon72d94862006-06-26 00:27:35 -070015#define DM_MSG_PREFIX "mirror log"
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017static LIST_HEAD(_log_types);
18static DEFINE_SPINLOCK(_lock);
19
20int dm_register_dirty_log_type(struct dirty_log_type *type)
21{
22 spin_lock(&_lock);
23 type->use_count = 0;
24 list_add(&type->list, &_log_types);
25 spin_unlock(&_lock);
26
27 return 0;
28}
29
30int dm_unregister_dirty_log_type(struct dirty_log_type *type)
31{
32 spin_lock(&_lock);
33
34 if (type->use_count)
35 DMWARN("Attempt to unregister a log type that is still in use");
36 else
37 list_del(&type->list);
38
39 spin_unlock(&_lock);
40
41 return 0;
42}
43
44static struct dirty_log_type *get_type(const char *type_name)
45{
46 struct dirty_log_type *type;
47
48 spin_lock(&_lock);
49 list_for_each_entry (type, &_log_types, list)
50 if (!strcmp(type_name, type->name)) {
51 if (!type->use_count && !try_module_get(type->module)){
52 spin_unlock(&_lock);
53 return NULL;
54 }
55 type->use_count++;
56 spin_unlock(&_lock);
57 return type;
58 }
59
60 spin_unlock(&_lock);
61 return NULL;
62}
63
64static void put_type(struct dirty_log_type *type)
65{
66 spin_lock(&_lock);
67 if (!--type->use_count)
68 module_put(type->module);
69 spin_unlock(&_lock);
70}
71
72struct dirty_log *dm_create_dirty_log(const char *type_name, struct dm_target *ti,
73 unsigned int argc, char **argv)
74{
75 struct dirty_log_type *type;
76 struct dirty_log *log;
77
78 log = kmalloc(sizeof(*log), GFP_KERNEL);
79 if (!log)
80 return NULL;
81
82 type = get_type(type_name);
83 if (!type) {
84 kfree(log);
85 return NULL;
86 }
87
88 log->type = type;
89 if (type->ctr(log, ti, argc, argv)) {
90 kfree(log);
91 put_type(type);
92 return NULL;
93 }
94
95 return log;
96}
97
98void dm_destroy_dirty_log(struct dirty_log *log)
99{
100 log->type->dtr(log);
101 put_type(log->type);
102 kfree(log);
103}
104
105/*-----------------------------------------------------------------
106 * Persistent and core logs share a lot of their implementation.
107 * FIXME: need a reload method to be called from a resume
108 *---------------------------------------------------------------*/
109/*
110 * Magic for persistent mirrors: "MiRr"
111 */
112#define MIRROR_MAGIC 0x4D695272
113
114/*
115 * The on-disk version of the metadata.
116 */
Patrick Caulfielda4fc4712006-02-01 03:04:51 -0800117#define MIRROR_DISK_VERSION 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#define LOG_OFFSET 2
119
120struct log_header {
121 uint32_t magic;
122
123 /*
124 * Simple, incrementing version. no backward
125 * compatibility.
126 */
127 uint32_t version;
128 sector_t nr_regions;
129};
130
131struct log_c {
132 struct dm_target *ti;
133 int touched;
134 uint32_t region_size;
135 unsigned int region_count;
136 region_t sync_count;
137
138 unsigned bitset_uint32_count;
139 uint32_t *clean_bits;
140 uint32_t *sync_bits;
141 uint32_t *recovering_bits; /* FIXME: this seems excessive */
142
143 int sync_search;
144
145 /* Resync flag */
146 enum sync {
147 DEFAULTSYNC, /* Synchronize if necessary */
148 NOSYNC, /* Devices known to be already in sync */
149 FORCESYNC, /* Force a sync to happen */
150 } sync;
151
152 /*
153 * Disk log fields
154 */
155 struct dm_dev *log_dev;
156 struct log_header header;
157
158 struct io_region header_location;
159 struct log_header *disk_header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160};
161
162/*
163 * The touched member needs to be updated every time we access
164 * one of the bitsets.
165 */
166static inline int log_test_bit(uint32_t *bs, unsigned bit)
167{
Patrick Caulfielda4fc4712006-02-01 03:04:51 -0800168 return ext2_test_bit(bit, (unsigned long *) bs) ? 1 : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169}
170
171static inline void log_set_bit(struct log_c *l,
172 uint32_t *bs, unsigned bit)
173{
Patrick Caulfielda4fc4712006-02-01 03:04:51 -0800174 ext2_set_bit(bit, (unsigned long *) bs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 l->touched = 1;
176}
177
178static inline void log_clear_bit(struct log_c *l,
179 uint32_t *bs, unsigned bit)
180{
Patrick Caulfielda4fc4712006-02-01 03:04:51 -0800181 ext2_clear_bit(bit, (unsigned long *) bs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 l->touched = 1;
183}
184
185/*----------------------------------------------------------------
186 * Header IO
187 *--------------------------------------------------------------*/
188static void header_to_disk(struct log_header *core, struct log_header *disk)
189{
190 disk->magic = cpu_to_le32(core->magic);
191 disk->version = cpu_to_le32(core->version);
192 disk->nr_regions = cpu_to_le64(core->nr_regions);
193}
194
195static void header_from_disk(struct log_header *core, struct log_header *disk)
196{
197 core->magic = le32_to_cpu(disk->magic);
198 core->version = le32_to_cpu(disk->version);
199 core->nr_regions = le64_to_cpu(disk->nr_regions);
200}
201
202static int read_header(struct log_c *log)
203{
204 int r;
205 unsigned long ebits;
206
207 r = dm_io_sync_vm(1, &log->header_location, READ,
208 log->disk_header, &ebits);
209 if (r)
210 return r;
211
212 header_from_disk(&log->header, log->disk_header);
213
214 /* New log required? */
215 if (log->sync != DEFAULTSYNC || log->header.magic != MIRROR_MAGIC) {
216 log->header.magic = MIRROR_MAGIC;
217 log->header.version = MIRROR_DISK_VERSION;
218 log->header.nr_regions = 0;
219 }
220
Patrick Caulfielda4fc4712006-02-01 03:04:51 -0800221#ifdef __LITTLE_ENDIAN
222 if (log->header.version == 1)
223 log->header.version = 2;
224#endif
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 if (log->header.version != MIRROR_DISK_VERSION) {
227 DMWARN("incompatible disk log version");
228 return -EINVAL;
229 }
230
231 return 0;
232}
233
234static inline int write_header(struct log_c *log)
235{
236 unsigned long ebits;
237
238 header_to_disk(&log->header, log->disk_header);
239 return dm_io_sync_vm(1, &log->header_location, WRITE,
240 log->disk_header, &ebits);
241}
242
243/*----------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 * core log constructor/destructor
245 *
246 * argv contains region_size followed optionally by [no]sync
247 *--------------------------------------------------------------*/
248#define BYTE_SHIFT 3
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700249static int create_log_context(struct dirty_log *log, struct dm_target *ti,
250 unsigned int argc, char **argv,
251 struct dm_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252{
253 enum sync sync = DEFAULTSYNC;
254
255 struct log_c *lc;
256 uint32_t region_size;
257 unsigned int region_count;
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700258 size_t bitset_size, buf_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260 if (argc < 1 || argc > 2) {
261 DMWARN("wrong number of arguments to mirror log");
262 return -EINVAL;
263 }
264
265 if (argc > 1) {
266 if (!strcmp(argv[1], "sync"))
267 sync = FORCESYNC;
268 else if (!strcmp(argv[1], "nosync"))
269 sync = NOSYNC;
270 else {
271 DMWARN("unrecognised sync argument to mirror log: %s",
272 argv[1]);
273 return -EINVAL;
274 }
275 }
276
277 if (sscanf(argv[0], "%u", &region_size) != 1) {
278 DMWARN("invalid region size string");
279 return -EINVAL;
280 }
281
282 region_count = dm_sector_div_up(ti->len, region_size);
283
284 lc = kmalloc(sizeof(*lc), GFP_KERNEL);
285 if (!lc) {
286 DMWARN("couldn't allocate core log");
287 return -ENOMEM;
288 }
289
290 lc->ti = ti;
291 lc->touched = 0;
292 lc->region_size = region_size;
293 lc->region_count = region_count;
294 lc->sync = sync;
295
296 /*
Alasdair G Kergon0e568222005-11-21 21:32:34 -0800297 * Work out how many "unsigned long"s we need to hold the bitset.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 */
299 bitset_size = dm_round_up(region_count,
Alasdair G Kergon29121bd2006-06-26 00:27:29 -0700300 sizeof(*lc->clean_bits) << BYTE_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 bitset_size >>= BYTE_SHIFT;
302
Alasdair G Kergon29121bd2006-06-26 00:27:29 -0700303 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits);
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700304
305 /*
306 * Disk log?
307 */
308 if (!dev) {
309 lc->clean_bits = vmalloc(bitset_size);
310 if (!lc->clean_bits) {
311 DMWARN("couldn't allocate clean bitset");
312 kfree(lc);
313 return -ENOMEM;
314 }
315 lc->disk_header = NULL;
316 } else {
317 lc->log_dev = dev;
318 lc->header_location.bdev = lc->log_dev->bdev;
319 lc->header_location.sector = 0;
320
321 /*
322 * Buffer holds both header and bitset.
323 */
324 buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
325 bitset_size, ti->limits.hardsect_size);
326 lc->header_location.count = buf_size >> SECTOR_SHIFT;
327
328 lc->disk_header = vmalloc(buf_size);
329 if (!lc->disk_header) {
330 DMWARN("couldn't allocate disk log buffer");
331 kfree(lc);
332 return -ENOMEM;
333 }
334
335 lc->clean_bits = (void *)lc->disk_header +
336 (LOG_OFFSET << SECTOR_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 }
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 memset(lc->clean_bits, -1, bitset_size);
340
341 lc->sync_bits = vmalloc(bitset_size);
342 if (!lc->sync_bits) {
343 DMWARN("couldn't allocate sync bitset");
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700344 if (!dev)
345 vfree(lc->clean_bits);
346 vfree(lc->disk_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 kfree(lc);
348 return -ENOMEM;
349 }
350 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size);
351 lc->sync_count = (sync == NOSYNC) ? region_count : 0;
352
353 lc->recovering_bits = vmalloc(bitset_size);
354 if (!lc->recovering_bits) {
355 DMWARN("couldn't allocate sync bitset");
356 vfree(lc->sync_bits);
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700357 if (!dev)
358 vfree(lc->clean_bits);
359 vfree(lc->disk_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 kfree(lc);
361 return -ENOMEM;
362 }
363 memset(lc->recovering_bits, 0, bitset_size);
364 lc->sync_search = 0;
365 log->context = lc;
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700366
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 return 0;
368}
369
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700370static int core_ctr(struct dirty_log *log, struct dm_target *ti,
371 unsigned int argc, char **argv)
372{
373 return create_log_context(log, ti, argc, argv, NULL);
374}
375
376static void destroy_log_context(struct log_c *lc)
377{
378 vfree(lc->sync_bits);
379 vfree(lc->recovering_bits);
380 kfree(lc);
381}
382
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383static void core_dtr(struct dirty_log *log)
384{
385 struct log_c *lc = (struct log_c *) log->context;
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 vfree(lc->clean_bits);
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700388 destroy_log_context(lc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389}
390
391/*----------------------------------------------------------------
392 * disk log constructor/destructor
393 *
394 * argv contains log_device region_size followed optionally by [no]sync
395 *--------------------------------------------------------------*/
396static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
397 unsigned int argc, char **argv)
398{
399 int r;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 struct dm_dev *dev;
401
402 if (argc < 2 || argc > 3) {
403 DMWARN("wrong number of arguments to disk mirror log");
404 return -EINVAL;
405 }
406
407 r = dm_get_device(ti, argv[0], 0, 0 /* FIXME */,
408 FMODE_READ | FMODE_WRITE, &dev);
409 if (r)
410 return r;
411
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700412 r = create_log_context(log, ti, argc - 1, argv + 1, dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 if (r) {
414 dm_put_device(ti, dev);
415 return r;
416 }
417
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419}
420
421static void disk_dtr(struct dirty_log *log)
422{
423 struct log_c *lc = (struct log_c *) log->context;
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700424
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 dm_put_device(lc->ti, lc->log_dev);
426 vfree(lc->disk_header);
Alasdair G Kergonb7cca192006-06-26 00:27:29 -0700427 destroy_log_context(lc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428}
429
430static int count_bits32(uint32_t *addr, unsigned size)
431{
432 int count = 0, i;
433
434 for (i = 0; i < size; i++) {
435 count += hweight32(*(addr+i));
436 }
437 return count;
438}
439
440static int disk_resume(struct dirty_log *log)
441{
442 int r;
443 unsigned i;
444 struct log_c *lc = (struct log_c *) log->context;
445 size_t size = lc->bitset_uint32_count * sizeof(uint32_t);
446
447 /* read the disk header */
448 r = read_header(lc);
449 if (r)
450 return r;
451
Alasdair G Kergon8a835f12006-06-26 00:27:30 -0700452 /* set or clear any new bits -- device has grown */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 if (lc->sync == NOSYNC)
454 for (i = lc->header.nr_regions; i < lc->region_count; i++)
455 /* FIXME: amazingly inefficient */
456 log_set_bit(lc, lc->clean_bits, i);
457 else
458 for (i = lc->header.nr_regions; i < lc->region_count; i++)
459 /* FIXME: amazingly inefficient */
460 log_clear_bit(lc, lc->clean_bits, i);
461
Alasdair G Kergon8a835f12006-06-26 00:27:30 -0700462 /* clear any old bits -- device has shrunk */
463 for (i = lc->region_count; i % (sizeof(*lc->clean_bits) << BYTE_SHIFT); i++)
464 log_clear_bit(lc, lc->clean_bits, i);
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 /* copy clean across to sync */
467 memcpy(lc->sync_bits, lc->clean_bits, size);
468 lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
Jonathan E Brassow88b20a12006-12-08 02:41:12 -0800469 lc->sync_search = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 /* set the correct number of regions in the header */
472 lc->header.nr_regions = lc->region_count;
473
474 /* write the new header */
475 return write_header(lc);
476}
477
478static uint32_t core_get_region_size(struct dirty_log *log)
479{
480 struct log_c *lc = (struct log_c *) log->context;
481 return lc->region_size;
482}
483
Jonathan E Brassow88b20a12006-12-08 02:41:12 -0800484static int core_resume(struct dirty_log *log)
485{
486 struct log_c *lc = (struct log_c *) log->context;
487 lc->sync_search = 0;
488 return 0;
489}
490
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491static int core_is_clean(struct dirty_log *log, region_t region)
492{
493 struct log_c *lc = (struct log_c *) log->context;
494 return log_test_bit(lc->clean_bits, region);
495}
496
497static int core_in_sync(struct dirty_log *log, region_t region, int block)
498{
499 struct log_c *lc = (struct log_c *) log->context;
500 return log_test_bit(lc->sync_bits, region);
501}
502
503static int core_flush(struct dirty_log *log)
504{
505 /* no op */
506 return 0;
507}
508
509static int disk_flush(struct dirty_log *log)
510{
511 int r;
512 struct log_c *lc = (struct log_c *) log->context;
513
514 /* only write if the log has changed */
515 if (!lc->touched)
516 return 0;
517
Kevin Corry702ca6f2006-06-26 00:27:28 -0700518 r = write_header(lc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 if (!r)
520 lc->touched = 0;
521
522 return r;
523}
524
525static void core_mark_region(struct dirty_log *log, region_t region)
526{
527 struct log_c *lc = (struct log_c *) log->context;
528 log_clear_bit(lc, lc->clean_bits, region);
529}
530
531static void core_clear_region(struct dirty_log *log, region_t region)
532{
533 struct log_c *lc = (struct log_c *) log->context;
534 log_set_bit(lc, lc->clean_bits, region);
535}
536
537static int core_get_resync_work(struct dirty_log *log, region_t *region)
538{
539 struct log_c *lc = (struct log_c *) log->context;
540
541 if (lc->sync_search >= lc->region_count)
542 return 0;
543
544 do {
Stefan Bader1113a7e2006-02-02 14:28:07 -0800545 *region = ext2_find_next_zero_bit(
546 (unsigned long *) lc->sync_bits,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 lc->region_count,
548 lc->sync_search);
549 lc->sync_search = *region + 1;
550
Darrick J. Wongac81b2e2006-01-06 00:20:11 -0800551 if (*region >= lc->region_count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 return 0;
553
554 } while (log_test_bit(lc->recovering_bits, *region));
555
556 log_set_bit(lc, lc->recovering_bits, *region);
557 return 1;
558}
559
Jonathan E Brassowf3ee6b22006-12-08 02:41:11 -0800560static void core_set_region_sync(struct dirty_log *log, region_t region,
561 int in_sync)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562{
563 struct log_c *lc = (struct log_c *) log->context;
564
565 log_clear_bit(lc, lc->recovering_bits, region);
Jonathan E Brassowf3ee6b22006-12-08 02:41:11 -0800566 if (in_sync) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 log_set_bit(lc, lc->sync_bits, region);
568 lc->sync_count++;
Jonathan E Brassowf3ee6b22006-12-08 02:41:11 -0800569 } else if (log_test_bit(lc->sync_bits, region)) {
570 lc->sync_count--;
571 log_clear_bit(lc, lc->sync_bits, region);
572 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573}
574
575static region_t core_get_sync_count(struct dirty_log *log)
576{
577 struct log_c *lc = (struct log_c *) log->context;
578
579 return lc->sync_count;
580}
581
582#define DMEMIT_SYNC \
583 if (lc->sync != DEFAULTSYNC) \
584 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
585
586static int core_status(struct dirty_log *log, status_type_t status,
587 char *result, unsigned int maxlen)
588{
589 int sz = 0;
590 struct log_c *lc = log->context;
591
592 switch(status) {
593 case STATUSTYPE_INFO:
594 break;
595
596 case STATUSTYPE_TABLE:
597 DMEMIT("%s %u %u ", log->type->name,
598 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size);
599 DMEMIT_SYNC;
600 }
601
602 return sz;
603}
604
605static int disk_status(struct dirty_log *log, status_type_t status,
606 char *result, unsigned int maxlen)
607{
608 int sz = 0;
609 char buffer[16];
610 struct log_c *lc = log->context;
611
612 switch(status) {
613 case STATUSTYPE_INFO:
614 break;
615
616 case STATUSTYPE_TABLE:
617 format_dev_t(buffer, lc->log_dev->bdev->bd_dev);
618 DMEMIT("%s %u %s %u ", log->type->name,
619 lc->sync == DEFAULTSYNC ? 2 : 3, buffer,
620 lc->region_size);
621 DMEMIT_SYNC;
622 }
623
624 return sz;
625}
626
627static struct dirty_log_type _core_type = {
628 .name = "core",
629 .module = THIS_MODULE,
630 .ctr = core_ctr,
631 .dtr = core_dtr,
Jonathan E Brassow88b20a12006-12-08 02:41:12 -0800632 .resume = core_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .get_region_size = core_get_region_size,
634 .is_clean = core_is_clean,
635 .in_sync = core_in_sync,
636 .flush = core_flush,
637 .mark_region = core_mark_region,
638 .clear_region = core_clear_region,
639 .get_resync_work = core_get_resync_work,
Jonathan E Brassowf3ee6b22006-12-08 02:41:11 -0800640 .set_region_sync = core_set_region_sync,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .get_sync_count = core_get_sync_count,
642 .status = core_status,
643};
644
645static struct dirty_log_type _disk_type = {
646 .name = "disk",
647 .module = THIS_MODULE,
648 .ctr = disk_ctr,
649 .dtr = disk_dtr,
650 .suspend = disk_flush,
651 .resume = disk_resume,
652 .get_region_size = core_get_region_size,
653 .is_clean = core_is_clean,
654 .in_sync = core_in_sync,
655 .flush = disk_flush,
656 .mark_region = core_mark_region,
657 .clear_region = core_clear_region,
658 .get_resync_work = core_get_resync_work,
Jonathan E Brassowf3ee6b22006-12-08 02:41:11 -0800659 .set_region_sync = core_set_region_sync,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .get_sync_count = core_get_sync_count,
661 .status = disk_status,
662};
663
664int __init dm_dirty_log_init(void)
665{
666 int r;
667
668 r = dm_register_dirty_log_type(&_core_type);
669 if (r)
670 DMWARN("couldn't register core log");
671
672 r = dm_register_dirty_log_type(&_disk_type);
673 if (r) {
674 DMWARN("couldn't register disk type");
675 dm_unregister_dirty_log_type(&_core_type);
676 }
677
678 return r;
679}
680
681void dm_dirty_log_exit(void)
682{
683 dm_unregister_dirty_log_type(&_disk_type);
684 dm_unregister_dirty_log_type(&_core_type);
685}
686
687EXPORT_SYMBOL(dm_register_dirty_log_type);
688EXPORT_SYMBOL(dm_unregister_dirty_log_type);
689EXPORT_SYMBOL(dm_create_dirty_log);
690EXPORT_SYMBOL(dm_destroy_dirty_log);