[PATCH 5/7] md: use block_device name vsprintf helper v2
changes from V1: -fix use bio after free on raid10 error path (spotted by Jan Kara) Signed-off-by: Dmitry Monakhov --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 66 drivers/md/raid5.c | 37 +-- 13 files changed, 173 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc->disk.c, -"verify failed at dev %s sector %llu", -bdevname(dc->bdev, name), -(uint64_t) bio->bi_iter.bi_sector); +"verify failed at dev %pg sector %llu", +dc->bdev, (uint64_t) bio->bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 << IO_ERROR_SHIFT, >io_errors); errors >>= IO_ERROR_SHIFT; if (errors < ca->set->error_limit) - pr_err("%s: IO error on %s, recovering", - bdevname(ca->bdev, buf), m); + pr_err("%pg: IO error on %s, recovering", ca->bdev , m); else bch_cache_set_error(ca->set, - "%s: too many IO errors %s", - bdevname(ca->bdev, buf), m); + "%pg: too many IO errors %s", + ca->bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(_register_lock); - pr_info("Caching disabled for %s", bdevname(dc->bdev, buf)); + pr_info("Caching disabled for %pg", dc->bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(>disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc->bdev, buf); if (memcmp(dc->sb.set_uuid, c->sb.set_uuid, 16)) return -ENOENT; if (dc->disk.c) { - pr_err("Can't attach %s: already attached", buf); + pr_err("Can't attach %pg: already attached", dc->bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, >flags)) { - pr_err("Can't attach %s: shutting down", buf); + pr_err("Can't attach %pg: shutting down", dc->bdev); return -EINVAL; } if (dc->sb.block_size < c->sb.block_size) { /* Will die */ - pr_err("Couldn't attach %s: block size less than set's block size", - buf); + pr_err("Couldn't attach %pg: block size less than set's block size", + dc->bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
[PATCH 5/7] md: use block_device name vsprintf helper v2
changes from V1: -fix use bio after free on raid10 error path (spotted by Jan Kara) Signed-off-by: Dmitry Monakhov dmonak...@openvz.org --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 66 drivers/md/raid5.c | 37 +-- 13 files changed, 173 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc-disk.c, -verify failed at dev %s sector %llu, -bdevname(dc-bdev, name), -(uint64_t) bio-bi_iter.bi_sector); +verify failed at dev %pg sector %llu, +dc-bdev, (uint64_t) bio-bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 IO_ERROR_SHIFT, ca-io_errors); errors = IO_ERROR_SHIFT; if (errors ca-set-error_limit) - pr_err(%s: IO error on %s, recovering, - bdevname(ca-bdev, buf), m); + pr_err(%pg: IO error on %s, recovering, ca-bdev , m); else bch_cache_set_error(ca-set, - %s: too many IO errors %s, - bdevname(ca-bdev, buf), m); + %pg: too many IO errors %s, + ca-bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(cl); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(bch_register_lock); - pr_info(Caching disabled for %s, bdevname(dc-bdev, buf)); + pr_info(Caching disabled for %pg, dc-bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(dc-disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc-bdev, buf); if (memcmp(dc-sb.set_uuid, c-sb.set_uuid, 16)) return -ENOENT; if (dc-disk.c) { - pr_err(Can't attach %s: already attached, buf); + pr_err(Can't attach %pg: already attached, dc-bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, c-flags)) { - pr_err(Can't attach %s: shutting down, buf); + pr_err(Can't attach %pg: shutting down, dc-bdev); return -EINVAL; } if (dc-sb.block_size c-sb.block_size) { /* Will die */ - pr_err(Couldn't attach %s: block size less than set's block size, - buf); + pr_err(Couldn't attach %pg: block size less than set's block size, + dc-bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (!u) {
Re: [PATCH 5/7] md: use block_device name vsprintf helper
On Mon 13-04-15 16:31:38, Dmitry Monakhov wrote: > > Signed-off-by: Dmitry Monakhov ... > @@ -2610,7 +2597,6 @@ static void handle_read_error(struct mddev *mddev, > struct r10bio *r10_bio) > struct bio *bio; > struct r10conf *conf = mddev->private; > struct md_rdev *rdev = r10_bio->devs[slot].rdev; > - char b[BDEVNAME_SIZE]; > unsigned long do_sync; > int max_sectors; > > @@ -2623,7 +2609,6 @@ static void handle_read_error(struct mddev *mddev, > struct r10bio *r10_bio) >* frozen. >*/ > bio = r10_bio->devs[slot].bio; > - bdevname(bio->bi_bdev, b); > bio_put(bio); > r10_bio->devs[slot].bio = NULL; > > @@ -2639,9 +2624,9 @@ static void handle_read_error(struct mddev *mddev, > struct r10bio *r10_bio) > read_more: > rdev = read_balance(conf, r10_bio, _sectors); > if (rdev == NULL) { > - printk(KERN_ALERT "md/raid10:%s: %s: unrecoverable I/O" > + printk(KERN_ALERT "md/raid10:%s: %pg: unrecoverable I/O" > " read error for block %llu\n", > -mdname(mddev), b, > +mdname(mddev), bio->bi_bdev, > (unsigned long long)r10_bio->sector); > raid_end_bio_io(r10_bio); > return; So it seems to me that in the above, you'll reference bio->bi_bdev of an already free bio since the code does bio_put() just after calling bdevname()... Honza -- Jan Kara SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/7] md: use block_device name vsprintf helper
On Mon 13-04-15 16:31:38, Dmitry Monakhov wrote: Signed-off-by: Dmitry Monakhov dmonak...@openvz.org ... @@ -2610,7 +2597,6 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio) struct bio *bio; struct r10conf *conf = mddev-private; struct md_rdev *rdev = r10_bio-devs[slot].rdev; - char b[BDEVNAME_SIZE]; unsigned long do_sync; int max_sectors; @@ -2623,7 +2609,6 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio) * frozen. */ bio = r10_bio-devs[slot].bio; - bdevname(bio-bi_bdev, b); bio_put(bio); r10_bio-devs[slot].bio = NULL; @@ -2639,9 +2624,9 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio) read_more: rdev = read_balance(conf, r10_bio, max_sectors); if (rdev == NULL) { - printk(KERN_ALERT md/raid10:%s: %s: unrecoverable I/O + printk(KERN_ALERT md/raid10:%s: %pg: unrecoverable I/O read error for block %llu\n, -mdname(mddev), b, +mdname(mddev), bio-bi_bdev, (unsigned long long)r10_bio-sector); raid_end_bio_io(r10_bio); return; So it seems to me that in the above, you'll reference bio-bi_bdev of an already free bio since the code does bio_put() just after calling bdevname()... Honza -- Jan Kara j...@suse.cz SUSE Labs, CR -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/7] md: use block_device name vsprintf helper
Signed-off-by: Dmitry Monakhov --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 64 +++ drivers/md/raid5.c | 37 +-- 13 files changed, 171 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc->disk.c, -"verify failed at dev %s sector %llu", -bdevname(dc->bdev, name), -(uint64_t) bio->bi_iter.bi_sector); +"verify failed at dev %pg sector %llu", +dc->bdev, (uint64_t) bio->bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 << IO_ERROR_SHIFT, >io_errors); errors >>= IO_ERROR_SHIFT; if (errors < ca->set->error_limit) - pr_err("%s: IO error on %s, recovering", - bdevname(ca->bdev, buf), m); + pr_err("%pg: IO error on %s, recovering", ca->bdev , m); else bch_cache_set_error(ca->set, - "%s: too many IO errors %s", - bdevname(ca->bdev, buf), m); + "%pg: too many IO errors %s", + ca->bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(_register_lock); - pr_info("Caching disabled for %s", bdevname(dc->bdev, buf)); + pr_info("Caching disabled for %pg", dc->bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(>disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc->bdev, buf); if (memcmp(dc->sb.set_uuid, c->sb.set_uuid, 16)) return -ENOENT; if (dc->disk.c) { - pr_err("Can't attach %s: already attached", buf); + pr_err("Can't attach %pg: already attached", dc->bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, >flags)) { - pr_err("Can't attach %s: shutting down", buf); + pr_err("Can't attach %pg: shutting down", dc->bdev); return -EINVAL; } if (dc->sb.block_size < c->sb.block_size) { /* Will die */ - pr_err("Couldn't attach %s: block size less than set's block size", - buf); + pr_err("Couldn't attach %pg: block size less than set's block size", + dc->bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (!u) { if (BDEV_STATE(>sb) == BDEV_STATE_DIRTY) { -
[PATCH 5/7] md: use block_device name vsprintf helper
Signed-off-by: Dmitry Monakhov dmonak...@openvz.org --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 64 +++ drivers/md/raid5.c | 37 +-- 13 files changed, 171 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc-disk.c, -verify failed at dev %s sector %llu, -bdevname(dc-bdev, name), -(uint64_t) bio-bi_iter.bi_sector); +verify failed at dev %pg sector %llu, +dc-bdev, (uint64_t) bio-bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 IO_ERROR_SHIFT, ca-io_errors); errors = IO_ERROR_SHIFT; if (errors ca-set-error_limit) - pr_err(%s: IO error on %s, recovering, - bdevname(ca-bdev, buf), m); + pr_err(%pg: IO error on %s, recovering, ca-bdev , m); else bch_cache_set_error(ca-set, - %s: too many IO errors %s, - bdevname(ca-bdev, buf), m); + %pg: too many IO errors %s, + ca-bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(cl); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(bch_register_lock); - pr_info(Caching disabled for %s, bdevname(dc-bdev, buf)); + pr_info(Caching disabled for %pg, dc-bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(dc-disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc-bdev, buf); if (memcmp(dc-sb.set_uuid, c-sb.set_uuid, 16)) return -ENOENT; if (dc-disk.c) { - pr_err(Can't attach %s: already attached, buf); + pr_err(Can't attach %pg: already attached, dc-bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, c-flags)) { - pr_err(Can't attach %s: shutting down, buf); + pr_err(Can't attach %pg: shutting down, dc-bdev); return -EINVAL; } if (dc-sb.block_size c-sb.block_size) { /* Will die */ - pr_err(Couldn't attach %s: block size less than set's block size, - buf); + pr_err(Couldn't attach %pg: block size less than set's block size, + dc-bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (!u) { if (BDEV_STATE(dc-sb) == BDEV_STATE_DIRTY) { -
[PATCH 5/7] md: use block_device name vsprintf helper
Signed-off-by: Dmitry Monakhov --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 64 +++ drivers/md/raid5.c | 37 +-- 13 files changed, 171 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc->disk.c, -"verify failed at dev %s sector %llu", -bdevname(dc->bdev, name), -(uint64_t) bio->bi_iter.bi_sector); +"verify failed at dev %pg sector %llu", +dc->bdev, (uint64_t) bio->bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 << IO_ERROR_SHIFT, >io_errors); errors >>= IO_ERROR_SHIFT; if (errors < ca->set->error_limit) - pr_err("%s: IO error on %s, recovering", - bdevname(ca->bdev, buf), m); + pr_err("%pg: IO error on %s, recovering", ca->bdev , m); else bch_cache_set_error(ca->set, - "%s: too many IO errors %s", - bdevname(ca->bdev, buf), m); + "%pg: too many IO errors %s", + ca->bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(_register_lock); - pr_info("Caching disabled for %s", bdevname(dc->bdev, buf)); + pr_info("Caching disabled for %pg", dc->bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(>disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc->bdev, buf); if (memcmp(dc->sb.set_uuid, c->sb.set_uuid, 16)) return -ENOENT; if (dc->disk.c) { - pr_err("Can't attach %s: already attached", buf); + pr_err("Can't attach %pg: already attached", dc->bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, >flags)) { - pr_err("Can't attach %s: shutting down", buf); + pr_err("Can't attach %pg: shutting down", dc->bdev); return -EINVAL; } if (dc->sb.block_size < c->sb.block_size) { /* Will die */ - pr_err("Couldn't attach %s: block size less than set's block size", - buf); + pr_err("Couldn't attach %pg: block size less than set's block size", + dc->bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (!u) { if (BDEV_STATE(>sb) == BDEV_STATE_DIRTY) { -
[PATCH 5/7] md: use block_device name vsprintf helper
Signed-off-by: Dmitry Monakhov dmonak...@openvz.org --- drivers/md/bcache/debug.c|6 +- drivers/md/bcache/io.c |8 +-- drivers/md/bcache/super.c| 32 -- drivers/md/dm-cache-target.c |5 +- drivers/md/dm-table.c| 32 - drivers/md/dm-thin.c |8 +-- drivers/md/linear.c |5 +- drivers/md/md.c | 141 -- drivers/md/multipath.c | 29 +++- drivers/md/raid0.c | 33 -- drivers/md/raid1.c | 37 --- drivers/md/raid10.c | 64 +++ drivers/md/raid5.c | 37 +-- 13 files changed, 171 insertions(+), 266 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 8b1f1d5..fb61f55 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -104,7 +104,6 @@ void bch_btree_verify(struct btree *b) void bch_data_verify(struct cached_dev *dc, struct bio *bio) { - char name[BDEVNAME_SIZE]; struct bio *check; struct bio_vec bv, *bv2; struct bvec_iter iter; @@ -127,9 +126,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) p2 + bv.bv_offset, bv.bv_len), dc-disk.c, -verify failed at dev %s sector %llu, -bdevname(dc-bdev, name), -(uint64_t) bio-bi_iter.bi_sector); +verify failed at dev %pg sector %llu, +dc-bdev, (uint64_t) bio-bi_iter.bi_sector); kunmap_atomic(p1); } diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index fa028fa..7e21113 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -188,18 +188,16 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m) } if (error) { - char buf[BDEVNAME_SIZE]; unsigned errors = atomic_add_return(1 IO_ERROR_SHIFT, ca-io_errors); errors = IO_ERROR_SHIFT; if (errors ca-set-error_limit) - pr_err(%s: IO error on %s, recovering, - bdevname(ca-bdev, buf), m); + pr_err(%pg: IO error on %s, recovering, ca-bdev , m); else bch_cache_set_error(ca-set, - %s: too many IO errors %s, - bdevname(ca-bdev, buf), m); + %pg: too many IO errors %s, + ca-bdev, m); } } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4dd2bb7..b15b7db 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -907,7 +907,6 @@ void bch_cached_dev_run(struct cached_dev *dc) static void cached_dev_detach_finish(struct work_struct *w) { struct cached_dev *dc = container_of(w, struct cached_dev, detach); - char buf[BDEVNAME_SIZE]; struct closure cl; closure_init_stack(cl); @@ -930,7 +929,7 @@ static void cached_dev_detach_finish(struct work_struct *w) mutex_unlock(bch_register_lock); - pr_info(Caching disabled for %s, bdevname(dc-bdev, buf)); + pr_info(Caching disabled for %pg, dc-bdev); /* Drop ref we took in cached_dev_detach() */ closure_put(dc-disk.cl); @@ -960,27 +959,24 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) { uint32_t rtime = cpu_to_le32(get_seconds()); struct uuid_entry *u; - char buf[BDEVNAME_SIZE]; - - bdevname(dc-bdev, buf); if (memcmp(dc-sb.set_uuid, c-sb.set_uuid, 16)) return -ENOENT; if (dc-disk.c) { - pr_err(Can't attach %s: already attached, buf); + pr_err(Can't attach %pg: already attached, dc-bdev); return -EINVAL; } if (test_bit(CACHE_SET_STOPPING, c-flags)) { - pr_err(Can't attach %s: shutting down, buf); + pr_err(Can't attach %pg: shutting down, dc-bdev); return -EINVAL; } if (dc-sb.block_size c-sb.block_size) { /* Will die */ - pr_err(Couldn't attach %s: block size less than set's block size, - buf); + pr_err(Couldn't attach %pg: block size less than set's block size, + dc-bdev); return -EINVAL; } @@ -996,13 +992,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (!u) { if (BDEV_STATE(dc-sb) == BDEV_STATE_DIRTY) { -