[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080508063030.3818.76328.stgit@bluto.andrew>
Date: Thu, 08 May 2008 00:30:30 -0600
From: Andrew Patterson <andrew.patterson@...com>
To: linux-scsi@...r.kernel.org
Cc: andrew.patterson@...com, linux-kernel@...r.kernel.org,
viro@...iv.linux.org.uk, axboe@...nel.dk,
andmike@...ux.vnet.ibm.com
Subject: [PATCH 2/5] Adjust block device size after an online resize of a disk.
Adjust block device size after an online resize of a disk.
The revalidate_disk routine now checks if a disk has been resized by
comparing the gendisk capacity to the bdev inode size. If they are
different (usually because the disk has been resized underneath the kernel)
the bdev inode size is adjusted to match the capacity.
Signed-off-by: Andrew Patterson <andrew.patterson@...com>
---
fs/block_dev.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 72aaf59..87014e6 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -879,11 +879,32 @@ EXPORT_SYMBOL(open_by_devnum);
*/
int revalidate_disk(struct gendisk *disk)
{
+ struct block_device *bdev;
+ loff_t disk_size, bdev_size;
int ret = 0;
if (disk->fops->revalidate_disk)
ret = disk->fops->revalidate_disk(disk);
+ bdev = bdget_disk(disk, 0);
+ if (!bdev)
+ return ret;
+
+ disk_size = (loff_t)get_capacity(disk) << 9;
+ mutex_lock(&bdev->bd_mutex);
+ bdev_size = i_size_read(bdev->bd_inode);
+ if (disk_size != bdev_size) {
+ char name[BDEVNAME_SIZE];
+
+ disk_name(disk, 0, name);
+ printk(KERN_INFO
+ "%s: detected capacity change from %lld to %lld\n",
+ name, bdev_size, disk_size);
+ i_size_write(bdev->bd_inode, disk_size);
+ }
+
+ mutex_unlock(&bdev->bd_mutex);
+ bdput(bdev);
return ret;
}
EXPORT_SYMBOL(revalidate_disk);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists