dm-thin: don't use the bi_next field for the holder of a cell.
BUGFIX: theoretical issue when stacking thin on devices that defer
bios (not seen in the wild).
When a cell is created the bio that triggered creation (the holder)
was added to the same bio list as subsequent bios. In some cases we
let the holder continue to lower devices. If those lower devices use
the bi_next field there will be trouble ...
This change keeps the holder in a new, separate field of the cell.
This also has the effect of simplifying some code that had to work out
which bio was the holder.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-thin.c | 81 ++++++++++++++++++++++++++++++++------------------
1 files changed, 52 insertions(+), 29 deletions(-)
@@ -220,8 +220,7 @@ static struct cell *__search_bucket(struct hlist_head *bucket,
* This may block if a new cell needs allocating. You must ensure that
* cells will be unlocked even if the calling thread is blocked.
*
- * Returns the number of entries in the cell prior to the new addition
- * or < 0 on failure.
+ * Returns 1 if the cell was already held, 0 if @inmate is the new holder.
*/
static int bio_detain(struct bio_prison *prison, struct cell_key *key,
struct bio *inmate, struct cell **ref)
@@ -256,21 +255,25 @@ static int bio_detain(struct bio_prison *prison, struct cell_key *key,