svn commit: r255115 - projects/camlock/sys/cam
Alexander Motin
mav at FreeBSD.org
Sun Sep 1 07:57:54 UTC 2013
Author: mav
Date: Sun Sep 1 07:57:53 2013
New Revision: 255115
URL: http://svnweb.freebsd.org/changeset/base/255115
Log:
Add debug trace points for freeze/release device queue.
Modified:
projects/camlock/sys/cam/cam_debug.h
projects/camlock/sys/cam/cam_periph.c
projects/camlock/sys/cam/cam_xpt.c
projects/camlock/sys/cam/cam_xpt.h
Modified: projects/camlock/sys/cam/cam_debug.h
==============================================================================
--- projects/camlock/sys/cam/cam_debug.h Sun Sep 1 07:10:06 2013 (r255114)
+++ projects/camlock/sys/cam/cam_debug.h Sun Sep 1 07:57:53 2013 (r255115)
@@ -99,6 +99,17 @@ extern u_int32_t cam_debug_delay;
DELAY(cam_debug_delay); \
}
+#define CAM_DEBUG_DEV(dev, flag, printfargs) \
+ if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
+ && (cam_dpath != NULL) \
+ && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \
+ && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \
+ xpt_print_device(dev); \
+ printf printfargs; \
+ if (cam_debug_delay != 0) \
+ DELAY(cam_debug_delay); \
+ }
+
#define CAM_DEBUG_PRINT(flag, printfargs) \
if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
printf("cam_debug: "); \
Modified: projects/camlock/sys/cam/cam_periph.c
==============================================================================
--- projects/camlock/sys/cam/cam_periph.c Sun Sep 1 07:10:06 2013 (r255114)
+++ projects/camlock/sys/cam/cam_periph.c Sun Sep 1 07:57:53 2013 (r255115)
@@ -1096,6 +1096,7 @@ cam_freeze_devq(struct cam_path *path)
{
struct ccb_hdr ccb_h;
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("cam_freeze_devq\n"));
xpt_setup_ccb(&ccb_h, path, /*priority*/1);
ccb_h.func_code = XPT_NOOP;
ccb_h.flags = CAM_DEV_QFREEZE;
@@ -1109,6 +1110,8 @@ cam_release_devq(struct cam_path *path,
{
struct ccb_relsim crs;
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("cam_release_devq(%u, %u, %u, %d)\n",
+ relsim_flags, openings, arg, getcount_only));
xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
crs.ccb_h.func_code = XPT_REL_SIMQ;
crs.ccb_h.flags = getcount_only ? CAM_DEV_QFREEZE : 0;
Modified: projects/camlock/sys/cam/cam_xpt.c
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.c Sun Sep 1 07:10:06 2013 (r255114)
+++ projects/camlock/sys/cam/cam_xpt.c Sun Sep 1 07:57:53 2013 (r255115)
@@ -3561,6 +3561,40 @@ xpt_path_comp(struct cam_path *path1, st
return (retval);
}
+int
+xpt_path_comp_dev(struct cam_path *path, struct cam_ed *dev)
+{
+ int retval = 0;
+
+ if (path->bus != dev->target->bus) {
+ if (path->bus->path_id == CAM_BUS_WILDCARD)
+ retval = 1;
+ else if (dev->target->bus->path_id == CAM_BUS_WILDCARD)
+ retval = 2;
+ else
+ return (-1);
+ }
+ if (path->target != dev->target) {
+ if (path->target->target_id == CAM_TARGET_WILDCARD) {
+ if (retval == 0)
+ retval = 1;
+ } else if (dev->target->target_id == CAM_TARGET_WILDCARD)
+ retval = 2;
+ else
+ return (-1);
+ }
+ if (path->device != dev) {
+ if (path->device->lun_id == CAM_LUN_WILDCARD) {
+ if (retval == 0)
+ retval = 1;
+ } else if (dev->lun_id == CAM_LUN_WILDCARD)
+ retval = 2;
+ else
+ return (-1);
+ }
+ return (retval);
+}
+
void
xpt_print_path(struct cam_path *path)
{
@@ -3594,6 +3628,21 @@ xpt_print_path(struct cam_path *path)
}
void
+xpt_print_device(struct cam_ed *device)
+{
+
+ if (device == NULL)
+ printf("(nopath): ");
+ else {
+ printf("(noperiph:%s%d:%d:%d:%d): ", device->sim->sim_name,
+ device->sim->unit_number,
+ device->sim->bus_id,
+ device->target->target_id,
+ device->lun_id);
+ }
+}
+
+void
xpt_print(struct cam_path *path, const char *fmt, ...)
{
va_list ap;
@@ -4223,6 +4272,8 @@ xpt_freeze_devq(struct cam_path *path, u
devq = dev->sim->devq;
mtx_lock(&devq->send_mtx);
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_freeze_devq() %u->%u\n",
+ dev->ccbq.queue.qfrozen_cnt, dev->ccbq.queue.qfrozen_cnt + count));
freeze = (dev->ccbq.queue.qfrozen_cnt += count);
/* Remove frozen device from sendq. */
if (device_is_queued(dev))
@@ -4251,6 +4302,7 @@ xpt_release_devq_timeout(void *arg)
struct cam_devq *devq;
dev = (struct cam_ed *)arg;
+ CAM_DEBUG_DEV(dev, CAM_DEBUG_TRACE, ("xpt_release_devq_timeout\n"));
devq = dev->sim->devq;
mtx_lock(&devq->send_mtx);
if (xpt_release_devq_device(dev, /*count*/1, /*run_queue*/TRUE))
@@ -4264,6 +4316,8 @@ xpt_release_devq(struct cam_path *path,
struct cam_ed *dev;
struct cam_devq *devq;
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_release_devq(%d, %d)\n",
+ count, run_queue));
dev = path->device;
devq = dev->sim->devq;
mtx_lock(&devq->send_mtx);
@@ -4277,6 +4331,9 @@ xpt_release_devq_device(struct cam_ed *d
{
mtx_assert(&dev->sim->devq->send_mtx, MA_OWNED);
+ CAM_DEBUG_DEV(dev, CAM_DEBUG_TRACE,
+ ("xpt_release_devq_device(%d, %d) %u->%u\n", count, run_queue,
+ dev->ccbq.queue.qfrozen_cnt, dev->ccbq.queue.qfrozen_cnt - count));
if (count > dev->ccbq.queue.qfrozen_cnt) {
#ifdef INVARIANTS
printf("xpt_release_devq(): requested %u > present %u\n",
Modified: projects/camlock/sys/cam/cam_xpt.h
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.h Sun Sep 1 07:10:06 2013 (r255114)
+++ projects/camlock/sys/cam/cam_xpt.h Sun Sep 1 07:57:53 2013 (r255115)
@@ -35,6 +35,7 @@
/* Forward Declarations */
union ccb;
struct cam_periph;
+struct cam_ed;
struct cam_sim;
/*
@@ -86,7 +87,10 @@ void xpt_path_counts(struct cam_path *
uint32_t *device_ref);
int xpt_path_comp(struct cam_path *path1,
struct cam_path *path2);
+int xpt_path_comp_dev(struct cam_path *path,
+ struct cam_ed *dev);
void xpt_print_path(struct cam_path *path);
+void xpt_print_device(struct cam_ed *device);
void xpt_print(struct cam_path *path, const char *fmt, ...);
int xpt_path_string(struct cam_path *path, char *str,
size_t str_len);
More information about the svn-src-projects
mailing list