linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* no EBUSY on BLKRRPART, regression?
@ 2021-04-15 11:31 Karel Zak
  2021-04-15 12:09 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Karel Zak @ 2021-04-15 11:31 UTC (permalink / raw)
  To: linux-block; +Cc: Jens Axboe, Christoph Hellwig



 Hi,

 it seems BLKRRPART does not return EBUSY although the whole-disk
 device contains mounted partitions. It seems like regression,
 or what did I overlook?

 BLKRRPART is very old way how fdisk-like programs detect that the
 whole-disk device is not used by system, otherwise it warns users. Now
 it does not work ;-( 

 Yes, it would be probably better to use open(O_EXCL) in these days.

        # lsblk /dev/sda
        NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
        sda      8:0    0 223.6G  0 disk
        ├─sda1   8:1    0   200M  0 part /boot/efi
        ├─sda2   8:2    0     5G  0 part /boot
        ├─sda3   8:3    0 125.5G  0 part
        ├─sda4   8:4    0    50G  0 part /
        └─sda5   8:5    0  42.9G  0 part /home/archive


        # strace -e ioctl blockdev --rereadpt /dev/sda
        ioctl(3, BLKRRPART)                     = 0

        # uname -r
        5.11.10-200.fc33.x86_64

 Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

* Re: no EBUSY on BLKRRPART, regression?
  2021-04-15 11:31 no EBUSY on BLKRRPART, regression? Karel Zak
@ 2021-04-15 12:09 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-04-15 12:09 UTC (permalink / raw)
  To: Karel Zak; +Cc: linux-block, Jens Axboe, Christoph Hellwig

Looks like the switch to go through blkdev_get_by_dev means we
now ignore the return value from bdev_disk_changed.

Something like the untested patch below should fix it:

diff --git a/block/ioctl.c b/block/ioctl.c
index ff241e663c018f..8ba1ed8defd0bb 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -89,6 +89,8 @@ static int blkdev_reread_part(struct block_device *bdev, fmode_t mode)
 		return -EINVAL;
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
+	if (bdev->bd_part_count)
+		return -EBUSY;
 
 	/*
 	 * Reopen the device to revalidate the driver state and force a

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

end of thread, other threads:[~2021-04-15 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-15 11:31 no EBUSY on BLKRRPART, regression? Karel Zak
2021-04-15 12:09 ` Christoph Hellwig

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).