Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MFC r256552:

Unify periph invalidation and destruction reporting.
Print message containing device model and serial number on invalidation.

Approved by:	re (hrs)
  • Loading branch information...
commit c896ef2cccb7601faf5c79451228435a0717d08b 1 parent 5411f69
Alexander Motin authored October 24, 2013
24  sys/cam/ata/ata_all.c
@@ -297,6 +297,18 @@ ata_print_ident(struct ata_params *ident_data)
297 297
 }
298 298
 
299 299
 void
  300
+ata_print_ident_short(struct ata_params *ident_data)
  301
+{
  302
+	char product[48], revision[16];
  303
+
  304
+	cam_strvis(product, ident_data->model, sizeof(ident_data->model),
  305
+		   sizeof(product));
  306
+	cam_strvis(revision, ident_data->revision, sizeof(ident_data->revision),
  307
+		   sizeof(revision));
  308
+	printf("<%s %s>", product, revision);
  309
+}
  310
+
  311
+void
300 312
 semb_print_ident(struct sep_identify_data *ident_data)
301 313
 {
302 314
 	char vendor[9], product[17], revision[5], fw[5], in[7], ins[5];
@@ -311,6 +323,18 @@ semb_print_ident(struct sep_identify_data *ident_data)
311 323
 	    vendor, product, revision, fw, in, ins);
312 324
 }
313 325
 
  326
+void
  327
+semb_print_ident_short(struct sep_identify_data *ident_data)
  328
+{
  329
+	char vendor[9], product[17], revision[5], fw[5];
  330
+
  331
+	cam_strvis(vendor, ident_data->vendor_id, 8, sizeof(vendor));
  332
+	cam_strvis(product, ident_data->product_id, 16, sizeof(product));
  333
+	cam_strvis(revision, ident_data->product_rev, 4, sizeof(revision));
  334
+	cam_strvis(fw, ident_data->firmware_rev, 4, sizeof(fw));
  335
+	printf("<%s %s %s %s>", vendor, product, revision, fw);
  336
+}
  337
+
314 338
 uint32_t
315 339
 ata_logical_sector_size(struct ata_params *ident_data)
316 340
 {
2  sys/cam/ata/ata_all.h
@@ -109,6 +109,7 @@ int	ata_status_sbuf(struct ccb_ataio *ataio, struct sbuf *sb);
109 109
 int	ata_res_sbuf(struct ccb_ataio *ataio, struct sbuf *sb);
110 110
 
111 111
 void	ata_print_ident(struct ata_params *ident_data);
  112
+void	ata_print_ident_short(struct ata_params *ident_data);
112 113
 
113 114
 uint32_t	ata_logical_sector_size(struct ata_params *ident_data);
114 115
 uint64_t	ata_physical_sector_size(struct ata_params *ident_data);
@@ -143,6 +144,7 @@ int	ata_identify_match(caddr_t identbuffer, caddr_t table_entry);
143 144
 int	ata_static_identify_match(caddr_t identbuffer, caddr_t table_entry);
144 145
 
145 146
 void	semb_print_ident(struct sep_identify_data *ident_data);
  147
+void	semb_print_ident_short(struct sep_identify_data *ident_data);
146 148
 
147 149
 void semb_receive_diagnostic_results(struct ccb_ataio *ataio,
148 150
 	u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb*),
2  sys/cam/ata/ata_da.c
@@ -907,7 +907,6 @@ adaoninvalidate(struct cam_periph *periph)
907 907
 	bioq_flush(&softc->trim_queue, NULL, ENXIO);
908 908
 
909 909
 	disk_gone(softc->disk);
910  
-	xpt_print(periph->path, "lost device\n");
911 910
 }
912 911
 
913 912
 static void
@@ -917,7 +916,6 @@ adacleanup(struct cam_periph *periph)
917 916
 
918 917
 	softc = (struct ada_softc *)periph->softc;
919 918
 
920  
-	xpt_print(periph->path, "removing device entry\n");
921 919
 	cam_periph_unlock(periph);
922 920
 
923 921
 	/*
2  sys/cam/ata/ata_pmp.c
@@ -241,7 +241,6 @@ pmponinvalidate(struct cam_periph *periph)
241 241
 		}
242 242
 	}
243 243
 	pmprelease(periph, -1);
244  
-	xpt_print(periph->path, "lost device\n");
245 244
 }
246 245
 
247 246
 static void
@@ -251,7 +250,6 @@ pmpcleanup(struct cam_periph *periph)
251 250
 
252 251
 	softc = (struct pmp_softc *)periph->softc;
253 252
 
254  
-	xpt_print(periph->path, "removing device entry\n");
255 253
 	cam_periph_unlock(periph);
256 254
 
257 255
 	/*
7  sys/cam/cam_periph.c
@@ -586,6 +586,8 @@ cam_periph_invalidate(struct cam_periph *periph)
586 586
 		return;
587 587
 
588 588
 	CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n"));
  589
+	if (periph->flags & CAM_PERIPH_ANNOUNCED)
  590
+		xpt_denounce_periph(periph);
589 591
 	periph->flags |= CAM_PERIPH_INVALID;
590 592
 	periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
591 593
 	if (periph->periph_oninval != NULL)
@@ -648,7 +650,10 @@ camperiphfree(struct cam_periph *periph)
648 650
 	xpt_remove_periph(periph);
649 651
 
650 652
 	xpt_unlock_buses();
651  
-	CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
  653
+	if (periph->flags & CAM_PERIPH_ANNOUNCED) {
  654
+		xpt_print(periph->path, "Periph destroyed\n");
  655
+	} else
  656
+		CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
652 657
 
653 658
 	if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {
654 659
 		union ccb ccb;
1  sys/cam/cam_periph.h
@@ -121,6 +121,7 @@ struct cam_periph {
121 121
 #define CAM_PERIPH_NEW_DEV_FOUND	0x10
122 122
 #define CAM_PERIPH_RECOVERY_INPROG	0x20
123 123
 #define CAM_PERIPH_FREE			0x80
  124
+#define CAM_PERIPH_ANNOUNCED		0x100
124 125
 	u_int32_t		 immediate_priority;
125 126
 	u_int32_t		 refcount;
126 127
 	SLIST_HEAD(, ccb_hdr)	 ccb_list;	/* For "immediate" requests */
32  sys/cam/cam_xpt.c
@@ -1023,6 +1023,7 @@ xpt_announce_periph(struct cam_periph *periph, char *announce_string)
1023 1023
 	struct	cam_path *path = periph->path;
1024 1024
 
1025 1025
 	mtx_assert(periph->sim->mtx, MA_OWNED);
  1026
+	periph->flags |= CAM_PERIPH_ANNOUNCED;
1026 1027
 
1027 1028
 	printf("%s%d at %s%d bus %d scbus%d target %d lun %d\n",
1028 1029
 	       periph->periph_name, periph->unit_number,
@@ -1071,6 +1072,37 @@ xpt_announce_quirks(struct cam_periph *periph, int quirks, char *bit_string)
1071 1072
 	}
1072 1073
 }
1073 1074
 
  1075
+void
  1076
+xpt_denounce_periph(struct cam_periph *periph)
  1077
+{
  1078
+	struct	cam_path *path = periph->path;
  1079
+
  1080
+	mtx_assert(periph->sim->mtx, MA_OWNED);
  1081
+	printf("%s%d at %s%d bus %d scbus%d target %d lun %d\n",
  1082
+	       periph->periph_name, periph->unit_number,
  1083
+	       path->bus->sim->sim_name,
  1084
+	       path->bus->sim->unit_number,
  1085
+	       path->bus->sim->bus_id,
  1086
+	       path->bus->path_id,
  1087
+	       path->target->target_id,
  1088
+	       path->device->lun_id);
  1089
+	printf("%s%d: ", periph->periph_name, periph->unit_number);
  1090
+	if (path->device->protocol == PROTO_SCSI)
  1091
+		scsi_print_inquiry_short(&path->device->inq_data);
  1092
+	else if (path->device->protocol == PROTO_ATA ||
  1093
+	    path->device->protocol == PROTO_SATAPM)
  1094
+		ata_print_ident_short(&path->device->ident_data);
  1095
+	else if (path->device->protocol == PROTO_SEMB)
  1096
+		semb_print_ident_short(
  1097
+		    (struct sep_identify_data *)&path->device->ident_data);
  1098
+	else
  1099
+		printf("Unknown protocol device");
  1100
+	if (path->device->serial_num_len > 0)
  1101
+		printf(" s/n %.60s", path->device->serial_num);
  1102
+	printf(" detached\n");
  1103
+}
  1104
+
  1105
+
1074 1106
 int
1075 1107
 xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
1076 1108
 {
1  sys/cam/cam_xpt_periph.h
@@ -47,6 +47,7 @@ void		xpt_announce_periph(struct cam_periph *periph,
47 47
 				    char *announce_string);
48 48
 void		xpt_announce_quirks(struct cam_periph *periph,
49 49
 				    int quirks, char *bit_string);
  50
+void		xpt_denounce_periph(struct cam_periph *periph);
50 51
 #endif
51 52
 
52 53
 #endif /* _CAM_CAM_XPT_PERIPH_H */
15  sys/cam/scsi/scsi_all.c
@@ -5249,6 +5249,21 @@ scsi_print_inquiry(struct scsi_inquiry_data *inq_data)
5249 5249
 	       dtype, rstr, qtype);
5250 5250
 }
5251 5251
 
  5252
+void
  5253
+scsi_print_inquiry_short(struct scsi_inquiry_data *inq_data)
  5254
+{
  5255
+	char vendor[16], product[48], revision[16];
  5256
+
  5257
+	cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor),
  5258
+		   sizeof(vendor));
  5259
+	cam_strvis(product, inq_data->product, sizeof(inq_data->product),
  5260
+		   sizeof(product));
  5261
+	cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision),
  5262
+		   sizeof(revision));
  5263
+
  5264
+	printf("<%s %s %s>", vendor, product, revision);
  5265
+}
  5266
+
5252 5267
 /*
5253 5268
  * Table of syncrates that don't follow the "divisible by 4"
5254 5269
  * rule. This table will be expanded in future SCSI specs.
1  sys/cam/scsi/scsi_all.h
@@ -2313,6 +2313,7 @@ char *		scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string,
2313 2313
 				size_t len);
2314 2314
 
2315 2315
 void		scsi_print_inquiry(struct scsi_inquiry_data *inq_data);
  2316
+void		scsi_print_inquiry_short(struct scsi_inquiry_data *inq_data);
2316 2317
 
2317 2318
 u_int		scsi_calc_syncsrate(u_int period_factor);
2318 2319
 u_int		scsi_calc_syncparam(u_int period);
3  sys/cam/scsi/scsi_cd.c
@@ -428,7 +428,6 @@ cdoninvalidate(struct cam_periph *periph)
428 428
 		camq_remove(&softc->changer->devq, softc->pinfo.index);
429 429
 
430 430
 	disk_gone(softc->disk);
431  
-	xpt_print(periph->path, "lost device, %d refs\n", periph->refcount);
432 431
 }
433 432
 
434 433
 static void
@@ -438,8 +437,6 @@ cdcleanup(struct cam_periph *periph)
438 437
 
439 438
 	softc = (struct cd_softc *)periph->softc;
440 439
 
441  
-	xpt_print(periph->path, "removing device entry\n");
442  
-
443 440
 	/*
444 441
 	 * In the queued, non-active case, the device in question
445 442
 	 * has already been removed from the changer run queue.  Since this
5  sys/cam/scsi/scsi_ch.c
@@ -306,9 +306,6 @@ choninvalidate(struct cam_periph *periph)
306 306
 	 * when it has cleaned up its state.
307 307
 	 */
308 308
 	destroy_dev_sched_cb(softc->dev, chdevgonecb, periph);
309  
-
310  
-	xpt_print(periph->path, "lost device\n");
311  
-
312 309
 }
313 310
 
314 311
 static void
@@ -318,8 +315,6 @@ chcleanup(struct cam_periph *periph)
318 315
 
319 316
 	softc = (struct ch_softc *)periph->softc;
320 317
 
321  
-	xpt_print(periph->path, "removing device entry\n");
322  
-
323 318
 	devstat_remove_entry(softc->device_stats);
324 319
 
325 320
 	free(softc, M_DEVBUF);
4  sys/cam/scsi/scsi_da.c
@@ -1561,9 +1561,6 @@ daoninvalidate(struct cam_periph *periph)
1561 1561
 	 * done cleaning up its resources.
1562 1562
 	 */
1563 1563
 	disk_gone(softc->disk);
1564  
-
1565  
-	xpt_print(periph->path, "lost device - %d outstanding, %d refs\n",
1566  
-		  softc->outstanding_cmds, periph->refcount);
1567 1564
 }
1568 1565
 
1569 1566
 static void
@@ -1573,7 +1570,6 @@ dacleanup(struct cam_periph *periph)
1573 1570
 
1574 1571
 	softc = (struct da_softc *)periph->softc;
1575 1572
 
1576  
-	xpt_print(periph->path, "removing device entry\n");
1577 1573
 	cam_periph_unlock(periph);
1578 1574
 
1579 1575
 	/*
5  sys/cam/scsi/scsi_enc.c
@@ -178,8 +178,6 @@ enc_oninvalidate(struct cam_periph *periph)
178 178
 	callout_drain(&enc->status_updater);
179 179
 
180 180
 	destroy_dev_sched_cb(enc->enc_dev, enc_devgonecb, periph);
181  
-
182  
-	xpt_print(periph->path, "lost device\n");
183 181
 }
184 182
 
185 183
 static void
@@ -189,9 +187,6 @@ enc_dtor(struct cam_periph *periph)
189 187
 
190 188
 	enc = periph->softc;
191 189
 
192  
-	xpt_print(periph->path, "removing device entry\n");
193  
-
194  
-
195 190
 	/* If the sub-driver has a cleanup routine, call it */
196 191
 	if (enc->enc_vec.softc_cleanup != NULL)
197 192
 		enc->enc_vec.softc_cleanup(enc);
7  sys/cam/scsi/scsi_pass.c
@@ -207,11 +207,6 @@ passoninvalidate(struct cam_periph *periph)
207 207
 	 * XXX Handle any transactions queued to the card
208 208
 	 *     with XPT_ABORT_CCB.
209 209
 	 */
210  
-
211  
-	if (bootverbose) {
212  
-		xpt_print(periph->path, "lost device\n");
213  
-	}
214  
-
215 210
 }
216 211
 
217 212
 static void
@@ -221,8 +216,6 @@ passcleanup(struct cam_periph *periph)
221 216
 
222 217
 	softc = (struct pass_softc *)periph->softc;
223 218
 
224  
-	if (bootverbose)
225  
-		xpt_print(periph->path, "removing device entry\n");
226 219
 	devstat_remove_entry(softc->device_stats);
227 220
 
228 221
 	cam_periph_unlock(periph);
3  sys/cam/scsi/scsi_pt.c
@@ -333,8 +333,6 @@ ptoninvalidate(struct cam_periph *periph)
333 333
 	 *     with XPT_ABORT_CCB.
334 334
 	 */
335 335
 	bioq_flush(&softc->bio_queue, NULL, ENXIO);
336  
-
337  
-	xpt_print(periph->path, "lost device\n");
338 336
 }
339 337
 
340 338
 static void
@@ -344,7 +342,6 @@ ptdtor(struct cam_periph *periph)
344 342
 
345 343
 	softc = (struct pt_softc *)periph->softc;
346 344
 
347  
-	xpt_print(periph->path, "removing device entry\n");
348 345
 	devstat_remove_entry(softc->device_stats);
349 346
 	cam_periph_unlock(periph);
350 347
 	destroy_dev(softc->dev);
4  sys/cam/scsi/scsi_sa.c
@@ -1401,9 +1401,6 @@ saoninvalidate(struct cam_periph *periph)
1401 1401
 	 */
1402 1402
 	bioq_flush(&softc->bio_queue, NULL, ENXIO);
1403 1403
 	softc->queue_count = 0;
1404  
-
1405  
-	xpt_print(periph->path, "lost device\n");
1406  
-
1407 1404
 }
1408 1405
 
1409 1406
 static void
@@ -1414,7 +1411,6 @@ sacleanup(struct cam_periph *periph)
1414 1411
 
1415 1412
 	softc = (struct sa_softc *)periph->softc;
1416 1413
 
1417  
-	xpt_print(periph->path, "removing device entry\n");
1418 1414
 	devstat_remove_entry(softc->device_stats);
1419 1415
 	cam_periph_unlock(periph);
1420 1416
 	destroy_dev(softc->devs.ctl_dev);
5  sys/cam/scsi/scsi_sg.c
@@ -238,9 +238,6 @@ sgoninvalidate(struct cam_periph *periph)
238 238
 	 *     with XPT_ABORT_CCB.
239 239
 	 */
240 240
 
241  
-	if (bootverbose) {
242  
-		xpt_print(periph->path, "lost device\n");
243  
-	}
244 241
 }
245 242
 
246 243
 static void
@@ -249,8 +246,6 @@ sgcleanup(struct cam_periph *periph)
249 246
 	struct sg_softc *softc;
250 247
 
251 248
 	softc = (struct sg_softc *)periph->softc;
252  
-	if (bootverbose)
253  
-		xpt_print(periph->path, "removing device entry\n");
254 249
 
255 250
 	devstat_remove_entry(softc->device_stats);
256 251
 

0 notes on commit c896ef2

Please sign in to comment.
Something went wrong with that request. Please try again.