Skip to contentSkip to conversation

some shared snapshot readability improvements

PATCH In review Mike Snitzer 2 participants 9 messages Apr 2, 2010 – Apr 6, 2010 Device mapper

lore
Share & tools
lore
#0 lore raw

cover some shared snapshot readability improvements

Quite a lot of churn but I think it is for the better in the end.

(I developed these changes on Wednesday but just got around to getting them sent out now)

Mike Snitzer (7):
document low hanging fruit to help improve code readability Improve name used for "persistent store" in 'struct dm_multisnap' Avoid exception store being confused with snapshot 's' Avoid struct members with the name 'dm'
rename snapid members to use 'snapid' names
move individual dm_multisnap 'flags' values
Removed remaining 'struct dm_exception_store' FIXMEs.

 drivers/md/dm-multisnap-alloc.c          |  271 +++++++++---------
 drivers/md/dm-multisnap-blocks.c         |  118 ++++----
 drivers/md/dm-multisnap-btree.c          |  330 +++++++++++-----------
 drivers/md/dm-multisnap-commit.c         |  140 +++++-----
 drivers/md/dm-multisnap-daniel.c         |   32 +-
 drivers/md/dm-multisnap-delete.c         |   70 +++---
 drivers/md/dm-multisnap-freelist.c       |   96 ++++----
 drivers/md/dm-multisnap-io.c             |  148 +++++-----
 drivers/md/dm-multisnap-mikulas-struct.h |    8 +-
 drivers/md/dm-multisnap-mikulas.c        |  441 +++++++++++++++---------------
 drivers/md/dm-multisnap-mikulas.h        |  110 ++++----
 drivers/md/dm-multisnap-private.h        |    8 +-
 drivers/md/dm-multisnap-snaps.c          |  234 ++++++++--------
 drivers/md/dm-multisnap.c                |   72 +++---
 drivers/md/dm-multisnap.h                |   38 ++--
 15 files changed, 1060 insertions(+), 1056 deletions(-)
#1 lore raw

PATCH 1/7 document low hanging fruit to help improve code readability

Documented some changes which should help improve code readability with FIXME.

---
 drivers/md/dm-multisnap-mikulas.c |    4 ++++
 drivers/md/dm-multisnap-mikulas.h |    7 +++++++
 drivers/md/dm-multisnap-private.h |    5 +++++
 3 files changed, 16 insertions(+), 0 deletions(-)
drivers/md/dm-multisnap-mikulas.c +4 -0
index e16c0d6..1c33dd2 100644
@@ -537,11 +537,15 @@ static void print_bitmaps(struct dm_exception_store *s)
  * Parse arguments, allocate structures and call read_super to read the data
  * from the disk.
  */
