Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Oct 2015 15:31:26 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289702 - head/sys/cam/ctl
Message-ID:  <201510211531.t9LFVQqN011371@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Oct 21 15:31:26 2015
New Revision: 289702
URL: https://svnweb.freebsd.org/changeset/base/289702

Log:
  Make some panic strings mode informative.

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_backend_block.c

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Wed Oct 21 15:06:48 2015	(r289701)
+++ head/sys/cam/ctl/ctl.c	Wed Oct 21 15:31:26 2015	(r289702)
@@ -3810,7 +3810,7 @@ ctl_expand_number(const char *buf, uint6
 static int
 ctl_init_page_index(struct ctl_lun *lun)
 {
-	int i;
+	int i, page_code;
 	struct ctl_page_index *page_index;
 	const char *value;
 	uint64_t ival;
@@ -3831,10 +3831,12 @@ ctl_init_page_index(struct ctl_lun *lun)
 		    (page_index->page_flags & CTL_PAGE_FLAG_CDROM) == 0)
 			continue;
 
-		switch (page_index->page_code & SMPH_PC_MASK) {
+		page_code = page_index->page_code & SMPH_PC_MASK;
+		switch (page_code) {
 		case SMS_RW_ERROR_RECOVERY_PAGE: {
-			if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
-				panic("subpage is incorrect!");
+			KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
+			    ("subpage %#x for page %#x is incorrect!",
+			    page_index->subpage, page_code));
 			memcpy(&lun->mode_pages.rw_er_page[CTL_PAGE_CURRENT],
 			       &rw_er_page_default,
 			       sizeof(rw_er_page_default));
@@ -3854,8 +3856,9 @@ ctl_init_page_index(struct ctl_lun *lun)
 		case SMS_FORMAT_DEVICE_PAGE: {
 			struct scsi_format_page *format_page;
 
-			if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
-				panic("subpage is incorrect!");
+			KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
+			    ("subpage %#x for page %#x is incorrect!",
+			    page_index->subpage, page_code));
 
 			/*
 			 * Sectors per track are set above.  Bytes per
@@ -3901,9 +3904,9 @@ ctl_init_page_index(struct ctl_lun *lun)
 			int shift;
 #endif /* !__XSCALE__ */
 
-			if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
-				panic("invalid subpage value %d",
-				      page_index->subpage);
+			KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
+			    ("subpage %#x for page %#x is incorrect!",
+			    page_index->subpage, page_code));
 
 			/*
 			 * Rotation rate and sectors per track are set
@@ -3981,9 +3984,9 @@ ctl_init_page_index(struct ctl_lun *lun)
 		case SMS_CACHING_PAGE: {
 			struct scsi_caching_page *caching_page;
 
-			if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
-				panic("invalid subpage value %d",
-				      page_index->subpage);
+			KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
+			    ("subpage %#x for page %#x is incorrect!",
+			    page_index->subpage, page_code));
 			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_DEFAULT],
 			       &caching_page_default,
 			       sizeof(caching_page_default));
@@ -4066,6 +4069,9 @@ ctl_init_page_index(struct ctl_lun *lun)
 				page_index->page_data =
 				    (uint8_t *)lun->mode_pages.control_ext_page;
 				break;
+			default:
+				panic("subpage %#x for page %#x is incorrect!",
+				      page_index->subpage, page_code);
 			}
 			break;
 		}
@@ -4157,10 +4163,18 @@ ctl_init_page_index(struct ctl_lun *lun)
 				       sizeof(lbp_page_default));
 				page_index->page_data =
 					(uint8_t *)lun->mode_pages.lbp_page;
-			}}
+				break;
+			}
+			default:
+				panic("subpage %#x for page %#x is incorrect!",
+				      page_index->subpage, page_code);
+			}
 			break;
 		}
 		case SMS_CDDVD_CAPS_PAGE:{
+			KASSERT(page_index->subpage == SMS_SUBPAGE_PAGE_0,
+			    ("subpage %#x for page %#x is incorrect!",
+			    page_index->subpage, page_code));
 			memcpy(&lun->mode_pages.cddvd_page[CTL_PAGE_DEFAULT],
 			       &cddvd_page_default,
 			       sizeof(cddvd_page_default));
@@ -4201,17 +4215,14 @@ ctl_init_page_index(struct ctl_lun *lun)
 				break;
 			}
 			default:
-				panic("invalid subpage value %d",
-				      page_index->subpage);
-				break;
+				panic("subpage %#x for page %#x is incorrect!",
+				      page_index->subpage, page_code);
 			}
-   			break;
+			break;
 		}
 		default:
-			panic("invalid page value %d",
-			      page_index->page_code & SMPH_PC_MASK);
-			break;
-    	}
+			panic("invalid page code value %#x", page_code);
+		}
 	}
 
 	return (CTL_RETVAL_COMPLETE);
@@ -6223,8 +6234,7 @@ ctl_mode_select(struct ctl_scsiio *ctsio
 		break;
 	}
 	default:
-		panic("Invalid CDB type %#x", ctsio->cdb[0]);
-		break;
+		panic("%s: Invalid CDB type %#x", __func__, ctsio->cdb[0]);
 	}
 
 	if (param_len < (header_size + bd_len)) {
@@ -6487,8 +6497,7 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
 		break;
 	}
 	default:
-		panic("invalid CDB type %#x", ctsio->cdb[0]);
-		break; /* NOTREACHED */
+		panic("%s: Invalid CDB type %#x", __func__, ctsio->cdb[0]);
 	}
 
 	/*
@@ -7502,7 +7511,7 @@ retry:
 		    lun->pr_key_count;
 		break;
 	default:
-		panic("Invalid PR type %x", cdb->action);
+		panic("%s: Invalid PR type %#x", __func__, cdb->action);
 	}
 	mtx_unlock(&lun->lun_lock);
 
@@ -7698,12 +7707,7 @@ retry:
 		break;
 	}
 	default:
-		/*
-		 * This is a bug, because we just checked for this above,
-		 * and should have returned an error.
-		 */
-		panic("Invalid PR type %x", cdb->action);
-		break; /* NOTREACHED */
+		panic("%s: Invalid PR type %#x", __func__, cdb->action);
 	}
 	mtx_unlock(&lun->lun_lock);
 
@@ -8421,7 +8425,7 @@ ctl_persistent_reserve_out(struct ctl_sc
 		break;
 	}
 	default:
-		panic("Invalid PR type %x", cdb->action);
+		panic("%s: Invalid PR type %#x", __func__, cdb->action);
 	}
 
 done:
@@ -11030,8 +11034,9 @@ ctl_check_for_blockage(struct ctl_lun *l
 	case CTL_SER_SKIP:
 		return (CTL_ACTION_SKIP);
 	default:
-		panic("invalid serialization value %d",
-		      serialize_row[pending_entry->seridx]);
+		panic("%s: Invalid serialization value %d for %d => %d",
+		    __func__, serialize_row[pending_entry->seridx],
+		    pending_entry->seridx, ooa_entry->seridx);
 	}
 
 	return (CTL_ACTION_ERROR);
@@ -11080,8 +11085,7 @@ ctl_check_ooa(struct ctl_lun *lun, union
 		case CTL_ACTION_PASS:
 			break;
 		default:
-			panic("invalid action %d", action);
-			break;  /* NOTREACHED */
+			panic("%s: Invalid action %d\n", __func__, action);
 		}
 	}
 
@@ -12558,9 +12562,8 @@ ctl_datamove(union ctl_io *io)
 				    io->taskio.tag_num, io->taskio.tag_type);
 			break;
 		default:
-			printf("Invalid CTL I/O type %d\n", io->io_hdr.io_type);
-			panic("Invalid CTL I/O type %d\n", io->io_hdr.io_type);
-			break;
+			panic("%s: Invalid CTL I/O type %d\n",
+			    __func__, io->io_hdr.io_type);
 		}
 		sbuf_cat(&sb, path_str);
 		sbuf_printf(&sb, "ctl_datamove: %jd seconds\n",
@@ -13093,9 +13096,8 @@ ctl_process_done(union ctl_io *io)
 				    io->taskio.tag_num, io->taskio.tag_type);
 			break;
 		default:
-			printf("Invalid CTL I/O type %d\n", io->io_hdr.io_type);
-			panic("Invalid CTL I/O type %d\n", io->io_hdr.io_type);
-			break;
+			panic("%s: Invalid CTL I/O type %d\n",
+			    __func__, io->io_hdr.io_type);
 		}
 		sbuf_cat(&sb, path_str);
 		sbuf_printf(&sb, "ctl_process_done: %jd seconds\n",
@@ -13114,9 +13116,8 @@ ctl_process_done(union ctl_io *io)
 		fe_done(io);
 		return;
 	default:
-		panic("ctl_process_done: invalid io type %d\n",
-		      io->io_hdr.io_type);
-		break; /* NOTREACHED */
+		panic("%s: Invalid CTL I/O type %d\n",
+		    __func__, io->io_hdr.io_type);
 	}
 
 	lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;

Modified: head/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend_block.c	Wed Oct 21 15:06:48 2015	(r289701)
+++ head/sys/cam/ctl/ctl_backend_block.c	Wed Oct 21 15:31:26 2015	(r289702)
@@ -2110,7 +2110,7 @@ ctl_be_block_close(struct ctl_be_block_l
 		case CTL_BE_BLOCK_NONE:
 			break;
 		default:
-			panic("Unexpected backend type.");
+			panic("Unexpected backend type %d", be_lun->dev_type);
 			break;
 		}
 		be_lun->dev_type = CTL_BE_BLOCK_NONE;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510211531.t9LFVQqN011371>