svn commit: r254178 - projects/camlock/sys/cam
Alexander Motin
mav at FreeBSD.org
Sat Aug 10 12:12:27 UTC 2013
Author: mav
Date: Sat Aug 10 12:12:26 2013
New Revision: 254178
URL: http://svnweb.freebsd.org/changeset/base/254178
Log:
Add xpt_clone_path() and xpt_copy_path() utility functions.
Modified:
projects/camlock/sys/cam/cam_xpt.c
projects/camlock/sys/cam/cam_xpt.h
Modified: projects/camlock/sys/cam/cam_xpt.c
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.c Sat Aug 10 07:39:15 2013 (r254177)
+++ projects/camlock/sys/cam/cam_xpt.c Sat Aug 10 12:12:26 2013 (r254178)
@@ -228,11 +228,13 @@ static void xpt_run_allocq(struct cam_p
static void xpt_run_devq(struct cam_devq *devq);
static timeout_t xpt_release_devq_timeout;
static void xpt_release_simq_timeout(void *arg) __unused;
+static void xpt_acquire_bus(struct cam_eb *bus);
static void xpt_release_bus(struct cam_eb *bus);
static int xpt_release_devq_device(struct cam_ed *dev, u_int count,
int run_queue);
static struct cam_et*
xpt_alloc_target(struct cam_eb *bus, target_id_t target_id);
+static void xpt_acquire_target(struct cam_et *target);
static void xpt_release_target(struct cam_et *target);
static struct cam_eb*
xpt_find_bus(path_id_t path_id);
@@ -3407,6 +3409,32 @@ xpt_compile_path(struct cam_path *new_pa
return (status);
}
+cam_status
+xpt_clone_path(struct cam_path **new_path_ptr, struct cam_path *path)
+{
+ struct cam_path *new_path;
+
+ new_path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT);
+ if (new_path == NULL)
+ return(CAM_RESRC_UNAVAIL);
+ xpt_copy_path(new_path, path);
+ *new_path_ptr = new_path;
+ return (CAM_REQ_CMP);
+}
+
+void
+xpt_copy_path(struct cam_path *new_path, struct cam_path *path)
+{
+
+ *new_path = *path;
+ if (path->bus != NULL)
+ xpt_acquire_bus(path->bus);
+ if (path->target != NULL)
+ xpt_acquire_target(path->target);
+ if (path->device != NULL)
+ xpt_acquire_device(path->device);
+}
+
void
xpt_release_path(struct cam_path *path)
{
@@ -4326,6 +4354,15 @@ cam_periph_getccb(struct cam_periph *per
}
static void
+xpt_acquire_bus(struct cam_eb *bus)
+{
+
+ xpt_lock_buses();
+ bus->refcount++;
+ xpt_unlock_buses();
+}
+
+static void
xpt_release_bus(struct cam_eb *bus)
{
@@ -4384,6 +4421,16 @@ xpt_alloc_target(struct cam_eb *bus, tar
}
static void
+xpt_acquire_target(struct cam_et *target)
+{
+ struct cam_eb *bus = target->bus;
+
+ mtx_lock(&bus->eb_mtx);
+ target->refcount++;
+ mtx_unlock(&bus->eb_mtx);
+}
+
+static void
xpt_release_target(struct cam_et *target)
{
struct cam_eb *bus = target->bus;
Modified: projects/camlock/sys/cam/cam_xpt.h
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.h Sat Aug 10 07:39:15 2013 (r254177)
+++ projects/camlock/sys/cam/cam_xpt.h Sat Aug 10 12:12:26 2013 (r254178)
@@ -110,6 +110,10 @@ cam_status xpt_compile_path(struct cam_
path_id_t path_id,
target_id_t target_id,
lun_id_t lun_id);
+cam_status xpt_clone_path(struct cam_path **new_path,
+ struct cam_path *path);
+void xpt_copy_path(struct cam_path *new_path,
+ struct cam_path *path);
void xpt_release_path(struct cam_path *path);
More information about the svn-src-projects
mailing list