* [PATCH 0/2] bd_invalidated shoud be cleared in revalidate_disk
@ 2012-10-19 3:16 MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 1/2] block: fs: bd_invalidated should " MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 2/2] block: fs: move 'bdev->bd_invalidated = 0' into check_disk_size_change() instead of putting the code every time after check_disk_size_change() MITSUNARI Shigeo
0 siblings, 2 replies; 3+ messages in thread
From: MITSUNARI Shigeo @ 2012-10-19 3:16 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Alexander Viro, linux-kernel, Jens Axboe, MITSUNARI Shigeo
rescan_partitions() and invalidate_partitions() in block/partition-generic.c
set bdev->bd_invalidated = 0 after calling check_disk_size_change().
But revalidate_disk() in fs/block_dev.c does not clear it.
If bdev->bd_invalidated = 1 then rescan_partitions() is called when
__blkdev_get() is called.
So if revalidate_disk() is once called, all buffer cache pages will be
cleared whenever the device is opened.
This bug causes the following problem.
mdadm monitor will clear file cache every 1000 seconds
after mdadm resize is executed once.
mdadm monitor only openes the device with O_RDONLY.
We verified the problem occurred at kernel 3.6.2 and mdadm v3.2.5 on
ubuntu 12.04LTS x86_64 and the patch worked well.
---
The following steps will reproduce the problem.
1. prepair a block device(ex. /dev/sdb).
2. create two partitions.
sudo parted /dev/sdb
mklabel gpt
mkpart primary 0% 50%
mkpart primary 50% 100%
3. create a md device.
sudo mdadm -C /dev/md/hoge -l 1 -n 2 -e 1.2 --assume-clean --auto=md \
--symlink=no /dev/sdb1 /dev/sdb2
4. create file system and mount it
sudo mkfs.ext3 /dev/md/hoge
sudo mkdir /mnt/test
sudo mount /dev/md/hoge /mnt/test
5. try to resize the device
sudo mdadm -G /dev/md/hoge --size=max
6. create a file to fill file cache.
sudo dd if=/dev/urandom of=/mnt/test/data bs=1M count=10
and verity the current status of file by free command.
7. mdadm monitor will open the md device every 1000 seconds
and you will find all file cache on the device are cleared.
The timing can be reduced by the following steps.
a) kill mdadm and restart it with --delay option
/sbin/mdadm --monitor --delay=30 --pid-file /var/run/mdadm/monitor.pid \
--daemonise --scan --syslog
or open the md device directly.
sudo dd if=/dev/md/hoge of=/dev/null bs=4096 count=1
MITSUNARI Shigeo (2):
block: fs: bd_invalidated should be cleared in revalidate_disk
block: fs: move 'bdev->bd_invalidated = 0' into
check_disk_size_change() instead of putting the code every time
after check_disk_size_change().
block/partition-generic.c | 2 --
fs/block_dev.c | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] block: fs: bd_invalidated should be cleared in revalidate_disk
2012-10-19 3:16 [PATCH 0/2] bd_invalidated shoud be cleared in revalidate_disk MITSUNARI Shigeo
@ 2012-10-19 3:16 ` MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 2/2] block: fs: move 'bdev->bd_invalidated = 0' into check_disk_size_change() instead of putting the code every time after check_disk_size_change() MITSUNARI Shigeo
1 sibling, 0 replies; 3+ messages in thread
From: MITSUNARI Shigeo @ 2012-10-19 3:16 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Alexander Viro, linux-kernel, Jens Axboe, MITSUNARI Shigeo
rescan_partitions() and invalidate_partitions() in block/partition-generic.c
set bdev->bd_invalidated = 0 after calling check_disk_size_change().
But revalidate_disk() in fs/block_dev.c does not clear it.
If bdev->bd_invalidated = 1 then rescan_partitions() is called when
__blkdev_get() is called.
So if revalidate_disk() is once called, all buffer cache pages will be
cleared whenever the device is opened.
This patch fixes the bug.
I add bdev->bd_invalidated = 0; after calling check_disk_size_change().
Signed-off-by: MITSUNARI Shigeo <herumi@nifty.com>
---
fs/block_dev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 38e721b..2577cf4 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1047,6 +1047,7 @@ int revalidate_disk(struct gendisk *disk)
mutex_lock(&bdev->bd_mutex);
check_disk_size_change(disk, bdev);
+ bdev->bd_invalidated = 0;
mutex_unlock(&bdev->bd_mutex);
bdput(bdev);
return ret;
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] block: fs: move 'bdev->bd_invalidated = 0' into check_disk_size_change() instead of putting the code every time after check_disk_size_change().
2012-10-19 3:16 [PATCH 0/2] bd_invalidated shoud be cleared in revalidate_disk MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 1/2] block: fs: bd_invalidated should " MITSUNARI Shigeo
@ 2012-10-19 3:16 ` MITSUNARI Shigeo
1 sibling, 0 replies; 3+ messages in thread
From: MITSUNARI Shigeo @ 2012-10-19 3:16 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Alexander Viro, linux-kernel, Jens Axboe, MITSUNARI Shigeo
The following code appeares in invalidate_partitions(), rescan_partitions() and revalidate_disk().
>check_disk_size_change(disk, bdev);
>bdev->bd_invalidted = 0;
check_disk_size_change() is called from only those three functions.
so how about setting bdev->bd_invalidated = 0 in check_disk_size_change()?
Signed-off-by: MITSUNARI Shigeo <herumi@nifty.com>
---
block/partition-generic.c | 2 --
fs/block_dev.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/block/partition-generic.c b/block/partition-generic.c
index f1d1451..6a65169 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -429,7 +429,6 @@ rescan:
if (disk->fops->revalidate_disk)
disk->fops->revalidate_disk(disk);
check_disk_size_change(disk, bdev);
- bdev->bd_invalidated = 0;
if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
return 0;
if (IS_ERR(state)) {
@@ -542,7 +541,6 @@ int invalidate_partitions(struct gendisk *disk, struct block_device *bdev)
set_capacity(disk, 0);
check_disk_size_change(disk, bdev);
- bdev->bd_invalidated = 0;
/* tell userspace that the media / partition table may have changed */
kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 2577cf4..ef0189b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1022,6 +1022,7 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev)
i_size_write(bdev->bd_inode, disk_size);
flush_disk(bdev, false);
}
+ bdev->bd_invalidated = 0;
}
EXPORT_SYMBOL(check_disk_size_change);
@@ -1047,7 +1048,6 @@ int revalidate_disk(struct gendisk *disk)
mutex_lock(&bdev->bd_mutex);
check_disk_size_change(disk, bdev);
- bdev->bd_invalidated = 0;
mutex_unlock(&bdev->bd_mutex);
bdput(bdev);
return ret;
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-19 3:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 3:16 [PATCH 0/2] bd_invalidated shoud be cleared in revalidate_disk MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 1/2] block: fs: bd_invalidated should " MITSUNARI Shigeo
2012-10-19 3:16 ` [PATCH 2/2] block: fs: move 'bdev->bd_invalidated = 0' into check_disk_size_change() instead of putting the code every time after check_disk_size_change() MITSUNARI Shigeo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®