mbox series

[V2,0/3] block: avoid to drop & re-add partitions if partitions aren't changed

Message ID 20210224035830.990123-1-ming.lei@redhat.com (mailing list archive)
Headers show
Series block: avoid to drop & re-add partitions if partitions aren't changed | expand

Message

Ming Lei Feb. 24, 2021, 3:58 a.m. UTC
Hi Guys,

The two patches changes block ioctl(BLKRRPART) for avoiding drop &
re-add partitions if partitions state isn't changed. The current
behavior confuses userspace because partitions can disappear anytime
when calling into ioctl(BLKRRPART).

V2:
	- don't save partitions state, and just check if current partition
	state is changed against partition devices	

Ming Lei (4):
  block: define parsed_partitions.flags as 'unsigned char'
  block: store partition flags into block_device
  block: re-organize blk_add_partitions
  block: avoid to drop & re-add partitions if partitions aren't changed

 block/partitions/check.h  |   2 +-
 block/partitions/core.c   | 126 ++++++++++++++++++++++++++++++++++----
 fs/block_dev.c            |  30 ++++-----
 include/linux/blk_types.h |   1 +
 include/linux/genhd.h     |   1 +
 5 files changed, 132 insertions(+), 28 deletions(-)

Cc: Ewan D. Milne <emilne@redhat.com>

Comments

Christoph Hellwig Feb. 24, 2021, 8:18 a.m. UTC | #1
On Wed, Feb 24, 2021 at 11:58:26AM +0800, Ming Lei wrote:
> Hi Guys,
> 
> The two patches changes block ioctl(BLKRRPART) for avoiding drop &
> re-add partitions if partitions state isn't changed. The current
> behavior confuses userspace because partitions can disappear anytime
> when calling into ioctl(BLKRRPART).

Which is the f***king point of BLKRRPART and the behavior it had
since day 1.  Please fix the application(s) that all it all the time
instead of bloating the kernel, as said before.
Ming Lei Feb. 24, 2021, 11:23 a.m. UTC | #2
On Wed, Feb 24, 2021 at 09:18:25AM +0100, Christoph Hellwig wrote:
> On Wed, Feb 24, 2021 at 11:58:26AM +0800, Ming Lei wrote:
> > Hi Guys,
> > 
> > The two patches changes block ioctl(BLKRRPART) for avoiding drop &
> > re-add partitions if partitions state isn't changed. The current
> > behavior confuses userspace because partitions can disappear anytime
> > when calling into ioctl(BLKRRPART).
> 
> Which is the f***king point of BLKRRPART and the behavior it had
> since day 1.  Please fix the application(s) that all it all the time
> instead of bloating the kernel, as said before.
> 

ioctl(BLKRRPART) can be called without changing partition table in
fdisk, cfdisk, sfdisk, systemd and blockdev at least, and it isn't only
on one single application. Even for blockdev, not sure if it can be fixed
because '--rereadpt' is simply one subcommand.
Christoph Hellwig Feb. 24, 2021, 4:14 p.m. UTC | #3
On Wed, Feb 24, 2021 at 07:23:54PM +0800, Ming Lei wrote:
> > > The two patches changes block ioctl(BLKRRPART) for avoiding drop &
> > > re-add partitions if partitions state isn't changed. The current
> > > behavior confuses userspace because partitions can disappear anytime
> > > when calling into ioctl(BLKRRPART).
> > 
> > Which is the f***king point of BLKRRPART and the behavior it had
> > since day 1.  Please fix the application(s) that all it all the time
> > instead of bloating the kernel, as said before.
> > 
> 
> ioctl(BLKRRPART) can be called without changing partition table in
> fdisk, cfdisk, sfdisk, systemd and blockdev at least, and it isn't only
> on one single application. Even for blockdev, not sure if it can be fixed
> because '--rereadpt' is simply one subcommand.

I can also do all kinds of other bad things when I really want to.  So
if a privileged user uses *fdisk, or explicitly calls
blockdev --rereadpt, we can expect this behavior, and all of them above
should not be frequent.

It seems like the main culprit is systemd, so please look into what is
going wrong there.