aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2006-02-01 06:04:50 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-01 11:53:10 -0500
commitaa14edeb994f8f7e223d02ad14780bf2fa719f6d (patch)
tree07fb8ba39d619708bdc0a68a32d4a7296abd955c /drivers/md/dm-snap.c
parentcb82a6cdf994d6656ad0a25ed28395af3416a27c (diff)
[PATCH] device-mapper snapshot: load metadata on creation
Move snapshot metadata loading to happen when the table is created instead of when the device is resumed. Writes to the origin device don't trigger exceptions until each snapshot table becomes active when resume() is called on each snapshot. If you're using lvm2, for this patch to work properly you should update to lvm2 version 2.02.01 or later and device-mapper version 1.02.02 or later. Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/dm-snap.c')
-rw-r--r--drivers/md/dm-snap.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 87727d84dbba..ad9b61f16c5e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -373,16 +373,11 @@ static inline ulong round_up(ulong n, ulong size)
373 373
374static void read_snapshot_metadata(struct dm_snapshot *s) 374static void read_snapshot_metadata(struct dm_snapshot *s)
375{ 375{
376 if (s->have_metadata)
377 return;
378
379 if (s->store.read_metadata(&s->store)) { 376 if (s->store.read_metadata(&s->store)) {
380 down_write(&s->lock); 377 down_write(&s->lock);
381 s->valid = 0; 378 s->valid = 0;
382 up_write(&s->lock); 379 up_write(&s->lock);
383 } 380 }
384
385 s->have_metadata = 1;
386} 381}
387 382
388/* 383/*
@@ -471,7 +466,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
471 s->chunk_shift = ffs(chunk_size) - 1; 466 s->chunk_shift = ffs(chunk_size) - 1;
472 467
473 s->valid = 1; 468 s->valid = 1;
474 s->have_metadata = 0; 469 s->active = 0;
475 s->last_percent = 0; 470 s->last_percent = 0;
476 init_rwsem(&s->lock); 471 init_rwsem(&s->lock);
477 s->table = ti->table; 472 s->table = ti->table;
@@ -506,7 +501,11 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
506 goto bad5; 501 goto bad5;
507 } 502 }
508 503
504 /* Metadata must only be loaded into one table at once */
505 read_snapshot_metadata(s);
506
509 /* Add snapshot to the list of snapshots for this origin */ 507 /* Add snapshot to the list of snapshots for this origin */
508 /* Exceptions aren't triggered till snapshot_resume() is called */
510 if (register_snapshot(s)) { 509 if (register_snapshot(s)) {
511 r = -EINVAL; 510 r = -EINVAL;
512 ti->error = "Cannot register snapshot origin"; 511 ti->error = "Cannot register snapshot origin";
@@ -862,7 +861,9 @@ static void snapshot_resume(struct dm_target *ti)
862{ 861{
863 struct dm_snapshot *s = (struct dm_snapshot *) ti->private; 862 struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
864 863
865 read_snapshot_metadata(s); 864 down_write(&s->lock);
865 s->active = 1;
866 up_write(&s->lock);
866} 867}
867 868
868static int snapshot_status(struct dm_target *ti, status_type_t type, 869static int snapshot_status(struct dm_target *ti, status_type_t type,
@@ -932,8 +933,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
932 /* Do all the snapshots on this origin */ 933 /* Do all the snapshots on this origin */
933 list_for_each_entry (snap, snapshots, list) { 934 list_for_each_entry (snap, snapshots, list) {
934 935
935 /* Only deal with valid snapshots */ 936 /* Only deal with valid and active snapshots */
936 if (!snap->valid) 937 if (!snap->valid || !snap->active)
937 continue; 938 continue;
938 939
939 /* Nothing to do if writing beyond end of snapshot */ 940 /* Nothing to do if writing beyond end of snapshot */
@@ -1104,7 +1105,7 @@ static int origin_status(struct dm_target *ti, status_type_t type, char *result,
1104 1105
1105static struct target_type origin_target = { 1106static struct target_type origin_target = {
1106 .name = "snapshot-origin", 1107 .name = "snapshot-origin",
1107 .version = {1, 0, 1}, 1108 .version = {1, 1, 0},
1108 .module = THIS_MODULE, 1109 .module = THIS_MODULE,
1109 .ctr = origin_ctr, 1110 .ctr = origin_ctr,
1110 .dtr = origin_dtr, 1111 .dtr = origin_dtr,
@@ -1115,7 +1116,7 @@ static struct target_type origin_target = {
1115 1116
1116static struct target_type snapshot_target = { 1117static struct target_type snapshot_target = {
1117 .name = "snapshot", 1118 .name = "snapshot",
1118 .version = {1, 0, 1}, 1119 .version = {1, 1, 0},
1119 .module = THIS_MODULE, 1120 .module = THIS_MODULE,
1120 .ctr = snapshot_ctr, 1121 .ctr = snapshot_ctr,
1121 .dtr = snapshot_dtr, 1122 .dtr = snapshot_dtr,