aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2015-10-21 15:31:26 +0000
committerAlexander Motin <mav@FreeBSD.org>2015-10-21 15:31:26 +0000
commit5124012aae68c3c1578b77b8be489b3a6a3bfdda (patch)
tree31f832fd87d666632027fb7a79f9cbd5e96178af
parentf9a5123470b0cea6056a755711e5c3e3c66d2021 (diff)
downloadsrc-5124012aae68c3c1578b77b8be489b3a6a3bfdda.tar.gz
src-5124012aae68c3c1578b77b8be489b3a6a3bfdda.zip
Make some panic strings mode informative.
Notes
Notes: svn path=/head/; revision=289702
-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 30c4eb094d5e..ccdc3d1785b9 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -3810,7 +3810,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;
@@ -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_scsiio *ctsio)
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 *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);
@@ -11080,8 +11085,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);
}
}
@@ -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;
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index 254f52bbc3b0..df65ffd94dee 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -2110,7 +2110,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;