Skip to contentSkip to conversation

block: Set inode of block_device size to zero when delete gendisk.

PATCH In review majianpeng 2 participants 2 messages Sep 17, 2013 – Sep 25, 2013

Subsystems (2)
lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH v2 1/2 block: Set inode of block_device size to zero when delete gendisk.

When remove gendisk, set the size of inode of block_device to zero. This is mainly let the vfs know disk removed.

---
 block/genhd.c | 6 ++++++
 1 file changed, 6 insertions(+)
block/genhd.c +6 -0
index dadf42b..9a4c245 100644
@@ -1369,6 +1369,12 @@ int invalidate_partition(struct gendisk *disk, int partno)
 	if (bdev) {
 		fsync_bdev(bdev);
 		res = __invalidate_device(bdev, true);
+		/*
+		 * 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
+		 */
+		i_size_write(bdev->bd_inode, 0);
 		bdput(bdev);
 	}
 	return res;
Signature · 1 line
1.8.4-rc0
Reviewed-by on v2 1/2
#1 lore raw
Quoted 4 lines · majianpeng

When remove gendisk, set the size of inode of block_device to zero. This is mainly let the vfs know disk removed.

Quoted 21 lines
---
 block/genhd.c | 6 ++++++
 1 file changed, 6 insertions(+)
block/genhd.c +6 -0
index dadf42b..9a4c245 100644
@@ -1369,6 +1369,12 @@ int invalidate_partition(struct gendisk *disk, int partno)
 	if (bdev) {
 		fsync_bdev(bdev);
 		res = __invalidate_device(bdev, true);
+		/*
+		 * 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
+		 */
+		i_size_write(bdev->bd_inode, 0);
 		bdput(bdev);
 	}
 	return res;