Skip to contentSkip to conversation

bio: Make the test correct for idx in __bio_clone_fast

PATCH In review Minfei Huang 1 participant 2 messages Dec 18, 2015 – Jan 18, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bio: Make the test correct for idx in __bio_clone_fast

It is more lucky that kernel crash does not happen, since we test the bi_pool in function __bio_clone_fast.

The idx will be still equal to BIO_POOL_NONE, if there is no bvec to be allocated.

Fix the bug_on condition to make the test correct.

---
 block/bio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/bio.c +1 -2
index 4f184d9..041ece0 100644
@@ -573,8 +573,7 @@ EXPORT_SYMBOL(bio_phys_segments);
  */
 void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
 {
-	BUG_ON(bio->bi_pool && BIO_POOL_IDX(bio) != BIO_POOL_NONE);
-
+	BUG_ON(BIO_POOL_IDX(bio) != BIO_POOL_NONE);
 	/*
 	 * most users will be overriding ->bi_bdev with a new target,
 	 * so we don't set nor calculate new physical/hw segment counts here
Signature · 1 line
2.6.3
#1 lore raw

Ping.
Any comment is appreciate.

Thanks
Minfei

Quoted 30 lines · Minfei Huang

It is more lucky that kernel crash does not happen, since we test the bi_pool in function __bio_clone_fast.

The idx will be still equal to BIO_POOL_NONE, if there is no bvec to be allocated.

Fix the bug_on condition to make the test correct.

---
 block/bio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/bio.c +1 -2
index 4f184d9..041ece0 100644
@@ -573,8 +573,7 @@ EXPORT_SYMBOL(bio_phys_segments);
  */
 void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
 {
-	BUG_ON(bio->bi_pool && BIO_POOL_IDX(bio) != BIO_POOL_NONE);
-
+	BUG_ON(BIO_POOL_IDX(bio) != BIO_POOL_NONE);
 	/*
 	 * most users will be overriding ->bi_bdev with a new target,
 	 * so we don't set nor calculate new physical/hw segment counts here
Signature · 1 line
2.6.3