linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: return EBUSY from drop_partitions on mounted whole disk device
@ 2015-08-05 19:13 Eric Sandeen
  2016-03-01 20:45 ` Eric Sandeen
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2015-08-05 19:13 UTC (permalink / raw)
  To: linux-fsdevel@vger.kernel.org; +Cc: Jens Axboe

The BLKRRPART ioctl already fails today if any partition under
the device is mounted.  However, if we mkfs a whole disk and mount
it, BLKRRPART happily proceeds down the invalidation path, which
seems like a bad idea.

Check whether the whole device is mounted by checking bd_super,
and return -EBUSY if so.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

I don't know for sure if this is the right approach, but figure
I'll ask in the form of a patch.  ;)

diff --git a/block/partition-generic.c b/block/partition-generic.c
index 0d9e5f9..04f304c 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -397,7 +397,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev)
 	struct hd_struct *part;
 	int res;
 
-	if (bdev->bd_part_count)
+	if (bdev->bd_super || bdev->bd_part_count)
 		return -EBUSY;
 	res = invalidate_partition(disk, 0);
 	if (res)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-02 22:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 19:13 [PATCH] block: return EBUSY from drop_partitions on mounted whole disk device Eric Sandeen
2016-03-01 20:45 ` Eric Sandeen
2016-03-02  3:38   ` Eric Sandeen
2016-03-02 22:13   ` Eric Sandeen
2016-03-02 22:15     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).