]> git.baikalelectronics.ru Git - kernel.git/commit
block: fix scan partition for exclusively open device again
authorYu Kuai <yukuai3@huawei.com>
Fri, 17 Feb 2023 02:22:00 +0000 (10:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:50:21 +0000 (08:50 +0100)
commitadd9c22534d08ae7fb4fd825456e218945dc04dc
tree926db1c136714718daa6237cde8268c6f45e74c0
parent7f8eef7abbc3080004bc38d5fe6332ea8d12780d
block: fix scan partition for exclusively open device again

[ Upstream commit 92ef14daac46a715708df375e0b9d383cbee28f3 ]

As explained in commit 97484fe6a145 ("block: Do not reread partition table
on exclusively open device"), reread partition on the device that is
exclusively opened by someone else is problematic.

This patch will make sure partition scan will only be proceed if current
thread open the device exclusively, or the device is not opened
exclusively, and in the later case, other scanners and exclusive openers
will be blocked temporarily until partition scan is done.

Fixes: 45703ec20f31 ("block: remove the bd_openers checks in blk_drop_partitions")
Cc: <stable@vger.kernel.org>
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230217022200.3092987-3-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/genhd.c
block/ioctl.c