[PATCH] Be less verbose with removable da(4).

Jung-uk Kim jkim at FreeBSD.org
Fri Jul 14 01:15:24 UTC 2006


This patch shuts up SCSI errors when there's no medium in the 
removable SCSI disk drive, e.g., flash card reader.  We could 
completely shut it up with SF_NO_PRINT flag from dagetcapacity() like 
scsi_cd.c does but I decided to add another flag, i.e., SF_QUIET_NM, 
because we don't want to miss any other errors and it can be used in 
scsi_cd.c and others later.

Thanks!

Jung-uk Kim
-------------- next part --------------
Index: sys/cam/scsi/scsi_all.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_all.c,v
retrieving revision 1.48
diff -u -r1.48 scsi_all.c
--- sys/cam/scsi/scsi_all.c	14 Apr 2005 03:52:50 -0000	1.48
+++ sys/cam/scsi/scsi_all.c	14 Jul 2006 00:54:45 -0000
@@ -1706,6 +1706,9 @@
 			 */
 			action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK);
 			action |= SS_NOP|SSQ_PRINT_SENSE;
+		} else if (sense_key == SSD_KEY_NOT_READY) {
+			if ((sense_flags & SF_QUIET_NM) != 0 && asc == 0x3a)
+				action &= ~SSQ_PRINT_SENSE;
 		} else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) {
 			if ((sense_flags & SF_QUIET_IR) != 0)
 				action &= ~SSQ_PRINT_SENSE;
Index: sys/cam/scsi/scsi_all.h
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_all.h,v
retrieving revision 1.25
diff -u -r1.25 scsi_all.h
--- sys/cam/scsi/scsi_all.h	30 May 2006 22:44:00 -0000	1.25
+++ sys/cam/scsi/scsi_all.h	14 Jul 2006 00:54:46 -0000
@@ -936,7 +936,7 @@
 #define SF_NO_PRINT	0x02
 #define SF_QUIET_IR	0x04	/* Be quiet about Illegal Request reponses */
 #define SF_PRINT_ALWAYS	0x08
-
+#define SF_QUIET_NM	0x10	/* Be quiet about Medium not present response */
 
 const char *	scsi_op_desc(u_int16_t opcode, 
 			     struct scsi_inquiry_data *inq_data);
Index: sys/cam/scsi/scsi_da.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_da.c,v
retrieving revision 1.190
diff -u -r1.190 scsi_da.c
--- sys/cam/scsi/scsi_da.c	18 Apr 2006 22:01:59 -0000	1.190
+++ sys/cam/scsi/scsi_da.c	14 Jul 2006 00:54:46 -0000
@@ -1751,12 +1751,15 @@
 	struct scsi_read_capacity_data_long *rcaplong;
 	uint32_t block_len;
 	uint64_t maxsector;
-	int error;
+	int error, sf;
 
 	softc = (struct da_softc *)periph->softc;
 	block_len = 0;
 	maxsector = 0;
 	error = 0;
+	sf = SF_RETRY_UA;
+	if (softc->flags & DA_FLAG_PACK_REMOVABLE)
+		sf |= SF_QUIET_NM;
 
 	/* Do a read capacity */
 	rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcaplong),
@@ -1775,7 +1778,7 @@
 
 	error = cam_periph_runccb(ccb, daerror,
 				  /*cam_flags*/CAM_RETRY_SELTO,
-				  /*sense_flags*/SF_RETRY_UA,
+				  /*sense_flags*/sf,
 				  softc->disk->d_devstat);
 
 	if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
@@ -1810,7 +1813,7 @@
 
 	error = cam_periph_runccb(ccb, daerror,
 				  /*cam_flags*/CAM_RETRY_SELTO,
-				  /*sense_flags*/SF_RETRY_UA,
+				  /*sense_flags*/sf,
 				  softc->disk->d_devstat);
 
 	if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
Index: sys/geom/geom_disk.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/geom_disk.c,v
retrieving revision 1.99
diff -u -r1.99 geom_disk.c
--- sys/geom/geom_disk.c	10 Apr 2006 03:55:13 -0000	1.99
+++ sys/geom/geom_disk.c	14 Jul 2006 00:54:46 -0000
@@ -133,7 +133,7 @@
 		if (dp->d_open != NULL) {
 			g_disk_lock_giant(dp);
 			error = dp->d_open(dp);
-			if (error != 0)
+			if (error != 0 && bootverbose)
 				printf("Opened disk %s -> %d\n",
 				    pp->name, error);
 			g_disk_unlock_giant(dp);


More information about the freebsd-scsi mailing list