cam/da: Only mark pack as valid if we know the size in daopen

Only mark the pack as 'valid' (eg clear the invalid bit) when we know
the size of the underlying drive and the periph hasn't been
invalidated. Previously, we'd unconditionally clear this bit, but
if the size isn't known, no I/O to the drive is possible.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D48688
This commit is contained in:
Warner Losh 2025-02-08 14:31:07 -07:00
parent c2de0116c8
commit 82fc49a0be

View file

@ -1803,10 +1803,17 @@ daopen(struct disk *dp)
(softc->quirks & DA_Q_NO_PREVENT) == 0)
daprevent(periph, PR_PREVENT);
if (error == 0) {
/*
* Only 'validate' the pack if the media size is non-zero and the
* underlying peripheral isn't invalid (the only error != 0 path).
*/
if (error == 0 && softc->params.sectors != 0)
softc->flags &= ~DA_FLAG_PACK_INVALID;
else
softc->flags |= DA_FLAG_PACK_INVALID;
if (error == 0)
softc->flags |= DA_FLAG_OPEN;
}
da_periph_unhold(periph, DA_REF_OPEN_HOLD);
cam_periph_unlock(periph);