aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-snap.c')
-rw-r--r--drivers/md/dm-snap.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index dc500a6f6232..fd04caa90340 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -72,6 +72,9 @@ struct dm_snapshot {
72 /* Origin writes don't trigger exceptions until this is set */ 72 /* Origin writes don't trigger exceptions until this is set */
73 int active; 73 int active;
74 74
75 /* Whether or not owning mapped_device is suspended */
76 int suspended;
77
75 mempool_t *pending_pool; 78 mempool_t *pending_pool;
76 79
77 atomic_t pending_exceptions_count; 80 atomic_t pending_exceptions_count;
@@ -656,6 +659,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
656 s->ti = ti; 659 s->ti = ti;
657 s->valid = 1; 660 s->valid = 1;
658 s->active = 0; 661 s->active = 0;
662 s->suspended = 0;
659 atomic_set(&s->pending_exceptions_count, 0); 663 atomic_set(&s->pending_exceptions_count, 0);
660 init_rwsem(&s->lock); 664 init_rwsem(&s->lock);
661 spin_lock_init(&s->pe_lock); 665 spin_lock_init(&s->pe_lock);
@@ -1175,12 +1179,22 @@ static int snapshot_end_io(struct dm_target *ti, struct bio *bio,
1175 return 0; 1179 return 0;
1176} 1180}
1177 1181
1182static void snapshot_postsuspend(struct dm_target *ti)
1183{
1184 struct dm_snapshot *s = ti->private;
1185
1186 down_write(&s->lock);
1187 s->suspended = 1;
1188 up_write(&s->lock);
1189}
1190
1178static void snapshot_resume(struct dm_target *ti) 1191static void snapshot_resume(struct dm_target *ti)
1179{ 1192{
1180 struct dm_snapshot *s = ti->private; 1193 struct dm_snapshot *s = ti->private;
1181 1194
1182 down_write(&s->lock); 1195 down_write(&s->lock);
1183 s->active = 1; 1196 s->active = 1;
1197 s->suspended = 0;
1184 up_write(&s->lock); 1198 up_write(&s->lock);
1185} 1199}
1186 1200
@@ -1489,12 +1503,13 @@ static struct target_type origin_target = {
1489 1503
1490static struct target_type snapshot_target = { 1504static struct target_type snapshot_target = {
1491 .name = "snapshot", 1505 .name = "snapshot",
1492 .version = {1, 8, 0}, 1506 .version = {1, 9, 0},
1493 .module = THIS_MODULE, 1507 .module = THIS_MODULE,
1494 .ctr = snapshot_ctr, 1508 .ctr = snapshot_ctr,
1495 .dtr = snapshot_dtr, 1509 .dtr = snapshot_dtr,
1496 .map = snapshot_map, 1510 .map = snapshot_map,
1497 .end_io = snapshot_end_io, 1511 .end_io = snapshot_end_io,
1512 .postsuspend = snapshot_postsuspend,
1498 .resume = snapshot_resume, 1513 .resume = snapshot_resume,
1499 .status = snapshot_status, 1514 .status = snapshot_status,
1500 .iterate_devices = snapshot_iterate_devices, 1515 .iterate_devices = snapshot_iterate_devices,