* [PATCH 1/2] block: Set inode of block_device size to zero when delete gendisk.
@ 2013-09-11 11:00 ` majianpeng
0 siblings, 0 replies; 2+ messages in thread
From: majianpeng @ 2013-09-11 11:00 UTC (permalink / raw)
To: axboe, viro; +Cc: linux-fsdevel, LKML
When remove gendisk, set the size of inode of block_device to zero.
This is mainly let the vfs know disk removed.
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
block/genhd.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/block/genhd.c b/block/genhd.c
index dadf42b..c3a54b4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -634,6 +634,7 @@ void del_gendisk(struct gendisk *disk)
{
struct disk_part_iter piter;
struct hd_struct *part;
+ struct block_device *bdev;
disk_del_events(disk);
@@ -655,6 +656,19 @@ void del_gendisk(struct gendisk *disk)
blk_unregister_queue(disk);
blk_unregister_region(disk_devt(disk), disk->minors);
+ /*
+ * When used buffer-mode on raw blockdevice,the disk removed.
+ * But the vfs don't know.So tell the vfs size of disk became zero,
+ * the buffer write can return
+ */
+ bdev = bdget_disk(disk, 0);
+ if (bdev) {
+ mutex_lock(&bdev->bd_inode->i_mutex);
+ i_size_write(bdev->bd_inode, 0);
+ mutex_unlock(&bdev->bd_inode->i_mutex);
+ bdput(bdev);
+ }
+
part_stat_set_all(&disk->part0, 0);
disk->part0.stamp = 0;
--
1.8.4-rc0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 1/2] block: Set inode of block_device size to zero when delete gendisk.
@ 2013-09-11 11:00 ` majianpeng
0 siblings, 0 replies; 2+ messages in thread
From: majianpeng @ 2013-09-11 11:00 UTC (permalink / raw)
To: axboe, viro; +Cc: linux-fsdevel, LKML
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1281 bytes --]
When remove gendisk, set the size of inode of block_device to zero.
This is mainly let the vfs know disk removed.
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
block/genhd.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/block/genhd.c b/block/genhd.c
index dadf42b..c3a54b4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -634,6 +634,7 @@ void del_gendisk(struct gendisk *disk)
{
struct disk_part_iter piter;
struct hd_struct *part;
+ struct block_device *bdev;
disk_del_events(disk);
@@ -655,6 +656,19 @@ void del_gendisk(struct gendisk *disk)
blk_unregister_queue(disk);
blk_unregister_region(disk_devt(disk), disk->minors);
+ /*
+ * When used buffer-mode on raw blockdevice,the disk removed.
+ * But the vfs don't know.So tell the vfs size of disk became zero,
+ * the buffer write can return
+ */
+ bdev = bdget_disk(disk, 0);
+ if (bdev) {
+ mutex_lock(&bdev->bd_inode->i_mutex);
+ i_size_write(bdev->bd_inode, 0);
+ mutex_unlock(&bdev->bd_inode->i_mutex);
+ bdput(bdev);
+ }
+
part_stat_set_all(&disk->part0, 0);
disk->part0.stamp = 0;
--
1.8.4-rc0
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-11 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 11:00 [PATCH 1/2] block: Set inode of block_device size to zero when delete gendisk majianpeng
2013-09-11 11:00 ` majianpeng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.