Commit 500b81a8 authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[PATCH] make the bdevname() API sane

bdevname returns a pointer to a static string.  Change it so that the caller
passes in the buffer.
parent b548867b
...@@ -55,9 +55,8 @@ static inline int dev_to_index(dev_t dev) ...@@ -55,9 +55,8 @@ static inline int dev_to_index(dev_t dev)
/* /*
* __bdevname may be called from interrupts, and must be atomic * __bdevname may be called from interrupts, and must be atomic
*/ */
const char *__bdevname(dev_t dev) const char *__bdevname(dev_t dev, char *buffer)
{ {
static char buffer[40];
char *name = "unknown-block"; char *name = "unknown-block";
unsigned int major = MAJOR(dev); unsigned int major = MAJOR(dev);
unsigned int minor = MINOR(dev); unsigned int minor = MINOR(dev);
...@@ -71,7 +70,7 @@ const char *__bdevname(dev_t dev) ...@@ -71,7 +70,7 @@ const char *__bdevname(dev_t dev)
break; break;
if (n) if (n)
name = &(n->name[0]); name = &(n->name[0]);
sprintf(buffer, "%s(%u,%u)", name, major, minor); snprintf(buffer, BDEVNAME_SIZE, "%s(%u,%u)", name, major, minor);
spin_unlock_irqrestore(&major_names_lock, flags); spin_unlock_irqrestore(&major_names_lock, flags);
return buffer; return buffer;
......
...@@ -1892,13 +1892,14 @@ void generic_make_request(struct bio *bio) ...@@ -1892,13 +1892,14 @@ void generic_make_request(struct bio *bio)
if (maxsector < nr_sectors || if (maxsector < nr_sectors ||
maxsector - nr_sectors < sector) { maxsector - nr_sectors < sector) {
char b[BDEVNAME_SIZE];
/* This may well happen - the kernel calls /* This may well happen - the kernel calls
* bread() without checking the size of the * bread() without checking the size of the
* device, e.g., when mounting a device. */ * device, e.g., when mounting a device. */
printk(KERN_INFO printk(KERN_INFO
"attempt to access beyond end of device\n"); "attempt to access beyond end of device\n");
printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n", printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n",
bdevname(bio->bi_bdev), bdevname(bio->bi_bdev, b),
bio->bi_rw, bio->bi_rw,
(unsigned long long) sector + nr_sectors, (unsigned long long) sector + nr_sectors,
(long long) maxsector); (long long) maxsector);
...@@ -1917,11 +1918,14 @@ void generic_make_request(struct bio *bio) ...@@ -1917,11 +1918,14 @@ void generic_make_request(struct bio *bio)
* Stacking drivers are expected to know what they are doing. * Stacking drivers are expected to know what they are doing.
*/ */
do { do {
char b[BDEVNAME_SIZE];
q = bdev_get_queue(bio->bi_bdev); q = bdev_get_queue(bio->bi_bdev);
if (!q) { if (!q) {
printk(KERN_ERR printk(KERN_ERR
"generic_make_request: Trying to access nonexistent block-device %s (%Lu)\n", "generic_make_request: Trying to access "
bdevname(bio->bi_bdev), "nonexistent block-device %s (%Lu)\n",
bdevname(bio->bi_bdev, b),
(long long) bio->bi_sector); (long long) bio->bi_sector);
end_io: end_io:
bio_endio(bio, bio->bi_size, -EIO); bio_endio(bio, bio->bi_size, -EIO);
...@@ -1930,7 +1934,7 @@ void generic_make_request(struct bio *bio) ...@@ -1930,7 +1934,7 @@ void generic_make_request(struct bio *bio)
if (unlikely(bio_sectors(bio) > q->max_sectors)) { if (unlikely(bio_sectors(bio) > q->max_sectors)) {
printk("bio too big device %s (%u > %u)\n", printk("bio too big device %s (%u > %u)\n",
bdevname(bio->bi_bdev), bdevname(bio->bi_bdev, b),
bio_sectors(bio), bio_sectors(bio),
q->max_sectors); q->max_sectors);
goto end_io; goto end_io;
......
...@@ -79,6 +79,7 @@ static int linear_status(struct dm_target *ti, status_type_t type, ...@@ -79,6 +79,7 @@ static int linear_status(struct dm_target *ti, status_type_t type,
char *result, int maxlen) char *result, int maxlen)
{ {
struct linear_c *lc = (struct linear_c *) ti->private; struct linear_c *lc = (struct linear_c *) ti->private;
char b[BDEVNAME_SIZE];
switch (type) { switch (type) {
case STATUSTYPE_INFO: case STATUSTYPE_INFO:
...@@ -87,7 +88,7 @@ static int linear_status(struct dm_target *ti, status_type_t type, ...@@ -87,7 +88,7 @@ static int linear_status(struct dm_target *ti, status_type_t type,
case STATUSTYPE_TABLE: case STATUSTYPE_TABLE:
snprintf(result, maxlen, "%s " SECTOR_FORMAT, snprintf(result, maxlen, "%s " SECTOR_FORMAT,
bdevname(lc->dev->bdev), lc->start); bdevname(lc->dev->bdev, b), lc->start);
break; break;
} }
return 0; return 0;
......
...@@ -209,6 +209,7 @@ static int stripe_status(struct dm_target *ti, ...@@ -209,6 +209,7 @@ static int stripe_status(struct dm_target *ti,
struct stripe_c *sc = (struct stripe_c *) ti->private; struct stripe_c *sc = (struct stripe_c *) ti->private;
int offset; int offset;
int i; int i;
char b[BDEVNAME_SIZE];
switch (type) { switch (type) {
case STATUSTYPE_INFO: case STATUSTYPE_INFO:
...@@ -222,7 +223,7 @@ static int stripe_status(struct dm_target *ti, ...@@ -222,7 +223,7 @@ static int stripe_status(struct dm_target *ti,
offset += offset +=
snprintf(result + offset, maxlen - offset, snprintf(result + offset, maxlen - offset,
" %s " SECTOR_FORMAT, " %s " SECTOR_FORMAT,
bdevname(sc->stripe[i].dev->bdev), bdevname(sc->stripe[i].dev->bdev, b),
sc->stripe[i].physical_start); sc->stripe[i].physical_start);
} }
break; break;
......
...@@ -197,8 +197,13 @@ static int linear_make_request (request_queue_t *q, struct bio *bio) ...@@ -197,8 +197,13 @@ static int linear_make_request (request_queue_t *q, struct bio *bio)
if (unlikely(block >= (tmp_dev->size + tmp_dev->offset) if (unlikely(block >= (tmp_dev->size + tmp_dev->offset)
|| block < tmp_dev->offset)) { || block < tmp_dev->offset)) {
printk ("linear_make_request: Block %llu out of bounds on dev %s size %ld offset %ld\n", char b[BDEVNAME_SIZE];
(unsigned long long)block, bdevname(tmp_dev->rdev->bdev), tmp_dev->size, tmp_dev->offset);
printk ("linear_make_request: Block %llu out of bounds on "
"dev %s size %ld offset %ld\n",
(unsigned long long)block,
bdevname(tmp_dev->rdev->bdev, b),
tmp_dev->size, tmp_dev->offset);
bio_io_error(bio, bio->bi_size); bio_io_error(bio, bio->bi_size);
return 0; return 0;
} }
......
...@@ -166,6 +166,7 @@ static int blkmtd_readpage(mtd_raw_dev_data_t *rawdevice, struct page *page) ...@@ -166,6 +166,7 @@ static int blkmtd_readpage(mtd_raw_dev_data_t *rawdevice, struct page *page)
int sectornr, sectors, i; int sectornr, sectors, i;
struct kiobuf *iobuf; struct kiobuf *iobuf;
sector_t *blocks; sector_t *blocks;
char b[BDEVNAME_SIZE];
if(!rawdevice) { if(!rawdevice) {
printk("blkmtd: readpage: PANIC file->private_data == NULL\n"); printk("blkmtd: readpage: PANIC file->private_data == NULL\n");
...@@ -173,7 +174,7 @@ static int blkmtd_readpage(mtd_raw_dev_data_t *rawdevice, struct page *page) ...@@ -173,7 +174,7 @@ static int blkmtd_readpage(mtd_raw_dev_data_t *rawdevice, struct page *page)
} }
DEBUG(2, "blkmtd: readpage called, dev = `%s' page = %p index = %ld\n", DEBUG(2, "blkmtd: readpage called, dev = `%s' page = %p index = %ld\n",
bdevname(rawdevice->binding), page, page->index); bdevname(rawdevice->binding, b), page, page->index);
if(PageUptodate(page)) { if(PageUptodate(page)) {
DEBUG(2, "blkmtd: readpage page %ld is already upto date\n", page->index); DEBUG(2, "blkmtd: readpage page %ld is already upto date\n", page->index);
...@@ -523,6 +524,7 @@ static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -523,6 +524,7 @@ static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr)
size_t from; size_t from;
u_long len; u_long len;
int err = 0; int err = 0;
char b[BDEVNAME_SIZE];
/* check readonly */ /* check readonly */
if(rawdevice->readonly) { if(rawdevice->readonly) {
...@@ -537,7 +539,7 @@ static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -537,7 +539,7 @@ static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr)
/* check erase region has valid start and length */ /* check erase region has valid start and length */
DEBUG(2, "blkmtd: erase: dev = `%s' from = 0x%x len = 0x%lx\n", DEBUG(2, "blkmtd: erase: dev = `%s' from = 0x%x len = 0x%lx\n",
bdevname(rawdevice->binding), from, len); bdevname(rawdevice->binding, b), from, len);
while(numregions) { while(numregions) {
DEBUG(3, "blkmtd: checking erase region = 0x%08X size = 0x%X num = 0x%x\n", DEBUG(3, "blkmtd: checking erase region = 0x%08X size = 0x%X num = 0x%x\n",
einfo->offset, einfo->erasesize, einfo->numblocks); einfo->offset, einfo->erasesize, einfo->numblocks);
...@@ -635,11 +637,12 @@ static int blkmtd_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -635,11 +637,12 @@ static int blkmtd_read(struct mtd_info *mtd, loff_t from, size_t len,
int err = 0; int err = 0;
int offset; int offset;
int pagenr, pages; int pagenr, pages;
char b[BDEVNAME_SIZE];
*retlen = 0; *retlen = 0;
DEBUG(2, "blkmtd: read: dev = `%s' from = %ld len = %d buf = %p\n", DEBUG(2, "blkmtd: read: dev = `%s' from = %ld len = %d buf = %p\n",
bdevname(rawdevice->binding), (long int)from, len, buf); bdevname(rawdevice->binding, b), (long int)from, len, buf);
pagenr = from >> PAGE_SHIFT; pagenr = from >> PAGE_SHIFT;
offset = from - (pagenr << PAGE_SHIFT); offset = from - (pagenr << PAGE_SHIFT);
...@@ -706,10 +709,11 @@ static int blkmtd_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -706,10 +709,11 @@ static int blkmtd_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t len1 = 0, len2 = 0, len3 = 0; size_t len1 = 0, len2 = 0, len3 = 0;
struct page **pages; struct page **pages;
int pagecnt = 0; int pagecnt = 0;
char b[BDEVNAME_SIZE];
21 e3
*retlen = 0; *retlen = 0;
DEBUG(2, "blkmtd: write: dev = `%s' to = %ld len = %d buf = %p\n", DEBUG(2, "blkmtd: write: dev = `%s' to = %ld len = %d buf = %p\n",
bdevname(rawdevice->binding), (long int)to, len, buf); bdevname(rawdevice->binding, b), (long int)to, len, buf);
/* handle readonly and out of range numbers */ /* handle readonly and out of range numbers */
...@@ -1060,6 +1064,7 @@ static int __init init_blkmtd(void) ...@@ -1060,6 +1064,7 @@ static int __init init_blkmtd(void)
int err; int err;
int mode; int mode;
int regions; int regions;
char b[BDEVNAME_SIZE];
/* Check args */ /* Check args */
if(device == 0) { if(device == 0) {
...@@ -1128,7 +1133,7 @@ static int __init init_blkmtd(void) ...@@ -1128,7 +1133,7 @@ static int __init init_blkmtd(void)
if (err) if (err)
return 1; return 1;
DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev)); DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev, b));
blocksize = BLOCK_SIZE; blocksize = BLOCK_SIZE;
blocksize = bs ? bs : block_size(bdev); blocksize = bs ? bs : block_size(bdev);
......
...@@ -1710,7 +1710,11 @@ static int wd7000_host_reset(Scsi_Cmnd * SCpnt) ...@@ -1710,7 +1710,11 @@ static int wd7000_host_reset(Scsi_Cmnd * SCpnt)
static int wd7000_biosparam(struct scsi_device *sdev, static int wd7000_biosparam(struct scsi_device *sdev,
struct block_device *bdev, sector_t capacity, int *ip) struct block_device *bdev, sector_t capacity, int *ip)
{ {
dprintk("wd7000_biosparam: dev=%s, size=%d, ", bdevname(bdev), capacity); char b[BDEVNAME_SIZE];
dprintk("wd7000_biosparam: dev=%s, size=%d, ",
bdevname(bdev, b), capacity);
(void)b; /* unused var warning? */
/* /*
* try default translation * try default translation
......
...@@ -155,8 +155,10 @@ __clear_page_buffers(struct page *page) ...@@ -155,8 +155,10 @@ __clear_page_buffers(struct page *page)
static void buffer_io_error(struct buffer_head *bh) static void buffer_io_error(struct buffer_head *bh)
{ {
char b[BDEVNAME_SIZE];
printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n", printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n",
bdevname(bh->b_bdev), bdevname(bh->b_bdev, b),
(unsigned long long)bh->b_blocknr); (unsigned long long)bh->b_blocknr);
} }
......
...@@ -82,8 +82,9 @@ EXPORT_SYMBOL(ext2_xattr_set); ...@@ -82,8 +82,9 @@ EXPORT_SYMBOL(ext2_xattr_set);
printk("\n"); \ printk("\n"); \
} while (0) } while (0)
# define ea_bdebug(bh, f...) do { \ # define ea_bdebug(bh, f...) do { \
char b[BDEVNAME_SIZE]; \
printk(KERN_DEBUG "block %s:%ld: ", \ printk(KERN_DEBUG "block %s:%ld: ", \
bdevname(bh->b_bdev), bh->b_blocknr); \ bdevname(bh->b_bdev, b), bh->b_blocknr); \
printk(f); \ printk(f); \
printk("\n"); \ printk("\n"); \
} while (0) } while (0)
......
...@@ -60,9 +60,11 @@ int journal_no_write[2]; ...@@ -60,9 +60,11 @@ int journal_no_write[2];
static void make_rdonly(struct block_device *bdev, int *no_write) static void make_rdonly(struct block_device *bdev, int *no_write)
{ {
char b[BDEVNAME_SIZE];
if (bdev) { if (bdev) {
printk(KERN_WARNING "Turning device %s read-only\n", printk(KERN_WARNING "Turning device %s read-only\n",
bdevname(bdev)); bdevname(bdev, b));
*no_write = 0xdead0000 + bdev->bd_dev; *no_write = 0xdead0000 + bdev->bd_dev;
} }
} }
...@@ -317,6 +319,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev) ...@@ -317,6 +319,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev)
{ {
struct block_device *bdev; struct block_device *bdev;
int err = -ENODEV; int err = -ENODEV;
char b[BDEVNAME_SIZE];
bdev = bdget(dev); bdev = bdget(dev);
if (bdev == NULL) if (bdev == NULL)
...@@ -328,7 +331,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev) ...@@ -328,7 +331,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev)
fail: fail:
printk(KERN_ERR "EXT3: failed to open journal device %s: %d\n", printk(KERN_ERR "EXT3: failed to open journal device %s: %d\n",
__bdevname(dev), err); __bdevname(dev, b), err);
return NULL; return NULL;
} }
...@@ -812,8 +815,10 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, ...@@ -812,8 +815,10 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
printk(KERN_INFO "EXT3 FS " EXT3FS_VERSION ", " EXT3FS_DATE " on %s, ", printk(KERN_INFO "EXT3 FS " EXT3FS_VERSION ", " EXT3FS_DATE " on %s, ",
sb->s_id); sb->s_id);
if (EXT3_SB(sb)->s_journal->j_inode == NULL) { if (EXT3_SB(sb)->s_journal->j_inode == NULL) {
char b[BDEVNAME_SIZE];
printk("external journal on %s\n", printk("external journal on %s\n",
bdevname(EXT3_SB(sb)->s_journal->j_dev)); bdevname(EXT3_SB(sb)->s_journal->j_dev, b));
} else { } else {
printk("internal journal\n"); printk("internal journal\n");
} }
......
...@@ -78,8 +78,9 @@ ...@@ -78,8 +78,9 @@
printk("\n"); \ printk("\n"); \
} while (0) } while (0)
# define ea_bdebug(bh, f...) do { \ # define ea_bdebug(bh, f...) do { \
char b[BDEVNAME_SIZE]; \
printk(KERN_DEBUG "block %s:%ld: ", \ printk(KERN_DEBUG "block %s:%ld: ", \
bdevname(bh->b_bdev), bh->b_blocknr); \ bdevname(bh->b_bdev, b), bh->b_blocknr); \
printk(f); \ printk(f); \
printk("\n"); \ printk("\n"); \
} while (0) } while (0)
......
...@@ -183,10 +183,11 @@ inline void presto_debug_fail_blkdev(struct presto_file_set *fset, ...@@ -183,10 +183,11 @@ inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
int minor = presto_f2m(fset); int minor = presto_f2m(fset);
int errorval = izo_channels[minor].uc_errorval; int errorval = izo_channels[minor].uc_errorval;
struct block_device *bdev = fset->fset_dentry->d_inode->i_sb->s_bdev; struct block_device *bdev = fset->fset_dentry->d_inode->i_sb->s_bdev;
char b[BDEVNAME_SIZE];
if (errorval && errorval == (long)value && !bdev_read_only(bdev)) { if (errorval && errorval == (long)value && !bdev_read_only(bdev)) {
CDEBUG(D_SUPER, "setting device %s read only\n", CDEBUG(D_SUPER, "setting device %s read only\n",
bdevname(bdev)); bdevname(bdev, b));
BLKDEV_FAIL(bdev, 1); BLKDEV_FAIL(bdev, 1);
izo_channels[minor].uc_errorval = -bdev->bd_dev; izo_channels[minor].uc_errorval = -bdev->bd_dev;
} }
......
...@@ -637,11 +637,13 @@ int journal_bmap(journal_t *journal, unsigned long blocknr, ...@@ -637,11 +637,13 @@ int journal_bmap(journal_t *journal, unsigned long blocknr,
if (ret) if (ret)
*retp = ret; *retp = ret;
else { else {
char b[BDEVNAME_SIZE];
printk(KERN_ALERT "%s: journal block not found " printk(KERN_ALERT "%s: journal block not found "
"at offset %lu on %s\n", "at offset %lu on %s\n",
__FUNCTION__, __FUNCTION__,
blocknr, blocknr,
bdevname(journal->j_dev)); bdevname(journal->j_dev, b));
err = -EIO; err = -EIO;
__journal_abort_soft(journal, err); __journal_abort_soft(journal, err);
} }
...@@ -1398,7 +1400,7 @@ int journal_wipe (journal_t *journal, int write) ...@@ -1398,7 +1400,7 @@ int journal_wipe (journal_t *journal, int write)
* device this journal is present. * device this journal is present.
*/ */
const char * journal_dev_name(journal_t *journal) const char *journal_dev_name(journal_t *journal, char *buffer)
{ {
struct block_device *bdev; struct block_device *bdev;
...@@ -1407,7 +1409,7 @@ const char * journal_dev_name(journal_t *journal) ...@@ -1407,7 +1409,7 @@ const char * journal_dev_name(journal_t *journal)
else else
bdev = journal->j_dev; bdev = journal->j_dev;
return bdevname(bdev); return bdevname(bdev, buffer);
} }
/* /*
...@@ -1424,12 +1426,13 @@ const char * journal_dev_name(journal_t *journal) ...@@ -1424,12 +1426,13 @@ const char * journal_dev_name(journal_t *journal)
void __journal_abort_hard (journal_t *journal) void __journal_abort_hard (journal_t *journal)
{ {
transaction_t *transaction; transaction_t *transaction;
char b[BDEVNAME_SIZE];
if (journal->j_flags & JFS_ABORT) if (journal->j_flags & JFS_ABORT)
return; return;
printk (KERN_ERR "Aborting journal on device %s.\n", printk (KERN_ERR "Aborting journal on device %s.\n",
journal_dev_name(journal)); journal_dev_name(journal, b));
journal->j_flags |= JFS_ABORT; journal->j_flags |= JFS_ABORT;
transaction = journal->j_running_transaction; transaction = journal->j_running_transaction;
......
...@@ -32,6 +32,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -32,6 +32,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
struct PartitionBlock *pb; struct PartitionBlock *pb;
int start_sect, nr_sects, blk, part, res = 0; int start_sect, nr_sects, blk, part, res = 0;
int slot = 1; int slot = 1;
char b[BDEVNAME_SIZE];
for (blk = 0; ; blk++, put_dev_sector(sect)) { for (blk = 0; ; blk++, put_dev_sector(sect)) {
if (blk == RDB_ALLOCATION_LIMIT) if (blk == RDB_ALLOCATION_LIMIT)
...@@ -40,7 +41,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -40,7 +41,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
if (!data) { if (!data) {
if (warn_no_part) if (warn_no_part)
printk("Dev %s: unable to read RDB block %d\n", printk("Dev %s: unable to read RDB block %d\n",
bdevname(bdev), blk); bdevname(bdev, b), blk);
goto rdb_done; goto rdb_done;
} }
if (*(u32 *)data != cpu_to_be32(IDNAME_RIGIDDISK)) if (*(u32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
...@@ -61,7 +62,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -61,7 +62,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
} }
printk("Dev %s: RDB in block %d has bad checksum\n", printk("Dev %s: RDB in block %d has bad checksum\n",
bdevname(bdev),blk); bdevname(bdev, b), blk);
} }
printk(" RDSK"); printk(" RDSK");
...@@ -72,7 +73,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -72,7 +73,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
if (!data) { if (!data) {
if (warn_no_part) if (warn_no_part)
printk("Dev %s: unable to read partition block %d\n", printk("Dev %s: unable to read partition block %d\n",
bdevname(bdev),blk); bdevname(bdev, b), blk);
goto rdb_done; goto rdb_done;
} }
pb = (struct PartitionBlock *)data; pb = (struct PartitionBlock *)data;
......
...@@ -35,6 +35,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -35,6 +35,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
Sector sect; Sector sect;
struct sgi_disklabel *label; struct sgi_disklabel *label;
struct sgi_partition *p; struct sgi_partition *p;
char b[BDEVNAME_SIZE];
label = (struct sgi_disklabel *) read_dev_sector(bdev, 0, &sect); label = (struct sgi_disklabel *) read_dev_sector(bdev, 0, &sect);
if (!label) if (!label)
...@@ -43,7 +44,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -43,7 +44,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
magic = label->magic_mushroom; magic = label->magic_mushroom;
if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) { if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
/*printk("Dev %s SGI disklabel: bad magic %08x\n", /*printk("Dev %s SGI disklabel: bad magic %08x\n",
bdevname(bdev), magic);*/ bdevname(bdev, b), magic);*/
put_dev_sector(sect); put_dev_sector(sect);
return 0; return 0;
} }
...@@ -54,7 +55,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -54,7 +55,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
} }
if(csum) { if(csum) {
printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n", printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
bdevname(bdev)); bdevname(bdev, b));
put_dev_sector(sect); put_dev_sector(sect);
return 0; return 0;
} }
......
...@@ -45,6 +45,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -45,6 +45,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
} * label; } * label;
struct sun_partition *p; struct sun_partition *p;
unsigned long spc; unsigned long spc;
char b[BDEVNAME_SIZE];
label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect); label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect);
if (!label) if (!label)
...@@ -53,7 +54,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -53,7 +54,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
p = label->partitions; p = label->partitions;
if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) { if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) {
/* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n", /* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n",
bdevname(bdev), be16_to_cpu(label->magic)); */ bdevname(bdev, b), be16_to_cpu(label->magic)); */
put_dev_sector(sect); put_dev_sector(sect);
return 0; return 0;
} }
...@@ -63,7 +64,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev) ...@@ -63,7 +64,7 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
csum ^= *ush--; csum ^= *ush--;
if (csum) { if (csum) {
printk("Dev %s Sun disklabel: Csum bad, label corrupted\n", printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
bdevname(bdev)); bdevname(bdev, b));
put_dev_sector(sect); put_dev_sector(sect);
return 0; return 0;
} }
......
...@@ -867,9 +867,11 @@ static int flush_older_journal_lists(struct super_block *p_s_sb, struct reiserfs ...@@ -867,9 +867,11 @@ static int flush_older_journal_lists(struct super_block *p_s_sb, struct reiserfs
} }
static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate) { static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate) {
char b[BDEVNAME_SIZE];
if (buffer_journaled(bh)) { if (buffer_journaled(bh)) {
reiserfs_warning("clm-2084: pinned buffer %lu:%s sent to disk\n", reiserfs_warning("clm-2084: pinned buffer %lu:%s sent to disk\n",
bh->b_blocknr, bdevname(bh->b_bdev)) ; bh->b_blocknr, bdevname(bh->b_bdev, b)) ;
} }
if (uptodate) if (uptodate)
set_buffer_uptodate(bh) ; set_buffer_uptodate(bh) ;
...@@ -1652,10 +1654,12 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1652,10 +1654,12 @@ static int journal_read(struct super_block *p_s_sb) {
int replay_count = 0 ; int replay_count = 0 ;
int continue_replay = 1 ; int continue_replay = 1 ;
int ret ; int ret ;
char b[BDEVNAME_SIZE];
cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ; cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
printk("reiserfs: checking transaction log (%s) for (%s)\n", printk("reiserfs: checking transaction log (%s) for (%s)\n",
bdevname(SB_JOURNAL(p_s_sb)->j_dev_bd), reiserfs_bdevname(p_s_sb)); bdevname(SB_JOURNAL(p_s_sb)->j_dev_bd, b),
reiserfs_bdevname(p_s_sb));
start = get_seconds() ; start = get_seconds() ;
/* step 1, read in the journal header block. Check the transaction it says /* step 1, read in the journal header block. Check the transaction it says
...@@ -1893,6 +1897,7 @@ static int journal_init_dev( struct super_block *super, ...@@ -1893,6 +1897,7 @@ static int journal_init_dev( struct super_block *super,
int result; int result;
dev_t jdev; dev_t jdev;
int blkdev_mode = FMODE_READ | FMODE_WRITE; int blkdev_mode = FMODE_READ | FMODE_WRITE;
char b[BDEVNAME_SIZE];
result = 0; result = 0;
...@@ -1915,7 +1920,7 @@ static int journal_init_dev( struct super_block *super, ...@@ -1915,7 +1920,7 @@ static int journal_init_dev( struct super_block *super,
result = -ENOMEM; result = -ENOMEM;
if( result != 0 ) if( result != 0 )
printk( "sh-458: journal_init_dev: cannot init journal device\n '%s': %i", printk( "sh-458: journal_init_dev: cannot init journal device\n '%s': %i",
bdevname(journal->j_dev_bd), result ); bdevname(journal->j_dev_bd, b), result );
else if (jdev != super->s_dev) { else if (jdev != super->s_dev) {
set_blocksize(journal->j_dev_bd, super->s_blocksize); set_blocksize(journal->j_dev_bd, super->s_blocksize);
...@@ -1948,7 +1953,8 @@ static int journal_init_dev( struct super_block *super, ...@@ -1948,7 +1953,8 @@ static int journal_init_dev( struct super_block *super,
if( result != 0 ) { if( result != 0 ) {
release_journal_dev( super, journal ); release_journal_dev( super, journal );
} }
printk( "journal_init_dev: journal device: %s\n", bdevname(journal->j_dev_bd)); printk( "journal_init_dev: journal device: %s\n",
bdevname(journal->j_dev_bd, b));
return result; return result;
} }
...@@ -1961,6 +1967,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo ...@@ -1961,6 +1967,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
struct reiserfs_super_block * rs; struct reiserfs_super_block * rs;
struct reiserfs_journal_header *jh; struct reiserfs_journal_header *jh;
struct reiserfs_journal *journal; struct reiserfs_journal *journal;
char b[BDEVNAME_SIZE];
if (sizeof(struct reiserfs_journal_commit) != 4096 || if (sizeof(struct reiserfs_journal_commit) != 4096 ||
sizeof(struct reiserfs_journal_desc) != 4096) { sizeof(struct reiserfs_journal_desc) != 4096) {
...@@ -2007,7 +2014,8 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo ...@@ -2007,7 +2014,8 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
if (is_reiserfs_jr(rs) && (jh->jh_journal.jp_journal_magic != sb_jp_journal_magic(rs))) { if (is_reiserfs_jr(rs) && (jh->jh_journal.jp_journal_magic != sb_jp_journal_magic(rs))) {
printk("sh-460: journal header magic %x (device %s) does not match " printk("sh-460: journal header magic %x (device %s) does not match "
"to magic found in super block %x (device %s)\n", "to magic found in super block %x (device %s)\n",
jh->jh_journal.jp_journal_magic, bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd ), jh->jh_journal.jp_journal_magic,
bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd, b),
sb_jp_journal_magic(rs), reiserfs_bdevname (p_s_sb)); sb_jp_journal_magic(rs), reiserfs_bdevname (p_s_sb));
brelse (bhjh); brelse (bhjh);
goto free_and_return; goto free_and_return;
...@@ -2058,7 +2066,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo ...@@ -2058,7 +2066,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
printk ("Reiserfs journal params: device %s, size %u, " printk ("Reiserfs journal params: device %s, size %u, "
"journal first block %u, max trans len %u, max batch %u, " "journal first block %u, max trans len %u, max batch %u, "
"max commit age %u, max trans age %u\n", "max commit age %u, max trans age %u\n",
bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd ), bdevname( SB_JOURNAL(p_s_sb)->j_dev_bd, b),
SB_ONDISK_JOURNAL_SIZE(p_s_sb), SB_ONDISK_JOURNAL_SIZE(p_s_sb),
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
SB_JOURNAL_TRANS_MAX(p_s_sb), SB_JOURNAL_TRANS_MAX(p_s_sb),
......
...@@ -139,8 +139,11 @@ static void sprintf_block_head (char * buf, struct buffer_head * bh) ...@@ -139,8 +139,11 @@ static void sprintf_block_head (char * buf, struct buffer_head * bh)
static void sprintf_buffer_head (char * buf, struct buffer_head * bh) static void sprintf_buffer_head (char * buf, struct buffer_head * bh)
{ {
char b[BDEVNAME_SIZE];
sprintf (buf, "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", sprintf (buf, "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
bdevname (bh->b_bdev), bh->b_size, (unsigned long long)bh->b_blocknr, bdevname (bh->b_bdev, b), bh->b_size,
(unsigned long long)bh->b_blocknr,
atomic_read (&(bh->b_count)), atomic_read (&(bh->b_count)),
bh->b_state, bh->b_page, bh->b_state, bh->b_page,
buffer_uptodate (bh) ? "UPTODATE" : "!UPTODATE", buffer_uptodate (bh) ? "UPTODATE" : "!UPTODATE",
...@@ -497,7 +500,7 @@ static int print_super_block (struct buffer_head * bh) ...@@ -497,7 +500,7 @@ static int print_super_block (struct buffer_head * bh)
struct reiserfs_super_block * rs = (struct reiserfs_super_block *)(bh->b_data); struct reiserfs_super_block * rs = (struct reiserfs_super_block *)(bh->b_data);
int skipped, data_blocks; int skipped, data_blocks;
char *version; char *version;
char b[BDEVNAME_SIZE];
if (is_reiserfs_3_5(rs)) { if (is_reiserfs_3_5(rs)) {
version = "3.5"; version = "3.5";
...@@ -510,7 +513,7 @@ static int print_super_block (struct buffer_head * bh) ...@@ -510,7 +513,7 @@ static int print_super_block (struct buffer_head * bh)
return 1; return 1;
} }
printk ("%s\'s super block is in block %llu\n", bdevname (bh->b_bdev), printk ("%s\'s super block is in block %llu\n", bdevname (bh->b_bdev, b),
(unsigned long long)bh->b_blocknr); (unsigned long long)bh->b_blocknr);
printk ("Reiserfs version %s\n", version ); printk ("Reiserfs version %s\n", version );
printk ("Block count %u\n", sb_block_count(rs)); printk ("Block count %u\n", sb_block_count(rs));
......
...@@ -460,6 +460,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, ...@@ -460,6 +460,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset,
struct reiserfs_super_block *rs; struct reiserfs_super_block *rs;
struct journal_params *jp; struct journal_params *jp;
int len = 0; int len = 0;
char b[BDEVNAME_SIZE];
sb = procinfo_prologue((int)data); sb = procinfo_prologue((int)data);
if( sb == NULL ) if( sb == NULL )
...@@ -516,7 +517,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, ...@@ -516,7 +517,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset,
"prepare_retry: \t%12lu\n", "prepare_retry: \t%12lu\n",
DJP( jp_journal_1st_block ), DJP( jp_journal_1st_block ),
bdevname(SB_JOURNAL(sb)->j_dev_bd), bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
DJP( jp_journal_dev ), DJP( jp_journal_dev ),
DJP( jp_journal_size ), DJP( jp_journal_size ),
DJP( jp_journal_trans_max ), DJP( jp_journal_trans_max ),
......
...@@ -526,8 +526,10 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -526,8 +526,10 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
} }
goto out; goto out;
} else { } else {
char b[BDEVNAME_SIZE];
s->s_flags = flags; s->s_flags = flags;
strncpy(s->s_id, bdevname(bdev), sizeof(s->s_id)); strncpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
s->s_old_blocksize = block_size(bdev); s->s_old_blocksize = block_size(bdev);
sb_set_blocksize(s, s->s_old_blocksize); sb_set_blocksize(s, s->s_old_blocksize);
error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
......
...@@ -323,6 +323,7 @@ xfs_showargs( ...@@ -323,6 +323,7 @@ xfs_showargs(
}; };
struct proc_xfs_info *xfs_infop; struct proc_xfs_info *xfs_infop;
struct xfs_mount *mp = XFS_BHVTOM(vfsp->vfs_fbhv); struct xfs_mount *mp = XFS_BHVTOM(vfsp->vfs_fbhv);
char b[BDEVNAME_SIZE];
for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) { for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
if (mp->m_flags & xfs_infop->flag) if (mp->m_flags & xfs_infop->flag)
...@@ -352,12 +353,12 @@ xfs_showargs( ...@@ -352,12 +353,12 @@ xfs_showargs(
if (mp->m_ddev_targp->pbr_dev != mp->m_logdev_targp->pbr_dev) if (mp->m_ddev_targp->pbr_dev != mp->m_logdev_targp->pbr_dev)
seq_printf(m, "," MNTOPT_LOGDEV "=%s", seq_printf(m, "," MNTOPT_LOGDEV "=%s",
bdevname(mp->m_logdev_targp->pbr_bdev)); bdevname(mp->m_logdev_targp->pbr_bdev, b));
if (mp->m_rtdev_targp && if (mp->m_rtdev_targp &&
mp->m_ddev_targp->pbr_dev != mp->m_rtdev_targp->pbr_dev) mp->m_ddev_targp->pbr_dev != mp->m_rtdev_targp->pbr_dev)
seq_printf(m, "," MNTOPT_RTDEV "=%s", seq_printf(m, "," MNTOPT_RTDEV "=%s",
bdevname(mp->m_rtdev_targp->pbr_bdev)); bdevname(mp->m_rtdev_targp->pbr_bdev, b));
if (mp->m_dalign > 0) if (mp->m_dalign > 0)
seq_printf(m, "," MNTOPT_SUNIT "=%d", seq_printf(m, "," MNTOPT_SUNIT "=%d",
......
...@@ -1069,10 +1069,11 @@ extern int unregister_chrdev(unsigned int, const char *); ...@@ -1069,10 +1069,11 @@ extern int unregister_chrdev(unsigned int, const char *);
extern int chrdev_open(struct inode *, struct file *); extern int chrdev_open(struct inode *, struct file *);
/* fs/block_dev.c */ /* fs/block_dev.c */
extern const char *__bdevname(dev_t); #define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
extern inline const char *bdevname(struct block_device *bdev) extern const char *__bdevname(dev_t, char *buffer);
extern inline const char *bdevname(struct block_device *bdev, char *buffer)
{ {
return __bdevname(bdev->bd_dev); return __bdevname(bdev->bd_dev, buffer);
} }
extern struct block_device *lookup_bdev(const char *); extern struct block_device *lookup_bdev(const char *);
extern struct block_device *open_bdev_excl(const char *, int, int, void *); extern struct block_device *open_bdev_excl(const char *, int, int, void *);
......
...@@ -245,6 +245,7 @@ void __init mount_block_root(char *name, int flags) ...@@ -245,6 +245,7 @@ void __init mount_block_root(char *name, int flags)
{ {
char *fs_names = __getname(); char *fs_names = __getname();
char *p; char *p;
char b[BDEVNAME_SIZE];
get_fs_names(fs_names); get_fs_names(fs_names);
retry: retry:
...@@ -263,12 +264,13 @@ void __init mount_block_root(char *name, int flags) ...@@ -263,12 +264,13 @@ void __init mount_block_root(char *name, int flags)
* Allow the user to distinguish between failed open * Allow the user to distinguish between failed open
* and bad superblock on root device. * and bad superblock on root device.
*/ */
__bdevname(ROOT_DEV, b);
printk("VFS: Cannot open root device \"%s\" or %s\n", printk("VFS: Cannot open root device \"%s\" or %s\n",
root_device_name, __bdevname(ROOT_DEV)); root_device_name, b);
printk("Please append a correct \"root=\" boot option\n"); printk("Please append a correct \"root=\" boot option\n");
panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV)); panic("VFS: Unable to mount root fs on %s", b);
} }
panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV)); panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
out: out:
putname(fs_names); putname(fs_names);
} }
......
...@@ -1152,13 +1152,15 @@ static int read_suspend_image(const char * specialfile, int noresume) ...@@ -1152,13 +1152,15 @@ static int read_suspend_image(const char * specialfile, int noresume)
union diskpage *cur; union diskpage *cur;
unsigned long scratch_page = 0; unsigned long scratch_page = 0;
int error; int error;
char b[BDEVNAME_SIZE];
resume_device = name_to_dev_t(specialfile); resume_device = name_to_dev_t(specialfile);
scratch_page = get_zeroed_page(GFP_ATOMIC); scratch_page = get_zeroed_page(GFP_ATOMIC);
cur = (void *) scratch_page; cur = (void *) scratch_page;
if (cur) { if (cur) {
struct block_device *bdev; struct block_device *bdev;
printk("Resuming from device %s\n", __bdevname(resume_device)); printk("Resuming from device %s\n",
__bdevname(resume_device, b));
bdev = bdget(resume_device); bdev = bdget(resume_device);
if (!bdev) { if (!bdev) {
printk("No such block device ?!\n"); printk("No such block device ?!\n");
......
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