diff options
| author | Christian Brauner <[email protected]> | 2023-10-17 18:48:20 +0000 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2023-10-28 11:29:22 +0000 |
| commit | 51b4cb4f3e2265cf8303ffd9a4f239ee3805d3ca (patch) | |
| tree | 73c4f79d3eaf2efc959e69e9c57389cae0208d3b /scripts/mod/file2alias.c | |
| parent | block: simplify bdev_del_partition() (diff) | |
| download | kernel-51b4cb4f3e2265cf8303ffd9a4f239ee3805d3ca.tar.gz kernel-51b4cb4f3e2265cf8303ffd9a4f239ee3805d3ca.zip | |
block: WARN_ON_ONCE() when we remove active partitions
The logic for disk->open_partitions is:
blkdev_get_by_*()
-> bdev_is_partition()
-> blkdev_get_part()
-> blkdev_get_whole() // bdev_whole->bd_openers++
-> if (part->bd_openers == 0)
disk->open_partitions++
part->bd_openers
In other words, when we first claim/open a partition we increment
disk->open_partitions and only when all part->bd_openers are closed will
disk->open_partitions be zero. That should mean that
disk->open_partitions is always > 0 as long as there's anyone that
has an open partition.
So the check for disk->open_partitions should mean that we can never
remove an active partition that has a holder and holder ops set. Assert
that in the code. The main disk isn't removed so that check doesn't work
for disk->part0 which is what we want. After all we only care about
partition not about the main disk.
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Jens Axboe <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'scripts/mod/file2alias.c')
0 files changed, 0 insertions, 0 deletions
