History

block: remove __bdevname

There is no good reason for __bdevname to exist. Just open code printing the string in the callers. For three of them the format string can be trivially merged into existing printk statements, and in init/do_mounts.c we can at least do the scnprintf once at the start of the function, and unconditional of CONFIG_BLOCK to make the output for tiny configfs a little more helpful.

Christoph Hellwig committed 6 years ago

Commit ea3edd41 parent d2332c56 files · +9 −33Browse files

Unified · Split

6 files
  1. block/partition-generic.c +0 −14
  2. drivers/md/md.c +2 −2
  3. fs/ext4/super.c +3 −3
  4. fs/reiserfs/journal.c +2 −3
  5. include/linux/fs.h +0 −1
  6. init/do_mounts.c +2 −10
block/partition-generic.c+0−14
@@ -57,20 +57,6 @@ const char *bio_devname(struct bio *bio, char *buf) · 56 unmodified lines
5757 }
5858 EXPORT_SYMBOL(bio_devname);
5959
60−/*
61− * There's very little reason to use this, you should really
62− * have a struct block_device just about everywhere and use
63− * bdevname() instead.
64− */
65−const char *__bdevname(dev_t dev, char *buffer)
66−{
67− scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
68− MAJOR(dev), MINOR(dev));
69− return buffer;
70−}
71−
72−EXPORT_SYMBOL(__bdevname);
73−
7460 static ssize_t part_partition_show(struct device *dev,
7561 struct device_attribute *attr, char *buf)
7662 {
drivers/md/md.c+2−2
@@ -2491,12 +2491,12 @@ static int lock_rdev(struct md_rdev *rdev, dev_t dev, int shared) · 2490 unmodified lines
24912491 {
24922492 int err = 0;
24932493 struct block_device *bdev;
2494− char b[BDEVNAME_SIZE];
24952494
24962495 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
24972496 shared ? (struct md_rdev *)lock_rdev : rdev);
24982497 if (IS_ERR(bdev)) {
2499− pr_warn("md: could not open %s.\n", __bdevname(dev, b));
2498+ pr_warn("md: could not open device unknown-block(%u,%u).\n",
2499+ MAJOR(dev), MINOR(dev));
25002500 return PTR_ERR(bdev);
25012501 }
25022502 rdev->bdev = bdev;
fs/ext4/super.c+3−3
@@ -927,7 +927,6 @@ void ext4_update_dynamic_rev(struct super_block *sb) · 926 unmodified lines
927927 static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)
928928 {
929929 struct block_device *bdev;
930− char b[BDEVNAME_SIZE];
931930
932931 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);
933932 if (IS_ERR(bdev))
@@ -935,8 +934,9 @@ static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) · 1 unmodified line
935934 return bdev;
936935
937936 fail:
938− ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld",
939− __bdevname(dev, b), PTR_ERR(bdev));
937+ ext4_msg(sb, KERN_ERR,
938+ "failed to open journal device unknown-block(%u,%u) %ld",
939+ MAJOR(dev), MINOR(dev), PTR_ERR(bdev));
940940 return NULL;
941941 }
942942
fs/reiserfs/journal.c+2−3
@@ -2599,7 +2599,6 @@ static int journal_init_dev(struct super_block *super, · 2598 unmodified lines
25992599 int result;
26002600 dev_t jdev;
26012601 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
2602− char b[BDEVNAME_SIZE];
26032602
26042603 result = 0;
26052604
@@ -2621,8 +2620,8 @@ static int journal_init_dev(struct super_block *super, · 15 unmodified lines
26212620 result = PTR_ERR(journal->j_dev_bd);
26222621 journal->j_dev_bd = NULL;
26232622 reiserfs_warning(super, "sh-458",
2624− "cannot init journal device '%s': %i",
2625− __bdevname(jdev, b), result);
2623+ "cannot init journal device unknown-block(%u,%u): %i",
2624+ MAJOR(jdev), MINOR(jdev), result);
26262625 return result;
26272626 } else if (jdev != super->s_dev)
26282627 set_blocksize(journal->j_dev_bd, super->s_blocksize);
include/linux/fs.h+0−1
@@ -2699,7 +2699,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name) · 2698 unmodified lines
26992699
27002700 #ifdef CONFIG_BLOCK
27012701 #define BLKDEV_MAJOR_MAX 512
2702−extern const char *__bdevname(dev_t, char *buffer);
27032702 extern const char *bdevname(struct block_device *bdev, char *buffer);
27042703 extern struct block_device *lookup_bdev(const char *);
27052704 extern void blkdev_show(struct seq_file *,off_t);
init/do_mounts.c+2−10
@@ -429,12 +429,10 @@ void __init mount_block_root(char *name, int flags) · 428 unmodified lines
429429 struct page *page = alloc_page(GFP_KERNEL);
430430 char *fs_names = page_address(page);
431431 char *p;
432−#ifdef CONFIG_BLOCK
433432 char b[BDEVNAME_SIZE];
434−#else
435− const char *b = name;
436−#endif
437433
434+ scnprintf(b, BDEVNAME_SIZE, "unknown-block(%u,%u)",
435+ MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
438436 get_fs_names(fs_names);
439437 retry:
440438 for (p = fs_names; *p; p += strlen(p)+1) {
@@ -451,9 +449,6 @@ retry: · 10 unmodified lines
451449 * and bad superblock on root device.
452450 * and give them a list of the available devices
453451 */
454−#ifdef CONFIG_BLOCK
455− __bdevname(ROOT_DEV, b);
456−#endif
457452 printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
458453 root_device_name, b, err);
459454 printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
@@ -476,9 +471,6 @@ retry: · 16 unmodified lines
476471 for (p = fs_names; *p; p += strlen(p)+1)
477472 printk(" %s", p);
478473 printk("\n");
479−#ifdef CONFIG_BLOCK
480− __bdevname(ROOT_DEV, b);
481−#endif
482474 panic("VFS: Unable to mount root fs on %s", b);
483475 out:
484476 put_page(page);