summaryrefslogtreecommitdiff
path: root/drivers/md/dm-cache-metadata.c
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2016-09-22 17:45:21 +0300
committerMike Snitzer <snitzer@redhat.com>2017-02-16 21:12:49 +0300
commit683bb1a3742bb0c8768711aa5ff1034d92e447f2 (patch)
tree6b8ade0e340f7b9ee5e2fd4fea756d079931ea3e /drivers/md/dm-cache-metadata.c
parent2151249eaabb48151cff6364adb4054b3497d62d (diff)
downloadlinux-683bb1a3742bb0c8768711aa5ff1034d92e447f2.tar.xz
dm cache metadata: use dm_bitset_new() to create the dirty bitset in format 2
Big speed up with large configs. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-cache-metadata.c')
-rw-r--r--drivers/md/dm-cache-metadata.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index 5a5ef996a26a..7e31a4b1c476 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -1547,10 +1547,16 @@ static int __set_dirty_bits_v1(struct dm_cache_metadata *cmd, unsigned nr_bits,
return 0;
}
+static int is_dirty_callback(uint32_t index, bool *value, void *context)
+{
+ unsigned long *bits = context;
+ *value = test_bit(index, bits);
+ return 0;
+}
+
static int __set_dirty_bits_v2(struct dm_cache_metadata *cmd, unsigned nr_bits, unsigned long *bits)
{
int r = 0;
- unsigned i;
/* nr_bits is really just a sanity check */
if (nr_bits != from_cblock(cmd->cache_blocks)) {
@@ -1558,18 +1564,12 @@ static int __set_dirty_bits_v2(struct dm_cache_metadata *cmd, unsigned nr_bits,
return -EINVAL;
}
- for (i = 0; i < nr_bits; i++) {
- if (test_bit(i, bits))
- r = dm_bitset_set_bit(&cmd->dirty_info, cmd->dirty_root, i, &cmd->dirty_root);
- else
- r = dm_bitset_clear_bit(&cmd->dirty_info, cmd->dirty_root, i, &cmd->dirty_root);
-
- if (r)
- return r;
- }
+ r = dm_bitset_del(&cmd->dirty_info, cmd->dirty_root);
+ if (r)
+ return r;
cmd->changed = true;
- return dm_bitset_flush(&cmd->dirty_info, cmd->dirty_root, &cmd->dirty_root);
+ return dm_bitset_new(&cmd->dirty_info, &cmd->dirty_root, nr_bits, is_dirty_callback, bits);
}
int dm_cache_set_dirty_bits(struct dm_cache_metadata *cmd,