lkml.org 
[lkml]   [2008]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/5] Adjust block device size after an online resize of a disk.
    Date
    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@hp.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);


    \
     
     \ /
      Last update: 2008-05-08 08:55    [W:0.036 / U:29.840 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site