Commit e515904b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] make __bdevname output more similar to bdevname

Currently __bdevname walks the obsolete list of block majors to
find a name for the given dev_t and falls back to unknown-block(%u,%u)
if that's not possible.  Replace this with an attempted get_gendisk() +
disk_name.  This means __bdevname can't be called from irq context
anymore, but as all old irq context callers are using bdevname() now
that fine (and I've added a big comment).
parent 8f998915
......@@ -52,30 +52,6 @@ static inline int dev_to_index(dev_t dev)
return major_to_index(MAJOR(dev));
}
/*
* __bdevname may be called from interrupts, and must be atomic
*/
const char *__bdevname(dev_t dev, char *buffer)
{
char *name = "unknown-block";
unsigned int major = MAJOR(dev);
unsigned int minor = MINOR(dev);
int index = major_to_index(major);
struct blk_major_name *n;
unsigned long flags;
spin_lock_irqsave(&major_names_lock, flags);
for (n = major_names[index]; n; n = n->next)
if (n->major == major)
break;
if (n)
name = &(n->name[0]);
snprintf(buffer, BDEVNAME_SIZE, "%s(%u,%u)", name, major, minor);
spin_unlock_irqrestore(&major_names_lock, flags);
return buffer;
}
/* get block device names in somewhat random order */
int get_blkdev_list(char *p)
{
......
......@@ -125,6 +125,29 @@ const char *bdevname(struct block_device *bdev, char *buf)
return disk_name(bdev->bd_disk, part, buf);
}
/*
* NOTE: this cannot be called from interrupt context.
*
* But in interrupt context you should really have a struct
* block_device anyway and use bdevname() above.
*/
const char *__bdevname(dev_t dev, char *buffer)
{
struct gendisk *disk;
int part;
disk = get_gendisk(dev, &part);
if (disk) {
buffer = disk_name(disk, part, buffer);
put_disk(disk);
} else {
snprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
MAJOR(dev), MINOR(dev));
}
return buffer;
}
static struct parsed_partitions *
check_partition(struct gendisk *hd, struct block_device *bdev)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment