[dm-devel] [RFC][PATCH] A bunch of small dm-snap.c changes
Christophe Saout
christophe at saout.de
Sat Jan 10 15:27:01 UTC 2004
Hi,
going through dm-snap.c I made some small modifications.
o Minumum hash size of 64 instead of setting hash size to 64 if the
calculated size would be smaller than 1.
o Only use list_entry if we are working on a list.
o Check for drop_snapshot function before calling it (transient
snapshots don't have one).
o Use correct size prefix in status sprintf for chunk size.
o Use C99 initializers.
--- linux.orig/drivers/md/dm-snap.c 2004-01-10 18:07:10.000000000 +0100
+++ linux/drivers/md/dm-snap.c 2004-01-10 18:33:22.000000000 +0100
@@ -373,7 +373,7 @@
* Make this smaller than the real hash table
*/
hash_size >>= 3;
- if (!hash_size)
+ if (hash_size < 64)
hash_size = 64;
if (init_exception_table(&s->pending, hash_size)) {
@@ -675,7 +675,7 @@
remove_exception(&pe->e);
flush = __flush_bios(pe);
- /* Submit any pending write BHs */
+ /* Submit any pending write bios */
up_write(&s->lock);
flush_bios(bio_list_get(&pe->snapshot_bios));
@@ -779,7 +779,7 @@
e = lookup_exception(&s->pending, chunk);
if (e) {
/* cast the exception to a pending exception */
- pe = list_entry(e, struct pending_exception, e);
+ pe = container_of(e, struct pending_exception, e);
} else {
/*
@@ -793,7 +793,7 @@
e = lookup_exception(&s->pending, chunk);
if (e) {
free_pending_exception(pe);
- pe = list_entry(e, struct pending_exception, e);
+ pe = container_of(e, struct pending_exception, e);
} else {
pe->e.old_chunk = chunk;
bio_list_init(&pe->origin_bios);
@@ -859,7 +859,8 @@
pe = __find_pending_exception(s, bio);
if (!pe) {
- s->store.drop_snapshot(&s->store);
+ if (s->store.drop_snapshot)
+ s->store.drop_snapshot(&s->store);
s->valid = 0;
r = -EIO;
up_write(&s->lock);
@@ -952,7 +953,7 @@
*/
format_dev_t(cow, snap->cow->bdev->bd_dev);
format_dev_t(org, snap->origin->bdev->bd_dev);
- snprintf(result, maxlen, "%s %s %c %lld", org, cow,
+ snprintf(result, maxlen, "%s %s %c " SECTOR_FORMAT, org, cow,
snap->type, snap->chunk_size);
break;
}
@@ -1165,25 +1166,25 @@
}
static struct target_type origin_target = {
- name: "snapshot-origin",
- version: {1, 0, 1},
- module: THIS_MODULE,
- ctr: origin_ctr,
- dtr: origin_dtr,
- map: origin_map,
- resume: origin_resume,
- status: origin_status,
+ .name = "snapshot-origin",
+ .version = {1, 0, 1},
+ .module = THIS_MODULE,
+ .ctr = origin_ctr,
+ .dtr = origin_dtr,
+ .map = origin_map,
+ .resume = origin_resume,
+ .status = origin_status,
};
static struct target_type snapshot_target = {
- name: "snapshot",
- version: {1, 0, 1},
- module: THIS_MODULE,
- ctr: snapshot_ctr,
- dtr: snapshot_dtr,
- map: snapshot_map,
- resume: snapshot_resume,
- status: snapshot_status,
+ .name = "snapshot",
+ .version = {1, 0, 1},
+ .module = THIS_MODULE,
+ .ctr = snapshot_ctr,
+ .dtr = snapshot_dtr,
+ .map = snapshot_map,
+ .resume = snapshot_resume,
+ .status = snapshot_status,
};
static int __init dm_snapshot_init(void)
More information about the dm-devel
mailing list