dm-snap-persistent.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
  3. * Copyright (C) 2006-2008 Red Hat GmbH
  4. *
  5. * This file is released under the GPL.
  6. */
  7. #include "dm-exception-store.h"
  8. #include <linux/mm.h>
  9. #include <linux/pagemap.h>
  10. #include <linux/vmalloc.h>
  11. #include <linux/slab.h>
  12. #include <linux/dm-io.h>
  13. #define DM_MSG_PREFIX "persistent snapshot"
  14. #define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */
  15. /*-----------------------------------------------------------------
  16. * Persistent snapshots, by persistent we mean that the snapshot
  17. * will survive a reboot.
  18. *---------------------------------------------------------------*/
  19. /*
  20. * We need to store a record of which parts of the origin have
  21. * been copied to the snapshot device. The snapshot code
  22. * requires that we copy exception chunks to chunk aligned areas
  23. * of the COW store. It makes sense therefore, to store the
  24. * metadata in chunk size blocks.
  25. *
  26. * There is no backward or forward compatibility implemented,
  27. * snapshots with different disk versions than the kernel will
  28. * not be usable. It is expected that "lvcreate" will blank out
  29. * the start of a fresh COW device before calling the snapshot
  30. * constructor.
  31. *
  32. * The first chunk of the COW device just contains the header.
  33. * After this there is a chunk filled with exception metadata,
  34. * followed by as many exception chunks as can fit in the
  35. * metadata areas.
  36. *
  37. * All on disk structures are in little-endian format. The end
  38. * of the exceptions info is indicated by an exception with a
  39. * new_chunk of 0, which is invalid since it would point to the
  40. * header chunk.
  41. */
  42. /*
  43. * Magic for persistent snapshots: "SnAp" - Feeble isn't it.
  44. */
  45. #define SNAP_MAGIC 0x70416e53
  46. /*
  47. * The on-disk version of the metadata.
  48. */
  49. #define SNAPSHOT_DISK_VERSION 1
  50. struct disk_header {
  51. uint32_t magic;
  52. /*
  53. * Is this snapshot valid. There is no way of recovering
  54. * an invalid snapshot.
  55. */
  56. uint32_t valid;
  57. /*
  58. * Simple, incrementing version. no backward
  59. * compatibility.
  60. */
  61. uint32_t version;
  62. /* In sectors */
  63. uint32_t chunk_size;
  64. };
  65. struct disk_exception {
  66. uint64_t old_chunk;
  67. uint64_t new_chunk;
  68. };
  69. struct commit_callback {
  70. void (*callback)(void *, int success);
  71. void *context;
  72. };
  73. /*
  74. * The top level structure for a persistent exception store.
  75. */
  76. struct pstore {
  77. struct dm_exception_store *store;
  78. int version;
  79. int valid;
  80. uint32_t exceptions_per_area;
  81. /*
  82. * Now that we have an asynchronous kcopyd there is no
  83. * need for large chunk sizes, so it wont hurt to have a
  84. * whole chunks worth of metadata in memory at once.
  85. */
  86. void *area;
  87. /*
  88. * An area of zeros used to clear the next area.
  89. */
  90. void *zero_area;
  91. /*
  92. * An area used for header. The header can be written
  93. * concurrently with metadata (when invalidating the snapshot),
  94. * so it needs a separate buffer.
  95. */
  96. void *header_area;
  97. /*
  98. * Used to keep track of which metadata area the data in
  99. * 'chunk' refers to.
  100. */
  101. chunk_t current_area;
  102. /*
  103. * The next free chunk for an exception.
  104. */
  105. chunk_t next_free;
  106. /*
  107. * The index of next free exception in the current
  108. * metadata area.
  109. */
  110. uint32_t current_committed;
  111. atomic_t pending_count;
  112. uint32_t callback_count;
  113. struct commit_callback *callbacks;
  114. struct dm_io_client *io_client;
  115. struct workqueue_struct *metadata_wq;
  116. };
  117. static unsigned sectors_to_pages(unsigned sectors)
  118. {
  119. return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
  120. }
  121. static int alloc_area(struct pstore *ps)
  122. {
  123. int r = -ENOMEM;
  124. size_t len;
  125. len = ps->store->chunk_size << SECTOR_SHIFT;
  126. /*
  127. * Allocate the chunk_size block of memory that will hold
  128. * a single metadata area.
  129. */
  130. ps->area = vmalloc(len);
  131. if (!ps->area)
  132. goto err_area;
  133. ps->zero_area = vmalloc(len);
  134. if (!ps->zero_area)
  135. goto err_zero_area;
  136. memset(ps->zero_area, 0, len);
  137. ps->header_area = vmalloc(len);
  138. if (!ps->header_area)
  139. goto err_header_area;
  140. return 0;
  141. err_header_area:
  142. vfree(ps->zero_area);
  143. err_zero_area:
  144. vfree(ps->area);
  145. err_area:
  146. return r;
  147. }
  148. static void free_area(struct pstore *ps)
  149. {
  150. if (ps->area)
  151. vfree(ps->area);
  152. ps->area = NULL;
  153. if (ps->zero_area)
  154. vfree(ps->zero_area);
  155. ps->zero_area = NULL;
  156. if (ps->header_area)
  157. vfree(ps->header_area);
  158. ps->header_area = NULL;
  159. }
  160. struct mdata_req {
  161. struct dm_io_region *where;
  162. struct dm_io_request *io_req;
  163. struct work_struct work;
  164. int result;
  165. };
  166. static void do_metadata(struct work_struct *work)
  167. {
  168. struct mdata_req *req = container_of(work, struct mdata_req, work);
  169. req->result = dm_io(req->io_req, 1, req->where, NULL);
  170. }
  171. /*
  172. * Read or write a chunk aligned and sized block of data from a device.
  173. */
  174. static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw,
  175. int metadata)
  176. {
  177. struct dm_io_region where = {
  178. .bdev = ps->store->cow->bdev,
  179. .sector = ps->store->chunk_size * chunk,
  180. .count = ps->store->chunk_size,
  181. };
  182. struct dm_io_request io_req = {
  183. .bi_rw = rw,
  184. .mem.type = DM_IO_VMA,
  185. .mem.ptr.vma = area,
  186. .client = ps->io_client,
  187. .notify.fn = NULL,
  188. };
  189. struct mdata_req req;
  190. if (!metadata)
  191. return dm_io(&io_req, 1, &where, NULL);
  192. req.where = &where;
  193. req.io_req = &io_req;
  194. /*
  195. * Issue the synchronous I/O from a different thread
  196. * to avoid generic_make_request recursion.
  197. */
  198. INIT_WORK(&req.work, do_metadata);
  199. queue_work(ps->metadata_wq, &req.work);
  200. flush_workqueue(ps->metadata_wq);
  201. return req.result;
  202. }
  203. /*
  204. * Convert a metadata area index to a chunk index.
  205. */
  206. static chunk_t area_location(struct pstore *ps, chunk_t area)
  207. {
  208. return 1 + ((ps->exceptions_per_area + 1) * area);
  209. }
  210. /*
  211. * Read or write a metadata area. Remembering to skip the first
  212. * chunk which holds the header.
  213. */
  214. static int area_io(struct pstore *ps, int rw)
  215. {
  216. int r;
  217. chunk_t chunk;
  218. chunk = area_location(ps, ps->current_area);
  219. r = chunk_io(ps, ps->area, chunk, rw, 0);
  220. if (r)
  221. return r;
  222. return 0;
  223. }
  224. static void zero_memory_area(struct pstore *ps)
  225. {
  226. memset(ps->area, 0, ps->store->chunk_size << SECTOR_SHIFT);
  227. }
  228. static int zero_disk_area(struct pstore *ps, chunk_t area)
  229. {
  230. return chunk_io(ps, ps->zero_area, area_location(ps, area), WRITE, 0);
  231. }
  232. static int read_header(struct pstore *ps, int *new_snapshot)
  233. {
  234. int r;
  235. struct disk_header *dh;
  236. unsigned chunk_size;
  237. int chunk_size_supplied = 1;
  238. char *chunk_err;
  239. /*
  240. * Use default chunk size (or logical_block_size, if larger)
  241. * if none supplied
  242. */
  243. if (!ps->store->chunk_size) {
  244. ps->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS,
  245. bdev_logical_block_size(ps->store->cow->bdev) >> 9);
  246. ps->store->chunk_mask = ps->store->chunk_size - 1;
  247. ps->store->chunk_shift = ffs(ps->store->chunk_size) - 1;
  248. chunk_size_supplied = 0;
  249. }
  250. ps->io_client = dm_io_client_create(sectors_to_pages(ps->store->
  251. chunk_size));
  252. if (IS_ERR(ps->io_client))
  253. return PTR_ERR(ps->io_client);
  254. r = alloc_area(ps);
  255. if (r)
  256. return r;
  257. r = chunk_io(ps, ps->header_area, 0, READ, 1);
  258. if (r)
  259. goto bad;
  260. dh = ps->header_area;
  261. if (le32_to_cpu(dh->magic) == 0) {
  262. *new_snapshot = 1;
  263. return 0;
  264. }
  265. if (le32_to_cpu(dh->magic) != SNAP_MAGIC) {
  266. DMWARN("Invalid or corrupt snapshot");
  267. r = -ENXIO;
  268. goto bad;
  269. }
  270. *new_snapshot = 0;
  271. ps->valid = le32_to_cpu(dh->valid);
  272. ps->version = le32_to_cpu(dh->version);
  273. chunk_size = le32_to_cpu(dh->chunk_size);
  274. if (ps->store->chunk_size == chunk_size)
  275. return 0;
  276. if (chunk_size_supplied)
  277. DMWARN("chunk size %u in device metadata overrides "
  278. "table chunk size of %u.",
  279. chunk_size, ps->store->chunk_size);
  280. /* We had a bogus chunk_size. Fix stuff up. */
  281. free_area(ps);
  282. r = dm_exception_store_set_chunk_size(ps->store, chunk_size,
  283. &chunk_err);
  284. if (r) {
  285. DMERR("invalid on-disk chunk size %u: %s.",
  286. chunk_size, chunk_err);
  287. return r;
  288. }
  289. r = dm_io_client_resize(sectors_to_pages(ps->store->chunk_size),
  290. ps->io_client);
  291. if (r)
  292. return r;
  293. r = alloc_area(ps);
  294. return r;
  295. bad:
  296. free_area(ps);
  297. return r;
  298. }
  299. static int write_header(struct pstore *ps)
  300. {
  301. struct disk_header *dh;
  302. memset(ps->header_area, 0, ps->store->chunk_size << SECTOR_SHIFT);
  303. dh = ps->header_area;
  304. dh->magic = cpu_to_le32(SNAP_MAGIC);
  305. dh->valid = cpu_to_le32(ps->valid);
  306. dh->version = cpu_to_le32(ps->version);
  307. dh->chunk_size = cpu_to_le32(ps->store->chunk_size);
  308. return chunk_io(ps, ps->header_area, 0, WRITE, 1);
  309. }
  310. /*
  311. * Access functions for the disk exceptions, these do the endian conversions.
  312. */
  313. static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
  314. {
  315. BUG_ON(index >= ps->exceptions_per_area);
  316. return ((struct disk_exception *) ps->area) + index;
  317. }
  318. static void read_exception(struct pstore *ps,
  319. uint32_t index, struct disk_exception *result)
  320. {
  321. struct disk_exception *e = get_exception(ps, index);
  322. /* copy it */
  323. result->old_chunk = le64_to_cpu(e->old_chunk);
  324. result->new_chunk = le64_to_cpu(e->new_chunk);
  325. }
  326. static void write_exception(struct pstore *ps,
  327. uint32_t index, struct disk_exception *de)
  328. {
  329. struct disk_exception *e = get_exception(ps, index);
  330. /* copy it */
  331. e->old_chunk = cpu_to_le64(de->old_chunk);
  332. e->new_chunk = cpu_to_le64(de->new_chunk);
  333. }
  334. /*
  335. * Registers the exceptions that are present in the current area.
  336. * 'full' is filled in to indicate if the area has been
  337. * filled.
  338. */
  339. static int insert_exceptions(struct pstore *ps,
  340. int (*callback)(void *callback_context,
  341. chunk_t old, chunk_t new),
  342. void *callback_context,
  343. int *full)
  344. {
  345. int r;
  346. unsigned int i;
  347. struct disk_exception de;
  348. /* presume the area is full */
  349. *full = 1;
  350. for (i = 0; i < ps->exceptions_per_area; i++) {
  351. read_exception(ps, i, &de);
  352. /*
  353. * If the new_chunk is pointing at the start of
  354. * the COW device, where the first metadata area
  355. * is we know that we've hit the end of the
  356. * exceptions. Therefore the area is not full.
  357. */
  358. if (de.new_chunk == 0LL) {
  359. ps->current_committed = i;
  360. *full = 0;
  361. break;
  362. }
  363. /*
  364. * Keep track of the start of the free chunks.
  365. */
  366. if (ps->next_free <= de.new_chunk)
  367. ps->next_free = de.new_chunk + 1;
  368. /*
  369. * Otherwise we add the exception to the snapshot.
  370. */
  371. r = callback(callback_context, de.old_chunk, de.new_chunk);
  372. if (r)
  373. return r;
  374. }
  375. return 0;
  376. }
  377. static int read_exceptions(struct pstore *ps,
  378. int (*callback)(void *callback_context, chunk_t old,
  379. chunk_t new),
  380. void *callback_context)
  381. {
  382. int r, full = 1;
  383. /*
  384. * Keeping reading chunks and inserting exceptions until
  385. * we find a partially full area.
  386. */
  387. for (ps->current_area = 0; full; ps->current_area++) {
  388. r = area_io(ps, READ);
  389. if (r)
  390. return r;
  391. r = insert_exceptions(ps, callback, callback_context, &full);
  392. if (r)
  393. return r;
  394. }
  395. ps->current_area--;
  396. return 0;
  397. }
  398. static struct pstore *get_info(struct dm_exception_store *store)
  399. {
  400. return (struct pstore *) store->context;
  401. }
  402. static void persistent_fraction_full(struct dm_exception_store *store,
  403. sector_t *numerator, sector_t *denominator)
  404. {
  405. *numerator = get_info(store)->next_free * store->chunk_size;
  406. *denominator = get_dev_size(store->cow->bdev);
  407. }
  408. static void persistent_dtr(struct dm_exception_store *store)
  409. {
  410. struct pstore *ps = get_info(store);
  411. destroy_workqueue(ps->metadata_wq);
  412. /* Created in read_header */
  413. if (ps->io_client)
  414. dm_io_client_destroy(ps->io_client);
  415. free_area(ps);
  416. /* Allocated in persistent_read_metadata */
  417. if (ps->callbacks)
  418. vfree(ps->callbacks);
  419. kfree(ps);
  420. }
  421. static int persistent_read_metadata(struct dm_exception_store *store,
  422. int (*callback)(void *callback_context,
  423. chunk_t old, chunk_t new),
  424. void *callback_context)
  425. {
  426. int r, uninitialized_var(new_snapshot);
  427. struct pstore *ps = get_info(store);
  428. /*
  429. * Read the snapshot header.
  430. */
  431. r = read_header(ps, &new_snapshot);
  432. if (r)
  433. return r;
  434. /*
  435. * Now we know correct chunk_size, complete the initialisation.
  436. */
  437. ps->exceptions_per_area = (ps->store->chunk_size << SECTOR_SHIFT) /
  438. sizeof(struct disk_exception);
  439. ps->callbacks = dm_vcalloc(ps->exceptions_per_area,
  440. sizeof(*ps->callbacks));
  441. if (!ps->callbacks)
  442. return -ENOMEM;
  443. /*
  444. * Do we need to setup a new snapshot ?
  445. */
  446. if (new_snapshot) {
  447. r = write_header(ps);
  448. if (r) {
  449. DMWARN("write_header failed");
  450. return r;
  451. }
  452. ps->current_area = 0;
  453. zero_memory_area(ps);
  454. r = zero_disk_area(ps, 0);
  455. if (r) {
  456. DMWARN("zero_disk_area(0) failed");
  457. return r;
  458. }
  459. } else {
  460. /*
  461. * Sanity checks.
  462. */
  463. if (ps->version != SNAPSHOT_DISK_VERSION) {
  464. DMWARN("unable to handle snapshot disk version %d",
  465. ps->version);
  466. return -EINVAL;
  467. }
  468. /*
  469. * Metadata are valid, but snapshot is invalidated
  470. */
  471. if (!ps->valid)
  472. return 1;
  473. /*
  474. * Read the metadata.
  475. */
  476. r = read_exceptions(ps, callback, callback_context);
  477. if (r)
  478. return r;
  479. }
  480. return 0;
  481. }
  482. static int persistent_prepare_exception(struct dm_exception_store *store,
  483. struct dm_snap_exception *e)
  484. {
  485. struct pstore *ps = get_info(store);
  486. uint32_t stride;
  487. chunk_t next_free;
  488. sector_t size = get_dev_size(store->cow->bdev);
  489. /* Is there enough room ? */
  490. if (size < ((ps->next_free + 1) * store->chunk_size))
  491. return -ENOSPC;
  492. e->new_chunk = ps->next_free;
  493. /*
  494. * Move onto the next free pending, making sure to take
  495. * into account the location of the metadata chunks.
  496. */
  497. stride = (ps->exceptions_per_area + 1);
  498. next_free = ++ps->next_free;
  499. if (sector_div(next_free, stride) == 1)
  500. ps->next_free++;
  501. atomic_inc(&ps->pending_count);
  502. return 0;
  503. }
  504. static void persistent_commit_exception(struct dm_exception_store *store,
  505. struct dm_snap_exception *e,
  506. void (*callback) (void *, int success),
  507. void *callback_context)
  508. {
  509. unsigned int i;
  510. struct pstore *ps = get_info(store);
  511. struct disk_exception de;
  512. struct commit_callback *cb;
  513. de.old_chunk = e->old_chunk;
  514. de.new_chunk = e->new_chunk;
  515. write_exception(ps, ps->current_committed++, &de);
  516. /*
  517. * Add the callback to the back of the array. This code
  518. * is the only place where the callback array is
  519. * manipulated, and we know that it will never be called
  520. * multiple times concurrently.
  521. */
  522. cb = ps->callbacks + ps->callback_count++;
  523. cb->callback = callback;
  524. cb->context = callback_context;
  525. /*
  526. * If there are exceptions in flight and we have not yet
  527. * filled this metadata area there's nothing more to do.
  528. */
  529. if (!atomic_dec_and_test(&ps->pending_count) &&
  530. (ps->current_committed != ps->exceptions_per_area))
  531. return;
  532. /*
  533. * If we completely filled the current area, then wipe the next one.
  534. */
  535. if ((ps->current_committed == ps->exceptions_per_area) &&
  536. zero_disk_area(ps, ps->current_area + 1))
  537. ps->valid = 0;
  538. /*
  539. * Commit exceptions to disk.
  540. */
  541. if (ps->valid && area_io(ps, WRITE_BARRIER))
  542. ps->valid = 0;
  543. /*
  544. * Advance to the next area if this one is full.
  545. */
  546. if (ps->current_committed == ps->exceptions_per_area) {
  547. ps->current_committed = 0;
  548. ps->current_area++;
  549. zero_memory_area(ps);
  550. }
  551. for (i = 0; i < ps->callback_count; i++) {
  552. cb = ps->callbacks + i;
  553. cb->callback(cb->context, ps->valid);
  554. }
  555. ps->callback_count = 0;
  556. }
  557. static void persistent_drop_snapshot(struct dm_exception_store *store)
  558. {
  559. struct pstore *ps = get_info(store);
  560. ps->valid = 0;
  561. if (write_header(ps))
  562. DMWARN("write header failed");
  563. }
  564. static int persistent_ctr(struct dm_exception_store *store,
  565. unsigned argc, char **argv)
  566. {
  567. struct pstore *ps;
  568. /* allocate the pstore */
  569. ps = kzalloc(sizeof(*ps), GFP_KERNEL);
  570. if (!ps)
  571. return -ENOMEM;
  572. ps->store = store;
  573. ps->valid = 1;
  574. ps->version = SNAPSHOT_DISK_VERSION;
  575. ps->area = NULL;
  576. ps->zero_area = NULL;
  577. ps->header_area = NULL;
  578. ps->next_free = 2; /* skipping the header and first area */
  579. ps->current_committed = 0;
  580. ps->callback_count = 0;
  581. atomic_set(&ps->pending_count, 0);
  582. ps->callbacks = NULL;
  583. ps->metadata_wq = create_singlethread_workqueue("ksnaphd");
  584. if (!ps->metadata_wq) {
  585. kfree(ps);
  586. DMERR("couldn't start header metadata update thread");
  587. return -ENOMEM;
  588. }
  589. store->context = ps;
  590. return 0;
  591. }
  592. static unsigned persistent_status(struct dm_exception_store *store,
  593. status_type_t status, char *result,
  594. unsigned maxlen)
  595. {
  596. unsigned sz = 0;
  597. switch (status) {
  598. case STATUSTYPE_INFO:
  599. break;
  600. case STATUSTYPE_TABLE:
  601. DMEMIT(" %s P %llu", store->cow->name,
  602. (unsigned long long)store->chunk_size);
  603. }
  604. return sz;
  605. }
  606. static struct dm_exception_store_type _persistent_type = {
  607. .name = "persistent",
  608. .module = THIS_MODULE,
  609. .ctr = persistent_ctr,
  610. .dtr = persistent_dtr,
  611. .read_metadata = persistent_read_metadata,
  612. .prepare_exception = persistent_prepare_exception,
  613. .commit_exception = persistent_commit_exception,
  614. .drop_snapshot = persistent_drop_snapshot,
  615. .fraction_full = persistent_fraction_full,
  616. .status = persistent_status,
  617. };
  618. static struct dm_exception_store_type _persistent_compat_type = {
  619. .name = "P",
  620. .module = THIS_MODULE,
  621. .ctr = persistent_ctr,
  622. .dtr = persistent_dtr,
  623. .read_metadata = persistent_read_metadata,
  624. .prepare_exception = persistent_prepare_exception,
  625. .commit_exception = persistent_commit_exception,
  626. .drop_snapshot = persistent_drop_snapshot,
  627. .fraction_full = persistent_fraction_full,
  628. .status = persistent_status,
  629. };
  630. int dm_persistent_snapshot_init(void)
  631. {
  632. int r;
  633. r = dm_exception_store_type_register(&_persistent_type);
  634. if (r) {
  635. DMERR("Unable to register persistent exception store type");
  636. return r;
  637. }
  638. r = dm_exception_store_type_register(&_persistent_compat_type);
  639. if (r) {
  640. DMERR("Unable to register old-style persistent exception "
  641. "store type");
  642. dm_exception_store_type_unregister(&_persistent_type);
  643. return r;
  644. }
  645. return r;
  646. }
  647. void dm_persistent_snapshot_exit(void)
  648. {
  649. dm_exception_store_type_unregister(&_persistent_type);
  650. dm_exception_store_type_unregister(&_persistent_compat_type);
  651. }