Re: [PATCH 09/10] md: only delete entries from all_mddevs when the disk is freed
From: Christoph Hellwig <hch@lst.de>
Date: 2022-07-19 07:14:41
Also in:
linux-block
From: Christoph Hellwig <hch@lst.de>
Date: 2022-07-19 07:14:41
Also in:
linux-block
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.
quoted
@@ -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.