block: remove bdevname
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>
This commit is contained in:
parent
c5b045b983
commit
900d156bac
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user