Messages in this thread Patch in this message | | | Date | Sun, 4 May 2003 19:17:09 +0200 | From | Christoph Hellwig <> | Subject | [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).
--- 1.83/drivers/block/genhd.c Fri Apr 25 18:16:28 2003 +++ edited/drivers/block/genhd.c Sun May 4 08:38:05 2003 @@ -52,30 +52,6 @@ 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) { --- 1.108/fs/partitions/check.c Tue Apr 29 17:42:50 2003 +++ edited/fs/partitions/check.c Sun May 4 08:37:43 2003 @@ -125,6 +112,29 @@ 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) { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |