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
57}57}
58EXPORT_SYMBOL(bio_devname);58EXPORT_SYMBOL(bio_devname);
59 59
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 */
65const 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
72EXPORT_SYMBOL(__bdevname);
73
74static ssize_t part_partition_show(struct device *dev,60static ssize_t part_partition_show(struct device *dev,
75 struct device_attribute *attr, char *buf)61 struct device_attribute *attr, char *buf)
76{62{
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
2491{2491{
2492 int err = 0;2492 int err = 0;
2493 struct block_device *bdev;2493 struct block_device *bdev;
2494 char b[BDEVNAME_SIZE];
2495 2494
2496 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL,2495 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
2497 shared ? (struct md_rdev *)lock_rdev : rdev);2496 shared ? (struct md_rdev *)lock_rdev : rdev);
2498 if (IS_ERR(bdev)) {2497 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));
2500 return PTR_ERR(bdev);2500 return PTR_ERR(bdev);
2501 }2501 }
2502 rdev->bdev = bdev;2502 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
927static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)927static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)
928{928{
929 struct block_device *bdev;929 struct block_device *bdev;
930 char b[BDEVNAME_SIZE];
931 930
932 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);931 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);
933 if (IS_ERR(bdev))932 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
935 return bdev;934 return bdev;
936 935
937fail:936fail:
938 ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld",937 ext4_msg(sb, KERN_ERR,
939 __bdevname(dev, b), PTR_ERR(bdev));938 "failed to open journal device unknown-block(%u,%u) %ld",
939 MAJOR(dev), MINOR(dev), PTR_ERR(bdev));
940 return NULL;940 return NULL;
941}941}
942 942
fs/reiserfs/journal.c+2−3
@@ -2599,7 +2599,6 @@ static int journal_init_dev(struct super_block *super, · 2598 unmodified lines
2599 int result;2599 int result;
2600 dev_t jdev;2600 dev_t jdev;
2601 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;2601 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
2602 char b[BDEVNAME_SIZE];
2603 2602
2604 result = 0;2603 result = 0;
2605 2604
@@ -2621,8 +2620,8 @@ static int journal_init_dev(struct super_block *super, · 15 unmodified lines
2621 result = PTR_ERR(journal->j_dev_bd);2620 result = PTR_ERR(journal->j_dev_bd);
2622 journal->j_dev_bd = NULL;2621 journal->j_dev_bd = NULL;
2623 reiserfs_warning(super, "sh-458",2622 reiserfs_warning(super, "sh-458",
2624 "cannot init journal device '%s': %i",2623 "cannot init journal device unknown-block(%u,%u): %i",
2625 __bdevname(jdev, b), result);2624 MAJOR(jdev), MINOR(jdev), result);
2626 return result;2625 return result;
2627 } else if (jdev != super->s_dev)2626 } else if (jdev != super->s_dev)
2628 set_blocksize(journal->j_dev_bd, super->s_blocksize);2627 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
2699 2699
2700#ifdef CONFIG_BLOCK2700#ifdef CONFIG_BLOCK
2701#define BLKDEV_MAJOR_MAX 5122701#define BLKDEV_MAJOR_MAX 512
2702extern const char *__bdevname(dev_t, char *buffer);
2703extern const char *bdevname(struct block_device *bdev, char *buffer);2702extern const char *bdevname(struct block_device *bdev, char *buffer);
2704extern struct block_device *lookup_bdev(const char *);2703extern struct block_device *lookup_bdev(const char *);
2705extern void blkdev_show(struct seq_file *,off_t);2704extern 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
429 struct page *page = alloc_page(GFP_KERNEL);429 struct page *page = alloc_page(GFP_KERNEL);
430 char *fs_names = page_address(page);430 char *fs_names = page_address(page);
431 char *p;431 char *p;
432#ifdef CONFIG_BLOCK
433 char b[BDEVNAME_SIZE];432 char b[BDEVNAME_SIZE];
434#else
435 const char *b = name;
436#endif
437 433
434 scnprintf(b, BDEVNAME_SIZE, "unknown-block(%u,%u)",
435 MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
438 get_fs_names(fs_names);436 get_fs_names(fs_names);
439retry:437retry:
440 for (p = fs_names; *p; p += strlen(p)+1) {438 for (p = fs_names; *p; p += strlen(p)+1) {
@@ -451,9 +449,6 @@ retry: · 10 unmodified lines
451 * and bad superblock on root device.449 * and bad superblock on root device.
452 * and give them a list of the available devices450 * and give them a list of the available devices
453 */451 */
454#ifdef CONFIG_BLOCK
455 __bdevname(ROOT_DEV, b);
456#endif
457 printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",452 printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
458 root_device_name, b, err);453 root_device_name, b, err);
459 printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");454 printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
@@ -476,9 +471,6 @@ retry: · 16 unmodified lines
476 for (p = fs_names; *p; p += strlen(p)+1)471 for (p = fs_names; *p; p += strlen(p)+1)
477 printk(" %s", p);472 printk(" %s", p);
478 printk("\n");473 printk("\n");
479#ifdef CONFIG_BLOCK
480 __bdevname(ROOT_DEV, b);
481#endif
482 panic("VFS: Unable to mount root fs on %s", b);474 panic("VFS: Unable to mount root fs on %s", b);
483out:475out:
484 put_page(page);476 put_page(page);