Commit 0f5cd781 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

bcache: remove the backing_dev_name field from struct cached_dev

Just use the %pg format specifier to print the name directly.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarColy Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20211020143812.6403-7-colyli@suse.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7e84c215
...@@ -395,8 +395,6 @@ struct cached_dev { ...@@ -395,8 +395,6 @@ struct cached_dev {
atomic_t io_errors; atomic_t io_errors;
unsigned int error_limit; unsigned int error_limit;
unsigned int offline_seconds; unsigned int offline_seconds;
char backing_dev_name[BDEVNAME_SIZE];
}; };
enum alloc_reserve { enum alloc_reserve {
......
...@@ -137,8 +137,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) ...@@ -137,8 +137,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
p2 + bv.bv_offset, p2 + bv.bv_offset,
bv.bv_len), bv.bv_len),
dc->disk.c, dc->disk.c,
"verify failed at dev %s sector %llu", "verify failed at dev %pg sector %llu",
dc->backing_dev_name, dc->bdev,
(uint64_t) bio->bi_iter.bi_sector); (uint64_t) bio->bi_iter.bi_sector);
kunmap_atomic(p1); kunmap_atomic(p1);
......
...@@ -65,15 +65,15 @@ void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio) ...@@ -65,15 +65,15 @@ void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio)
* we shouldn't count failed REQ_RAHEAD bio to dc->io_errors. * we shouldn't count failed REQ_RAHEAD bio to dc->io_errors.
*/ */
if (bio->bi_opf & REQ_RAHEAD) { if (bio->bi_opf & REQ_RAHEAD) {
pr_warn_ratelimited("%s: Read-ahead I/O failed on backing device, ignore\n", pr_warn_ratelimited("%pg: Read-ahead I/O failed on backing device, ignore\n",
dc->backing_dev_name); dc->bdev);
return; return;
} }
errors = atomic_add_return(1, &dc->io_errors); errors = atomic_add_return(1, &dc->io_errors);
if (errors < dc->error_limit) if (errors < dc->error_limit)
pr_err("%s: IO error on backing device, unrecoverable\n", pr_err("%pg: IO error on backing device, unrecoverable\n",
dc->backing_dev_name); dc->bdev);
else else
bch_cached_dev_error(dc); bch_cached_dev_error(dc);
} }
......
...@@ -651,8 +651,8 @@ static void backing_request_endio(struct bio *bio) ...@@ -651,8 +651,8 @@ static void backing_request_endio(struct bio *bio)
*/ */
if (unlikely(s->iop.writeback && if (unlikely(s->iop.writeback &&
bio->bi_opf & REQ_PREFLUSH)) { bio->bi_opf & REQ_PREFLUSH)) {
pr_err("Can't flush %s: returned bi_status %i\n", pr_err("Can't flush %pg: returned bi_status %i\n",
dc->backing_dev_name, bio->bi_status); dc->bdev, bio->bi_status);
} else { } else {
/* set to orig_bio->bi_status in bio_complete() */ /* set to orig_bio->bi_status in bio_complete() */
s->iop.status = bio->bi_status; s->iop.status = bio->bi_status;
......
...@@ -1026,8 +1026,8 @@ static int cached_dev_status_update(void *arg) ...@@ -1026,8 +1026,8 @@ static int cached_dev_status_update(void *arg)
dc->offline_seconds = 0; dc->offline_seconds = 0;
if (dc->offline_seconds >= BACKING_DEV_OFFLINE_TIMEOUT) { if (dc->offline_seconds >= BACKING_DEV_OFFLINE_TIMEOUT) {
pr_err("%s: device offline for %d seconds\n", pr_err("%pg: device offline for %d seconds\n",
dc->backing_dev_name, dc->bdev,
BACKING_DEV_OFFLINE_TIMEOUT); BACKING_DEV_OFFLINE_TIMEOUT);
pr_err("%s: disable I/O request due to backing device offline\n", pr_err("%s: disable I/O request due to backing device offline\n",
dc->disk.name); dc->disk.name);
...@@ -1058,15 +1058,13 @@ int bch_cached_dev_run(struct cached_dev *dc) ...@@ -1058,15 +1058,13 @@ int bch_cached_dev_run(struct cached_dev *dc)
}; };
if (dc->io_disable) { if (dc->io_disable) {
pr_err("I/O disabled on cached dev %s\n", pr_err("I/O disabled on cached dev %pg\n", dc->bdev);
dc->backing_dev_name);
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
if (atomic_xchg(&dc->running, 1)) { if (atomic_xchg(&dc->running, 1)) {
pr_info("cached dev %s is running already\n", pr_info("cached dev %pg is running already\n", dc->bdev);
dc->backing_dev_name);
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
...@@ -1163,7 +1161,7 @@ static void cached_dev_detach_finish(struct work_struct *w) ...@@ -1163,7 +1161,7 @@ static void cached_dev_detach_finish(struct work_struct *w)
mutex_unlock(&bch_register_lock); mutex_unlock(&bch_register_lock);
pr_info("Caching disabled for %s\n", dc->backing_dev_name); pr_info("Caching disabled for %pg\n", dc->bdev);
/* Drop ref we took in cached_dev_detach() */ /* Drop ref we took in cached_dev_detach() */
closure_put(&dc->disk.cl); closure_put(&dc->disk.cl);
...@@ -1203,29 +1201,27 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, ...@@ -1203,29 +1201,27 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
return -ENOENT; return -ENOENT;
if (dc->disk.c) { if (dc->disk.c) {
pr_err("Can't attach %s: already attached\n", pr_err("Can't attach %pg: already attached\n", dc->bdev);
dc->backing_dev_name);
return -EINVAL; return -EINVAL;
} }
if (test_bit(CACHE_SET_STOPPING, &c->flags)) { if (test_bit(CACHE_SET_STOPPING, &c->flags)) {
pr_err("Can't attach %s: shutting down\n", pr_err("Can't attach %pg: shutting down\n", dc->bdev);
dc->backing_dev_name);
return -EINVAL; return -EINVAL;
} }
if (dc->sb.block_size < c->cache->sb.block_size) { if (dc->sb.block_size < c->cache->sb.block_size) {
/* Will die */ /* Will die */
pr_err("Couldn't attach %s: block size less than set's block size\n", pr_err("Couldn't attach %pg: block size less than set's block size\n",
dc->backing_dev_name); dc->bdev);
return -EINVAL; return -EINVAL;
} }
/* Check whether already attached */ /* Check whether already attached */
list_for_each_entry_safe(exist_dc, t, &c->cached_devs, list) { list_for_each_entry_safe(exist_dc, t, &c->cached_devs, list) {
if (!memcmp(dc->sb.uuid, exist_dc->sb.uuid, 16)) { if (!memcmp(dc->sb.uuid, exist_dc->sb.uuid, 16)) {
pr_err("Tried to attach %s but duplicate UUID already attached\n", pr_err("Tried to attach %pg but duplicate UUID already attached\n",
dc->backing_dev_name); dc->bdev);
return -EINVAL; return -EINVAL;
} }
...@@ -1243,15 +1239,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, ...@@ -1243,15 +1239,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
if (!u) { if (!u) {
if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) { if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
pr_err("Couldn't find uuid for %s in set\n", pr_err("Couldn't find uuid for %pg in set\n", dc->bdev);
dc->backing_dev_name);
return -ENOENT; return -ENOENT;
} }
u = uuid_find_empty(c); u = uuid_find_empty(c);
if (!u) { if (!u) {
pr_err("Not caching %s, no room for UUID\n", pr_err("Not caching %pg, no room for UUID\n", dc->bdev);
dc->backing_dev_name);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -1319,8 +1313,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, ...@@ -1319,8 +1313,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
*/ */
kthread_stop(dc->writeback_thread); kthread_stop(dc->writeback_thread);
cancel_writeback_rate_update_dwork(dc); cancel_writeback_rate_update_dwork(dc);
pr_err("Couldn't run cached device %s\n", pr_err("Couldn't run cached device %pg\n", dc->bdev);
dc->backing_dev_name);
return ret; return ret;
} }
...@@ -1336,8 +1329,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, ...@@ -1336,8 +1329,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
/* Allow the writeback thread to proceed */ /* Allow the writeback thread to proceed */
up_write(&dc->writeback_lock); up_write(&dc->writeback_lock);
pr_info("Caching %s as %s on set %pU\n", pr_info("Caching %pg as %s on set %pU\n",
dc->backing_dev_name, dc->bdev,
dc->disk.disk->disk_name, dc->disk.disk->disk_name,
dc->disk.c->set_uuid); dc->disk.c->set_uuid);
return 0; return 0;
...@@ -1461,7 +1454,6 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk, ...@@ -1461,7 +1454,6 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
struct cache_set *c; struct cache_set *c;
int ret = -ENOMEM; int ret = -ENOMEM;
bdevname(bdev, dc->backing_dev_name);
memcpy(&dc->sb, sb, sizeof(struct cache_sb)); memcpy(&dc->sb, sb, sizeof(struct cache_sb));
dc->bdev = bdev; dc->bdev = bdev;
dc->bdev->bd_holder = dc; dc->bdev->bd_holder = dc;
...@@ -1476,7 +1468,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk, ...@@ -1476,7 +1468,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj)) if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
goto err; goto err;
pr_info("registered backing device %s\n", dc->backing_dev_name); pr_info("registered backing device %pg\n", dc->bdev);
list_add(&dc->list, &uncached_devices); list_add(&dc->list, &uncached_devices);
/* attach to a matched cache set if it exists */ /* attach to a matched cache set if it exists */
...@@ -1493,7 +1485,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk, ...@@ -1493,7 +1485,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
return 0; return 0;
err: err:
pr_notice("error %s: %s\n", dc->backing_dev_name, err); pr_notice("error %pg: %s\n", dc->bdev, err);
bcache_device_stop(&dc->disk); bcache_device_stop(&dc->disk);
return ret; return ret;
} }
...@@ -1621,8 +1613,8 @@ bool bch_cached_dev_error(struct cached_dev *dc) ...@@ -1621,8 +1613,8 @@ bool bch_cached_dev_error(struct cached_dev *dc)
/* make others know io_disable is true earlier */ /* make others know io_disable is true earlier */
smp_mb(); smp_mb();
pr_err("stop %s: too many IO errors on backing device %s\n", pr_err("stop %s: too many IO errors on backing device %pg\n",
dc->disk.disk->disk_name, dc->backing_dev_name); dc->disk.disk->disk_name, dc->bdev);
bcache_device_stop(&dc->disk); bcache_device_stop(&dc->disk);
return true; return true;
......
...@@ -271,7 +271,7 @@ SHOW(__bch_cached_dev) ...@@ -271,7 +271,7 @@ SHOW(__bch_cached_dev)
} }
if (attr == &sysfs_backing_dev_name) { if (attr == &sysfs_backing_dev_name) {
snprintf(buf, BDEVNAME_SIZE + 1, "%s", dc->backing_dev_name); snprintf(buf, BDEVNAME_SIZE + 1, "%pg", dc->bdev);
strcat(buf, "\n"); strcat(buf, "\n");
return strlen(buf); return strlen(buf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment