diff options
author | Paul Clements <paul.clements@steeleye.com> | 2007-10-17 02:27:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:55 -0400 |
commit | 4b86a872561ad052bdc6f092a06807822d26beb1 (patch) | |
tree | 4a7af69e0a6d8b74f17c0034b173bc45896d8f08 | |
parent | dff4982f5cd4e30e2a140a3bca95d8814115bf5b (diff) |
NBD: set uninitialized devices to size 0
This fixes errors with utilities (such as LVM's vgscan) that try to scan all
devices. Previously this would generate read errors when uninitialized nbd
devices were scanned:
# vgscan
Reading all physical volumes. This may take a while...
/dev/nbd0: read failed after 0 of 1024 at 0: Input/output error
/dev/nbd0: read failed after 0 of 1024 at 509804544: Input/output error
/dev/nbd0: read failed after 0 of 2048 at 0: Input/output error
/dev/nbd1: read failed after 0 of 1024 at 509804544: Input/output error
/dev/nbd1: read failed after 0 of 2048 at 0: Input/output error
From now on, uninitialized nbd devices will have size zero, which
prevents these errors.
Signed-off-by: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/block/nbd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index dc88bcf320e8..89bdafd88dbd 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -578,6 +578,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
578 | printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name); | 578 | printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name); |
579 | if (file) | 579 | if (file) |
580 | fput(file); | 580 | fput(file); |
581 | lo->bytesize = 0; | ||
582 | inode->i_bdev->bd_inode->i_size = 0; | ||
583 | set_capacity(lo->disk, 0); | ||
581 | return lo->harderror; | 584 | return lo->harderror; |
582 | case NBD_CLEAR_QUE: | 585 | case NBD_CLEAR_QUE: |
583 | /* | 586 | /* |
@@ -655,14 +658,14 @@ static int __init nbd_init(void) | |||
655 | mutex_init(&nbd_dev[i].tx_lock); | 658 | mutex_init(&nbd_dev[i].tx_lock); |
656 | init_waitqueue_head(&nbd_dev[i].active_wq); | 659 | init_waitqueue_head(&nbd_dev[i].active_wq); |
657 | nbd_dev[i].blksize = 1024; | 660 | nbd_dev[i].blksize = 1024; |
658 | nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ | 661 | nbd_dev[i].bytesize = 0; |
659 | disk->major = NBD_MAJOR; | 662 | disk->major = NBD_MAJOR; |
660 | disk->first_minor = i; | 663 | disk->first_minor = i; |
661 | disk->fops = &nbd_fops; | 664 | disk->fops = &nbd_fops; |
662 | disk->private_data = &nbd_dev[i]; | 665 | disk->private_data = &nbd_dev[i]; |
663 | disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; | 666 | disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; |
664 | sprintf(disk->disk_name, "nbd%d", i); | 667 | sprintf(disk->disk_name, "nbd%d", i); |
665 | set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */ | 668 | set_capacity(disk, 0); |
666 | add_disk(disk); | 669 | add_disk(disk); |
667 | } | 670 | } |
668 | 671 | ||