Re: [PATCH v2 07/28] block: Introduce zone write plugging

Christoph Hellwig
2024-03-26T06:51:10Z

On Tue, Mar 26, 2024 at 12:12:03PM +0900, Damien Le Moal wrote:
> Nope, we cannot. The reason is that BIO issuing and zone reset/finish can be
> concurrently processed and we need to be ready for a user doing really stupid
> things like resetting or finishing a zone while BIOs for that zone are being
> issued. When zone reset/finish is processed, the plug is removed from the hash
> table, but disk_get_zone_wplug_locked() may still get a reference to it because
> we do not have the plug locked yet. Hence the flag, to prevent reusing the plug
> for the reset/finished zone that was already removed from the hash table. This
> is mentioned with a comment in disk_get_zone_wplug_locked():
>
> /*
> * Check that a BIO completion or a zone reset or finish
> * operation has not already flagged the zone write plug for
> * freeing and dropped its reference count. In such case, we
> * need to get a new plug so start over from the beginning.
> */
>
> The reference count dropping to 0 will then be the trigger for actually freeing
> the plug, after all in-flight or plugged BIOs are completed (most likely failed).

Maybe the comment should be expanded even more and move to the definition
of the freeing flag?