On 7/19/22 09:14, Christoph Hellwig wrote:
On Mon, Jul 18, 2022 at 09:17:42AM +0200, Hannes Reinecke wrote:
Why can't we use 'atomic_inc_unless_zero' here and do away with the
additional 'deleted' flag?
See my previous reply.
@@ -3338,6 +3342,8 @@ static bool md_rdev_overlaps(struct md_rdev *rdev)
spin_lock(&all_mddevs_lock);
list_for_each_entry(mddev, &all_mddevs, all_mddevs) {
+ if (mddev->deleted)
+ continue;
Any particular reason why you can't use the 'mddev_get()' / 'mddev_put()'
sequence here?
Mostly because it would be pretty mess. mdev_put takes all_mddevs_lock,
so we'd have to add an unlock/relock cycle for each loop iteration.
After all, I don't think that 'mddev' should vanish while being in this
loop, no?
It won't, at least without the call to mddev_put. Once mddev_put is
in the game things aren't that easy, and I suspect the exising and
new code might have bugs in that area in the reboot notifier and
md_exit for extreme corner cases.
And again, MD mess.
But thanks for start clearing it up.
Cheers,
Hannes