All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: Don't reread partitions of disk which already mouted.
@ 2013-09-29  7:36 majianpeng
  0 siblings, 0 replies; only message in thread
From: majianpeng @ 2013-09-29  7:36 UTC (permalink / raw)
  To: axboe; +Cc: Jeff Moyer, LKML

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1254 bytes --]

If reread partitions of disk, the paths are:
blkdev_ioctl->blkdev_reread_part->rescan_partitions->drop_partitions
->invalidate_partition->__invalidate_device
In func __invalidate_device, if disk already mounted, it will do
shrink_dcache_sb and invalidate_inodes.
This operation will effect the fs.
So add a judgement before doing rescan_partiontions to judge disk
whether mounted.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
 block/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/ioctl.c b/block/ioctl.c
index a31d91d..374af7e 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -154,11 +154,19 @@ static int blkdev_reread_part(struct block_device *bdev)
 {
 	struct gendisk *disk = bdev->bd_disk;
 	int res;
+	struct super_block *sb;
 
 	if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
 		return -EINVAL;
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
+
+	sb = get_super(bdev);
+	if (sb) {
+		drop_super(sb);
+		return -EBUSY;
+	}
+
 	if (!mutex_trylock(&bdev->bd_mutex))
 		return -EBUSY;
 	res = rescan_partitions(disk, bdev);
-- 
1.8.4
ÿôèº{.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] only message in thread

only message in thread, other threads:[~2013-09-29  7:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-29  7:36 [PATCH] block: Don't reread partitions of disk which already mouted 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.