From: Andrew Patterson <andrew.patterson@hp.com>
To: linux-scsi@vger.kernel.org
Cc: andrew.patterson@hp.com, linux-kernel@vger.kernel.org,
viro@zeniv.linux.org.uk, axboe@kernel.dk,
andmike@linux.vnet.ibm.com
Subject: [PATCH 2/5] Adjust block device size after an online resize of a disk.
Date: Thu, 08 May 2008 00:30:30 -0600 [thread overview]
Message-ID: <20080508063030.3818.76328.stgit@bluto.andrew> (raw)
In-Reply-To: <20080508062930.3818.31401.stgit@bluto.andrew>
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);
next prev parent reply other threads:[~2008-05-08 6:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 6:29 [PATCH 0/5] detect online disk resize Andrew Patterson
2008-05-08 6:30 ` [PATCH 1/5] Wrapper for lower-level revalidate_disk routines Andrew Patterson
2008-05-08 6:30 ` Andrew Patterson [this message]
2008-05-08 6:31 ` [PATCH 3/5] SCSI sd driver calls revalidate_disk wrapper Andrew Patterson
2008-05-08 6:31 ` [PATCH 4/5] Added flush_disk to factor out common buffer cache flushing code Andrew Patterson
2008-05-08 6:32 ` [PATCH 5/5] Call flush_disk() after detecting an online resize Andrew Patterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080508063030.3818.76328.stgit@bluto.andrew \
--to=andrew.patterson@hp.com \
--cc=andmike@linux.vnet.ibm.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox