]> git.baikalelectronics.ru Git - kernel.git/commit
block: Do not reread partition table on exclusively open device
authorJan Kara <jack@suse.cz>
Wed, 30 Nov 2022 17:56:53 +0000 (18:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jan 2023 10:29:01 +0000 (11:29 +0100)
commit71c6991e511c96c425a4877552659e1ac365aa0d
tree64dc62d4e1364ccf89802d621bc5a2a21204ce2d
parent0c984cf09b3c99171e3bf8f8735db4fc11b2ac70
block: Do not reread partition table on exclusively open device

commit 36369f46e91785688a5f39d7a5590e3f07981316 upstream.

Since commit fa724e284efa ("block: remove the bd_openers checks in
blk_drop_partitions") we allow rereading of partition table although
there are users of the block device. This has an undesirable consequence
that e.g. if sda and sdb are assembled to a RAID1 device md0 with
partitions, BLKRRPART ioctl on sda will rescan partition table and
create sda1 device. This partition device under a raid device confuses
some programs (such as libstorage-ng used for initial partitioning for
distribution installation) leading to failures.

Fix the problem refusing to rescan partitions if there is another user
that has the block device exclusively open.

Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20221130135344.2ul4cyfstfs3znxg@quack3
Fixes: fa724e284efa ("block: remove the bd_openers checks in blk_drop_partitions")
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20221130175653.24299-1-jack@suse.cz
[axboe: fold in followup fix]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/blk.h
block/genhd.c
block/ioctl.c