Misc snapshot updates: 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. [Christophe Saout] --- diff/drivers/md/dm-snap.c 2003-12-29 10:16:45.000000000 +0000 +++ source/drivers/md/dm-snap.c 2004-01-16 13:27:22.000000000 +0000 @@ -372,7 +372,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)) { @@ -694,7 +694,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(pe->snapshot_bios); @@ -798,7 +798,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 { /* @@ -812,7 +812,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; pe->origin_bios = pe->snapshot_bios = NULL; @@ -877,7 +877,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); @@ -970,7 +971,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; } @@ -1183,25 +1184,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)