]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: remove bdevname
authorChristoph Hellwig <hch@lst.de>
Wed, 13 Jul 2022 05:53:17 +0000 (07:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Jul 2022 16:27:56 +0000 (10:27 -0600)
Replace the remaining calls of bdevname with snprintf using the %pg
format specifier.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20220713055317.1888500-10-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c
drivers/md/md.c
drivers/md/raid1.c
drivers/md/raid10.c
fs/ext4/mmp.c
fs/jbd2/journal.c
include/linux/blkdev.h
kernel/trace/blktrace.c

index 9d30f159c59ac3890278c79009c1418e463c129c..44dfcf67ed96a192007c88663de73e07c32536ea 100644 (file)
@@ -101,29 +101,6 @@ bool set_capacity_and_notify(struct gendisk *disk, sector_t size)
 }
 EXPORT_SYMBOL_GPL(set_capacity_and_notify);
 
-/*
- * Format the device name of the indicated block device into the supplied buffer
- * and return a pointer to that same buffer for convenience.
- *
- * Note: do not use this in new code, use the %pg specifier to sprintf and
- * printk insted.
- */
-const char *bdevname(struct block_device *bdev, char *buf)
-{
-       struct gendisk *hd = bdev->bd_disk;
-       int partno = bdev->bd_partno;
-
-       if (!partno)
-               snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
-       else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
-               snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno);
-       else
-               snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno);
-
-       return buf;
-}
-EXPORT_SYMBOL(bdevname);
-
 static void part_stat_read_all(struct block_device *part,
                struct disk_stats *stat)
 {
index 076255ec9ba18e4bf2d30cba80b3af9ab81cb0cb..4be9d81730712417036339622dead9e15bbb8b2b 100644 (file)
@@ -2438,7 +2438,7 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev)
                        mdname(mddev), mddev->max_disks);
                return -EBUSY;
        }
-       bdevname(rdev->bdev,b);
+       snprintf(b, sizeof(b), "%pg", rdev->bdev);
        strreplace(b, '/', '!');
 
        rdev->mddev = mddev;
index 258d4eb2d63c3066016c765ee0776984dde5015e..65cd90f0b2a8bb4d0b7ceacb8ac15658ae6cea98 100644 (file)
@@ -1240,7 +1240,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
                rcu_read_lock();
                rdev = rcu_dereference(conf->mirrors[r1_bio->read_disk].rdev);
                if (rdev)
-                       bdevname(rdev->bdev, b);
+                       snprintf(b, sizeof(b), "%pg", rdev->bdev);
                else
                        strcpy(b, "???");
                rcu_read_unlock();
index d589f823feb116ae7bb44cd21b06efad553e1b63..a7dcb1bf6b0a9f50da5ff7d341a3798a04f7e236 100644 (file)
@@ -1164,7 +1164,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
                disk = r10_bio->devs[slot].devnum;
                err_rdev = rcu_dereference(conf->mirrors[disk].rdev);
                if (err_rdev)
-                       bdevname(err_rdev->bdev, b);
+                       snprintf(b, sizeof(b), "%pg", err_rdev->bdev);
                else {
                        strcpy(b, "???");
                        /* This never gets dereferenced */
index b7a850b0070b83b69fe68df59b499c56b0b62cf0..b221f313ded6c619c3e14ab618740852a2578377 100644 (file)
@@ -371,7 +371,8 @@ skip:
        EXT4_SB(sb)->s_mmp_bh = bh;
 
        BUILD_BUG_ON(sizeof(mmp->mmp_bdevname) < BDEVNAME_SIZE);
-       bdevname(bh->b_bdev, mmp->mmp_bdevname);
+       snprintf(mmp->mmp_bdevname, sizeof(mmp->mmp_bdevname),
+                "%pg", bh->b_bdev);
 
        /*
         * Start a kernel thread to update the MMP block periodically.
index c0cbeeaec2d1aa33d0ff97217ae02e2205c248ba..9015f5fa28620e612b00b6eaaeb0cbb753729df7 100644 (file)
@@ -1465,7 +1465,8 @@ journal_t *jbd2_journal_init_dev(struct block_device *bdev,
        if (!journal)
                return NULL;
 
-       bdevname(journal->j_dev, journal->j_devname);
+       snprintf(journal->j_devname, sizeof(journal->j_devname),
+                "%pg", journal->j_dev);
        strreplace(journal->j_devname, '/', '!');
        jbd2_stats_proc_init(journal);
 
@@ -1507,7 +1508,8 @@ journal_t *jbd2_journal_init_inode(struct inode *inode)
                return NULL;
 
        journal->j_inode = inode;
-       bdevname(journal->j_dev, journal->j_devname);
+       snprintf(journal->j_devname, sizeof(journal->j_devname),
+                "%pg", journal->j_dev);
        p = strreplace(journal->j_devname, '/', '!');
        sprintf(p, "-%lu", journal->j_inode->i_ino);
        jbd2_stats_proc_init(journal);
index 22c477fadc0f3830416f01a10b765f1529f99d75..2775763c51b991199ab0d6b35af8269b08f20d08 100644 (file)
@@ -1457,7 +1457,6 @@ static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time)
 int bdev_read_only(struct block_device *bdev);
 int set_blocksize(struct block_device *bdev, int size);
 
-const char *bdevname(struct block_device *bdev, char *buffer);
 int lookup_bdev(const char *pathname, dev_t *dev);
 
 void blkdev_show(struct seq_file *seqf, off_t offset);
index c584effe5fe99285092a6ae1cd54d18fe870829f..4752bda1b1a0c8c31ee41e715ac30973869ee832 100644 (file)
@@ -736,12 +736,12 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
 
        switch (cmd) {
        case BLKTRACESETUP:
-               bdevname(bdev, b);
+               snprintf(b, sizeof(b), "%pg", bdev);
                ret = __blk_trace_setup(q, b, bdev->bd_dev, bdev, arg);
                break;
 #if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64)
        case BLKTRACESETUP32:
-               bdevname(bdev, b);
+               snprintf(b, sizeof(b), "%pg", bdev);
                ret = compat_blk_trace_setup(q, b, bdev->bd_dev, bdev, arg);
                break;
 #endif