Date: Thu, 6 Feb 2025 18:42:37 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 25105fa029da - main - cam/cd: Simplify to remove invalid flag Message-ID: <202502061842.516IgbcA057930@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=25105fa029da88d5e02a94481733aa5a2d947ba4 commit 25105fa029da88d5e02a94481733aa5a2d947ba4 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2025-02-06 18:19:06 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2025-02-06 18:40:22 +0000 cam/cd: Simplify to remove invalid flag cdoninvalidate set the CD_FLAG_INVALID flag. However, the periph's invalid flag is set before that routine is called, so it's always set when CD_FLAG_INVALID is set. It's therefore redundant. The code in strategy can be simplified by checking the periph's CAM_PERIPH_INVALID flag. Since this is a locked access, they will always be the same. The check in cdopen is currently redundant because both cam_periph_acquire and cam_periph_hold will return an error when CAM_PERIPH_INVALID is set, the former being unlocked, the latter being locked (to catch the race, but in this case the race doesn't matter). Since these are the only places we use this flag, we can simplfy the code by removing it entirely and changing cdstreategy slightly. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D48840 --- sys/cam/scsi/scsi_cd.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index d9a40544e845..ec6e31d49b22 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -100,7 +100,6 @@ typedef enum { "\007RETRY_BUSY" typedef enum { - CD_FLAG_INVALID = 0x0001, CD_FLAG_NEW_DISC = 0x0002, CD_FLAG_DISC_LOCKED = 0x0004, CD_FLAG_DISC_REMOVABLE = 0x0008, @@ -376,8 +375,6 @@ cdoninvalidate(struct cam_periph *periph) */ xpt_register_async(0, cdasync, periph, periph->path); - softc->flags |= CD_FLAG_INVALID; - /* * Return all queued I/O with ENXIO. * XXX Handle any transactions queued to the card @@ -740,23 +737,15 @@ static int cdopen(struct disk *dp) { struct cam_periph *periph; - struct cd_softc *softc; int error; periph = (struct cam_periph *)dp->d_drv1; - softc = (struct cd_softc *)periph->softc; if (cam_periph_acquire(periph) != 0) return(ENXIO); cam_periph_lock(periph); - if (softc->flags & CD_FLAG_INVALID) { - cam_periph_release_locked(periph); - cam_periph_unlock(periph); - return(ENXIO); - } - if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) { cam_periph_release_locked(periph); cam_periph_unlock(periph); @@ -861,7 +850,7 @@ cdstrategy(struct bio *bp) /* * If the device has been made invalid, error out */ - if ((softc->flags & CD_FLAG_INVALID)) { + if ((periph->flags & CAM_PERIPH_INVALID) != 0) { cam_periph_unlock(periph); biofinish(bp, NULL, ENXIO); return;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502061842.516IgbcA057930>