Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Acked-by: Theodore Ts'o <tytso@mit.edu> # for ext4
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
ea3edd4d d2332c5c

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