Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-03-20 10:18:01 +0100
committerTakashi Iwai <tiwai@suse.de>2019-03-20 10:18:01 +0100
commit74a50fae2a62d1ef9d205083fce6f640bc5417fa (patch)
treedeb617ecd506659c9523034bbad8835f6681999e
parent3bf2ca7fe8c25236b550dcfbd2b68d1ed2f35a1f (diff)
parentbc841e1504a67c01c7e5402614d8274c6cd238d9 (diff)
Merge branch 'users/hare/SLE15/for-next' into SLE15
Pull block fix from Hannes Reinecke
-rw-r--r--patches.fixes/bio-Introduce-BIO_ALLOCED-flag-and-check-it-in-bio_f.patch59
-rw-r--r--series.conf1
2 files changed, 60 insertions, 0 deletions
diff --git a/patches.fixes/bio-Introduce-BIO_ALLOCED-flag-and-check-it-in-bio_f.patch b/patches.fixes/bio-Introduce-BIO_ALLOCED-flag-and-check-it-in-bio_f.patch
new file mode 100644
index 0000000000..0671eebfff
--- /dev/null
+++ b/patches.fixes/bio-Introduce-BIO_ALLOCED-flag-and-check-it-in-bio_f.patch
@@ -0,0 +1,59 @@
+From: Johannes Thumshirn <jthumshirn@suse.de>
+Date: Wed, 20 Mar 2019 09:40:18 +0100
+Subject: [PATCH] bio: Introduce BIO_ALLOCED flag and check it in bio_free
+Patch-Mainline: submitted linux-block 2019/03/20
+References: bsc#1128094
+
+When we're submitting a bio from stack and this ends up being split, we
+call bio_put(). bio_put() will eventually call bio_free() if the reference
+count drops to 0. But freeing the bio is wrong, as it was never allocated
+out of the bio's mempool.
+
+Flag each normally allocated bio as 'BIO_ALLOCATED' and skip freeing if the
+flag isn't set.
+
+Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Hannes Reinecke <hare@suse.com>
+---
+ block/bio.c | 4 ++++
+ include/linux/blk_types.h | 2 ++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/block/bio.c b/block/bio.c
+index 336eb9eab377..073cd81877fa 100644
+--- a/block/bio.c
++++ b/block/bio.c
+@@ -253,6 +253,9 @@ static void bio_free(struct bio *bio)
+
+ bio_uninit(bio);
+
++ if (!bio_flagged(bio, BIO_ALLOCED))
++ return;
++
+ if (bs) {
+ bvec_free(bs->bvec_pool, bio->bi_io_vec, BVEC_POOL_IDX(bio));
+
+@@ -518,6 +521,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
+ bvl = bio->bi_inline_vecs;
+ }
+
++ bio_set_flag(bio, BIO_ALLOCED);
+ bio->bi_pool = bs;
+ bio->bi_max_vecs = nr_iovecs;
+ bio->bi_io_vec = bvl;
+diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
+index f6ea9d9656b5..bf6d5f4df94a 100644
+--- a/include/linux/blk_types.h
++++ b/include/linux/blk_types.h
+@@ -162,6 +162,8 @@ struct bio {
+ * throttling rules. Don't do it again. */
+ #define BIO_TRACE_COMPLETION 10 /* bio_endio() should trace the final completion
+ * of this bio. */
++#define BIO_ALLOCED 13 /* bio has been allocated by bio_alloc_bioset */
++
+ /* See BVEC_POOL_OFFSET below before adding new flags */
+
+ /*
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 5f9e7d6d75..e402ea604b 100644
--- a/series.conf
+++ b/series.conf
@@ -20964,6 +20964,7 @@
patches.suse/0001-drm-vmwgfx-Don-t-double-free-the-mode-stored-in-par-.patch
patches.arch/pseries-energy-Use-OF-accessor-function-to-read-ibm-.patch
patches.fixes/block_dev-fix-crash-on-chained-bios-with-O_DIRECT.patch
+ patches.fixes/bio-Introduce-BIO_ALLOCED-flag-and-check-it-in-bio_f.patch
########################################################
# end of sorted patches