drivers/md/Kconfig | 4 +- drivers/md/dm-multisnap-alloc.c | 24 ++++++----- drivers/md/dm-multisnap-blocks.c | 31 ++++++++------- drivers/md/dm-multisnap-btree.c | 55 +++++++++++++++----------- drivers/md/dm-multisnap-commit.c | 23 ++++++----- drivers/md/dm-multisnap-daniel.c | 32 +++++++++------ drivers/md/dm-multisnap-freelist.c | 19 +++++---- drivers/md/dm-multisnap-mikulas.c | 49 +++++++++++++---------- drivers/md/dm-multisnap-snaps.c | 76 +++++++++++++++++++++--------------- drivers/md/dm-multisnap.c | 22 +++++----- 10 files changed, 186 insertions(+), 149 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index c30bf70..4b7de2e 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -273,8 +273,8 @@ config DM_MULTISNAPSHOT_DANIEL depends on DM_MULTISNAPSHOT ---help--- Daniel Philips' exception store. The data structures were - designed by Daniel Phillips for Zumastore project, a porting - to kernel space was done by Fujita Tomonorig. + designed by Daniel Phillips for Zumastor project. The port + to kernel space was done by Fujita Tomonori. This store has limit of at most 64 snapshots and supports snapshot deletion. diff --git a/drivers/md/dm-multisnap-alloc.c b/drivers/md/dm-multisnap-alloc.c index 02f89be..8b39354 100644 --- a/drivers/md/dm-multisnap-alloc.c +++ b/drivers/md/dm-multisnap-alloc.c @@ -27,22 +27,22 @@ void dm_multisnap_create_bitmaps(struct dm_exception_store *s, chunk_t *writing_ if (*writing_block >= s->dev_size) { DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, - ("dm_multisnap_create_bitmaps: device is too small")); + ("%s: device is too small", __func__)); return; } if (*writing_block >= s->chunk_size << BITS_PER_BYTE_SHIFT) { DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, - ("dm_multisnap_create_bitmaps: invalid block to write: %llx", - (unsigned long long)*writing_block)); + ("%s: invalid block to write: %llx", + __func__, (unsigned long long)*writing_block)); return; } bmp = dm_bufio_new(s->bufio, *writing_block, &bp); if (IS_ERR(bmp)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(bmp), - ("dm_multisnap_create_bitmaps: can't create direct bitmap block at %llx", - (unsigned long long)*writing_block)); + ("%s: can't create direct bitmap block at %llx", + __func__, (unsigned long long)*writing_block)); return; } cond_resched(); @@ -174,7 +174,8 @@ static void dm_multisnap_add_bitmap(struct dm_exception_store *s) * Return the block in block and path in path. */ void *dm_multisnap_map_bitmap(struct dm_exception_store *s, bitmap_t bitmap, - struct dm_buffer **bp, chunk_t *block, struct path_element *path) + struct dm_buffer **bp, chunk_t *block, + struct path_element *path) { __u64 *bmp; unsigned idx; @@ -186,8 +187,8 @@ void *dm_multisnap_map_bitmap(struct dm_exception_store *s, bitmap_t bitmap, bmp = dm_multisnap_read_block(s, blk, bp); if (unlikely(!bmp)) { /* error is already set in dm_multisnap_read_block */ - DMERR("dm_multisnap_map_bitmap: can't read bitmap at " - "%llx (%llx), pointed to by %llx (%llx), depth %d/%d, index %llx", + DMERR("%s: can't read bitmap at %llx (%llx), pointed to by" + "%llx (%llx), depth %d/%d, index %llx", __func__, (unsigned long long)blk, (unsigned long long)dm_multisnap_remap_block(s, blk), (unsigned long long)parent, @@ -330,7 +331,8 @@ bit_find_failed: bitmap_no = 0; wrap_around++; if (wrap_around >= 2) { - DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, ("snapshot overflow")); + DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, + ("%s: snapshot overflow", __func__)); return -1; } } @@ -487,8 +489,8 @@ void dm_multisnap_free_blocks_immediate(struct dm_exception_store *s, chunk_t bl if (unlikely(block + n_blocks > s->dev_size)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_free_block_immediate: freeing invalid blocks %llx, %x", - (unsigned long long)block, n_blocks)); + ("%s: freeing invalid blocks %llx, %x", + __func__, (unsigned long long)block, n_blocks)); return; } diff --git a/drivers/md/dm-multisnap-blocks.c b/drivers/md/dm-multisnap-blocks.c index 8715ed9..7e24ef4 100644 --- a/drivers/md/dm-multisnap-blocks.c +++ b/drivers/md/dm-multisnap-blocks.c @@ -17,8 +17,10 @@ static int check_invalid(struct dm_exception_store *s, chunk_t block) unlikely(block == SB_BLOCK) || unlikely(dm_multisnap_is_commit_block(s, block))) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("check_invalid: access to invalid part of the device: %llx, size %llx", - (unsigned long long)block, (unsigned long long)s->dev_size)); + ("%s: access to invalid part of the device: " + "%llx, size %llx", + __func__, (unsigned long long)block, + (unsigned long long)s->dev_size)); return 1; } return 0; @@ -72,8 +74,8 @@ void *dm_multisnap_read_block(struct dm_exception_store *s, chunk_t block, buf = dm_bufio_read(s->bufio, block, bp); if (unlikely(IS_ERR(buf))) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(buf), - ("dm_multisnap_read_block: error read chunk %llx", - (unsigned long long)block)); + ("%s: error read chunk %llx", + __func__, (unsigned long long)block)); return NULL; } return buf; @@ -191,8 +193,8 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *s, chunk_t old_chu if (t) { if (unlikely(t->bitmap_idx != bitmap_idx)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_duplicate_block: bitmap_idx doesn't match, %X != %X", - t->bitmap_idx, bitmap_idx)); + ("%s: bitmap_idx doesn't match, %X != %X", + __func__, t->bitmap_idx, bitmap_idx)); return NULL; } *to_free_ptr = t->new; @@ -200,7 +202,7 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *s, chunk_t old_chu } else { if (unlikely(list_empty(&s->free_tmp_remaps))) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_duplicate_block: all remap blocks used")); + ("%s: all remap blocks used", __func__)); return NULL; } t = list_first_entry(&s->free_tmp_remaps, struct tmp_remap, list); @@ -224,8 +226,8 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *s, chunk_t old_chu buf = dm_bufio_read(s->bufio, new_chunk, bp); if (IS_ERR(buf)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(buf), - ("dm_multisnap_duplicate_block: error reading chunk %llx", - (unsigned long long)new_chunk)); + ("%s: error reading chunk %llx", + __func__, (unsigned long long)new_chunk)); return NULL; } return buf; @@ -260,8 +262,8 @@ void *dm_multisnap_make_block(struct dm_exception_store *s, chunk_t new_chunk, buf = dm_bufio_new(s->bufio, new_chunk, bp); if (unlikely(IS_ERR(buf))) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(buf), - ("dm_multisnap_make_block: error creating new block at chunk %llx", - (unsigned long long)new_chunk)); + ("%s: error creating new block at chunk %llx", + __func__, (unsigned long long)new_chunk)); return NULL; } return buf; @@ -318,12 +320,13 @@ void dm_multisnap_init_stop_cycles(struct stop_cycles *cy) cy->count = 0; } -int dm_multisnap_stop_cycles(struct dm_exception_store *s, struct stop_cycles *cy, chunk_t key) +int dm_multisnap_stop_cycles(struct dm_exception_store *s, + struct stop_cycles *cy, chunk_t key) { if (unlikely(cy->key == key) && unlikely(cy->count != 0)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_stop_cycles: cycle detected at chunk %llx", - (unsigned long long)key)); + ("%s: cycle detected at chunk %llx", + __func__, (unsigned long long)key)); return -1; } cy->count++; diff --git a/drivers/md/dm-multisnap-btree.c b/drivers/md/dm-multisnap-btree.c index a7e3b60..b01aaaa 100644 --- a/drivers/md/dm-multisnap-btree.c +++ b/drivers/md/dm-multisnap-btree.c @@ -27,8 +27,8 @@ dm_multisnap_read_btnode(struct dm_exception_store *s, int depth, if (unlikely(node->signature != BT_SIGNATURE)) { dm_bufio_release(*bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_read_btnode: bad signature on btree node %llx", - (unsigned long long)block)); + ("%s: bad signature on btree node %llx", + __func__, (unsigned long long)block)); return NULL; } @@ -36,8 +36,8 @@ dm_multisnap_read_btnode(struct dm_exception_store *s, int depth, (want_entries && unlikely(le32_to_cpu(node->n_entries) != want_entries))) { dm_bufio_release(*bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_read_btnode: bad number of entries in btree node " - "%llx: %x, wanted %x", + ("%s: bad number of entries in btree node " + "%llx: %x, wanted %x", __func__, (unsigned long long)block, le32_to_cpu(node->n_entries), want_entries)); @@ -93,15 +93,15 @@ void dm_multisnap_create_btree(struct dm_exception_store *s, chunk_t *writing_bl if (*writing_block >= s->dev_size) { DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, - ("dm_multisnap_create_btree: device is too small")); + ("%s: device is too small", __func__)); return; } node = dm_bufio_new(s->bufio, *writing_block, &bp); if (IS_ERR(node)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(node), - ("dm_multisnap_create_btree: 't create direct bitmap block at %llx", - (unsigned long long)*writing_block)); + ("%s: cannot create direct bitmap block at %llx", + __func__, (unsigned long long)*writing_block)); return; } memset(node, 0, s->chunk_size); @@ -220,9 +220,10 @@ static int walk_btree(struct dm_exception_store *s, struct bt_key *key, unlikely(last_snapid != want_last_snapid)) { dm_bufio_release(*bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("walk_btree: invalid last entry in node %llx/%llx: " + ("%s: invalid last entry in node %llx/%llx: " "last_chunk %llx, want_last_chunk %llx, last_snapid: %llx, " "want_last_snapid: %llx, searching for %llx, %llx-%llx", + __func__, (unsigned long long)block, (unsigned long long)dm_multisnap_remap_block(s, block), (unsigned long long)last_chunk, @@ -327,8 +328,8 @@ list_next_node: if (unlikely(r <= 0)) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_list_btree: non-monotonic btree: node " - "%llx, index %x", + ("%s: non-monotonic btree: node " + "%llx, index %x", __func__, (unsigned long long)path[depth].block, idx)); return 0; } @@ -374,8 +375,8 @@ void dm_multisnap_add_to_btree(struct dm_exception_store *s, struct bt_key *key, if (r > 0) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_add_to_btree: adding key that already exists: " - "%llx, %llx-%llx", + ("%s: adding key that already exists: " + "%llx, %llx-%llx", __func__, (unsigned long long)key->chunk, (unsigned long long)key->snap_from, (unsigned long long)key->snap_to)); @@ -450,7 +451,7 @@ go_up: if (s->bt_depth >= MAX_BT_DEPTH) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_add_to_btree: max b+-tree depth reached")); + ("%s: max b+-tree depth reached", __func__)); return; } @@ -508,9 +509,10 @@ static void dm_multisnap_fixup_backlimits(struct dm_exception_store *s, unlikely(mikulas_snapid_to_cpu(node->entries[idx].snap_to) != old_snapid)) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_fixup_backlimits: btree limit does not match, block " - "%llx, idx %x, orig_chunk %llx, snap_from %llx, snap_to " - "%llx, want %llx, %llx", + ("%s: btree limit does not match, block %llx, " + "idx %x, orig_chunk %llx, snap_from %llx, " + "snap_to %llx, want %llx, %llx", + __func__, (unsigned long long)path[depth].block, idx, (unsigned long long)read_48(&node->entries[idx], orig_chunk), @@ -530,7 +532,8 @@ static void dm_multisnap_fixup_backlimits(struct dm_exception_store *s, return; } DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_fixup_backlimits: the last entry modified, %llx/%llx -> %llx/%llx", + ("%s: the last entry modified, %llx/%llx -> %llx/%llx", + __func__, (unsigned long long)old_chunk, (unsigned long long)old_snapid, (unsigned long long)new_chunk, @@ -558,7 +561,8 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *s, struct bt_k if (!r) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_restrict_btree_entry: unknown key: %llx, %llx-%llx", + ("%s: unknown key: %llx, %llx-%llx", + __func__, (unsigned long long)key->chunk, (unsigned long long)key->snap_from, (unsigned long long)key->snap_to)); @@ -581,8 +585,9 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *s, struct bt_k } else { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_restrict_btree_entry: invali range to restruct: " + ("%s: invalid range to restrict: " "%llx, %llx-%llx %llx-%llx", + __func__, (unsigned long long)key->chunk, (unsigned long long)from, (unsigned long long)to, @@ -619,8 +624,8 @@ void dm_multisnap_extend_btree_entry(struct dm_exception_store *s, struct bt_key if (!r) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_extend_btree_entry: unknown key: " - "%llx, %llx-%llx", + ("%s: unknown key: %llx, %llx-%llx", + __func__, (unsigned long long)key->chunk, (unsigned long long)key->snap_from, (unsigned long long)key->snap_to)); @@ -675,7 +680,8 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *s, struct bt_key if (unlikely(!r)) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_from_btree: unknown key: %llx, %llx-%llx", + ("%s: unknown key: %llx, %llx-%llx", + __func__, (unsigned long long)key->chunk, (unsigned long long)key->snap_from, (unsigned long long)key->snap_to)); @@ -691,8 +697,9 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *s, struct bt_key if (unlikely(from != key->snap_from) || unlikely(to != key->snap_to)) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_from_btree: invalid range to restrict: " + ("%s: invalid range to restrict: " "%llx, %llx-%llx %llx-%llx", + __func__, (unsigned long long)key->chunk, (unsigned long long)from, (unsigned long long)to, @@ -705,7 +712,7 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *s, struct bt_key dm_bufio_release(bp); if (unlikely(!depth)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_from_btree: b-tree is empty")); + ("%s: b-tree is empty", __func__)); return; } dm_multisnap_free_block_and_duplicates(s, path[depth].block); diff --git a/drivers/md/dm-multisnap-commit.c b/drivers/md/dm-multisnap-commit.c index 78b2583..96a07ca 100644 --- a/drivers/md/dm-multisnap-commit.c +++ b/drivers/md/dm-multisnap-commit.c @@ -42,8 +42,8 @@ static void dm_multisnap_finalize_tmp_remaps(struct dm_exception_store *s) continue; } else { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_finalize_tmp_remaps: no bitmap tmp remaps, n_used_tmp_remaps %u", - s->n_used_tmp_remaps)); + ("%s: no bitmap tmp_remaps, n_used_tmp_remaps %u", + __func__, s->n_used_tmp_remaps)); return; } } @@ -85,7 +85,7 @@ void dm_multisnap_prepare_for_commit(struct dm_exception_store *s) r = dm_bufio_write_dirty_buffers(s->bufio); if (unlikely(r < 0)) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("dm_multisnap_prepare_for_commit: error writing data")); + ("%s: error writing data", __func__)); return; } } @@ -140,7 +140,7 @@ void dm_multisnap_commit(struct dm_exception_store *s) r = dm_bufio_write_dirty_buffers(s->bufio); if (unlikely(r < 0)) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("dm_multisnap_commit: error writing data")); + ("%s: error writing data", __func__)); return; } @@ -157,8 +157,8 @@ void dm_multisnap_commit(struct dm_exception_store *s) cb = dm_bufio_new(s->bufio, cb_addr, &bp); if (IS_ERR(cb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(cb), - ("dm_multisnap_commit: can't allocate new commit block at %llx", - (unsigned long long)cb_addr)); + ("%s: can't allocate new commit block at %llx", + __func__, (unsigned long long)cb_addr)); return; } @@ -203,8 +203,8 @@ void dm_multisnap_commit(struct dm_exception_store *s) r = dm_bufio_write_dirty_buffers(s->bufio); if (unlikely(r < 0)) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("dm_multisnap_commit: can't write commit block at %llx", - (unsigned long long)cb_addr)); + ("%s: can't write commit block at %llx", + __func__, (unsigned long long)cb_addr)); return; } @@ -215,14 +215,15 @@ void dm_multisnap_commit(struct dm_exception_store *s) sb = dm_bufio_read(s->bufio, SB_BLOCK, &bp); if (IS_ERR(sb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(sb), - ("dm_multisnap_commit: can't read super block")); + ("%s: can't read super block", __func__)); return; } if (unlikely(sb->signature != SB_SIGNATURE)) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_commit: invalid super block signature when committing")); + ("%s: invalid super block signature when committing", + __func__)); return; } @@ -232,7 +233,7 @@ void dm_multisnap_commit(struct dm_exception_store *s) dm_bufio_release(bp); r = dm_bufio_write_dirty_buffers(s->bufio); if (unlikely(r < 0)) { - DM_MULTISNAP_SET_ERROR(s->dm, r, ("dm_multisnap_commit: can't write super block")); + DM_MULTISNAP_SET_ERROR(s->dm, r, ("%s: can't write super block", __func__)); return; } diff --git a/drivers/md/dm-multisnap-daniel.c b/drivers/md/dm-multisnap-daniel.c index 00fd3c0..0d6c1b0 100644 --- a/drivers/md/dm-multisnap-daniel.c +++ b/drivers/md/dm-multisnap-daniel.c @@ -192,9 +192,10 @@ static int chunk_io(struct dm_exception_store *ps, chunk_t chunk, int rw, void * int r = dm_io(&io_req, 1, &where, NULL); if (r) { - DM_MULTISNAP_SET_ERROR(ps->dm, r, ("io error when %s %llx: %d", - rw == WRITE ? "writing" : "reading", - (unsigned long long)chunk, r)); + DM_MULTISNAP_SET_ERROR(ps->dm, r, ("%s: io error when %s %llx: %d", + __func__, + rw == WRITE ? "writing" : "reading", + (unsigned long long)chunk, r)); } return r; } @@ -207,7 +208,8 @@ static int write_header(struct dm_exception_store *ps) dh = (struct disk_header *) ps->area; dh->magic = cpu_to_le32(SNAP_MAGIC); - dh->valid = cpu_to_le32(dm_multisnap_drop_on_error(ps->dm) && dm_multisnap_has_error(ps->dm)); + dh->valid = cpu_to_le32(dm_multisnap_drop_on_error(ps->dm) && + dm_multisnap_has_error(ps->dm)); dh->version = cpu_to_le32(ps->version); dh->chunk_size = cpu_to_le32(ps->chunk_size >> SECTOR_SHIFT); @@ -358,7 +360,9 @@ again: /* todo: check # free chunks */ if (start_chunk == ps->cur_bitmap_chunk) { - DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC, ("%s %d: fail to find a new chunk", __func__, __LINE__)); + DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC, + ("%s %d: fail to find a new chunk", + __func__, __LINE__)); return 0; } @@ -1118,7 +1122,8 @@ static void check_leaf(struct dm_exception_store *ps, struct leaf *leaf, u64 sna /* !!! should also check for any zero sharemaps here */ if (le64_to_cpu(p->share) & snapmask) { DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR, - ("nonzero bits %016llx outside snapmask %016llx", + ("%s: nonzero bits %016llx outside snapmask %016llx", + __func__, (unsigned long long)p->share, (unsigned long long)snapmask)); } @@ -1502,7 +1507,8 @@ static int shared_allocate_snapid(struct dm_exception_store *ps, int i; if (snap_of_snap) { - DMERR("shared_allocate_snapid: this exception store doesn't support snapshots of snapshots"); + DMERR("%s: this exception store doesn't support snapshots of snapshots", + __func__); return -EOPNOTSUPP; } @@ -1512,20 +1518,20 @@ static int shared_allocate_snapid(struct dm_exception_store *ps, return 0; } - DMERR("shared_allocate_snapid: limit of 64 snapshots reached"); + DMERR("%s: limit of 64 snapshots reached", __func__); return -ENOSPC; } static int shared_create_snapshot(struct dm_exception_store *ps, snapid_t snapid) { if (snapid >= MAX_SNAPSHOTS) { - DMERR("shared_create_snapshot: invalid snapshot id %llx", - (unsigned long long)snapid); + DMERR("%s: invalid snapshot id %llx", + __func__, (unsigned long long)snapid); return -EINVAL; } if (ps->snapmask & 1LL << snapid) { - DMERR("shared_create_snapshot: snapshot with id %llx already exists", - (unsigned long long)snapid); + DMERR("%s: snapshot with id %llx already exists", + __func__, (unsigned long long)snapid); return -EINVAL; } ps->snapmask |= 1LL << snapid; @@ -1707,5 +1713,5 @@ module_init(dm_multisnapshot_daniel_module_init); module_exit(dm_multisnapshot_daniel_module_exit); MODULE_DESCRIPTION(DM_NAME " multisnapshot Fujita/Daniel's exceptions store"); -MODULE_AUTHOR("Fujita Tomonorig, Daniel Phillips"); +MODULE_AUTHOR("Fujita Tomonori, Daniel Phillips"); MODULE_LICENSE("GPL"); diff --git a/drivers/md/dm-multisnap-freelist.c b/drivers/md/dm-multisnap-freelist.c index 6ec1476..62d49cf 100644 --- a/drivers/md/dm-multisnap-freelist.c +++ b/drivers/md/dm-multisnap-freelist.c @@ -38,7 +38,8 @@ static int add_to_freelist(struct dm_exception_store *s, chunk_t block, unsigned unsigned f = le16_to_cpu(fl->entries[i].run_length) & FREELIST_DATA_FLAG; if (block >= x && block < x + r) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("add_to_freelist: freeing already free block %llx (%llx - %x)", + ("%s: freeing already free block %llx (%llx - %x)", + __func__, (unsigned long long)block, (unsigned long long)x, r)); @@ -77,22 +78,22 @@ read_freelist(struct dm_exception_store *s, chunk_t block, struct dm_buffer **bp fl = dm_bufio_read(s->bufio, block, bp); if (IS_ERR(fl)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(fl), - ("read_freelist: can't read freelist block %llx", - (unsigned long long)block)); + ("%s: can't read freelist block %llx", + __func__, (unsigned long long)block)); return NULL; } if (fl->signature != FL_SIGNATURE) { dm_bufio_release(*bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("read_freelist: bad signature freelist block %llx", - (unsigned long long)block)); + ("%s: bad signature freelist block %llx", + __func__, (unsigned long long)block)); return NULL; } if (le32_to_cpu(fl->n_entries) > dm_multisnap_freelist_entries(s->chunk_size)) { dm_bufio_release(*bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("read_freelist: bad number of entries in freelist block %llx", - (unsigned long long)block)); + ("%s: bad number of entries in freelist block %llx", + __func__, (unsigned long long)block)); return NULL; } return fl; @@ -114,8 +115,8 @@ static void alloc_write_freelist(struct dm_exception_store *s) fl = dm_bufio_new(s->bufio, new_block, &bp); if (IS_ERR(fl)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(fl), - ("alloc_write_freelist: can't make new freelist block %llx", - (unsigned long long)new_block)); + ("%s: can't make new freelist block %llx", + __func__, (unsigned long long)new_block)); return; } diff --git a/drivers/md/dm-multisnap-mikulas.c b/drivers/md/dm-multisnap-mikulas.c index 778c3a3..27cc050 100644 --- a/drivers/md/dm-multisnap-mikulas.c +++ b/drivers/md/dm-multisnap-mikulas.c @@ -63,14 +63,16 @@ static void load_commit_block(struct dm_exception_store *s) cb = dm_bufio_read(s->bufio, s->valid_commit_block, &bp); if (IS_ERR(cb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(cb), - ("load_commit_block: can't re-read commit block %llx", + ("%s: can't re-read commit block %llx", + __func__, (unsigned long long)s->valid_commit_block)); return; } if (cb->signature != CB_SIGNATURE) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("load_commit_block: bad signature when re-reading commit block %llx", + ("%s: bad signature when re-reading commit block %llx", + __func__, (unsigned long long)s->valid_commit_block)); return; } @@ -93,8 +95,8 @@ static void load_commit_block(struct dm_exception_store *s) if (s->bt_depth > MAX_BT_DEPTH || !s->bt_depth) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("load_commit_block: invalid b+-tree depth in commit block %llx", - (unsigned long long)s->valid_commit_block)); + ("%s: invalid b+-tree depth in commit block %llx", + __func__, (unsigned long long)s->valid_commit_block)); return; } @@ -121,13 +123,14 @@ static void load_commit_block(struct dm_exception_store *s) if ((chunk_t)(dev_size + s->cb_stride) < (chunk_t)dev_size) { DM_MULTISNAP_SET_ERROR(s->dm, -ERANGE, - ("load_commit_block: device is too large. Compile kernel with 64-bit sector numbers")); + ("%s: device is too large. Compile kernel with 64-bit sector numbers", + __func__)); return; } bitmap_depth = dm_multisnap_bitmap_depth(s->chunk_shift, dev_size); if (bitmap_depth < 0) { DM_MULTISNAP_SET_ERROR(s->dm, bitmap_depth, - ("load_commit_block: device is too large")); + ("%s: device is too large", __func__)); return; } s->dev_size = dev_size; @@ -157,15 +160,15 @@ try_next: cb = dm_bufio_read(s->bufio, cb_addr, &bp); if (IS_ERR(cb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(cb), - ("find_commit_block: can't read commit block %llx", - (unsigned long long)cb_addr)); + ("%s: can't read commit block %llx", + __func__, (unsigned long long)cb_addr)); return; } if (cb->signature != CB_SIGNATURE) { dm_bufio_release(bp); DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("find_commit_block: bad signature on commit block %llx", - (unsigned long long)cb_addr)); + ("%s: bad signature on commit block %llx", + __func__, (unsigned long long)cb_addr)); return; } @@ -184,7 +187,7 @@ try_next: } if (!s->valid_commit_block) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("find_commit_block: no valid commit block")); + ("%s: no valid commit block", __func__)); return; } } @@ -220,7 +223,8 @@ static void initialize_device(struct dm_exception_store *s) r = get_size(s, &s->dev_size); if (r) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("initialize_device: device is too large. Compile kernel with 64-bit sector numbers")); + ("%s: device is too large. Compile kernel with 64-bit sector numbers", + __func__)); return; } @@ -244,15 +248,15 @@ static void initialize_device(struct dm_exception_store *s) /* Write commit blocks */ if (FIRST_CB_BLOCK >= s->dev_size) { DM_MULTISNAP_SET_ERROR(s->dm, -ENOSPC, - ("initialize_device: device is too small")); + ("%s: device is too small", __func__)); return; } for (cb_block = FIRST_CB_BLOCK; cb_block < s->dev_size; cb_block += s->cb_stride) { cb = dm_bufio_new(s->bufio, cb_block, &bp); if (IS_ERR(cb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(cb), - ("initialize_device: can't allocate commit block at %llx", - (unsigned long long)cb_block)); + ("%s: can't allocate commit block at %llx", + __func__, (unsigned long long)cb_block)); return; } memset(cb, 0, s->chunk_size); @@ -276,7 +280,7 @@ static void initialize_device(struct dm_exception_store *s) r = dm_bufio_write_dirty_buffers(s->bufio); if (r) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("initialize_device: write error when initializing device")); + ("%s: write error when initializing device", __func__)); return; } @@ -284,7 +288,7 @@ static void initialize_device(struct dm_exception_store *s) sb = dm_bufio_new(s->bufio, SB_BLOCK, &bp); if (IS_ERR(sb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(sb), - ("initialize_device: can't allocate super block")); + ("%s: can't allocate super block", __func__)); return; } memset(sb, 0, s->chunk_size); @@ -298,7 +302,7 @@ static void initialize_device(struct dm_exception_store *s) r = dm_bufio_write_dirty_buffers(s->bufio); if (r) { DM_MULTISNAP_SET_ERROR(s->dm, r, - ("initialize_device: can't write super block")); + ("%s: can't write super block", __func__)); return; } } @@ -322,8 +326,8 @@ static void extend_exception_store(struct dm_exception_store *s, chunk_t new_siz cb = dm_bufio_new(s->bufio, cb_block, &bp); if (IS_ERR(cb)) { DM_MULTISNAP_SET_ERROR(s->dm, PTR_ERR(cb), - ("initialize_device: can't allocate commit block at %llx", - (unsigned long long)cb_block)); + ("%s: can't allocate commit block at %llx", + __func__, (unsigned long long)cb_block)); return; } memset(cb, 0, s->chunk_size); @@ -423,7 +427,8 @@ re_read: if (e < 0) { /* Don't read the B+-tree if there was an error */ DM_MULTISNAP_SET_ERROR(s->dm, e, - ("read_super: activating invalidated snapshot store, error %d", e)); + ("%s: activating invalidated snapshot store, error %d", + __func__, e)); return 0; } @@ -464,7 +469,7 @@ static void dm_multisnap_mikulas_lock_acquired(struct dm_exception_store *s, int if (unlikely(new_size != s->dev_size)) { if (unlikely(new_size < s->dev_size)) { DM_MULTISNAP_SET_ERROR(s->dm, -EINVAL, - ("dm_multisnap_mikulas_lock_acquired: device shrinked")); + ("%s: device shrank", __func__)); return; } extend_exception_store(s, new_size); diff --git a/drivers/md/dm-multisnap-snaps.c b/drivers/md/dm-multisnap-snaps.c index 9947673..3f94ca0 100644 --- a/drivers/md/dm-multisnap-snaps.c +++ b/drivers/md/dm-multisnap-snaps.c @@ -40,14 +40,18 @@ go_left: } else { if (!add) { found = rn; - /* If there is range query, we need to find the leftmost node */ + /* + * If there is range query, we need + * to find the leftmost node + */ if (from < rn->from) goto go_left; break; } else { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("rb_insert_snapshot: inserting overlapping entry: " + ("%s: inserting overlapping entry: " "(%llx,%llx) overlaps (%llx,%llx)", + __func__, (unsigned long long)from, (unsigned long long)to, (unsigned long long)rn->from, @@ -65,7 +69,8 @@ go_left: new = kmalloc(sizeof(struct snapshot_range), GFP_KERNEL); if (!new) { DM_MULTISNAP_SET_ERROR(s->dm, -ENOMEM, - ("rb_insert_snapshot: can't allocate memory for snapshot descriptor")); + ("%s: can't allocate memory for snapshot descriptor", + __func__)); return NULL; } @@ -127,14 +132,14 @@ static int rb_extend_range(struct dm_exception_store *s, rn = rb_find_insert_snapshot(s, from, from, 0); if (!rn) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("rb_extend_range: snapshot %llx not found", - (unsigned long long)from)); + ("%s: snapshot %llx not found", + __func__, (unsigned long long)from)); return -1; } if (rn->to != from) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("rb_extend_range: bad attempt to extend range: " - "%llx >= %llx", + ("%s: bad attempt to extend range: " + "%llx >= %llx", __func__, (unsigned long long)rn->to, (unsigned long long)from)); return -1; @@ -158,8 +163,8 @@ static int rb_delete_range(struct dm_exception_store *s, if (!sr || sr->to < to) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("rb_delete_range: deleting non-existing snapid " - "%llx-%llx", + ("%s: deleting non-existing snapid " + "%llx-%llx", __func__, (unsigned long long)from, (unsigned long long)to)); return -1; @@ -294,7 +299,7 @@ find_next: if (r) { if (unlikely(snap_key.snap_to > DM_SNAPID_T_MAX)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_read_snapshots: invalid snapshot id")); + ("%s: invalid snapshot id", __func__)); return; } r = rb_insert_snapshot(s, snap_key.snap_from, snap_key.snap_to); @@ -316,23 +321,25 @@ int dm_multisnap_allocate_snapid(struct dm_exception_store *s, if (snap_of_snap) { #ifdef CONFIG_DM_MULTISNAPSHOT_MIKULAS_SNAP_OF_SNAP if (!dm_multisnap_snapid_is_master(master)) { - DMERR("dm_multisnap_allocate_snapid: only two levels of snapshots are supported"); + DMERR("%s: only two levels of snapshots are supported", __func__); return -EOPNOTSUPP; } *snapid = dm_multisnap_find_next_subsnapshot(s, master); if (*snapid == master) { - DMERR("dm_multisnap_allocate_snapid: 2^32 snapshots-of-snapshot limit reached"); + DMERR("%s: 2^32 snapshots-of-snapshot limit reached", __func__); return -ENOSPC; } return 0; #else - DMERR("dm_multisnap_allocate_snapid: snapshots of snapshots not supported with 32-bit snapshot IDs"); + DMERR("%s: snapshots of snapshots not supported with 32-bit snapshot IDs", + __func__); return -EOPNOTSUPP; #endif } - *snapid = ((mikulas_snapid_t)s->snapshot_num << DM_MIKULAS_SNAPID_STEP_BITS) | DM_MIKULAS_SUBSNAPID_MASK; + *snapid = ((mikulas_snapid_t)s->snapshot_num << DM_MIKULAS_SNAPID_STEP_BITS) | + DM_MIKULAS_SUBSNAPID_MASK; if (s->snapshot_num == 0xffffffff || *snapid > DM_SNAPID_T_MAX) { - DMERR("dm_multisnap_allocate_snapid: 2^32 snapshot limit reached"); + DMERR("%s: 2^32 snapshot limit reached", __func__); return -ENOSPC; } return 0; @@ -402,14 +409,15 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *s, if (r <= 0) { if (!r) DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_snapshot: snapshot id %llx not found in b-tree", - (unsigned long long)from)); + ("%s: snapshot id %llx not found in b-tree", + __func__, (unsigned long long)from)); return dm_multisnap_has_error(s->dm); } if (snap_key.snap_to < to) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_snapshot: snapshot id %llx-%llx not found in b-tree", - (unsigned long long)from, (unsigned long long)to)); + ("%s: snapshot id %llx-%llx not found in b-tree", + __func__, (unsigned long long)from, + (unsigned long long)to)); return -EFSERROR; } @@ -443,22 +451,24 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *s, /* * Create a subsnapshot. */ -static int dm_multisnap_create_subsnapshot(struct dm_exception_store *s, snapid_t snapid) +static int dm_multisnap_create_subsnapshot(struct dm_exception_store *s, + snapid_t snapid) { int r; snapid_t master, next_sub; master = snapid | DM_MIKULAS_SUBSNAPID_MASK; if (!dm_multisnap_snapshot_exists(s->dm, master)) { - DMERR("dm_multisnap_create_subsnapshot: master snapshot with id %llx doesn't exist", - (unsigned long long)snapid); + DMERR("%s: master snapshot with id %llx doesn't exist", + __func__, (unsigned long long)snapid); return -EINVAL; } next_sub = dm_multisnap_find_next_subsnapshot(s, master); if (snapid < next_sub) { - DMERR("dm_multisnap_create_subsnapshot: invalid subsnapshot id %llx " + DMERR("%s: invalid subsnapshot id %llx " "(allowed range %llx - %llx)", + __func__, (unsigned long long)snapid, (unsigned long long)next_sub, (unsigned long long)master - 1); @@ -488,16 +498,18 @@ int dm_multisnap_create_snapshot(struct dm_exception_store *s, snapid_t snapid) if (!dm_multisnap_snapid_is_master(snapid)) return dm_multisnap_create_subsnapshot(s, snapid); - if ((snapid >> DM_MIKULAS_SNAPID_STEP_BITS) < s->snapshot_num || snapid > DM_SNAPID_T_MAX) { - DMERR("dm_multisnap_create_snapshot: invalid snapshot id %llx (allowed range %llx - %llx)", - (unsigned long long)snapid, - (unsigned long long)s->snapshot_num, - (unsigned long long)DM_SNAPID_T_MAX); + if ((snapid >> DM_MIKULAS_SNAPID_STEP_BITS) < s->snapshot_num || + snapid > DM_SNAPID_T_MAX) { + DMERR("%s: invalid snapshot id %llx (allowed range %llx - %llx)", + __func__, + (unsigned long long)snapid, + (unsigned long long)s->snapshot_num, + (unsigned long long)DM_SNAPID_T_MAX); return -EINVAL; } if (dm_multisnap_snapshot_exists(s->dm, snapid)) { - DMERR("dm_multisnap_create_snapshot: snapshot with id %llx already exists", - (unsigned long long)snapid); + DMERR("%s: snapshot with id %llx already exists", + __func__, (unsigned long long)snapid); return -EINVAL; } @@ -521,8 +533,8 @@ int dm_multisnap_delete_snapshot(struct dm_exception_store *s, snapid_t snapid) if (!dm_multisnap_snapshot_exists(s->dm, snapid)) { DM_MULTISNAP_SET_ERROR(s->dm, -EFSERROR, - ("dm_multisnap_delete_snapshot: snapshot id %llx not found in rb-tree", - (unsigned long long)snapid)); + ("%s: snapshot id %llx not found in rb-tree", + __func__, (unsigned long long)snapid)); return -EFSERROR; } diff --git a/drivers/md/dm-multisnap.c b/drivers/md/dm-multisnap.c index a2db7d5..a4a712e 100644 --- a/drivers/md/dm-multisnap.c +++ b/drivers/md/dm-multisnap.c @@ -485,8 +485,8 @@ static void remap_callback(int read_err, unsigned long write_err, void *pe_) struct dm_multisnap *s = pe->s; if (unlikely((read_err | write_err) != 0)) - DM_MULTISNAP_SET_ERROR(s, -EIO, ("remap_callback: kcopyd I/O error: " - "%d, %lx", read_err, write_err)); + DM_MULTISNAP_SET_ERROR(s, -EIO, ("%s: kcopyd I/O error: %d, %lx", + __func__, read_err, write_err)); list_add_tail(&pe->list, &s->pes_waiting_for_commit); @@ -606,8 +606,9 @@ static void do_origin_write(struct dm_multisnap *s, struct bio *bio) BUG_ON(bio_rw(bio) != WRITE); if (bio->bi_sector + (bio->bi_size >> SECTOR_SHIFT) > s->origin_sectors) { - DMERR("do_origin_write: access beyond end of device, flags %lx, " + DMERR("%s: access beyond end of device, flags %lx, " "sector %llx, size %x, origin sectors %llx", + __func__, bio->bi_flags, (unsigned long long)bio->bi_sector, bio->bi_size, @@ -1952,12 +1953,11 @@ static int __init dm_multisnapshot_init(void) { int r; - pending_exception_cache = kmem_cache_create( - "dm_multisnap_pending_exception", - sizeof(struct dm_multisnap_pending_exception), - __alignof__(struct dm_multisnap_pending_exception), - 0, - pending_exception_ctor); + pending_exception_cache = + kmem_cache_create("dm_multisnap_pending_exception", + sizeof(struct dm_multisnap_pending_exception), + __alignof__(struct dm_multisnap_pending_exception), + 0, pending_exception_ctor); if (!pending_exception_cache) { DMERR("Couldn't create exception cache."); r = -ENOMEM; @@ -1972,13 +1972,13 @@ static int __init dm_multisnapshot_init(void) r = dm_register_target(&multisnap_origin_target); if (r < 0) { - DMERR("multisnap_origin_target target register failed %d", r); + DMERR("multisnapshot target register failed %d", r); goto bad_multisnap_origin_target; } r = dm_register_target(&multisnap_snap_target); if (r < 0) { - DMERR("multisnap_snap_target target register failed %d", r); + DMERR("multisnap-snap target register failed %d", r); goto bad_multisnap_snap_target; }