+/* FIXME rename all 'struct dm_multisnap *dm' to be using 's' for snapshot, e.g.: */
+/* dm-multisnap-private.h:dm_multisnap_snap uses 'struct dm_multisnap *s' */
 static int dm_multisnap_mikulas_init(struct dm_multisnap *dm,
 				     struct dm_exception_store **sp,
 				     unsigned argc, char **argv, char **error)
 {
 	int r, i;
+	/* FIXME replace all 's' with 'ps' in entire dm-multisnap-mikulas.c */
+	/* avoids confusion with 's' being widely known as some form of snapshot in dm */
 	struct dm_exception_store *s;
 
 	s = kzalloc(sizeof(struct dm_exception_store), GFP_KERNEL);
drivers/md/dm-multisnap-mikulas.h +7 -0
index 52c87e0..3fdc97e 100644
@@ -49,6 +49,7 @@ struct tmp_remap {
 
 struct bt_key {
 	chunk_t chunk;
+	/* FIXME rename: snapid_{from,to}? */
 	mikulas_snapid_t snap_from;
 	mikulas_snapid_t snap_to;
 };
@@ -59,8 +60,13 @@ struct path_element {
 	unsigned n_entries;
 };
 
+/* FIXME reusing 'dm_exception_store' name lends itself to confusion with legacy snapshots? */
+/* FIXME not to mention, each multisnap stores' 'dm_exception_store' is different */
+/* FIXME rename: dm_multisnap_persistent_exception_store? */
 struct dm_exception_store {
+	/* FIXME rename: multisnap? or just 's' for snapshot? */
 	struct dm_multisnap *dm;
+	/* FIXME rename: bufio_client? */
 	struct dm_bufio_client *bufio;
 
 	chunk_t dev_size;
@@ -71,6 +77,7 @@ struct dm_exception_store {
 	__u8 bt_depth;
 	__u8 flags;
 	__u32 snapshot_num;
+	/* FIXME rename: commit_block_stride? */
 	unsigned cb_stride;
 
 	chunk_t bitmap_root;
drivers/md/dm-multisnap-private.h +5 -0
index b623027..5d13ded 100644
@@ -40,6 +40,10 @@ struct dm_multisnap_bio_queue {
 #define DM_MULTISNAP_N_QUEUES	2
 
 struct dm_multisnap {
+	/* FIXME rename 'p' to be more descriptive, maybe 'ps' or 'pstore' for persistent store? */
+	/* FIXME also reorder in struct; put 'store' before 'ps' (_init() order)? */
+	// struct dm_multisnap_exception_store *store;
+	// struct dm_multisnap_persistent_exception_store *ps;
 	struct dm_exception_store *p;
 	struct dm_multisnap_exception_store *store;
 
@@ -52,6 +56,7 @@ struct dm_multisnap {
 	unsigned char chunk_shift;
 
 	unsigned char flags;
+	/* FIXME these flags should be defined outside the struct, like agk fixed for merge */
 #define DM_MULTISNAP_SYNC_SNAPSHOTS		1
 #define DM_MULTISNAP_PRESERVE_ON_ERROR		2
 
Signature · 1 line
1.6.6.1
#2 lore raw

PATCH 2/7 Improve name used for "persistent store" in 'struct dm_multisnap'

In reply to Mike Snitzer

Renamed 'struct dm_exception_store *p' to 'ps' in 'struct dm_multisnap'. While not perfect, 'ps' does offer some addiitonal consistency relative to the existing snapshot code base.

---
 drivers/md/dm-multisnap-private.h |    6 +---
 drivers/md/dm-multisnap.c         |   72 ++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 41 deletions(-)
drivers/md/dm-multisnap-private.h +1 -5
index 5d13ded..935ddc1 100644
@@ -40,12 +40,8 @@ struct dm_multisnap_bio_queue {
 #define DM_MULTISNAP_N_QUEUES	2
 
 struct dm_multisnap {
-	/* FIXME rename 'p' to be more descriptive, maybe 'ps' or 'pstore' for persistent store? */
-	/* FIXME also reorder in struct; put 'store' before 'ps' (_init() order)? */
-	// struct dm_multisnap_exception_store *store;
-	// struct dm_multisnap_persistent_exception_store *ps;
-	struct dm_exception_store *p;
 	struct dm_multisnap_exception_store *store;
+	struct dm_exception_store *ps;
 
 	struct dm_dev *origin;
 	struct dm_dev *snapshot;
drivers/md/dm-multisnap.c +36 -36

257 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#3 lore raw

PATCH 4/7 Avoid struct members with the name 'dm'

In reply to Mike Snitzer

perl -pi -e 's|ps->dm|ps->s|g' dm-multi*.[ch]

Could just as easily use 'multisnap' rather than 's' for the 'struct dm_multisnap' snapshot pointer.

---
 drivers/md/dm-multisnap-alloc.c    |   32 +++++++-------
 drivers/md/dm-multisnap-blocks.c   |   14 +++---
 drivers/md/dm-multisnap-btree.c    |   34 ++++++++--------
 drivers/md/dm-multisnap-commit.c   |   26 ++++++------
 drivers/md/dm-multisnap-daniel.c   |   32 +++++++-------
 drivers/md/dm-multisnap-delete.c   |   14 +++---
 drivers/md/dm-multisnap-freelist.c |   20 +++++-----
 drivers/md/dm-multisnap-io.c       |   12 +++---
 drivers/md/dm-multisnap-mikulas.c  |   78 +++++++++++++++++------------------
 drivers/md/dm-multisnap-mikulas.h  |    6 +--
 drivers/md/dm-multisnap-snaps.c    |   62 ++++++++++++++--------------
 drivers/md/dm-multisnap.h          |    2 +-
 12 files changed, 163 insertions(+), 169 deletions(-)
drivers/md/dm-multisnap-alloc.c +16 -16
index dd9b1d4..1e5a2d0 100644
@@ -26,13 +26,13 @@ void dm_multisnap_create_bitmaps(struct dm_exception_store *ps, chunk_t *writing
 		(*writing_block)++;
 
 	if (*writing_block >= ps->dev_size) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC,
+		DM_MULTISNAP_SET_ERROR(ps->s, -ENOSPC,
 				       ("%s: device is too small", __func__));
 		return;
 	}
 
 	if (*writing_block >= ps->chunk_size << BITS_PER_BYTE_SHIFT) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC,
+		DM_MULTISNAP_SET_ERROR(ps->s, -ENOSPC,
 				       ("%s: invalid block to write: %llx",
 					__func__, (unsigned long long)*writing_block));
 		return;
@@ -40,7 +40,7 @@ void dm_multisnap_create_bitmaps(struct dm_exception_store *ps, chunk_t *writing
 
 	bmp = dm_bufio_new(ps->bufio, *writing_block, &bp);
 	if (IS_ERR(bmp)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(bmp),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(bmp),
 				       ("%s: can't create direct bitmap block at %llx",
 					__func__, (unsigned long long)*writing_block));
 		return;
@@ -49,9 +49,9 @@ void dm_multisnap_create_bitmaps(struct dm_exception_store *ps, chunk_t *writing
 	memset(bmp, 0, ps->chunk_size);
 	for (i = 0; i <= *writing_block; i++) {
 		generic___set_le_bit(i, bmp);
-		dm_multisnap_status_lock(ps->dm);
+		dm_multisnap_status_lock(ps->s);
 		ps->total_allocated++;
-		dm_multisnap_status_unlock(ps->dm);
+		dm_multisnap_status_unlock(ps->s);
 		cond_resched();
 	}
 	ps->bitmap_root = *writing_block;
@@ -81,7 +81,7 @@ void dm_multisnap_extend_bitmaps(struct dm_exception_store *ps, chunk_t new_size
 		chunk_t c = ps->dev_size;
 		if (!i) {
 			dm_multisnap_add_bitmap(ps);
-			if (unlikely(dm_multisnap_has_error(ps->dm)))
+			if (unlikely(dm_multisnap_has_error(ps->s)))
 				return;
 		}
 		bmp = dm_multisnap_map_bitmap(ps, bitmap_no, &bp, NULL, NULL);
@@ -331,7 +331,7 @@ bit_find_failed:
 				bitmap_no = 0;
 				wrap_around++;
 				if (wrap_around >= 2) {
-					DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC,
+					DM_MULTISNAP_SET_ERROR(ps->s, -ENOSPC,
 							       ("%s: snapshot overflow", __func__));
 					return -1;
 				}
@@ -343,7 +343,7 @@ bit_find_failed:
 		dm_bufio_release(bp);
 
 		c = dm_multisnap_check_allocated_block(ps, results[i]);
-		if (dm_multisnap_has_error(ps->dm))
+		if (dm_multisnap_has_error(ps->s))
 			return -1;
 
 		bmp = dm_multisnap_read_block(ps, block, &bp);
@@ -369,7 +369,7 @@ find_another_bit_for_bitmap:
 
 		dm_bufio_release(bp);
 		c = dm_multisnap_check_allocated_block(ps, new_block);
-		if (dm_multisnap_has_error(ps->dm))
+		if (dm_multisnap_has_error(ps->s))
 			return -1;
 
 		bmp = dm_multisnap_read_block(ps, block, &bp);
@@ -393,16 +393,16 @@ find_another_bit_for_bitmap:
 			return -1;
 
 		generic___set_le_bit(bit, bmp);
-		dm_multisnap_status_lock(ps->dm);
+		dm_multisnap_status_lock(ps->s);
 		ps->total_allocated++;
-		dm_multisnap_status_unlock(ps->dm);
+		dm_multisnap_status_unlock(ps->s);
 	}
 
 	for (i = 0; i < n_blocks; i++)
 		generic___set_le_bit(results[i] & ((ps->chunk_size << BITS_PER_BYTE_SHIFT) - 1), bmp);
-	dm_multisnap_status_lock(ps->dm);
+	dm_multisnap_status_lock(ps->s);
 	ps->total_allocated += n_blocks;
-	dm_multisnap_status_unlock(ps->dm);
+	dm_multisnap_status_unlock(ps->s);
 
 	dm_bufio_mark_buffer_dirty(bp);
 
@@ -488,7 +488,7 @@ void dm_multisnap_free_blocks_immediate(struct dm_exception_store *ps, chunk_t b
 		return;
 
 	if (unlikely(block + n_blocks > ps->dev_size)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: freeing invalid blocks %llx, %x",
 					__func__, (unsigned long long)block, n_blocks));
 		return;
@@ -506,9 +506,9 @@ void dm_multisnap_free_blocks_immediate(struct dm_exception_store *ps, chunk_t b
 
 		do {
 			generic___clear_le_bit(block & ((ps->chunk_size << BITS_PER_BYTE_SHIFT) - 1), bmp);
-			dm_multisnap_status_lock(ps->dm);
+			dm_multisnap_status_lock(ps->s);
 			ps->total_allocated--;
-			dm_multisnap_status_unlock(ps->dm);
+			dm_multisnap_status_unlock(ps->s);
 			n_blocks--;
 			block++;
 			cond_resched();
drivers/md/dm-multisnap-blocks.c +7 -7
index 40150e5..d83ee80 100644
@@ -16,7 +16,7 @@ static int check_invalid(struct dm_exception_store *ps, chunk_t block)
 	if (unlikely(block >= ps->dev_size) ||
 	    unlikely(block == SB_BLOCK) ||
 	    unlikely(dm_multisnap_is_commit_block(ps, block))) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: access to invalid part of the device: "
 					"%llx, size %llx",
 					__func__, (unsigned long long)block,
@@ -73,7 +73,7 @@ void *dm_multisnap_read_block(struct dm_exception_store *ps, chunk_t block,
 
 	buf = dm_bufio_read(ps->bufio, block, bp);
 	if (unlikely(IS_ERR(buf))) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(buf),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(buf),
 				       ("%s: error read chunk %llx",
 					__func__, (unsigned long long)block));
 		return NULL;
@@ -192,7 +192,7 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *ps, chunk_t old_ch
 	t = find_tmp_remap(ps, old_chunk);
 	if (t) {
 		if (unlikely(t->bitmap_idx != bitmap_idx)) {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: bitmap_idx doesn't match, %X != %X",
 						__func__, t->bitmap_idx, bitmap_idx));
 			return NULL;
@@ -201,7 +201,7 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *ps, chunk_t old_ch
 		t->new = new_chunk;
 	} else {
 		if (unlikely(list_empty(&ps->free_tmp_remaps))) {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: all remap blocks used", __func__));
 			return NULL;
 		}
@@ -225,7 +225,7 @@ void *dm_multisnap_duplicate_block(struct dm_exception_store *ps, chunk_t old_ch
 
 	buf = dm_bufio_read(ps->bufio, new_chunk, bp);
 	if (IS_ERR(buf)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(buf),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(buf),
 				       ("%s: error reading chunk %llx",
 					__func__, (unsigned long long)new_chunk));
 		return NULL;
@@ -261,7 +261,7 @@ void *dm_multisnap_make_block(struct dm_exception_store *ps, chunk_t new_chunk,
 
 	buf = dm_bufio_new(ps->bufio, new_chunk, bp);
 	if (unlikely(IS_ERR(buf))) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(buf),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(buf),
 				       ("%s: error creating new block at chunk %llx",
 					__func__, (unsigned long long)new_chunk));
 		return NULL;
@@ -324,7 +324,7 @@ int dm_multisnap_stop_cycles(struct dm_exception_store *ps,
 			     struct stop_cycles *cy, chunk_t key)
 {
 	if (unlikely(cy->key == key) && unlikely(cy->count != 0)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: cycle detected at chunk %llx",
 					__func__, (unsigned long long)key));
 		return -1;
drivers/md/dm-multisnap-btree.c +17 -17
index 2d73851..626940c 100644
@@ -26,7 +26,7 @@ dm_multisnap_read_btnode(struct dm_exception_store *ps, int depth,
 
 	if (unlikely(node->signature != BT_SIGNATURE)) {
 		dm_bufio_release(*bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: bad signature on btree node %llx",
 					__func__, (unsigned long long)block));
 		return NULL;
@@ -35,7 +35,7 @@ dm_multisnap_read_btnode(struct dm_exception_store *ps, int depth,
 	if (unlikely((unsigned)(le32_to_cpu(node->n_entries) - 1) >= ps->btree_entries) ||
 	    (want_entries && unlikely(le32_to_cpu(node->n_entries) != want_entries))) {
 		dm_bufio_release(*bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: bad number of entries in btree node "
 					"%llx: %x, wanted %x", __func__,
 					(unsigned long long)block,
@@ -92,14 +92,14 @@ void dm_multisnap_create_btree(struct dm_exception_store *ps, chunk_t *writing_b
 		(*writing_block)++;
 
 	if (*writing_block >= ps->dev_size) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC,
+		DM_MULTISNAP_SET_ERROR(ps->s, -ENOSPC,
 				       ("%s: device is too small", __func__));
 		return;
 	}
 
 	node = dm_bufio_new(ps->bufio, *writing_block, &bp);
 	if (IS_ERR(node)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(node),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(node),
 				       ("%s: cannot create direct bitmap block at %llx",
 					__func__, (unsigned long long)*writing_block));
 		return;
@@ -219,7 +219,7 @@ static int walk_btree(struct dm_exception_store *ps, struct bt_key *key,
 		if (unlikely(last_chunk != want_last_chunk) ||
 		    unlikely(last_snapid != want_last_snapid)) {
 			dm_bufio_release(*bp);
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%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",
@@ -327,7 +327,7 @@ list_next_node:
 			r = compare_key(&node->entries[idx], key);
 			if (unlikely(r <= 0)) {
 				dm_bufio_release(bp);
-				DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+				DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 						       ("%s: non-monotonic btree: node "
 							"%llx, index %x", __func__,
 							(unsigned long long)path[depth].block, idx));
@@ -374,7 +374,7 @@ void dm_multisnap_add_to_btree(struct dm_exception_store *ps, struct bt_key *key
 	if (unlikely(r)) {
 		if (r > 0) {
 			dm_bufio_release(bp);
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: adding key that already exists: "
 						"%llx, %llx-%llx", __func__,
 						(unsigned long long)key->chunk,
@@ -450,7 +450,7 @@ go_up:
 	}
 
 	if (ps->bt_depth >= MAX_BT_DEPTH) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: max b+-tree depth reached", __func__));
 		return;
 	}
@@ -508,7 +508,7 @@ static void dm_multisnap_fixup_backlimits(struct dm_exception_store *ps,
 		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snap_from) != old_snapid) ||
 		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snap_to) != old_snapid)) {
 			dm_bufio_release(bp);
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: btree limit does not match, block %llx, "
 						"idx %x, orig_chunk %llx, snap_from %llx, "
 						"snap_to %llx, want %llx, %llx",
@@ -531,7 +531,7 @@ static void dm_multisnap_fixup_backlimits(struct dm_exception_store *ps,
 		if (path[depth].idx != path[depth].n_entries - 1)
 			return;
 	}
-	DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+	DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 			       ("%s: the last entry modified, %llx/%llx -> %llx/%llx",
 				__func__,
 				(unsigned long long)old_chunk,
@@ -560,7 +560,7 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *ps, struct bt_
 
 	if (!r) {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
@@ -584,7 +584,7 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *ps, struct bt_
 		entry->snap_to = cpu_to_mikulas_snapid(new_to);
 	} else {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: invalid range to restrict: "
 					"%llx, %llx-%llx %llx-%llx",
 					__func__,
@@ -623,7 +623,7 @@ void dm_multisnap_extend_btree_entry(struct dm_exception_store *ps, struct bt_ke
 
 	if (!r) {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
@@ -679,7 +679,7 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 
 	if (unlikely(!r)) {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
@@ -696,7 +696,7 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 	to = mikulas_snapid_to_cpu(entry->snap_to);
 	if (unlikely(from != key->snap_from) || unlikely(to != key->snap_to)) {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: invalid range to restrict: "
 					"%llx, %llx-%llx %llx-%llx",
 					__func__,
@@ -711,7 +711,7 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 	while (unlikely((n_entries = le32_to_cpu(node->n_entries)) == 1)) {
 		dm_bufio_release(bp);
 		if (unlikely(!depth)) {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: b-tree is empty", __func__));
 			return;
 		}
@@ -805,7 +805,7 @@ void dm_multisnap_bt_finalize_tmp_remap(struct dm_exception_store *ps,
 	      (unsigned long long)key.snap_from);
 	for (i = 0; i < ps->bt_depth; i++)
 		DMERR("path[%d]: %llx/%x", i, (unsigned long long)path[i].block, path[i].idx);
-	dm_multisnap_set_error(ps->dm, -EFSERROR);
+	dm_multisnap_set_error(ps->s, -EFSERROR);
 	return;
 
 found:
drivers/md/dm-multisnap-commit.c +13 -13
index 61bb82f..57c72c5 100644
@@ -17,7 +17,7 @@ static void dm_multisnap_finalize_tmp_remaps(struct dm_exception_store *ps)
 	int i;
 
 	while (ps->n_used_tmp_remaps) {
-		if (dm_multisnap_has_error(ps->dm))
+		if (dm_multisnap_has_error(ps->s))
 			return;
 		if (ps->n_used_tmp_remaps < N_REMAPS - 1) {
 			/*
@@ -41,14 +41,14 @@ static void dm_multisnap_finalize_tmp_remaps(struct dm_exception_store *ps)
 			dm_multisnap_free_tmp_remap(ps, t);
 			continue;
 		} else {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: no bitmap tmp_remaps, n_used_tmp_remaps %u",
 						__func__, ps->n_used_tmp_remaps));
 			return;
 		}
 	}
 
-	if (dm_multisnap_has_error(ps->dm))
+	if (dm_multisnap_has_error(ps->s))
 		return;
 
 	for (i = ps->n_preallocated_blocks - 1; i >= 0; i--)
@@ -84,7 +84,7 @@ void dm_multisnap_prepare_for_commit(struct dm_exception_store *ps)
 
 	r = dm_bufio_write_dirty_buffers(ps->bufio);
 	if (unlikely(r < 0)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, r,
+		DM_MULTISNAP_SET_ERROR(ps->s, r,
 				       ("%s: error writing data", __func__));
 		return;
 	}
@@ -114,8 +114,8 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 
 	dm_multisnap_flush_freelist_before_commit(ps);
 
-	if (dm_multisnap_has_error(ps->dm)) {
-		if (!dm_multisnap_drop_on_error(ps->dm))
+	if (dm_multisnap_has_error(ps->s)) {
+		if (!dm_multisnap_drop_on_error(ps->s))
 			return;
 
 		sb = dm_bufio_read(ps->bufio, SB_BLOCK, &bp);
@@ -123,7 +123,7 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 			return;
 
 		if (!le32_to_cpu(sb->error)) {
-			sb->error = cpu_to_le32(dm_multisnap_has_error(ps->dm));
+			sb->error = cpu_to_le32(dm_multisnap_has_error(ps->s));
 			dm_bufio_mark_buffer_dirty(bp);
 		}
 
@@ -139,7 +139,7 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 
 	r = dm_bufio_write_dirty_buffers(ps->bufio);
 	if (unlikely(r < 0)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, r,
+		DM_MULTISNAP_SET_ERROR(ps->s, r,
 				       ("%s: error writing data", __func__));
 		return;
 	}
@@ -156,7 +156,7 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 
 	cb = dm_bufio_new(ps->bufio, cb_addr, &bp);
 	if (IS_ERR(cb)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(cb),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(cb),
 				       ("%s: can't allocate new commit block at %llx",
 					__func__, (unsigned long long)cb_addr));
 		return;
@@ -202,7 +202,7 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 	dm_bufio_release(bp);
 	r = dm_bufio_write_dirty_buffers(ps->bufio);
 	if (unlikely(r < 0)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, r,
+		DM_MULTISNAP_SET_ERROR(ps->s, r,
 				       ("%s: can't write commit block at %llx",
 					__func__, (unsigned long long)cb_addr));
 		return;
@@ -214,14 +214,14 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 
 	sb = dm_bufio_read(ps->bufio, SB_BLOCK, &bp);
 	if (IS_ERR(sb)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(sb),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(sb),
 				       ("%s: can't read super block", __func__));
 		return;
 	}
 
 	if (unlikely(sb->signature != SB_SIGNATURE)) {
 		dm_bufio_release(bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: invalid super block signature when committing",
 					__func__));
 		return;
@@ -233,7 +233,7 @@ void dm_multisnap_commit(struct dm_exception_store *ps)
 	dm_bufio_release(bp);
 	r = dm_bufio_write_dirty_buffers(ps->bufio);
 	if (unlikely(r < 0)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, r, ("%s: can't write super block", __func__));
+		DM_MULTISNAP_SET_ERROR(ps->s, r, ("%s: can't write super block", __func__));
 		return;
 	}
 
drivers/md/dm-multisnap-daniel.c +16 -16
index 0d6c1b0..4cde432 100644
@@ -106,7 +106,7 @@ struct commit_callback {
  * The top level structure for a persistent exception store.
  */
 struct dm_exception_store {
-	struct dm_multisnap *dm;
+	struct dm_multisnap *s;
 
 	void *area;
 
@@ -178,7 +178,7 @@ static void free_area(struct dm_exception_store *ps)
 static int chunk_io(struct dm_exception_store *ps, chunk_t chunk, int rw, void *data)
 {
 	struct dm_io_region where = {
-		.bdev = dm_multisnap_snapshot_bdev(ps->dm),
+		.bdev = dm_multisnap_snapshot_bdev(ps->s),
 		.sector = (ps->chunk_size >> SECTOR_SHIFT) * chunk,
 		.count = (ps->chunk_size >> SECTOR_SHIFT),
 	};
@@ -192,7 +192,7 @@ 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, ("%s: io error when %s %llx: %d",
+		DM_MULTISNAP_SET_ERROR(ps->s, r, ("%s: io error when %s %llx: %d",
 						   __func__,
 						   rw == WRITE ? "writing" : "reading",
 						   (unsigned long long)chunk, r));
@@ -208,8 +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->s) &&
+				dm_multisnap_has_error(ps->s));
 	dh->version = cpu_to_le32(ps->version);
 	dh->chunk_size = cpu_to_le32(ps->chunk_size >> SECTOR_SHIFT);
 
@@ -282,7 +282,7 @@ static struct chunk_buffer *alloc_chunk_buffer(struct dm_exception_store *ps)
 	/* Mikulas: changed to GFP_NOIO */
 	b = kzalloc(sizeof(*b), GFP_NOIO);
 	if (!b) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -ENOMEM,
+		DM_MULTISNAP_SET_ERROR(ps->s, -ENOMEM,
 				       ("%s %d: out of memory", __func__, __LINE__));
 		return NULL;
 	}
@@ -291,7 +291,7 @@ static struct chunk_buffer *alloc_chunk_buffer(struct dm_exception_store *ps)
 	b->data = __vmalloc(ps->chunk_size, GFP_NOIO | __GFP_HIGHMEM, PAGE_KERNEL);
 	if (!b->data) {
 		kfree(b);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -ENOMEM,
+		DM_MULTISNAP_SET_ERROR(ps->s, -ENOMEM,
 				       ("%s %d: out of memory", __func__, __LINE__));
 		return NULL;
 	}
@@ -360,7 +360,7 @@ again:
 
 		/* todo: check # free chunks */
 		if (start_chunk == ps->cur_bitmap_chunk) {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -ENOSPC,
+			DM_MULTISNAP_SET_ERROR(ps->s, -ENOSPC,
 					       ("%s %d: fail to find a new chunk",
 						__func__, __LINE__));
 			return 0;
@@ -385,7 +385,7 @@ static int shared_free_chunk(struct dm_exception_store *ps, chunk_t chunk)
 	chunk_io(ps, ps->cur_bitmap_chunk, READ, ps->bitmap);
 
 	if (!ext2_test_bit(idx, ps->bitmap)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: trying to free free block %lld %lld %u", __func__,
 					(unsigned long long)chunk,
 					(unsigned long long)ps->cur_bitmap_chunk, idx));
@@ -578,7 +578,7 @@ static int shared_read_header(struct dm_exception_store *ps, int *new_snapshot)
 
 	*new_snapshot = 0;
 	if (le32_to_cpu(dh->valid))
-		dm_multisnap_set_error(ps->dm, -EINVAL);
+		dm_multisnap_set_error(ps->s, -EINVAL);
 	ps->version = le32_to_cpu(dh->version);
 
 	ps->root_tree_chunk = le64_to_cpu(dh->root_tree_chunk);
@@ -616,7 +616,7 @@ static void shared_drop_header(struct dm_exception_store *ps)
 static int shared_read_metadata(struct dm_exception_store *ps, char **error)
 {
 	int i, r, uninitialized_var(new_snapshot);
-	size_t size = i_size_read(dm_multisnap_snapshot_bdev(ps->dm)->bd_inode);
+	size_t size = i_size_read(dm_multisnap_snapshot_bdev(ps->s)->bd_inode);
 	chunk_t bitmap_chunk_bytes;
 	unsigned chunk_bytes = ps->chunk_size;
 
@@ -1121,7 +1121,7 @@ static void check_leaf(struct dm_exception_store *ps, struct leaf *leaf, u64 sna
 		for (p = emap(leaf, i); p < emap(leaf, i+1); p++) {
 			/* !!! should also check for any zero sharemaps here */
 			if (le64_to_cpu(p->share) & snapmask) {
-				DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+				DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 						       ("%s: nonzero bits %016llx outside snapmask %016llx",
 							__func__,
 							(unsigned long long)p->share,
@@ -1444,7 +1444,7 @@ found:
 	return 0;
 }
 
-static int shared_init(struct dm_multisnap *dm, struct dm_exception_store **sp,
+static int shared_init(struct dm_multisnap *s, struct dm_exception_store **sp,
 		       unsigned argc, char **argv, char **error)
 {
 	int r;
@@ -1458,8 +1458,8 @@ static int shared_init(struct dm_multisnap *dm, struct dm_exception_store **sp,
 	}
 	*sp = ps;
 
-	ps->dm = dm;
-	ps->chunk_size = dm_multisnap_chunk_size(dm);
+	ps->s = s;
+	ps->chunk_size = dm_multisnap_chunk_size(s);
 	ps->chunk_shift = ffs(ps->chunk_size) - 1;
 
 	if (argc != 0) {
@@ -1631,7 +1631,7 @@ static void shared_add_next_remap(struct dm_exception_store *ps,
 
 	ret = origin_chunk_unique(buffer2leaf(cb), chunk, ps->snapmask);
 	if (ret) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s %d: bug %llu %d", __func__, __LINE__,
 					(unsigned long long)chunk, ret));
 		return;
drivers/md/dm-multisnap-delete.c +7 -7
index f8a5f67..3644629 100644
@@ -87,12 +87,12 @@ static void delete_step(struct dm_exception_store *ps)
 		ps->flags &= ~DM_MULTISNAP_FLAG_DELETING;
 
 		/* If we finished the job and there is no pending I/O, commit */
-		if (dm_multisnap_can_commit(ps->dm))
-			dm_multisnap_call_commit(ps->dm);
+		if (dm_multisnap_can_commit(ps->s))
+			dm_multisnap_call_commit(ps->s);
 
 		return;
 	case RET_DO_FREE:
-		if (unlikely(dm_multisnap_has_error(ps->dm)))
+		if (unlikely(dm_multisnap_has_error(ps->s)))
 			return;
 
 		dm_multisnap_delete_from_btree(ps, &lc.key);
@@ -103,10 +103,10 @@ static void delete_step(struct dm_exception_store *ps)
 
 		/* fall through */
 	case RET_RESCHEDULE:
-		if (dm_multisnap_can_commit(ps->dm)) {
+		if (dm_multisnap_can_commit(ps->s)) {
 			if (++ps->delete_commit_count >= COMMIT_AFTER) {
 				ps->delete_commit_count = 0;
-				dm_multisnap_call_commit(ps->dm);
+				dm_multisnap_call_commit(ps->s);
 			}
 		}
 		return;
@@ -120,7 +120,7 @@ static void delete_step(struct dm_exception_store *ps)
 void dm_multisnap_background_delete(struct dm_exception_store *ps,
 				    struct dm_multisnap_background_work *bw)
 {
-	if (unlikely(dm_multisnap_has_error(ps->dm)))
+	if (unlikely(dm_multisnap_has_error(ps->s)))
 		return;
 
 	if (ps->flags & DM_MULTISNAP_FLAG_DELETING) {
@@ -133,5 +133,5 @@ void dm_multisnap_background_delete(struct dm_exception_store *ps,
 	} else
 		return;
 
-	dm_multisnap_queue_work(ps->dm, &ps->delete_work);
+	dm_multisnap_queue_work(ps->s, &ps->delete_work);
 }
drivers/md/dm-multisnap-freelist.c +10 -10
index 57e5a1e..2eb6da6 100644
@@ -37,7 +37,7 @@ static int add_to_freelist(struct dm_exception_store *ps, chunk_t block, unsigne
 		unsigned r = le16_to_cpu(fl->entries[i].run_length) & FREELIST_RL_MASK;
 		unsigned f = le16_to_cpu(fl->entries[i].run_length) & FREELIST_DATA_FLAG;
 		if (block >= x && block < x + r) {
-			DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: freeing already free block %llx (%llx - %x)",
 						__func__,
 						(unsigned long long)block,
@@ -77,21 +77,21 @@ read_freelist(struct dm_exception_store *ps, chunk_t block, struct dm_buffer **b
 	struct dm_multisnap_freelist *fl;
 	fl = dm_bufio_read(ps->bufio, block, bp);
 	if (IS_ERR(fl)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(fl),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(fl),
 				       ("%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(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: bad signature freelist block %llx",
 					__func__, (unsigned long long)block));
 		return NULL;
 	}
 	if (le32_to_cpu(fl->n_entries) > dm_multisnap_freelist_entries(ps->chunk_size)) {
 		dm_bufio_release(*bp);
-		DM_MULTISNAP_SET_ERROR(ps->dm, -EFSERROR,
+		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: bad number of entries in freelist block %llx",
 					__func__, (unsigned long long)block));
 		return NULL;
@@ -114,7 +114,7 @@ static void alloc_write_freelist(struct dm_exception_store *ps)
 
 	fl = dm_bufio_new(ps->bufio, new_block, &bp);
 	if (IS_ERR(fl)) {
-		DM_MULTISNAP_SET_ERROR(ps->dm, PTR_ERR(fl),
+		DM_MULTISNAP_SET_ERROR(ps->s, PTR_ERR(fl),
 				       ("%s: can't make new freelist block %llx",
 					__func__, (unsigned long long)new_block));
 		return;
@@ -140,7 +140,7 @@ void dm_multisnap_free_block(struct dm_exception_store *ps, chunk_t block, unsig
 		return;
 
 	alloc_write_freelist(ps);
-	if (unlikely(dm_multisnap_has_error(ps->dm)))
+	if (unlikely(dm_multisnap_has_error(ps->s)))
 		return;
 
 	if (likely(add_to_freelist(ps, block, flags)))
@@ -229,7 +229,7 @@ void dm_multisnap_flush_freelist_before_commit(struct dm_exception_store *ps)
 {
 	alloc_write_freelist(ps);
 
-	if (dm_multisnap_has_error(ps->dm))
+	if (dm_multisnap_has_error(ps->s))
 		return;
 
 	ps->freelist_ptr = read_48(ps->freelist, backlink);
@@ -248,9 +248,9 @@ static void free_blocks_in_freelist(struct dm_exception_store *ps,
 		unsigned f = le16_to_cpu(fl->entries[i].run_length) & FREELIST_DATA_FLAG;
 		dm_multisnap_free_blocks_immediate(ps, x, r);
 		if (likely(f & FREELIST_DATA_FLAG)) {
-			dm_multisnap_status_lock(ps->dm);
+			dm_multisnap_status_lock(ps->s);
 			ps->data_allocated -= r;
-			dm_multisnap_status_unlock(ps->dm);
+			dm_multisnap_status_unlock(ps->s);
 		}
 		cond_resched();
 	}
@@ -277,7 +277,7 @@ void dm_multisnap_load_freelist(struct dm_exception_store *ps)
 		if (dm_multisnap_stop_cycles(ps, &cy, fl_block))
 			break;
 
-		if (dm_multisnap_has_error(ps->dm))
+		if (dm_multisnap_has_error(ps->s))
 			break;
 
 		fl = read_freelist(ps, fl_block, &bp);
drivers/md/dm-multisnap-io.c +6 -6
index 790b636..398184c 100644
@@ -104,7 +104,7 @@ int dm_multisnap_query_next_remap(struct dm_exception_store *ps, chunk_t chunk)
 	while (dm_multisnap_find_next_snapid_range(ps, ps->query_snapid, &from, &to)) {
 		struct bt_key key;
 next_btree_search:
-		if (dm_multisnap_has_error(ps->dm))
+		if (dm_multisnap_has_error(ps->s))
 			return -1;
 		key.chunk = chunk;
 		key.snap_from = from;
@@ -158,9 +158,9 @@ void dm_multisnap_add_next_remap(struct dm_exception_store *ps,
 	if (unlikely(r < 0))
 		return;
 
-	dm_multisnap_status_lock(ps->dm);
+	dm_multisnap_status_lock(ps->s);
 	ps->data_allocated++;
-	dm_multisnap_status_unlock(ps->dm);
+	dm_multisnap_status_unlock(ps->s);
 
 	dm_multisnap_add_to_btree(ps, &ps->query_new_key, *new_chunk);
 	dm_multisnap_transition_mark(ps);
@@ -184,14 +184,14 @@ void dm_multisnap_make_chunk_writeable(struct dm_exception_store *ps,
 	if (unlikely(r < 0))
 		return;
 
-	dm_multisnap_status_lock(ps->dm);
+	dm_multisnap_status_lock(ps->s);
 	ps->data_allocated++;
-	dm_multisnap_status_unlock(ps->dm);
+	dm_multisnap_status_unlock(ps->s);
 
 	dm_multisnap_restrict_btree_entry(ps, &ps->query_new_key);
 	dm_multisnap_transition_mark(ps);
 
-	if (unlikely(dm_multisnap_has_error(ps->dm)))
+	if (unlikely(dm_multisnap_has_error(ps->s)))
 		return;
 
 	dm_multisnap_add_to_btree(ps, &ps->query_new_key, *new_chunk);
drivers/md/dm-multisnap-mikulas.c +38 -40

259 lines not on this page · raw message

drivers/md/dm-multisnap-mikulas.h +1 -5
index 3fd78b0..446f37a 100644
@@ -60,12 +60,8 @@ struct path_element {
 	unsigned n_entries;
 };
 
-/* FIXME reusing 'dm_exception_store' name lends itself to confusion with legacy snapshots? */
-/* FIXME not to mention, each multisnap stores' 'dm_exception_store' is different */
-/* FIXME rename: dm_multisnap_persistent_exception_store? */
 struct dm_exception_store {
-	/* FIXME rename: multisnap? or just 's' for snapshot? */
-	struct dm_multisnap *dm;
+	struct dm_multisnap *s;
 	/* FIXME rename: bufio_client? */
 	struct dm_bufio_client *bufio;
 
drivers/md/dm-multisnap-snaps.c +31 -31

207 lines not on this page · raw message

drivers/md/dm-multisnap.h +1 -1
index 6c7af89..50ce4d8 100644
@@ -49,7 +49,7 @@ struct dm_multisnap_exception_store {
 	const char *name;
 
 	/* < 0 - error */
-	int (*init_exception_store)(struct dm_multisnap *dm, struct dm_exception_store **psp,
+	int (*init_exception_store)(struct dm_multisnap *s, struct dm_exception_store **psp,
 				    unsigned argc, char **argv, char **error);
 
 	void (*exit_exception_store)(struct dm_exception_store *ps);
Signature · 1 line
1.6.6.1
#4 lore raw

PATCH 5/7 rename snapid members to use 'snapid' names

In reply to Mike Snitzer

perl -pi -e 's|snap_from|snapid_from|g' dm-multi*.[ch]
perl -pi -e 's|snap_to|snapid_to|g' dm-multi*.[ch]

---
 drivers/md/dm-multisnap-btree.c          |  112 +++++++++++++++---------------
 drivers/md/dm-multisnap-delete.c         |   14 ++--
 drivers/md/dm-multisnap-io.c             |   54 +++++++-------
 drivers/md/dm-multisnap-mikulas-struct.h |    8 +-
 drivers/md/dm-multisnap-mikulas.c        |    4 +-
 drivers/md/dm-multisnap-mikulas.h        |    5 +-
 drivers/md/dm-multisnap-snaps.c          |   36 +++++-----
 7 files changed, 116 insertions(+), 117 deletions(-)
drivers/md/dm-multisnap-btree.c +56 -56
index 626940c..35b43ec 100644
@@ -72,8 +72,8 @@ static void add_at_idx(struct dm_multisnap_bt_node *node, unsigned index,
 		(le32_to_cpu(node->n_entries) - index) * sizeof(struct dm_multisnap_bt_entry));
 	write_orig_chunk(&node->entries[index], key->chunk);
 	write_48(&node->entries[index], new_chunk, new_chunk);
-	node->entries[index].snap_from = cpu_to_mikulas_snapid(key->snap_from);
-	node->entries[index].snap_to = cpu_to_mikulas_snapid(key->snap_to);
+	node->entries[index].snapid_from = cpu_to_mikulas_snapid(key->snapid_from);
+	node->entries[index].snapid_to = cpu_to_mikulas_snapid(key->snapid_to);
 	node->entries[index].flags = cpu_to_le32(0);
 	node->n_entries = cpu_to_le32(le32_to_cpu(node->n_entries) + 1);
 }
@@ -112,7 +112,7 @@ void dm_multisnap_create_btree(struct dm_exception_store *ps, chunk_t *writing_b
 	 * A btree node must have at least one entry --- so create this empty
 	 * one
 	 */
-	new_key.snap_from = new_key.snap_to = DM_SNAPID_T_LAST;
+	new_key.snapid_from = new_key.snapid_to = DM_SNAPID_T_LAST;
 	new_key.chunk = DM_CHUNK_T_LAST;
 	add_at_idx(node, 0, &new_key, 0);
 
@@ -138,9 +138,9 @@ static int compare_key(struct dm_multisnap_bt_entry *e, struct bt_key *key)
 	if (orig_chunk > key->chunk)
 		return 1;
 
-	if (mikulas_snapid_to_cpu(e->snap_to) < key->snap_from)
+	if (mikulas_snapid_to_cpu(e->snapid_to) < key->snapid_from)
 		return -1;
-	if (mikulas_snapid_to_cpu(e->snap_from) > key->snap_to)
+	if (mikulas_snapid_to_cpu(e->snapid_from) > key->snapid_to)
 		return 1;
 
 	return 0;
@@ -215,7 +215,7 @@ static int walk_btree(struct dm_exception_store *ps, struct bt_key *key,
 
 		/* Check consistency (can be commented out) */
 		last_chunk = read_48(&node->entries[path[d].n_entries - 1], orig_chunk);
-		last_snapid = mikulas_snapid_to_cpu(node->entries[path[d].n_entries - 1].snap_to);
+		last_snapid = mikulas_snapid_to_cpu(node->entries[path[d].n_entries - 1].snapid_to);
 		if (unlikely(last_chunk != want_last_chunk) ||
 		    unlikely(last_snapid != want_last_snapid)) {
 			dm_bufio_release(*bp);
@@ -231,15 +231,15 @@ static int walk_btree(struct dm_exception_store *ps, struct bt_key *key,
 						(unsigned long long)last_snapid,
 						(unsigned long long)want_last_snapid,
 						(unsigned long long)key->chunk,
-						(unsigned long long)key->snap_from,
-						(unsigned long long)key->snap_to));
+						(unsigned long long)key->snapid_from,
+						(unsigned long long)key->snapid_to));
 			return -1;
 		}
 
 		r = binary_search(node, key, &path[d].idx);
 
 		want_last_chunk = read_48(&node->entries[path[d].idx], orig_chunk);
-		want_last_snapid = mikulas_snapid_to_cpu(node->entries[path[d].idx].snap_to);
+		want_last_snapid = mikulas_snapid_to_cpu(node->entries[path[d].idx].snapid_to);
 
 		block = read_48(&node->entries[path[d].idx], new_chunk);
 		if (++d == ps->bt_depth)
@@ -274,8 +274,8 @@ int dm_multisnap_find_in_btree(struct dm_exception_store *ps, struct bt_key *key
 		struct dm_multisnap_bt_entry *entry = &node->entries[path[ps->bt_depth - 1].idx];
 		*result = read_48(entry, new_chunk);
 		key->chunk = read_48(entry, orig_chunk);
-		key->snap_from = mikulas_snapid_to_cpu(entry->snap_from);
-		key->snap_to = mikulas_snapid_to_cpu(entry->snap_to);
+		key->snapid_from = mikulas_snapid_to_cpu(entry->snapid_from);
+		key->snapid_to = mikulas_snapid_to_cpu(entry->snapid_to);
 	}
 	dm_bufio_release(bp);
 
@@ -378,8 +378,8 @@ void dm_multisnap_add_to_btree(struct dm_exception_store *ps, struct bt_key *key
 					       ("%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));
+						(unsigned long long)key->snapid_from,
+						(unsigned long long)key->snapid_to));
 		}
 		return;
 	}
@@ -433,8 +433,8 @@ go_up:
 
 	last_one = &node->entries[split_index - 1];
 	new_key.chunk = read_48(last_one, orig_chunk);
-	new_key.snap_from = mikulas_snapid_to_cpu(last_one->snap_to);
-	new_key.snap_to = mikulas_snapid_to_cpu(last_one->snap_to);
+	new_key.snapid_from = mikulas_snapid_to_cpu(last_one->snapid_to);
+	new_key.snapid_to = mikulas_snapid_to_cpu(last_one->snapid_to);
 
 	key = &new_key;
 
@@ -465,7 +465,7 @@ go_up:
 	node->signature = BT_SIGNATURE;
 	node->n_entries = cpu_to_le32(0);
 	add_at_idx(node, 0, &new_key, new_chunk);
-	new_key.snap_from = new_key.snap_to = DM_SNAPID_T_LAST;
+	new_key.snapid_from = new_key.snapid_to = DM_SNAPID_T_LAST;
 	new_key.chunk = DM_CHUNK_T_LAST;
 	add_at_idx(node, 1, &new_key, path[0].block);
 
@@ -505,25 +505,25 @@ static void dm_multisnap_fixup_backlimits(struct dm_exception_store *ps,
 		idx = path[depth].idx;
 
 		if (unlikely(read_48(&node->entries[idx], orig_chunk) != old_chunk) ||
-		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snap_from) != old_snapid) ||
-		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snap_to) != old_snapid)) {
+		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snapid_from) != old_snapid) ||
+		    unlikely(mikulas_snapid_to_cpu(node->entries[idx].snapid_to) != old_snapid)) {
 			dm_bufio_release(bp);
 			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: btree limit does not match, block %llx, "
-						"idx %x, orig_chunk %llx, snap_from %llx, "
-						"snap_to %llx, want %llx, %llx",
+						"idx %x, orig_chunk %llx, snapid_from %llx, "
+						"snapid_to %llx, want %llx, %llx",
 						__func__,
 						(unsigned long long)path[depth].block,
 						idx,
 						(unsigned long long)read_48(&node->entries[idx], orig_chunk),
-						(unsigned long long)mikulas_snapid_to_cpu(node->entries[idx].snap_from),
-						(unsigned long long)mikulas_snapid_to_cpu(node->entries[idx].snap_to),
+						(unsigned long long)mikulas_snapid_to_cpu(node->entries[idx].snapid_from),
+						(unsigned long long)mikulas_snapid_to_cpu(node->entries[idx].snapid_to),
 						(unsigned long long)old_chunk,
 						(unsigned long long)old_snapid));
 			return;
 		}
 		write_48(&node->entries[idx], orig_chunk, new_chunk);
-		node->entries[idx].snap_from = node->entries[idx].snap_to = cpu_to_mikulas_snapid(new_snapid);
+		node->entries[idx].snapid_from = node->entries[idx].snapid_to = cpu_to_mikulas_snapid(new_snapid);
 
 		dm_bufio_mark_buffer_dirty(bp);
 		dm_bufio_release(bp);
@@ -564,8 +564,8 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *ps, struct bt_
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
-					(unsigned long long)key->snap_from,
-					(unsigned long long)key->snap_to));
+					(unsigned long long)key->snapid_from,
+					(unsigned long long)key->snapid_to));
 		return;
 	}
 
@@ -575,13 +575,13 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *ps, struct bt_
 
 	idx = path[ps->bt_depth - 1].idx;
 	entry = &node->entries[idx];
-	from = mikulas_snapid_to_cpu(entry->snap_from);
-	to = new_to = mikulas_snapid_to_cpu(entry->snap_to);
-	if (key->snap_from == from && key->snap_to < to) {
-		entry->snap_from = cpu_to_mikulas_snapid(key->snap_to + 1);
-	} else if (key->snap_from > from && key->snap_to == to) {
-		new_to = key->snap_from - 1;
-		entry->snap_to = cpu_to_mikulas_snapid(new_to);
+	from = mikulas_snapid_to_cpu(entry->snapid_from);
+	to = new_to = mikulas_snapid_to_cpu(entry->snapid_to);
+	if (key->snapid_from == from && key->snapid_to < to) {
+		entry->snapid_from = cpu_to_mikulas_snapid(key->snapid_to + 1);
+	} else if (key->snapid_from > from && key->snapid_to == to) {
+		new_to = key->snapid_from - 1;
+		entry->snapid_to = cpu_to_mikulas_snapid(new_to);
 	} else {
 		dm_bufio_release(bp);
 		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
@@ -591,8 +591,8 @@ void dm_multisnap_restrict_btree_entry(struct dm_exception_store *ps, struct bt_
 					(unsigned long long)key->chunk,
 					(unsigned long long)from,
 					(unsigned long long)to,
-					(unsigned long long)key->snap_from,
-					(unsigned long long)key->snap_to));
+					(unsigned long long)key->snapid_from,
+					(unsigned long long)key->snapid_to));
 		return;
 	}
 
@@ -627,8 +627,8 @@ void dm_multisnap_extend_btree_entry(struct dm_exception_store *ps, struct bt_ke
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
-					(unsigned long long)key->snap_from,
-					(unsigned long long)key->snap_to));
+					(unsigned long long)key->snapid_from,
+					(unsigned long long)key->snapid_to));
 		return;
 	}
 
@@ -639,13 +639,13 @@ void dm_multisnap_extend_btree_entry(struct dm_exception_store *ps, struct bt_ke
 
 	idx = path[ps->bt_depth - 1].idx;
 	entry = &node->entries[idx];
-	from = mikulas_snapid_to_cpu(entry->snap_from);
-	to = new_to = mikulas_snapid_to_cpu(entry->snap_to);
-	if (key->snap_from < from)
-		entry->snap_from = cpu_to_mikulas_snapid(key->snap_from);
-	if (key->snap_to > to) {
-		new_to = key->snap_to;
-		entry->snap_to = cpu_to_mikulas_snapid(new_to);
+	from = mikulas_snapid_to_cpu(entry->snapid_from);
+	to = new_to = mikulas_snapid_to_cpu(entry->snapid_to);
+	if (key->snapid_from < from)
+		entry->snapid_from = cpu_to_mikulas_snapid(key->snapid_from);
+	if (key->snapid_to > to) {
+		new_to = key->snapid_to;
+		entry->snapid_to = cpu_to_mikulas_snapid(new_to);
 	}
 
 	dm_bufio_mark_buffer_dirty(bp);
@@ -671,7 +671,7 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 
 	struct dm_multisnap_bt_entry *last_one;
 	chunk_t last_one_chunk;
-	mikulas_snapid_t last_one_snap_to;
+	mikulas_snapid_t last_one_snapid_to;
 
 	int r = walk_btree(ps, key, &node, &bp, path);
 	if (unlikely(r < 0))
@@ -683,8 +683,8 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 				       ("%s: unknown key: %llx, %llx-%llx",
 					__func__,
 					(unsigned long long)key->chunk,
-					(unsigned long long)key->snap_from,
-					(unsigned long long)key->snap_to));
+					(unsigned long long)key->snapid_from,
+					(unsigned long long)key->snapid_to));
 		return;
 	}
 
@@ -692,9 +692,9 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 
 	idx = path[depth].idx;
 	entry = &node->entries[idx];
-	from = mikulas_snapid_to_cpu(entry->snap_from);
-	to = mikulas_snapid_to_cpu(entry->snap_to);
-	if (unlikely(from != key->snap_from) || unlikely(to != key->snap_to)) {
+	from = mikulas_snapid_to_cpu(entry->snapid_from);
+	to = mikulas_snapid_to_cpu(entry->snapid_to);
+	if (unlikely(from != key->snapid_from) || unlikely(to != key->snapid_to)) {
 		dm_bufio_release(bp);
 		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: invalid range to restrict: "
@@ -703,8 +703,8 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 					(unsigned long long)key->chunk,
 					(unsigned long long)from,
 					(unsigned long long)to,
-					(unsigned long long)key->snap_from,
-					(unsigned long long)key->snap_to));
+					(unsigned long long)key->snapid_from,
+					(unsigned long long)key->snapid_to));
 		return;
 	}
 
@@ -740,15 +740,15 @@ void dm_multisnap_delete_from_btree(struct dm_exception_store *ps, struct bt_key
 
 	last_one = &node->entries[n_entries - 1];
 	last_one_chunk = read_48(last_one, orig_chunk);
-	last_one_snap_to = mikulas_snapid_to_cpu(last_one->snap_to);
+	last_one_snapid_to = mikulas_snapid_to_cpu(last_one->snapid_to);
 
 	dm_bufio_mark_buffer_dirty(bp);
 	dm_bufio_release(bp);
 
 	if (unlikely(idx == n_entries))
 		dm_multisnap_fixup_backlimits(ps, path, depth, key->chunk,
-					      key->snap_to, last_one_chunk,
-					      last_one_snap_to);
+					      key->snapid_to, last_one_chunk,
+					      last_one_snapid_to);
 }
 
 /*
@@ -785,7 +785,7 @@ void dm_multisnap_bt_finalize_tmp_remap(struct dm_exception_store *ps,
 	if (!node)
 		return;
 	key.chunk = read_48(&node->entries[0], orig_chunk);
-	key.snap_from = key.snap_to = mikulas_snapid_to_cpu(node->entries[0].snap_from);
+	key.snapid_from = key.snapid_to = mikulas_snapid_to_cpu(node->entries[0].snapid_from);
 	dm_bufio_release(bp);
 
 	r = walk_btree(ps, &key, &node, &bp, path);
@@ -802,7 +802,7 @@ void dm_multisnap_bt_finalize_tmp_remap(struct dm_exception_store *ps,
 	      (unsigned long long)tmp_remap->old,
 	      (unsigned long long)tmp_remap->new,
 	      (unsigned long long)key.chunk,
-	      (unsigned long long)key.snap_from);
+	      (unsigned long long)key.snapid_from);
 	for (i = 0; i < ps->bt_depth; i++)
 		DMERR("path[%d]: %llx/%x", i, (unsigned long long)path[i].block, path[i].idx);
 	dm_multisnap_set_error(ps->s, -EFSERROR);
drivers/md/dm-multisnap-delete.c +7 -7
index 3644629..faa4740 100644
@@ -32,20 +32,20 @@ static int list_callback(struct dm_exception_store *ps,
 	mikulas_snapid_t found_from, found_to;
 
 	lc->key.chunk = read_48(bt, orig_chunk);
-	lc->key.snap_from = mikulas_snapid_to_cpu(bt->snap_from);
-	lc->key.snap_to = mikulas_snapid_to_cpu(bt->snap_to);
+	lc->key.snapid_from = mikulas_snapid_to_cpu(bt->snapid_from);
+	lc->key.snapid_to = mikulas_snapid_to_cpu(bt->snapid_to);
 
 	if (unlikely(lc->key.chunk > DM_CHUNK_T_MAX))
 		return RET_END;
 
 	ps->delete_rover_chunk = lc->key.chunk;
-	ps->delete_rover_snapid = lc->key.snap_to + 1;
+	ps->delete_rover_snapid = lc->key.snapid_to + 1;
 	if (unlikely(!ps->delete_rover_snapid))
 		ps->delete_rover_chunk++;
 
-	if (!dm_multisnap_find_next_snapid_range(ps, lc->key.snap_from,
+	if (!dm_multisnap_find_next_snapid_range(ps, lc->key.snapid_from,
 						 &found_from, &found_to) ||
-	    found_from > lc->key.snap_to) {
+	    found_from > lc->key.snapid_to) {
 		/*
 		 * This range maps unused snapshots, delete it.
 		 * But we can't do it now, so submit it to the caller;
@@ -73,8 +73,8 @@ static void delete_step(struct dm_exception_store *ps)
 	struct list_cookie lc;
 
 	key.chunk = ps->delete_rover_chunk;
-	key.snap_from = ps->delete_rover_snapid;
-	key.snap_to = ps->delete_rover_snapid;
+	key.snapid_from = ps->delete_rover_snapid;
+	key.snapid_to = ps->delete_rover_snapid;
 
 	r = dm_multisnap_list_btree(ps, &key, list_callback, &lc);
 
drivers/md/dm-multisnap-io.c +27 -27

111 lines not on this page · raw message

drivers/md/dm-multisnap-mikulas-struct.h +4 -4
index 39eaa16..b558429 100644
@@ -109,7 +109,7 @@
  * so that the node fits into one chunk.
  *
  * The internal nodes have the same structure as the leaf nodes, except that:
- * Both snapshot ID range entries (snap_from and snap_to) must be equal.
+ * Both snapshot ID range entries (snapid_from and snapid_to) must be equal.
  * New_chunk is really pointer to the subordinate b+tree node.
  *
  * The pointer to the root node and the depth of the b+tree is stored in the
@@ -321,7 +321,7 @@ static inline int dm_multisnap_bitmap_depth(unsigned chunk_shift, __u64 device_s
 }
 
 
-/* B+-tree entry. Sorted by orig_chunk and snap_from/to */
+/* B+-tree entry. Sorted by orig_chunk and snapid_from/to */
 
 #define MAX_BT_DEPTH		12
 
@@ -331,8 +331,8 @@ struct dm_multisnap_bt_entry {
 	__u16 new_chunk2;
 	__u32 new_chunk1;
 	__u32 flags;
-	mikulas_snapid_t snap_from;
-	mikulas_snapid_t snap_to;
+	mikulas_snapid_t snapid_from;
+	mikulas_snapid_t snapid_to;
 };
 
 #define BT_SIGNATURE	cpu_to_be32(0xF6014254)
drivers/md/dm-multisnap-mikulas.c +2 -2
index 076068a..182c4c3 100644
@@ -489,8 +489,8 @@ static int print_btree_callback(struct dm_exception_store *ps,
 {
 	printk(KERN_DEBUG "entry: %llx, %llx-%llx -> %llx\n",
 		(unsigned long long)read_48(bt, orig_chunk),
-		(unsigned long long)cpu_to_mikulas_snapid(bt->snap_from),
-		(unsigned long long)cpu_to_mikulas_snapid(bt->snap_to),
+		(unsigned long long)cpu_to_mikulas_snapid(bt->snapid_from),
+		(unsigned long long)cpu_to_mikulas_snapid(bt->snapid_to),
 		(unsigned long long)read_48(bt, new_chunk));
 	return 0;
 }
drivers/md/dm-multisnap-mikulas.h +2 -3
index 446f37a..fb5bf03 100644
@@ -49,9 +49,8 @@ struct tmp_remap {
 
 struct bt_key {
 	chunk_t chunk;
-	/* FIXME rename: snapid_{from,to}? */
-	mikulas_snapid_t snap_from;
-	mikulas_snapid_t snap_to;
+	mikulas_snapid_t snapid_from;
+	mikulas_snapid_t snapid_to;
 };
 
 struct path_element {
drivers/md/dm-multisnap-snaps.c +18 -18
index 8bde4c4..0ae8db5 100644
@@ -286,9 +286,9 @@ void dm_multisnap_read_snapshots(struct dm_exception_store *ps)
 
 	dm_multisnap_destroy_snapshot_tree(ps);
 
-	snap_key.snap_from = 0;
+	snap_key.snapid_from = 0;
 find_next:
-	snap_key.snap_to = DM_SNAPID_T_MAX;
+	snap_key.snapid_to = DM_SNAPID_T_MAX;
 	snap_key.chunk = DM_CHUNK_T_SNAP_PRESENT;
 
 	r = dm_multisnap_find_in_btree(ps, &snap_key, &ignore);
@@ -297,15 +297,15 @@ find_next:
 		return;
 
 	if (r) {
-		if (unlikely(snap_key.snap_to > DM_SNAPID_T_MAX)) {
+		if (unlikely(snap_key.snapid_to > DM_SNAPID_T_MAX)) {
 			DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 					       ("%s: invalid snapshot id", __func__));
 			return;
 		}
-		r = rb_insert_snapshot(ps, snap_key.snap_from, snap_key.snap_to);
+		r = rb_insert_snapshot(ps, snap_key.snapid_from, snap_key.snapid_to);
 		if (unlikely(r < 0))
 			return;
-		snap_key.snap_from = snap_key.snap_to + 1;
+		snap_key.snapid_from = snap_key.snapid_to + 1;
 		goto find_next;
 	}
 }
@@ -364,8 +364,8 @@ static int dm_multisnap_create_snapid_range(struct dm_exception_store *ps,
 			return dm_multisnap_has_error(ps->s);
 
 		snap_key.chunk = DM_CHUNK_T_SNAP_PRESENT;
-		snap_key.snap_from = from - 1;
-		snap_key.snap_to = to;
+		snap_key.snapid_from = from - 1;
+		snap_key.snapid_to = to;
 		dm_multisnap_extend_btree_entry(ps, &snap_key);
 	} else {
 		/* Add new entry */
@@ -375,8 +375,8 @@ static int dm_multisnap_create_snapid_range(struct dm_exception_store *ps,
 			return dm_multisnap_has_error(ps->s);
 
 		snap_key.chunk = DM_CHUNK_T_SNAP_PRESENT;
-		snap_key.snap_from = from;
-		snap_key.snap_to = to;
+		snap_key.snapid_from = from;
+		snap_key.snapid_to = to;
 		dm_multisnap_add_to_btree(ps, &snap_key, 0);
 	}
 	if (dm_multisnap_has_error(ps->s))
@@ -402,8 +402,8 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *ps,
 		return dm_multisnap_has_error(ps->s);
 
 	snap_key.chunk = DM_CHUNK_T_SNAP_PRESENT;
-	snap_key.snap_from = from;
-	snap_key.snap_to = from;
+	snap_key.snapid_from = from;
+	snap_key.snapid_to = from;
 
 	r = dm_multisnap_find_in_btree(ps, &snap_key, &ignore);
 	if (r <= 0) {
@@ -413,7 +413,7 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *ps,
 						__func__, (unsigned long long)from));
 		return dm_multisnap_has_error(ps->s);
 	}
-	if (snap_key.snap_to < to) {
+	if (snap_key.snapid_to < to) {
 		DM_MULTISNAP_SET_ERROR(ps->s, -EFSERROR,
 				       ("%s: snapshot id %llx-%llx not found in b-tree",
 					__func__, (unsigned long long)from,
@@ -421,8 +421,8 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *ps,
 		return -EFSERROR;
 	}
 
-	if (snap_key.snap_from < from) {
-		snap_key.snap_from = from;
+	if (snap_key.snapid_from < from) {
+		snap_key.snapid_from = from;
 		dm_multisnap_restrict_btree_entry(ps, &snap_key);
 
 		dm_multisnap_transition_mark(ps);
@@ -430,13 +430,13 @@ static int dm_multisnap_delete_snapid_range(struct dm_exception_store *ps,
 		if (dm_multisnap_has_error(ps->s))
 			return dm_multisnap_has_error(ps->s);
 
-		if (snap_key.snap_to > to) {
-			snap_key.snap_from = to + 1;
+		if (snap_key.snapid_to > to) {
+			snap_key.snapid_from = to + 1;
 			dm_multisnap_add_to_btree(ps, &snap_key, 0);
 		}
 	} else {
-		if (snap_key.snap_to > to) {
-			snap_key.snap_to = to;
+		if (snap_key.snapid_to > to) {
+			snap_key.snapid_to = to;
 			dm_multisnap_restrict_btree_entry(ps, &snap_key);
 		} else {
 			dm_multisnap_delete_from_btree(ps, &snap_key);
Signature · 1 line
1.6.6.1
#5 lore raw

PATCH 6/7 move individual dm_multisnap 'flags' values

In reply to Mike Snitzer

Moved the definitions of DM_MULTISNAP_SYNC_SNAPSHOTS and DM_MULTISNAP_PRESERVE_ON_ERROR outside of 'struct dm_multisnap'

---
 drivers/md/dm-multisnap-private.h |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/md/dm-multisnap-private.h +4 -3
index 935ddc1..f27e42a 100644
@@ -39,6 +39,10 @@ struct dm_multisnap_bio_queue {
 
 #define DM_MULTISNAP_N_QUEUES	2
 
+/* multisnap flags which get set by multisnap_origin_ctr() */
+#define DM_MULTISNAP_SYNC_SNAPSHOTS		1
+#define DM_MULTISNAP_PRESERVE_ON_ERROR		2
+
 struct dm_multisnap {
 	struct dm_multisnap_exception_store *store;
 	struct dm_exception_store *ps;
@@ -52,9 +56,6 @@ struct dm_multisnap {
 	unsigned char chunk_shift;
 
 	unsigned char flags;
-	/* FIXME these flags should be defined outside the struct, like agk fixed for merge */
-#define DM_MULTISNAP_SYNC_SNAPSHOTS		1
-#define DM_MULTISNAP_PRESERVE_ON_ERROR		2
 
 	sector_t origin_sectors;
 
Signature · 1 line
1.6.6.1
#6 lore raw

PATCH 7/7 Removed remaining 'struct dm_exception_store' FIXMEs.

In reply to Mike Snitzer

Remaining FIXMEs are not particularly important at this point.

---
 drivers/md/dm-multisnap-mikulas.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/md/dm-multisnap-mikulas.h +0 -2
index fb5bf03..6091fdc 100644
@@ -61,7 +61,6 @@ struct path_element {
 
 struct dm_exception_store {
 	struct dm_multisnap *s;
-	/* FIXME rename: bufio_client? */
 	struct dm_bufio_client *bufio;
 
 	chunk_t dev_size;
@@ -72,7 +71,6 @@ struct dm_exception_store {
 	__u8 bt_depth;
 	__u8 flags;
 	__u32 snapshot_num;
-	/* FIXME rename: commit_block_stride? */
 	unsigned cb_stride;
 
 	chunk_t bitmap_root;
Signature · 1 line
1.6.6.1
maintainer
#7 lore raw
In reply to Mike Snitzer

Hi

Is it needed to just rename variables?

It doesn't add readability, the new variable names are no more readable than the old ones --- chaning "s" and "p" to "ps" and "dm" to "s" doesn't seem to make anything but confusion.

Mikulas

Quoted 31 lines · Mike Snitzer

Quite a lot of churn but I think it is for the better in the end.

(I developed these changes on Wednesday but just got around to getting them sent out now)

Mike Snitzer (7):
document low hanging fruit to help improve code readability Improve name used for "persistent store" in 'struct dm_multisnap' Avoid exception store being confused with snapshot 's' Avoid struct members with the name 'dm'
rename snapid members to use 'snapid' names
move individual dm_multisnap 'flags' values
Removed remaining 'struct dm_exception_store' FIXMEs.

 drivers/md/dm-multisnap-alloc.c          |  271 +++++++++---------
 drivers/md/dm-multisnap-blocks.c         |  118 ++++----
 drivers/md/dm-multisnap-btree.c          |  330 +++++++++++-----------
 drivers/md/dm-multisnap-commit.c         |  140 +++++-----
 drivers/md/dm-multisnap-daniel.c         |   32 +-
 drivers/md/dm-multisnap-delete.c         |   70 +++---
 drivers/md/dm-multisnap-freelist.c       |   96 ++++----
 drivers/md/dm-multisnap-io.c             |  148 +++++-----
 drivers/md/dm-multisnap-mikulas-struct.h |    8 +-
 drivers/md/dm-multisnap-mikulas.c        |  441 +++++++++++++++---------------
 drivers/md/dm-multisnap-mikulas.h        |  110 ++++----
 drivers/md/dm-multisnap-private.h        |    8 +-
 drivers/md/dm-multisnap-snaps.c          |  234 ++++++++--------
 drivers/md/dm-multisnap.c                |   72 +++---
 drivers/md/dm-multisnap.h                |   38 ++--
 15 files changed, 1060 insertions(+), 1056 deletions(-)
#8 lore raw

Hi,

Using 's' for something other than snapshot is confusing. 'ps' is better than 'p' as it builds on other snapshot code that established the use of 'ps' for a persistent store. And using 'dm' for dm_multisnap is just awkward.

Figured it best to make all variables consistent across the codebase. If there were accessor functions these renames wouldn't be so wide-spread but I can easily see why accessors weren't ever introduced.

I believe the new names and consistency to be better. If you think it's a problem to make these edits then feel free to ignore them.

Mike

Quoted 49 lines · Mikulas Patocka

Hi

Is it needed to just rename variables?

It doesn't add readability, the new variable names are no more readable than the old ones --- chaning "s" and "p" to "ps" and "dm" to "s" doesn't seem to make anything but confusion.

Mikulas

Quoted 17 lines · Mike Snitzer

Quite a lot of churn but I think it is for the better in the end.

(I developed these changes on Wednesday but just got around to getting them sent out now)

Mike Snitzer (7):
  document low hanging fruit to help improve code readability Improve name used for "persistent store" in 'struct dm_multisnap' Avoid exception store being confused with snapshot 's' Avoid struct members with the name 'dm'
  rename snapid members to use 'snapid' names
  move individual dm_multisnap 'flags' values
  Removed remaining 'struct dm_exception_store' FIXMEs.

 drivers/md/dm-multisnap-alloc.c          |  271 +++++++++--------- drivers/md/dm-multisnap-blocks.c         |  118 ++++---- drivers/md/dm-multisnap-btree.c          |  330 +++++++++++-----------

Quoted 14 lines
 drivers/md/dm-multisnap-commit.c         |  140 +++++-----
 drivers/md/dm-multisnap-daniel.c         |   32 +-
 drivers/md/dm-multisnap-delete.c         |   70 +++---
 drivers/md/dm-multisnap-freelist.c       |   96 ++++----
 drivers/md/dm-multisnap-io.c             |  148 +++++-----
 drivers/md/dm-multisnap-mikulas-struct.h |    8 +-
 drivers/md/dm-multisnap-mikulas.c        |  441 +++++++++++++++---------------
 drivers/md/dm-multisnap-mikulas.h        |  110 ++++----
 drivers/md/dm-multisnap-private.h        |    8 +-
 drivers/md/dm-multisnap-snaps.c          |  234 ++++++++--------
 drivers/md/dm-multisnap.c                |   72 +++---
 drivers/md/dm-multisnap.h                |   38 ++--
 15 files changed, 1060 insertions(+), 1056 deletions(-)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel