summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-10-05 07:10:09 +0000
committermav <mav@FreeBSD.org>2015-10-05 07:10:09 +0000
commiteeb9c6755e66a4709ca9730e3c83786ca232f3e2 (patch)
tree9b679e02eddad4cc9440445b31580ec56ed7c952
parent7d808295113c5c15e74c86300f1d292526274917 (diff)
downloadFreeBSD-src-eeb9c6755e66a4709ca9730e3c83786ca232f3e2.zip
FreeBSD-src-eeb9c6755e66a4709ca9730e3c83786ca232f3e2.tar.gz
MFC r277440 (by will):
Restore the CAM XPT peripheral generation counter, and export it via sysctl. Define it as an atomic uint32_t. These increments happen infrequently enough for the atomic overhead to be a problem, and since they're now independent atomics, they won't contend with xpt_lock_buses(). This counter is useful as a means of cheaply identifying whether any changes have been made to the CAM peripheral list. Userland programs have no guarantee that the counter won't change on them while being returned or while processing the information, so they must be written accordingly.
-rw-r--r--sys/cam/cam_xpt.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 645ded0..17b4f19 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -93,6 +93,8 @@ struct xpt_task {
};
struct xpt_softc {
+ uint32_t xpt_generation;
+
/* number of high powered commands that can go through right now */
struct mtx xpt_highpower_lock;
STAILQ_HEAD(highpowerlist, cam_ed) highpowerq;
@@ -154,6 +156,8 @@ MTX_SYSINIT(xpt_topo_init, &xsoftc.xpt_topo_lock, "XPT topology lock", MTX_DEF);
TUNABLE_INT("kern.cam.boot_delay", &xsoftc.boot_delay);
SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN,
&xsoftc.boot_delay, 0, "Bus registration wait time");
+SYSCTL_UINT(_kern_cam, OID_AUTO, xpt_generation, CTLFLAG_RD,
+ &xsoftc.xpt_generation, 0, "CAM peripheral generation count");
struct cam_doneq {
struct mtx_padalign cam_doneq_mtx;
@@ -981,6 +985,7 @@ xpt_add_periph(struct cam_periph *periph)
device->generation++;
SLIST_INSERT_HEAD(&device->periphs, periph, periph_links);
mtx_unlock(&device->target->bus->eb_mtx);
+ atomic_add_32(&xsoftc.xpt_generation, 1);
}
return (status);
@@ -997,6 +1002,7 @@ xpt_remove_periph(struct cam_periph *periph)
device->generation++;
SLIST_REMOVE(&device->periphs, periph, cam_periph, periph_links);
mtx_unlock(&device->target->bus->eb_mtx);
+ atomic_add_32(&xsoftc.xpt_generation, 1);
}
}
OpenPOWER on IntegriCloud