move bio code from dm into bio
Subsystems (3)
RFC PATCH 1/1 move bio code from dm into bio
Jens, last December you observed there was bio code duplicated in the dm drivers.
Here are a collection of patches that implements support for local bio and bvec pools into bio.c and then removes the duplicate bio code from the dm drivers.
It also replaces a call to alloc_bio() in dm.c with a call to use a local bio pool. This removes a deadlock case in that code.
These patches are against 2.6.11-rc1. If that's not a good source version to patch against, let me now what versions I should generate patches for.
I still need to implement some form of congestion
control in the dm code. As things are now, the snapshot target can consume all the bio's in the system. With the elmination of the deadlock case in dm.c, the system nolonger deadlocks. But instead, it starts invoking the oom killer. That'll be the next patch set to this code.
Please review.
Thanks!
drivers/md/dm.c +9 -1
@@ -96,10 +96,16 @@static kmem_cache_t *_io_cache;static kmem_cache_t *_tio_cache; +static struct bio_set *dm_set; +static int __init local_init (void ) {int r; + dm_set =bioset_create (512 ,512 ,1 ); +if (!dm_set) +return -ENOMEM ; +/* allocate a slab for the dm_ios */ _io_cache =kmem_cache_create ("dm_io" ,sizeof (struct dm_io ),0 ,0 ,NULL ,NULL );
@@ -133,6 +139,8 @@kmem_cache_destroy (_tio_cache);kmem_cache_destroy (_io_cache); +bioset_free (dm_set); +if (unregister_blkdev (_major, _name) <0 )DMERR ("devfs_unregister_blkdev failed" );
@@ -393,7 +401,7 @@struct bio *clone;struct bio_vec *bv = bio->bi_io_vec + idx; - clone =bio_alloc (GFP_NOIO ,1 ); + clone =bio_alloc_bs (GFP_NOIO ,1 , dm_set); *clone->bi_io_vec = *bv; clone->bi_sector = sector;
drivers/md/dm-io.c +9 -228
285 lines not on this page · raw message
drivers/md/dm-zero.c +0 -17
@@ -24,23 +24,6 @@ }/* -* Fills the bio pages with zeros -*/ -static void zero_fill_bio (struct bio *bio) -{ -unsigned long flags; -struct bio_vec *bv; -int i; - -bio_for_each_segment (bv, bio, i) { -char *data =bvec_kmap_irq (bv, &flags); -memset (data,0 , bv->bv_len); -flush_dcache_page (bv->bv_page); -bvec_kunmap_irq (data, &flags); - } -} - -/* * Return zeros only on reads */ static int zero_map(struct dm_target *ti, struct bio *bio,
fs/bio.c +147 -54
309 lines not on this page · raw message
include/linux/bio.h +20 -0
@@ -59,6 +59,7 @@unsigned int bv_offset; }; +struct bio_set ;struct bio ;typedef int (bio_end_io_t ) (struct bio *,unsigned int ,int );typedef void (bio_destructor_t ) (struct bio *);
@@ -109,6 +110,7 @@void *bi_private;bio_destructor_t *bi_destructor;/* destructor */ +struct bio_set *bi_set;/* memory pools set */ };/*
@@ -258,7 +260,11 @@extern mempool_t *bio_split_pool;extern void bio_pair_release (struct bio_pair *dbio); +extern struct bio_set *bioset_create (int ,int ,int ); +extern void bioset_free (struct bio_set *); +extern struct bio *bio_alloc (int ,int ); +extern struct bio *bio_alloc_bs (int ,int ,struct bio_set *);extern void bio_put (struct bio *);extern void bio_endio (struct bio *,unsigned int ,int );
@@ -329,4 +335,18 @@ __bio_kmap_irq((bio), (bio)->bi_idx, (flags))#define bio_kunmap_irq (buf,flags) __bio_kunmap_irq(buf, flags) +extern inline void zero_fill_bio (struct bio *bio) +{ +unsigned long flags; +struct bio_vec *bv; +int i; + +bio_for_each_segment (bv, bio, i) { +char *data =bvec_kmap_irq (bv, &flags); +memset (data,0 , bv->bv_len); +flush_dcache_page (bv->bv_page); +bvec_kunmap_irq (data, &flags); + } +} +#endif /* __LINUX_BIO_H */
Quoted 3 lines · Dave Olien
Jens, last December you observed there was bio code duplicated in the dm drivers.
Yep
Quoted 11 lines
Here are a collection of patches that implements support for local bio and bvec pools into
bio.cand then removes the duplicate bio code from the dm drivers.It also replaces a call to
alloc_bio()indm.cwith a call to use a local bio pool. This removes a deadlock case in that code.These patches are against 2.6.11-rc1. If that's not a good source version to patch against, let me now what versions I should generate patches for.
Just check if they apply to current BK tree, in general it's just best to do patches against latest -rc1-bkX (or just the bk tree, if you use that).
But the patch looks good, the bio_set approach is the cleanest way to fix it I think. It will be easy to fix the bounce deadlock as well, by adding a bio_set_bounce to mm/highmem.c as well.
Thanks for doing this! I'll review the patch in detail, the concept and solution is definitely good though.
Signature · 1 line
Jens Axboe
Thanks! I'll continue to do more testing as well.
Quoted 23 lines · Jens Axboe
Quoted 3 lines · Dave Olien
Jens, last December you observed there was bio code duplicated in the dm drivers.
Yep
Quoted 11 lines
Here are a collection of patches that implements support for local bio and bvec pools into
bio.cand then removes the duplicate bio code from the dm drivers.It also replaces a call to
alloc_bio()indm.cwith a call to use a local bio pool. This removes a deadlock case in that code.These patches are against 2.6.11-rc1. If that's not a good source version to patch against, let me now what versions I should generate patches for.
Just check if they apply to current BK tree, in general it's just best to do patches against latest -rc1-bkX (or just the bk tree, if you use that).
Quoted 15 lines
But the patch looks good, the
bio_setapproach is the cleanest way to fix it I think. It will be easy to fix the bounce deadlock as well, by adding abio_set_bouncetomm/highmem.cas well.Thanks for doing this! I'll review the patch in detail, the concept and solution is definitely good though.
Signature · 7 lines
Jens Axboe - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel