Re: [Bcache v13 02/16] Bio pool freeing

From
Tejun Heo <hidden>
Date
2012-05-15 16:24:09
Also in
dm-devel, lkml
Reply to
Kent Overstreet, 2012-05-10
On Wed, May 09, 2012 at 11:08:34PM -0400, Kent Overstreet wrote:
quoted hunk ↗ jump to hunk
When you allocate a bio from a bio pool, to free it you have to know
where it came from; this adds a flag which, if set, means bi_destructor
is the pointer to the pool and bio_put() can do the right thing.

This is used in bcache, so we can cleanly use per device bio pools.

Signed-off-by: Kent Overstreet <redacted>
---
@@ -417,7 +418,11 @@ void bio_put(struct bio *bio)
 	 */
 	if (atomic_dec_and_test(&bio->bi_cnt)) {
 		bio->bi_next = NULL;
-		bio->bi_destructor(bio);
+
+		if (bio_flagged(bio, BIO_HAS_POOL))
+			bio_free(bio, (void *) bio->bi_destructor);
+		else
+			bio->bi_destructor(bio);
Ummm... this is way too cryptic.  Please just add another field to
bio.

Thanks.

-- 
tejun
Thread (83 messages) 83 messages, 9 authors, last reply 2012-06-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help