]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
block: don't set GD_NEED_PART_SCAN if scan partition failed
authorYu Kuai <yukuai3@huawei.com>
Wed, 22 Mar 2023 03:59:26 +0000 (11:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 7 Apr 2023 02:41:53 +0000 (20:41 -0600)
commit3723091ea1884d599cc8b8bf719d6f42e8d4d8b1
tree5be8cf89940a0cc888ee2c76b50cf0f22e92c4e3
parent5b3b9197c28c8245c3c13ddf3ddf4eb10c2b23e1
block: don't set GD_NEED_PART_SCAN if scan partition failed

Currently if disk_scan_partitions() failed, GD_NEED_PART_SCAN will still
set, and partition scan will be proceed again when blkdev_get_by_dev()
is called. However, this will cause a problem that re-assemble partitioned
raid device will creat partition for underlying disk.

Test procedure:

mdadm -CR /dev/md0 -l 1 -n 2 /dev/sda /dev/sdb -e 1.0
sgdisk -n 0:0:+100MiB /dev/md0
blockdev --rereadpt /dev/sda
blockdev --rereadpt /dev/sdb
mdadm -S /dev/md0
mdadm -A /dev/md0 /dev/sda /dev/sdb

Test result: underlying disk partition and raid partition can be
observed at the same time

Note that this can still happen in come corner cases that
GD_NEED_PART_SCAN can be set for underlying disk while re-assemble raid
device.

Fixes: e5cfefa97bcc ("block: fix scan partition for exclusively open device again")
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c