From cb6b771b05c3026a85ed4817c1b87c5e6f41d136 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 10 Apr 2020 14:31:47 +0200
Subject: [PATCH] block: fix busy device checking in blk_drop_partitions again
Git-commit: cb6b771b05c3026a85ed4817c1b87c5e6f41d136
Patch-mainline: v5.7-rc1
References: bsc#1171948
The previous fix had an off by one in the bd_openers checking, counting
the callers blkdev_get.
Fixes: d3ef5536274f ("block: fix busy device checking in blk_drop_partitions")
Reported-by: Qian Cai <cai@lca.pw>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Qian Cai <cai@lca.pw>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Acked-by: Jan Kara <jack@suse.cz>
---
block/partition-generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -435,7 +435,7 @@ static int drop_partitions(struct gendis
struct hd_struct *part;
int res;
- if (bdev->bd_part_count || bdev->bd_openers)
+ if (bdev->bd_part_count || bdev->bd_openers > 1)
return -EBUSY;
res = invalidate_partition(disk, 0);
if (res)