From: Alasdair G Kergon <agk@redhat.com>

Handle writes to a snapshot-origin device that has been extended since the
snapshot was taken.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/md/dm-snap.c  |    4 ++++
 drivers/md/dm-table.c |    1 +
 2 files changed, 5 insertions(+)

diff -puN drivers/md/dm-snap.c~device-mapper-snapshots-handle-origin-extension drivers/md/dm-snap.c
--- 25/drivers/md/dm-snap.c~device-mapper-snapshots-handle-origin-extension	Fri Jul  8 16:45:36 2005
+++ 25-akpm/drivers/md/dm-snap.c	Fri Jul  8 16:45:36 2005
@@ -931,6 +931,10 @@ static int __origin_write(struct list_he
 		if (!snap->valid)
 			continue;
 
+		/* Nothing to do if writing beyond end of snapshot */
+		if (bio->bi_sector >= dm_table_get_size(snap->table))
+			continue;
+
 		down_write(&snap->lock);
 
 		/*
diff -puN drivers/md/dm-table.c~device-mapper-snapshots-handle-origin-extension drivers/md/dm-table.c
--- 25/drivers/md/dm-table.c~device-mapper-snapshots-handle-origin-extension	Fri Jul  8 16:45:36 2005
+++ 25-akpm/drivers/md/dm-table.c	Fri Jul  8 16:45:36 2005
@@ -943,6 +943,7 @@ EXPORT_SYMBOL(dm_vcalloc);
 EXPORT_SYMBOL(dm_get_device);
 EXPORT_SYMBOL(dm_put_device);
 EXPORT_SYMBOL(dm_table_event);
+EXPORT_SYMBOL(dm_table_get_size);
 EXPORT_SYMBOL(dm_table_get_mode);
 EXPORT_SYMBOL(dm_table_put);
 EXPORT_SYMBOL(dm_table_get);
_