mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: majianpeng <majianpeng@gmail.com>
To: axboe <axboe@kernel.dk>
Cc: "Jeff Moyer" <jmoyer@redhat.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] block: Don't reread partitions of disk which already mouted.
Date: Sun, 29 Sep 2013 15:36:25 +0800	[thread overview]
Message-ID: <201309291536174186150@gmail.com> (raw)

[-- 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¥

                 reply	other threads:[~2013-09-29  7:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201309291536174186150@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome