summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-11-13 19:21:45 +0000
committermav <mav@FreeBSD.org>2015-11-13 19:21:45 +0000
commit8daf7a11eb8011162714afbbdc363b7c232854a7 (patch)
treedcbdb68e261d429a088ae611623a3211b0211a50 /sys/cam
parent80bd9cee4ad7d3602670364a93e5cf09ee6c479f (diff)
downloadFreeBSD-src-8daf7a11eb8011162714afbbdc363b7c232854a7.zip
FreeBSD-src-8daf7a11eb8011162714afbbdc363b7c232854a7.tar.gz
MFC r289702: Make some panic strings mode informative.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c93
-rw-r--r--sys/cam/ctl/ctl_backend_block.c2
2 files changed, 48 insertions, 47 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index cde8489..926ab75 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -3817,7 +3817,7 @@ ctl_expand_number(const char *buf, uint64_t *num)
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;
@@ -3838,10 +3838,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));
@@ -3861,8 +3863,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
@@ -3908,9 +3911,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
@@ -3988,9 +3991,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));
@@ -4073,6 +4076,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;
}
@@ -4164,10 +4170,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));
@@ -4208,17 +4222,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);
@@ -6230,8 +6241,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)) {
@@ -6494,8 +6504,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]);
}
/*
@@ -7509,7 +7518,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);
@@ -7705,12 +7714,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);
@@ -8428,7 +8432,7 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
break;
}
default:
- panic("Invalid PR type %x", cdb->action);
+ panic("%s: Invalid PR type %#x", __func__, cdb->action);
}
done:
@@ -11037,8 +11041,9 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io,
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);
@@ -11087,8 +11092,7 @@ ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io,
case CTL_ACTION_PASS:
break;
default:
- panic("invalid action %d", action);
- break; /* NOTREACHED */
+ panic("%s: Invalid action %d\n", __func__, action);
}
}
@@ -12565,9 +12569,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",
@@ -13100,9 +13103,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",
@@ -13121,9 +13123,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;
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index b8ff26b..5b86356 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -2113,7 +2113,7 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun)
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;
OpenPOWER on IntegriCloud