diff options
| -rw-r--r-- | Documentation/device-mapper/cache.txt | 11 | ||||
| -rw-r--r-- | Documentation/device-mapper/thin-provisioning.txt | 34 | ||||
| -rw-r--r-- | drivers/md/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/md/dm-cache-policy-mq.c | 4 | ||||
| -rw-r--r-- | drivers/md/dm-snap-persistent.c | 3 | ||||
| -rw-r--r-- | drivers/md/dm-thin-metadata.c | 37 | ||||
| -rw-r--r-- | drivers/md/dm-thin-metadata.h | 11 | ||||
| -rw-r--r-- | drivers/md/dm-thin.c | 304 | ||||
| -rw-r--r-- | drivers/md/persistent-data/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/md/persistent-data/dm-space-map-metadata.c | 113 |
10 files changed, 425 insertions, 112 deletions
diff --git a/Documentation/device-mapper/cache.txt b/Documentation/device-mapper/cache.txt index e6b72d355151..68c0f517c60e 100644 --- a/Documentation/device-mapper/cache.txt +++ b/Documentation/device-mapper/cache.txt | |||
| @@ -124,12 +124,11 @@ the default being 204800 sectors (or 100MB). | |||
| 124 | Updating on-disk metadata | 124 | Updating on-disk metadata |
| 125 | ------------------------- | 125 | ------------------------- |
| 126 | 126 | ||
| 127 | On-disk metadata is committed every time a REQ_SYNC or REQ_FUA bio is | 127 | On-disk metadata is committed every time a FLUSH or FUA bio is written. |
| 128 | written. If no such requests are made then commits will occur every | 128 | If no such requests are made then commits will occur every second. This |
| 129 | second. This means the cache behaves like a physical disk that has a | 129 | means the cache behaves like a physical disk that has a volatile write |
| 130 | write cache (the same is true of the thin-provisioning target). If | 130 | cache. If power is lost you may lose some recent writes. The metadata |
| 131 | power is lost you may lose some recent writes. The metadata should | 131 | should always be consistent in spite of any crash. |
| 132 | always be consistent in spite of any crash. | ||
| 133 | 132 | ||
| 134 | The 'dirty' state for a cache block changes far too frequently for us | 133 | The 'dirty' state for a cache block changes far too frequently for us |
| 135 | to keep updating it on the fly. So we treat it as a hint. In normal | 134 | to keep updating it on the fly. So we treat it as a hint. In normal |
diff --git a/Documentation/device-mapper/thin-provisioning.txt b/Documentation/device-mapper/thin-provisioning.txt index 8a7a3d46e0da..05a27e9442bd 100644 --- a/Documentation/device-mapper/thin-provisioning.txt +++ b/Documentation/device-mapper/thin-provisioning.txt | |||
| @@ -116,6 +116,35 @@ Resuming a device with a new table itself triggers an event so the | |||
| 116 | userspace daemon can use this to detect a situation where a new table | 116 | userspace daemon can use this to detect a situation where a new table |
| 117 | already exceeds the threshold. | 117 | already exceeds the threshold. |
| 118 | 118 | ||
| 119 | A low water mark for the metadata device is maintained in the kernel and | ||
| 120 | will trigger a dm event if free space on the metadata device drops below | ||
| 121 | it. | ||
| 122 | |||
| 123 | Updating on-disk metadata | ||
| 124 | ------------------------- | ||
| 125 | |||
| 126 | On-disk metadata is committed every time a FLUSH or FUA bio is written. | ||
| 127 | If no such requests are made then commits will occur every second. This | ||
| 128 | means the thin-provisioning target behaves like a physical disk that has | ||
| 129 | a volatile write cache. If power is lost you may lose some recent | ||
| 130 | writes. The metadata should always be consistent in spite of any crash. | ||
| 131 | |||
| 132 | If data space is exhausted the pool will either error or queue IO | ||
| 133 | according to the configuration (see: error_if_no_space). If metadata | ||
| 134 | space is exhausted or a metadata operation fails: the pool will error IO | ||
| 135 | until the pool is taken offline and repair is performed to 1) fix any | ||
| 136 | potential inconsistencies and 2) clear the flag that imposes repair. | ||
| 137 | Once the pool's metadata device is repaired it may be resized, which | ||
| 138 | will allow the pool to return to normal operation. Note that if a pool | ||
| 139 | is flagged as needing repair, the pool's data and metadata devices | ||
| 140 | cannot be resized until repair is performed. It should also be noted | ||
| 141 | that when the pool's metadata space is exhausted the current metadata | ||
| 142 | transaction is aborted. Given that the pool will cache IO whose | ||
| 143 | completion may have already been acknowledged to upper IO layers | ||
| 144 | (e.g. filesystem) it is strongly suggested that consistency checks | ||
| 145 | (e.g. fsck) be performed on those layers when repair of the pool is | ||
| 146 | required. | ||
| 147 | |||
| 119 | Thin provisioning | 148 | Thin provisioning |
| 120 | ----------------- | 149 | ----------------- |
| 121 | 150 | ||
| @@ -258,10 +287,9 @@ ii) Status | |||
| 258 | should register for the event and then check the target's status. | 287 | should register for the event and then check the target's status. |
| 259 | 288 | ||
| 260 | held metadata root: | 289 | held metadata root: |
| 261 | The location, in sectors, of the metadata root that has been | 290 | The location, in blocks, of the metadata root that has been |
| 262 | 'held' for userspace read access. '-' indicates there is no | 291 | 'held' for userspace read access. '-' indicates there is no |
| 263 | held root. This feature is not yet implemented so '-' is | 292 | held root. |
| 264 | always returned. | ||
| 265 | 293 | ||
| 266 | discard_passdown|no_discard_passdown | 294 | discard_passdown|no_discard_passdown |
| 267 | Whether or not discards are actually being passed down to the | 295 | Whether or not discards are actually being passed down to the |
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 9a06fe883766..95ad936e6048 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig | |||
| @@ -254,16 +254,6 @@ config DM_THIN_PROVISIONING | |||
| 254 | ---help--- | 254 | ---help--- |
| 255 | Provides thin provisioning and snapshots that share a data store. | 255 | Provides thin provisioning and snapshots that share a data store. |
| 256 | 256 | ||
| 257 | config DM_DEBUG_BLOCK_STACK_TRACING | ||
| 258 | boolean "Keep stack trace of persistent data block lock holders" | ||
| 259 | depends on STACKTRACE_SUPPORT && DM_PERSISTENT_DATA | ||
| 260 | select STACKTRACE | ||
| 261 | ---help--- | ||
| 262 | Enable this for messages that may help debug problems with the | ||
| 263 | block manager locking used by thin provisioning and caching. | ||
| 264 | |||
| 265 | If unsure, say N. | ||
| 266 | |||
| 267 | config DM_CACHE | 257 | config DM_CACHE |
| 268 | tristate "Cache target (EXPERIMENTAL)" | 258 | tristate "Cache target (EXPERIMENTAL)" |
| 269 | depends on BLK_DEV_DM | 259 | depends on BLK_DEV_DM |
diff --git a/drivers/md/dm-cache-policy-mq.c b/drivers/md/dm-cache-policy-mq.c index 1e018e986610..0e385e40909e 100644 --- a/drivers/md/dm-cache-policy-mq.c +++ b/drivers/md/dm-cache-policy-mq.c | |||
| @@ -872,7 +872,7 @@ static void mq_destroy(struct dm_cache_policy *p) | |||
| 872 | { | 872 | { |
| 873 | struct mq_policy *mq = to_mq_policy(p); | 873 | struct mq_policy *mq = to_mq_policy(p); |
| 874 | 874 | ||
| 875 | kfree(mq->table); | 875 | vfree(mq->table); |
| 876 | epool_exit(&mq->cache_pool); | 876 | epool_exit(&mq->cache_pool); |
| 877 | epool_exit(&mq->pre_cache_pool); | 877 | epool_exit(&mq->pre_cache_pool); |
| 878 | kfree(mq); | 878 | kfree(mq); |
| @@ -1245,7 +1245,7 @@ static struct dm_cache_policy *mq_create(dm_cblock_t cache_size, | |||
| 1245 | 1245 | ||
| 1246 | mq->nr_buckets = next_power(from_cblock(cache_size) / 2, 16); | 1246 | mq->nr_buckets = next_power(from_cblock(cache_size) / 2, 16); |
| 1247 | mq->hash_bits = ffs(mq->nr_buckets) - 1; | 1247 | mq->hash_bits = ffs(mq->nr_buckets) - 1; |
| 1248 | mq->table = kzalloc(sizeof(*mq->table) * mq->nr_buckets, GFP_KERNEL); | 1248 | mq->table = vzalloc(sizeof(*mq->table) * mq->nr_buckets); |
| 1249 | if (!mq->table) | 1249 | if (!mq->table) |
| 1250 | goto bad_alloc_table; | 1250 | goto bad_alloc_table; |
| 1251 | 1251 | ||
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index afc3d017de4c..d6e88178d22c 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
| @@ -546,6 +546,9 @@ static int read_exceptions(struct pstore *ps, | |||
| 546 | r = insert_exceptions(ps, area, callback, callback_context, | 546 | r = insert_exceptions(ps, area, callback, callback_context, |
| 547 | &full); | 547 | &full); |
| 548 | 548 | ||
| 549 | if (!full) | ||
| 550 | memcpy(ps->area, area, ps->store->chunk_size << SECTOR_SHIFT); | ||
| 551 | |||
| 549 | dm_bufio_release(bp); | 552 | dm_bufio_release(bp); |
| 550 | 553 | ||
| 551 | dm_bufio_forget(client, chunk); | 554 | dm_bufio_forget(client, chunk); |
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index baa87ff12816..fb9efc829182 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
| @@ -76,7 +76,7 @@ | |||
| 76 | 76 | ||
| 77 | #define THIN_SUPERBLOCK_MAGIC 27022010 | 77 | #define THIN_SUPERBLOCK_MAGIC 27022010 |
| 78 | #define THIN_SUPERBLOCK_LOCATION 0 | 78 | #define THIN_SUPERBLOCK_LOCATION 0 |
| 79 | #define THIN_VERSION 1 | 79 | #define THIN_VERSION 2 |
| 80 | #define THIN_METADATA_CACHE_SIZE 64 | 80 | #define THIN_METADATA_CACHE_SIZE 64 |
| 81 | #define SECTOR_TO_BLOCK_SHIFT 3 | 81 | #define SECTOR_TO_BLOCK_SHIFT 3 |
| 82 | 82 | ||
| @@ -1755,3 +1755,38 @@ int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, | |||
| 1755 | 1755 | ||
| 1756 | return r; | 1756 | return r; |
| 1757 | } | 1757 | } |
| 1758 | |||
| 1759 | int dm_pool_metadata_set_needs_check(struct dm_pool_metadata *pmd) | ||
| 1760 | { | ||
| 1761 | int r; | ||
| 1762 | struct dm_block *sblock; | ||
| 1763 | struct thin_disk_superblock *disk_super; | ||
| 1764 | |||
| 1765 | down_write(&pmd->root_lock); | ||
| 1766 | pmd->flags |= THIN_METADATA_NEEDS_CHECK_FLAG; | ||
| 1767 | |||
| 1768 | r = superblock_lock(pmd, &sblock); | ||
| 1769 | if (r) { | ||
| 1770 | DMERR("couldn't read superblock"); | ||
| 1771 | goto out; | ||
| 1772 | } | ||
| 1773 | |||
| 1774 | disk_super = dm_block_data(sblock); | ||
| 1775 | disk_super->flags = cpu_to_le32(pmd->flags); | ||
| 1776 | |||
| 1777 | dm_bm_unlock(sblock); | ||
