From: Alasdair G Kergon <[email-masked]>

Put the cell structs on the stack to avoid the new spinlock.
We can reconsider other options later if stack size becomes a problem.

Signed-off-by: Alasdair G Kergon <[email-masked]>
---

FIXME fold this into the previous patch

 drivers/md/dm-thin.c |   26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

Index: linux/drivers/md/dm-thin.c
===================================================================
--- linux.orig/drivers/md/dm-thin.c
+++ linux/drivers/md/dm-thin.c
@@ -222,13 +222,6 @@ struct thin_c {
 
 	struct pool *pool;
 	struct dm_thin_device *td;
-
-	/*
-	 * The cell structures are too big to put on the stack, so we have
-	 * a couple here for use by the main mapping function.
-	 */
-	spinlock_t lock;
-	struct dm_bio_prison_cell cell1, cell2;
 };
 
 /*----------------------------------------------------------------*/
@@ -1459,6 +1452,8 @@ static int thin_bio_map(struct dm_target
 	struct dm_thin_lookup_result result;
 	struct dm_cell_key key;
 	struct dm_bio_prison_cell *cell_result;
+	struct dm_bio_prison_cell cell1, cell2;
+
 
 	thin_hook_bio(tc, bio);
 
@@ -1498,24 +1493,19 @@ static int thin_bio_map(struct dm_target
 			return DM_MAPIO_SUBMITTED;
 		}
 
-		spin_lock(&tc->lock);
 		build_virtual_key(tc->td, block, &key);
-		if (dm_bio_detain(tc->pool->prison, &key, bio, &tc->cell1, &cell_result)) {
-			spin_unlock(&tc->lock);
+		if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1, &cell_result))
 			return DM_MAPIO_SUBMITTED;
-		}
 
 		build_data_key(tc->td, result.block, &key);
-		if (dm_bio_detain(tc->pool->prison, &key, bio, &tc->cell2, &cell_result)) {
-			cell_defer_no_holder_no_free(tc, &tc->cell1);
-			spin_unlock(&tc->lock);
+		if (dm_bio_detain(tc->pool->prison, &key, bio, &cell2, &cell_result)) {
+			cell_defer_no_holder_no_free(tc, &cell1);
 			return DM_MAPIO_SUBMITTED;
 		}
 
 		inc_all_io_entry(tc->pool, bio);
-		cell_defer_no_holder_no_free(tc, &tc->cell2);
-		cell_defer_no_holder_no_free(tc, &tc->cell1);
-		spin_unlock(&tc->lock);
+		cell_defer_no_holder_no_free(tc, &cell2);
+		cell_defer_no_holder_no_free(tc, &cell1);
 
 		remap(tc, bio, result.block);
 		return DM_MAPIO_REMAPPED;
@@ -2660,8 +2650,6 @@ static int thin_ctr(struct dm_target *ti
 	if (r)
 		goto bad_thin_open;
 
-	spin_lock_init(&tc->lock);
-
 	ti->num_flush_bios = 1;
 	ti->flush_supported = true;
 	ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook);