Drop "internal" CTL frontend.
Its idea was to be a simple initiator and execute several commands from kernel level, but FreeBSD never had consumer for that functionality, while its implementation polluted many unrelated places..
This commit is contained in:
parent
fcb92d50f7
commit
2f444d157b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286806
@ -366,16 +366,6 @@ This is a CTL frontend port that is also a CAM SIM. The idea is that this
|
|||||||
frontend allows for using CTL without any target-capable hardware. So any
|
frontend allows for using CTL without any target-capable hardware. So any
|
||||||
LUNs you create in CTL are visible via this port.
|
LUNs you create in CTL are visible via this port.
|
||||||
|
|
||||||
|
|
||||||
ctl_frontend_internal.c
|
|
||||||
ctl_frontend_internal.h:
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
This is a frontend port written for Copan to do some system-specific tasks
|
|
||||||
that required sending commands into CTL from inside the kernel. This isn't
|
|
||||||
entirely relevant to FreeBSD in general, but can perhaps be repurposed or
|
|
||||||
removed later.
|
|
||||||
|
|
||||||
ctl_ha.h:
|
ctl_ha.h:
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_util.h>
|
#include <cam/ctl/ctl_util.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
@ -392,9 +391,6 @@ static int ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio);
|
|||||||
static int ctl_ioctl_submit_wait(union ctl_io *io);
|
static int ctl_ioctl_submit_wait(union ctl_io *io);
|
||||||
static void ctl_ioctl_datamove(union ctl_io *io);
|
static void ctl_ioctl_datamove(union ctl_io *io);
|
||||||
static void ctl_ioctl_done(union ctl_io *io);
|
static void ctl_ioctl_done(union ctl_io *io);
|
||||||
static void ctl_ioctl_hard_startstop_callback(void *arg,
|
|
||||||
struct cfi_metatask *metatask);
|
|
||||||
static void ctl_ioctl_bbrread_callback(void *arg,struct cfi_metatask *metatask);
|
|
||||||
static int ctl_ioctl_fill_ooa(struct ctl_lun *lun, uint32_t *cur_fill_num,
|
static int ctl_ioctl_fill_ooa(struct ctl_lun *lun, uint32_t *cur_fill_num,
|
||||||
struct ctl_ooa *ooa_hdr,
|
struct ctl_ooa *ooa_hdr,
|
||||||
struct ctl_ooa_entry *kern_entries);
|
struct ctl_ooa_entry *kern_entries);
|
||||||
@ -2093,38 +2089,6 @@ ctl_ioctl_done(union ctl_io *io)
|
|||||||
mtx_unlock(¶ms->ioctl_mtx);
|
mtx_unlock(¶ms->ioctl_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
ctl_ioctl_hard_startstop_callback(void *arg, struct cfi_metatask *metatask)
|
|
||||||
{
|
|
||||||
struct ctl_fe_ioctl_startstop_info *sd_info;
|
|
||||||
|
|
||||||
sd_info = (struct ctl_fe_ioctl_startstop_info *)arg;
|
|
||||||
|
|
||||||
sd_info->hs_info.status = metatask->status;
|
|
||||||
sd_info->hs_info.total_luns = metatask->taskinfo.startstop.total_luns;
|
|
||||||
sd_info->hs_info.luns_complete =
|
|
||||||
metatask->taskinfo.startstop.luns_complete;
|
|
||||||
sd_info->hs_info.luns_failed = metatask->taskinfo.startstop.luns_failed;
|
|
||||||
|
|
||||||
cv_broadcast(&sd_info->sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ctl_ioctl_bbrread_callback(void *arg, struct cfi_metatask *metatask)
|
|
||||||
{
|
|
||||||
struct ctl_fe_ioctl_bbrread_info *fe_bbr_info;
|
|
||||||
|
|
||||||
fe_bbr_info = (struct ctl_fe_ioctl_bbrread_info *)arg;
|
|
||||||
|
|
||||||
mtx_lock(fe_bbr_info->lock);
|
|
||||||
fe_bbr_info->bbr_info->status = metatask->status;
|
|
||||||
fe_bbr_info->bbr_info->bbr_status = metatask->taskinfo.bbrread.status;
|
|
||||||
fe_bbr_info->wakeup_done = 1;
|
|
||||||
mtx_unlock(fe_bbr_info->lock);
|
|
||||||
|
|
||||||
cv_broadcast(&fe_bbr_info->sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns 0 for success, errno for failure.
|
* Returns 0 for success, errno for failure.
|
||||||
*/
|
*/
|
||||||
@ -2724,103 +2688,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTL_HARD_START:
|
|
||||||
case CTL_HARD_STOP: {
|
|
||||||
struct ctl_fe_ioctl_startstop_info ss_info;
|
|
||||||
struct cfi_metatask *metatask;
|
|
||||||
struct mtx hs_mtx;
|
|
||||||
|
|
||||||
mtx_init(&hs_mtx, "HS Mutex", NULL, MTX_DEF);
|
|
||||||
|
|
||||||
cv_init(&ss_info.sem, "hard start/stop cv" );
|
|
||||||
|
|
||||||
metatask = cfi_alloc_metatask(/*can_wait*/ 1);
|
|
||||||
if (metatask == NULL) {
|
|
||||||
retval = ENOMEM;
|
|
||||||
mtx_destroy(&hs_mtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd == CTL_HARD_START)
|
|
||||||
metatask->tasktype = CFI_TASK_STARTUP;
|
|
||||||
else
|
|
||||||
metatask->tasktype = CFI_TASK_SHUTDOWN;
|
|
||||||
|
|
||||||
metatask->callback = ctl_ioctl_hard_startstop_callback;
|
|
||||||
metatask->callback_arg = &ss_info;
|
|
||||||
|
|
||||||
cfi_action(metatask);
|
|
||||||
|
|
||||||
/* Wait for the callback */
|
|
||||||
mtx_lock(&hs_mtx);
|
|
||||||
cv_wait_sig(&ss_info.sem, &hs_mtx);
|
|
||||||
mtx_unlock(&hs_mtx);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All information has been copied from the metatask by the
|
|
||||||
* time cv_broadcast() is called, so we free the metatask here.
|
|
||||||
*/
|
|
||||||
cfi_free_metatask(metatask);
|
|
||||||
|
|
||||||
memcpy((void *)addr, &ss_info.hs_info, sizeof(ss_info.hs_info));
|
|
||||||
|
|
||||||
mtx_destroy(&hs_mtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTL_BBRREAD: {
|
|
||||||
struct ctl_bbrread_info *bbr_info;
|
|
||||||
struct ctl_fe_ioctl_bbrread_info fe_bbr_info;
|
|
||||||
struct mtx bbr_mtx;
|
|
||||||
struct cfi_metatask *metatask;
|
|
||||||
|
|
||||||
bbr_info = (struct ctl_bbrread_info *)addr;
|
|
||||||
|
|
||||||
bzero(&fe_bbr_info, sizeof(fe_bbr_info));
|
|
||||||
|
|
||||||
bzero(&bbr_mtx, sizeof(bbr_mtx));
|
|
||||||
mtx_init(&bbr_mtx, "BBR Mutex", NULL, MTX_DEF);
|
|
||||||
|
|
||||||
fe_bbr_info.bbr_info = bbr_info;
|
|
||||||
fe_bbr_info.lock = &bbr_mtx;
|
|
||||||
|
|
||||||
cv_init(&fe_bbr_info.sem, "BBR read cv");
|
|
||||||
metatask = cfi_alloc_metatask(/*can_wait*/ 1);
|
|
||||||
|
|
||||||
if (metatask == NULL) {
|
|
||||||
mtx_destroy(&bbr_mtx);
|
|
||||||
cv_destroy(&fe_bbr_info.sem);
|
|
||||||
retval = ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
metatask->tasktype = CFI_TASK_BBRREAD;
|
|
||||||
metatask->callback = ctl_ioctl_bbrread_callback;
|
|
||||||
metatask->callback_arg = &fe_bbr_info;
|
|
||||||
metatask->taskinfo.bbrread.lun_num = bbr_info->lun_num;
|
|
||||||
metatask->taskinfo.bbrread.lba = bbr_info->lba;
|
|
||||||
metatask->taskinfo.bbrread.len = bbr_info->len;
|
|
||||||
|
|
||||||
cfi_action(metatask);
|
|
||||||
|
|
||||||
mtx_lock(&bbr_mtx);
|
|
||||||
while (fe_bbr_info.wakeup_done == 0)
|
|
||||||
cv_wait_sig(&fe_bbr_info.sem, &bbr_mtx);
|
|
||||||
mtx_unlock(&bbr_mtx);
|
|
||||||
|
|
||||||
bbr_info->status = metatask->status;
|
|
||||||
bbr_info->bbr_status = metatask->taskinfo.bbrread.status;
|
|
||||||
bbr_info->scsi_status = metatask->taskinfo.bbrread.scsi_status;
|
|
||||||
memcpy(&bbr_info->sense_data,
|
|
||||||
&metatask->taskinfo.bbrread.sense_data,
|
|
||||||
MIN(sizeof(bbr_info->sense_data),
|
|
||||||
sizeof(metatask->taskinfo.bbrread.sense_data)));
|
|
||||||
|
|
||||||
cfi_free_metatask(metatask);
|
|
||||||
|
|
||||||
mtx_destroy(&bbr_mtx);
|
|
||||||
cv_destroy(&fe_bbr_info.sem);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CTL_DELAY_IO: {
|
case CTL_DELAY_IO: {
|
||||||
struct ctl_io_delay_info *delay_info;
|
struct ctl_io_delay_info *delay_info;
|
||||||
#ifdef CTL_IO_DELAY
|
#ifdef CTL_IO_DELAY
|
||||||
|
@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_ha.h>
|
#include <cam/ctl/ctl_ha.h>
|
||||||
#include <cam/ctl/ctl_private.h>
|
#include <cam/ctl/ctl_private.h>
|
||||||
|
@ -84,7 +84,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_scsi_all.h>
|
#include <cam/ctl/ctl_scsi_all.h>
|
||||||
#include <cam/ctl/ctl_error.h>
|
#include <cam/ctl/ctl_error.h>
|
||||||
|
@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_util.h>
|
#include <cam/ctl/ctl_util.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_debug.h>
|
#include <cam/ctl/ctl_debug.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_error.h>
|
#include <cam/ctl/ctl_error.h>
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_ha.h>
|
#include <cam/ctl/ctl_ha.h>
|
||||||
#include <cam/ctl/ctl_private.h>
|
#include <cam/ctl/ctl_private.h>
|
||||||
|
@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_error.h>
|
#include <cam/ctl/ctl_error.h>
|
||||||
|
@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
/* XXX KDM move defines from ctl_ioctl.h to somewhere else */
|
/* XXX KDM move defines from ctl_ioctl.h to somewhere else */
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
|
@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_debug.h>
|
#include <cam/ctl/ctl_debug.h>
|
||||||
|
|
||||||
#define io_ptr spriv_ptr1
|
#define io_ptr spriv_ptr1
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,154 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2004 Silicon Graphics International Corp.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions, and the following disclaimer,
|
|
||||||
* without modification.
|
|
||||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
||||||
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
||||||
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
||||||
* including a substantially similar Disclaimer requirement for further
|
|
||||||
* binary redistribution.
|
|
||||||
*
|
|
||||||
* NO WARRANTY
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_frontend_internal.h#1 $
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* CTL kernel internal frontend target driver. This allows kernel-level
|
|
||||||
* clients to send commands into CTL.
|
|
||||||
*
|
|
||||||
* Author: Ken Merry <ken@FreeBSD.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CTL_FRONTEND_INTERNAL_H_
|
|
||||||
#define _CTL_FRONTEND_INTERNAL_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are general metatask error codes. If the error code is CFI_MT_ERROR,
|
|
||||||
* check any metatask-specific status codes for more detail on the problem.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
CFI_MT_NONE,
|
|
||||||
CFI_MT_PORT_OFFLINE,
|
|
||||||
CFI_MT_ERROR,
|
|
||||||
CFI_MT_SUCCESS
|
|
||||||
} cfi_mt_status;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CFI_TASK_NONE,
|
|
||||||
CFI_TASK_SHUTDOWN,
|
|
||||||
CFI_TASK_STARTUP,
|
|
||||||
CFI_TASK_BBRREAD
|
|
||||||
} cfi_tasktype;
|
|
||||||
|
|
||||||
struct cfi_task_startstop {
|
|
||||||
int total_luns;
|
|
||||||
int luns_complete;
|
|
||||||
int luns_failed;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error code description:
|
|
||||||
* CFI_BBR_SUCCESS - the read was successful
|
|
||||||
* CFI_BBR_LUN_UNCONFIG - CFI probe for this lun hasn't completed
|
|
||||||
* CFI_BBR_NO_LUN - this lun doesn't exist, as far as CFI knows
|
|
||||||
* CFI_BBR_NO_MEM - memory allocation error
|
|
||||||
* CFI_BBR_BAD_LEN - data length isn't a multiple of the blocksize
|
|
||||||
* CFI_BBR_RESERV_CONFLICT - another initiator has this lun reserved, so
|
|
||||||
* we can't issue I/O at all.
|
|
||||||
* CFI_BBR_LUN_STOPPED - the lun is powered off.
|
|
||||||
* CFI_BBR_LUN_OFFLINE_CTL - the lun is offline from a CTL standpoint
|
|
||||||
* CFI_BBR_LUN_OFFLINE_RC - the lun is offline from a RAIDCore standpoint.
|
|
||||||
* This is bad, because it basically means we've
|
|
||||||
* had a double failure on the LUN.
|
|
||||||
* CFI_BBR_SCSI_ERROR - generic SCSI error, see status byte and sense
|
|
||||||
* data for more resolution if you want it.
|
|
||||||
* CFI_BBR_ERROR - the catch-all error code.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
CFI_BBR_SUCCESS,
|
|
||||||
CFI_BBR_LUN_UNCONFIG,
|
|
||||||
CFI_BBR_NO_LUN,
|
|
||||||
CFI_BBR_NO_MEM,
|
|
||||||
CFI_BBR_BAD_LEN,
|
|
||||||
CFI_BBR_RESERV_CONFLICT,
|
|
||||||
CFI_BBR_LUN_STOPPED,
|
|
||||||
CFI_BBR_LUN_OFFLINE_CTL,
|
|
||||||
CFI_BBR_LUN_OFFLINE_RC,
|
|
||||||
CFI_BBR_SCSI_ERROR,
|
|
||||||
CFI_BBR_ERROR,
|
|
||||||
} cfi_bbrread_status;
|
|
||||||
|
|
||||||
struct cfi_task_bbrread {
|
|
||||||
int lun_num; /* lun number */
|
|
||||||
uint64_t lba; /* logical block address */
|
|
||||||
int len; /* length in bytes */
|
|
||||||
cfi_bbrread_status status; /* BBR status */
|
|
||||||
uint8_t scsi_status; /* SCSI status */
|
|
||||||
struct scsi_sense_data sense_data; /* SCSI sense data */
|
|
||||||
};
|
|
||||||
|
|
||||||
union cfi_taskinfo {
|
|
||||||
struct cfi_task_startstop startstop;
|
|
||||||
struct cfi_task_bbrread bbrread;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cfi_metatask;
|
|
||||||
|
|
||||||
typedef void (*cfi_cb_t)(void *arg, struct cfi_metatask *metatask);
|
|
||||||
|
|
||||||
struct cfi_metatask {
|
|
||||||
cfi_tasktype tasktype; /* passed to CFI */
|
|
||||||
cfi_mt_status status; /* returned from CFI */
|
|
||||||
union cfi_taskinfo taskinfo; /* returned from CFI */
|
|
||||||
struct ctl_mem_element *element; /* used by CFI, don't touch*/
|
|
||||||
cfi_cb_t callback; /* passed to CFI */
|
|
||||||
void *callback_arg; /* passed to CFI */
|
|
||||||
STAILQ_ENTRY(cfi_metatask) links; /* used by CFI, don't touch*/
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
|
|
||||||
MALLOC_DECLARE(M_CTL_CFI);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the API for sending meta commands (commands that are sent to more
|
|
||||||
* than one LUN) to the internal frontend:
|
|
||||||
* - Allocate a metatask using cfi_alloc_metatask(). can_wait == 0 means
|
|
||||||
* that you're calling from an interrupt context. can_wait == 1 means
|
|
||||||
* that you're calling from a thread context and don't mind waiting to
|
|
||||||
* allocate memory.
|
|
||||||
* - Setup the task type, callback and callback argument.
|
|
||||||
* - Call cfi_action().
|
|
||||||
* - When the callback comes, note the status and any per-command status
|
|
||||||
* (see the taskinfo union) and then free the metatask with
|
|
||||||
* cfi_free_metatask().
|
|
||||||
*/
|
|
||||||
struct cfi_metatask *cfi_alloc_metatask(int can_wait);
|
|
||||||
void cfi_free_metatask(struct cfi_metatask *metatask);
|
|
||||||
void cfi_action(struct cfi_metatask *metatask);
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
|
||||||
|
|
||||||
#endif /* _CTL_FRONTEND_INTERNAL_H_ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* vim: ts=8
|
|
||||||
*/
|
|
@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_error.h>
|
#include <cam/ctl/ctl_error.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_debug.h>
|
#include <cam/ctl/ctl_debug.h>
|
||||||
#include <cam/ctl/ctl_ha.h>
|
#include <cam/ctl/ctl_ha.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
|
@ -92,23 +92,6 @@ struct ctl_ooa_info {
|
|||||||
ctl_ooa_status status; /* Returned from CTL */
|
ctl_ooa_status status; /* Returned from CTL */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ctl_hard_startstop_info {
|
|
||||||
cfi_mt_status status;
|
|
||||||
int total_luns;
|
|
||||||
int luns_complete;
|
|
||||||
int luns_failed;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ctl_bbrread_info {
|
|
||||||
int lun_num; /* Passed in to CTL */
|
|
||||||
uint64_t lba; /* Passed in to CTL */
|
|
||||||
int len; /* Passed in to CTL */
|
|
||||||
cfi_mt_status status; /* Returned from CTL */
|
|
||||||
cfi_bbrread_status bbr_status; /* Returned from CTL */
|
|
||||||
uint8_t scsi_status; /* Returned from CTL */
|
|
||||||
struct scsi_sense_data sense_data; /* Returned from CTL */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CTL_DELAY_TYPE_NONE,
|
CTL_DELAY_TYPE_NONE,
|
||||||
CTL_DELAY_TYPE_CONT,
|
CTL_DELAY_TYPE_CONT,
|
||||||
@ -828,10 +811,6 @@ struct ctl_lun_map {
|
|||||||
#define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry)
|
#define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry)
|
||||||
#define CTL_DUMP_OOA _IO(CTL_MINOR, 0x06)
|
#define CTL_DUMP_OOA _IO(CTL_MINOR, 0x06)
|
||||||
#define CTL_CHECK_OOA _IOWR(CTL_MINOR, 0x07, struct ctl_ooa_info)
|
#define CTL_CHECK_OOA _IOWR(CTL_MINOR, 0x07, struct ctl_ooa_info)
|
||||||
#define CTL_HARD_STOP _IOR(CTL_MINOR, 0x08, \
|
|
||||||
struct ctl_hard_startstop_info)
|
|
||||||
#define CTL_HARD_START _IOR(CTL_MINOR, 0x09, \
|
|
||||||
struct ctl_hard_startstop_info)
|
|
||||||
#define CTL_DELAY_IO _IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info)
|
#define CTL_DELAY_IO _IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info)
|
||||||
#define CTL_REALSYNC_GET _IOR(CTL_MINOR, 0x11, int)
|
#define CTL_REALSYNC_GET _IOR(CTL_MINOR, 0x11, int)
|
||||||
#define CTL_REALSYNC_SET _IOW(CTL_MINOR, 0x12, int)
|
#define CTL_REALSYNC_SET _IOW(CTL_MINOR, 0x12, int)
|
||||||
@ -839,7 +818,6 @@ struct ctl_lun_map {
|
|||||||
#define CTL_GETSYNC _IOWR(CTL_MINOR, 0x14, struct ctl_sync_info)
|
#define CTL_GETSYNC _IOWR(CTL_MINOR, 0x14, struct ctl_sync_info)
|
||||||
#define CTL_GETSTATS _IOWR(CTL_MINOR, 0x15, struct ctl_stats)
|
#define CTL_GETSTATS _IOWR(CTL_MINOR, 0x15, struct ctl_stats)
|
||||||
#define CTL_ERROR_INJECT _IOWR(CTL_MINOR, 0x16, struct ctl_error_desc)
|
#define CTL_ERROR_INJECT _IOWR(CTL_MINOR, 0x16, struct ctl_error_desc)
|
||||||
#define CTL_BBRREAD _IOWR(CTL_MINOR, 0x17, struct ctl_bbrread_info)
|
|
||||||
#define CTL_GET_OOA _IOWR(CTL_MINOR, 0x18, struct ctl_ooa)
|
#define CTL_GET_OOA _IOWR(CTL_MINOR, 0x18, struct ctl_ooa)
|
||||||
#define CTL_DUMP_STRUCTS _IO(CTL_MINOR, 0x19)
|
#define CTL_DUMP_STRUCTS _IO(CTL_MINOR, 0x19)
|
||||||
#define CTL_GET_PORT_LIST _IOWR(CTL_MINOR, 0x20, struct ctl_port_list)
|
#define CTL_GET_PORT_LIST _IOWR(CTL_MINOR, 0x20, struct ctl_port_list)
|
||||||
|
@ -47,18 +47,6 @@
|
|||||||
#define CTL_PROCESSOR_PRODUCT "CTLPROCESSOR "
|
#define CTL_PROCESSOR_PRODUCT "CTLPROCESSOR "
|
||||||
#define CTL_UNKNOWN_PRODUCT "CTLDEVICE "
|
#define CTL_UNKNOWN_PRODUCT "CTLDEVICE "
|
||||||
|
|
||||||
struct ctl_fe_ioctl_startstop_info {
|
|
||||||
struct cv sem;
|
|
||||||
struct ctl_hard_startstop_info hs_info;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ctl_fe_ioctl_bbrread_info {
|
|
||||||
struct cv sem;
|
|
||||||
struct ctl_bbrread_info *bbr_info;
|
|
||||||
int wakeup_done;
|
|
||||||
struct mtx *lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CTL_IOCTL_INPROG,
|
CTL_IOCTL_INPROG,
|
||||||
CTL_IOCTL_DATAMOVE,
|
CTL_IOCTL_DATAMOVE,
|
||||||
|
@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_util.h>
|
#include <cam/ctl/ctl_util.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
|
@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_frontend.h>
|
#include <cam/ctl/ctl_frontend.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_util.h>
|
#include <cam/ctl/ctl_util.h>
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
|
@ -83,7 +83,6 @@ cam/ctl/ctl_backend_ramdisk.c optional ctl
|
|||||||
cam/ctl/ctl_cmd_table.c optional ctl
|
cam/ctl/ctl_cmd_table.c optional ctl
|
||||||
cam/ctl/ctl_frontend.c optional ctl
|
cam/ctl/ctl_frontend.c optional ctl
|
||||||
cam/ctl/ctl_frontend_cam_sim.c optional ctl
|
cam/ctl/ctl_frontend_cam_sim.c optional ctl
|
||||||
cam/ctl/ctl_frontend_internal.c optional ctl
|
|
||||||
cam/ctl/ctl_frontend_iscsi.c optional ctl
|
cam/ctl/ctl_frontend_iscsi.c optional ctl
|
||||||
cam/ctl/ctl_scsi_all.c optional ctl
|
cam/ctl/ctl_scsi_all.c optional ctl
|
||||||
cam/ctl/ctl_tpc.c optional ctl
|
cam/ctl/ctl_tpc.c optional ctl
|
||||||
|
@ -11,7 +11,6 @@ SRCS+= ctl_backend_ramdisk.c
|
|||||||
SRCS+= ctl_cmd_table.c
|
SRCS+= ctl_cmd_table.c
|
||||||
SRCS+= ctl_frontend.c
|
SRCS+= ctl_frontend.c
|
||||||
SRCS+= ctl_frontend_cam_sim.c
|
SRCS+= ctl_frontend_cam_sim.c
|
||||||
SRCS+= ctl_frontend_internal.c
|
|
||||||
SRCS+= ctl_frontend_iscsi.c
|
SRCS+= ctl_frontend_iscsi.c
|
||||||
SRCS+= ctl_scsi_all.c
|
SRCS+= ctl_scsi_all.c
|
||||||
SRCS+= ctl_tpc.c
|
SRCS+= ctl_tpc.c
|
||||||
|
@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl_scsi_all.h>
|
#include <cam/ctl/ctl_scsi_all.h>
|
||||||
#include <cam/ctl/ctl_util.h>
|
#include <cam/ctl/ctl_util.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
|
|
||||||
|
@ -83,12 +83,6 @@
|
|||||||
.Op Fl c Ar cdbsize
|
.Op Fl c Ar cdbsize
|
||||||
.Op Fl N
|
.Op Fl N
|
||||||
.Nm
|
.Nm
|
||||||
.Ic bbrread
|
|
||||||
.Aq target:lun
|
|
||||||
.Op general options
|
|
||||||
.Aq Fl -l Ar lba
|
|
||||||
.Aq Fl -d Ar datalen
|
|
||||||
.Nm
|
|
||||||
.Ic readcap
|
.Ic readcap
|
||||||
.Aq target:lun
|
.Aq target:lun
|
||||||
.Op general options
|
.Op general options
|
||||||
@ -129,10 +123,6 @@
|
|||||||
.Ic startup
|
.Ic startup
|
||||||
.Op general options
|
.Op general options
|
||||||
.Nm
|
.Nm
|
||||||
.Ic hardstop
|
|
||||||
.Nm
|
|
||||||
.Ic hardstart
|
|
||||||
.Nm
|
|
||||||
.Ic lunlist
|
.Ic lunlist
|
||||||
.Nm
|
.Nm
|
||||||
.Ic delay
|
.Ic delay
|
||||||
@ -364,34 +354,6 @@ to the kernel when doing a write, just execute the command without copying
|
|||||||
data.
|
data.
|
||||||
This is to be used for performance testing.
|
This is to be used for performance testing.
|
||||||
.El
|
.El
|
||||||
.It Ic bbrread
|
|
||||||
Issue a SCSI READ command to the logical device to potentially force a bad
|
|
||||||
block on a disk in the RAID set to be reconstructed from the other disks in
|
|
||||||
the array. This command should only be used on an array that is in the
|
|
||||||
normal state. If used on a critical array, it could cause the array to go
|
|
||||||
offline if the bad block to be remapped is on one of the disks that is
|
|
||||||
still active in the array.
|
|
||||||
.Pp
|
|
||||||
The data for this particular command will be discarded, and not returned to
|
|
||||||
the user.
|
|
||||||
.Pp
|
|
||||||
In order to determine which LUN to read from, the user should first
|
|
||||||
determine which LUN the disk with a bad block belongs to. Then he should
|
|
||||||
map the bad disk block back to the logical block address for the array in
|
|
||||||
order to determine which LBA to pass in to the
|
|
||||||
.Ic bbrread
|
|
||||||
command.
|
|
||||||
.Pp
|
|
||||||
This command is primarily intended for testing. In practice, bad block
|
|
||||||
remapping will generally be triggered by the in-kernel Disk Aerobics and
|
|
||||||
Disk Scrubbing code.
|
|
||||||
.Bl -tag -width 10n
|
|
||||||
.It Fl l Ar lba
|
|
||||||
Specify the starting Logical Block Address.
|
|
||||||
.It Fl d Ar datalen
|
|
||||||
Specify the amount of data in bytes to read from the LUN. This must be a
|
|
||||||
multiple of the LUN blocksize.
|
|
||||||
.El
|
|
||||||
.It Ic readcap
|
.It Ic readcap
|
||||||
Send the
|
Send the
|
||||||
.Tn SCSI
|
.Tn SCSI
|
||||||
@ -545,22 +507,6 @@ START STOP UNIT command with the start bit set and the on/offline bit set
|
|||||||
to all direct access LUNs. This will mark all direct access LUNs "online"
|
to all direct access LUNs. This will mark all direct access LUNs "online"
|
||||||
again. It will not cause any LUNs to start up. A separate start command
|
again. It will not cause any LUNs to start up. A separate start command
|
||||||
without the on/offline bit set is necessary for that.
|
without the on/offline bit set is necessary for that.
|
||||||
.It Ic hardstop
|
|
||||||
Use the kernel facility for stopping all direct access LUNs and setting the
|
|
||||||
offline bit. Unlike the
|
|
||||||
.Ic shutdown
|
|
||||||
command above, this command allows shutting down LUNs with I/O active. It
|
|
||||||
will also issue a LUN reset to any reserved LUNs to break the reservation
|
|
||||||
so that the LUN can be stopped.
|
|
||||||
.Ic shutdown
|
|
||||||
command instead.
|
|
||||||
.It Ic hardstart
|
|
||||||
This command is functionally identical to the
|
|
||||||
.Ic startup
|
|
||||||
command described above. The primary difference is that the LUNs are
|
|
||||||
enumerated and commands sent by the in-kernel Front End Target Driver
|
|
||||||
instead of by
|
|
||||||
.Nm .
|
|
||||||
.It Ic lunlist
|
.It Ic lunlist
|
||||||
List all LUNs registered with CTL.
|
List all LUNs registered with CTL.
|
||||||
Because this command uses the ioctl port, it will only work when the FETDs
|
Because this command uses the ioctl port, it will only work when the FETDs
|
||||||
|
@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/scsi/scsi_message.h>
|
#include <cam/scsi/scsi_message.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_backend_block.h>
|
#include <cam/ctl/ctl_backend_block.h>
|
||||||
@ -106,14 +105,11 @@ typedef enum {
|
|||||||
CTLADM_CMD_SHUTDOWN,
|
CTLADM_CMD_SHUTDOWN,
|
||||||
CTLADM_CMD_STARTUP,
|
CTLADM_CMD_STARTUP,
|
||||||
CTLADM_CMD_LUNLIST,
|
CTLADM_CMD_LUNLIST,
|
||||||
CTLADM_CMD_HARDSTOP,
|
|
||||||
CTLADM_CMD_HARDSTART,
|
|
||||||
CTLADM_CMD_DELAY,
|
CTLADM_CMD_DELAY,
|
||||||
CTLADM_CMD_REALSYNC,
|
CTLADM_CMD_REALSYNC,
|
||||||
CTLADM_CMD_SETSYNC,
|
CTLADM_CMD_SETSYNC,
|
||||||
CTLADM_CMD_GETSYNC,
|
CTLADM_CMD_GETSYNC,
|
||||||
CTLADM_CMD_ERR_INJECT,
|
CTLADM_CMD_ERR_INJECT,
|
||||||
CTLADM_CMD_BBRREAD,
|
|
||||||
CTLADM_CMD_PRES_IN,
|
CTLADM_CMD_PRES_IN,
|
||||||
CTLADM_CMD_PRES_OUT,
|
CTLADM_CMD_PRES_OUT,
|
||||||
CTLADM_CMD_INQ_VPD_DEVID,
|
CTLADM_CMD_INQ_VPD_DEVID,
|
||||||
@ -172,7 +168,6 @@ static const char startstop_opts[] = "io";
|
|||||||
|
|
||||||
static struct ctladm_opts option_table[] = {
|
static struct ctladm_opts option_table[] = {
|
||||||
{"adddev", CTLADM_CMD_ADDDEV, CTLADM_ARG_NONE, NULL},
|
{"adddev", CTLADM_CMD_ADDDEV, CTLADM_ARG_NONE, NULL},
|
||||||
{"bbrread", CTLADM_CMD_BBRREAD, CTLADM_ARG_NEED_TL, "d:l:"},
|
|
||||||
{"create", CTLADM_CMD_CREATE, CTLADM_ARG_NONE, "b:B:d:l:o:s:S:t:"},
|
{"create", CTLADM_CMD_CREATE, CTLADM_ARG_NONE, "b:B:d:l:o:s:S:t:"},
|
||||||
{"delay", CTLADM_CMD_DELAY, CTLADM_ARG_NEED_TL, "T:l:t:"},
|
{"delay", CTLADM_CMD_DELAY, CTLADM_ARG_NEED_TL, "T:l:t:"},
|
||||||
{"devid", CTLADM_CMD_INQ_VPD_DEVID, CTLADM_ARG_NEED_TL, NULL},
|
{"devid", CTLADM_CMD_INQ_VPD_DEVID, CTLADM_ARG_NEED_TL, NULL},
|
||||||
@ -180,8 +175,6 @@ static struct ctladm_opts option_table[] = {
|
|||||||
{"dumpooa", CTLADM_CMD_DUMPOOA, CTLADM_ARG_NONE, NULL},
|
{"dumpooa", CTLADM_CMD_DUMPOOA, CTLADM_ARG_NONE, NULL},
|
||||||
{"dumpstructs", CTLADM_CMD_DUMPSTRUCTS, CTLADM_ARG_NONE, NULL},
|
{"dumpstructs", CTLADM_CMD_DUMPSTRUCTS, CTLADM_ARG_NONE, NULL},
|
||||||
{"getsync", CTLADM_CMD_GETSYNC, CTLADM_ARG_NEED_TL, NULL},
|
{"getsync", CTLADM_CMD_GETSYNC, CTLADM_ARG_NEED_TL, NULL},
|
||||||
{"hardstart", CTLADM_CMD_HARDSTART, CTLADM_ARG_NONE, NULL},
|
|
||||||
{"hardstop", CTLADM_CMD_HARDSTOP, CTLADM_ARG_NONE, NULL},
|
|
||||||
{"help", CTLADM_CMD_HELP, CTLADM_ARG_NONE, NULL},
|
{"help", CTLADM_CMD_HELP, CTLADM_ARG_NONE, NULL},
|
||||||
{"inject", CTLADM_CMD_ERR_INJECT, CTLADM_ARG_NEED_TL, "cd:i:p:r:s:"},
|
{"inject", CTLADM_CMD_ERR_INJECT, CTLADM_ARG_NEED_TL, "cd:i:p:r:s:"},
|
||||||
{"inquiry", CTLADM_CMD_INQUIRY, CTLADM_ARG_NEED_TL, NULL},
|
{"inquiry", CTLADM_CMD_INQUIRY, CTLADM_ARG_NEED_TL, NULL},
|
||||||
@ -228,11 +221,6 @@ static int cctl_do_io(int fd, int retries, union ctl_io *io, const char *func);
|
|||||||
static int cctl_delay(int fd, int target, int lun, int argc, char **argv,
|
static int cctl_delay(int fd, int target, int lun, int argc, char **argv,
|
||||||
char *combinedopt);
|
char *combinedopt);
|
||||||
static int cctl_lunlist(int fd);
|
static int cctl_lunlist(int fd);
|
||||||
static void cctl_cfi_mt_statusstr(cfi_mt_status status, char *str, int str_len);
|
|
||||||
static void cctl_cfi_bbr_statusstr(cfi_bbrread_status, char *str, int str_len);
|
|
||||||
static int cctl_hardstopstart(int fd, ctladm_cmdfunction command);
|
|
||||||
static int cctl_bbrread(int fd, int target, int lun, int iid, int argc,
|
|
||||||
char **argv, char *combinedopt);
|
|
||||||
static int cctl_startup_shutdown(int fd, int target, int lun, int iid,
|
static int cctl_startup_shutdown(int fd, int target, int lun, int iid,
|
||||||
ctladm_cmdfunction command);
|
ctladm_cmdfunction command);
|
||||||
static int cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
|
static int cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
|
||||||
@ -1341,180 +1329,6 @@ cctl_lunlist(int fd)
|
|||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cctl_cfi_mt_statusstr(cfi_mt_status status, char *str, int str_len)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case CFI_MT_PORT_OFFLINE:
|
|
||||||
snprintf(str, str_len, "Port Offline");
|
|
||||||
break;
|
|
||||||
case CFI_MT_ERROR:
|
|
||||||
snprintf(str, str_len, "Error");
|
|
||||||
break;
|
|
||||||
case CFI_MT_SUCCESS:
|
|
||||||
snprintf(str, str_len, "Success");
|
|
||||||
break;
|
|
||||||
case CFI_MT_NONE:
|
|
||||||
snprintf(str, str_len, "None??");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
snprintf(str, str_len, "Unknown status: %d", status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cctl_cfi_bbr_statusstr(cfi_bbrread_status status, char *str, int str_len)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case CFI_BBR_SUCCESS:
|
|
||||||
snprintf(str, str_len, "Success");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_LUN_UNCONFIG:
|
|
||||||
snprintf(str, str_len, "LUN not configured");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_NO_LUN:
|
|
||||||
snprintf(str, str_len, "LUN does not exist");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_NO_MEM:
|
|
||||||
snprintf(str, str_len, "Memory allocation error");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_BAD_LEN:
|
|
||||||
snprintf(str, str_len, "Length is not a multiple of blocksize");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_RESERV_CONFLICT:
|
|
||||||
snprintf(str, str_len, "Reservation conflict");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_LUN_STOPPED:
|
|
||||||
snprintf(str, str_len, "LUN is powered off");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_LUN_OFFLINE_CTL:
|
|
||||||
snprintf(str, str_len, "LUN is offline");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_LUN_OFFLINE_RC:
|
|
||||||
snprintf(str, str_len, "RAIDCore array is offline (double "
|
|
||||||
"failure?)");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_SCSI_ERROR:
|
|
||||||
snprintf(str, str_len, "SCSI Error");
|
|
||||||
break;
|
|
||||||
case CFI_BBR_ERROR:
|
|
||||||
snprintf(str, str_len, "Error");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
snprintf(str, str_len, "Unknown status: %d", status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
cctl_hardstopstart(int fd, ctladm_cmdfunction command)
|
|
||||||
{
|
|
||||||
struct ctl_hard_startstop_info hs_info;
|
|
||||||
char error_str[256];
|
|
||||||
int do_start;
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
retval = 0;
|
|
||||||
|
|
||||||
if (command == CTLADM_CMD_HARDSTART)
|
|
||||||
do_start = 1;
|
|
||||||
else
|
|
||||||
do_start = 0;
|
|
||||||
|
|
||||||
if (ioctl(fd, (do_start == 1) ? CTL_HARD_START : CTL_HARD_STOP,
|
|
||||||
&hs_info) == -1) {
|
|
||||||
warn("%s: CTL_HARD_%s ioctl failed", __func__,
|
|
||||||
(do_start == 1) ? "START" : "STOP");
|
|
||||||
retval = 1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stdout, "Hard %s Status: ", (command == CTLADM_CMD_HARDSTOP) ?
|
|
||||||
"Stop" : "Start");
|
|
||||||
cctl_cfi_mt_statusstr(hs_info.status, error_str, sizeof(error_str));
|
|
||||||
fprintf(stdout, "%s\n", error_str);
|
|
||||||
fprintf(stdout, "Total LUNs: %d\n", hs_info.total_luns);
|
|
||||||
fprintf(stdout, "LUNs complete: %d\n", hs_info.luns_complete);
|
|
||||||
fprintf(stdout, "LUNs failed: %d\n", hs_info.luns_failed);
|
|
||||||
|
|
||||||
bailout:
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
cctl_bbrread(int fd, int target __unused, int lun, int iid __unused,
|
|
||||||
int argc, char **argv, char *combinedopt)
|
|
||||||
{
|
|
||||||
struct ctl_bbrread_info bbr_info;
|
|
||||||
char error_str[256];
|
|
||||||
int datalen = -1;
|
|
||||||
uint64_t lba = 0;
|
|
||||||
int lba_set = 0;
|
|
||||||
int retval;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
retval = 0;
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, combinedopt)) != -1) {
|
|
||||||
switch (c) {
|
|
||||||
case 'd':
|
|
||||||
datalen = strtoul(optarg, NULL, 0);
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
lba = strtoull(optarg, NULL, 0);
|
|
||||||
lba_set = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lba_set == 0) {
|
|
||||||
warnx("%s: you must specify an LBA with -l", __func__);
|
|
||||||
retval = 1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datalen == -1) {
|
|
||||||
warnx("%s: you must specify a length with -d", __func__);
|
|
||||||
retval = 1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
|
|
||||||
bbr_info.lun_num = lun;
|
|
||||||
bbr_info.lba = lba;
|
|
||||||
/*
|
|
||||||
* XXX KDM get the blocksize first??
|
|
||||||
*/
|
|
||||||
if ((datalen % 512) != 0) {
|
|
||||||
warnx("%s: data length %d is not a multiple of 512 bytes",
|
|
||||||
__func__, datalen);
|
|
||||||
retval = 1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
bbr_info.len = datalen;
|
|
||||||
|
|
||||||
if (ioctl(fd, CTL_BBRREAD, &bbr_info) == -1) {
|
|
||||||
warn("%s: CTL_BBRREAD ioctl failed", __func__);
|
|
||||||
retval = 1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
cctl_cfi_mt_statusstr(bbr_info.status, error_str, sizeof(error_str));
|
|
||||||
fprintf(stdout, "BBR Read Overall Status: %s\n", error_str);
|
|
||||||
cctl_cfi_bbr_statusstr(bbr_info.bbr_status, error_str,
|
|
||||||
sizeof(error_str));
|
|
||||||
fprintf(stdout, "BBR Read Status: %s\n", error_str);
|
|
||||||
/*
|
|
||||||
* XXX KDM should we bother printing out SCSI status if we get
|
|
||||||
* CFI_BBR_SCSI_ERROR back?
|
|
||||||
*
|
|
||||||
* Return non-zero if this fails?
|
|
||||||
*/
|
|
||||||
bailout:
|
|
||||||
return (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cctl_startup_shutdown(int fd, int target, int lun, int iid,
|
cctl_startup_shutdown(int fd, int target, int lun, int iid,
|
||||||
ctladm_cmdfunction command)
|
ctladm_cmdfunction command)
|
||||||
@ -4499,11 +4313,8 @@ usage(int error)
|
|||||||
" ctladm devlist [-b backend] [-v] [-x]\n"
|
" ctladm devlist [-b backend] [-v] [-x]\n"
|
||||||
" ctladm shutdown\n"
|
" ctladm shutdown\n"
|
||||||
" ctladm startup\n"
|
" ctladm startup\n"
|
||||||
" ctladm hardstop\n"
|
|
||||||
" ctladm hardstart\n"
|
|
||||||
" ctladm lunlist\n"
|
" ctladm lunlist\n"
|
||||||
" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n"
|
" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n"
|
||||||
" ctladm bbrread [dev_id] <-l lba> <-d datalen>\n"
|
|
||||||
" ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n"
|
" ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n"
|
||||||
" [-t secs]\n"
|
" [-t secs]\n"
|
||||||
" ctladm realsync <on|off|query>\n"
|
" ctladm realsync <on|off|query>\n"
|
||||||
@ -4610,10 +4421,7 @@ usage(int error)
|
|||||||
"lunmap options:\n"
|
"lunmap options:\n"
|
||||||
"-p targ_port : specify target port number\n"
|
"-p targ_port : specify target port number\n"
|
||||||
"-L pLUN : specify port-visible LUN\n"
|
"-L pLUN : specify port-visible LUN\n"
|
||||||
"-L cLUN : specify CTL LUN\n"
|
"-L cLUN : specify CTL LUN\n",
|
||||||
"bbrread options:\n"
|
|
||||||
"-l lba : starting LBA\n"
|
|
||||||
"-d datalen : length, in bytes, to read\n",
|
|
||||||
CTL_DEFAULT_DEV);
|
CTL_DEFAULT_DEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4864,14 +4672,6 @@ main(int argc, char **argv)
|
|||||||
retval = cctl_startup_shutdown(fd, target, lun, initid,
|
retval = cctl_startup_shutdown(fd, target, lun, initid,
|
||||||
command);
|
command);
|
||||||
break;
|
break;
|
||||||
case CTLADM_CMD_HARDSTOP:
|
|
||||||
case CTLADM_CMD_HARDSTART:
|
|
||||||
retval = cctl_hardstopstart(fd, command);
|
|
||||||
break;
|
|
||||||
case CTLADM_CMD_BBRREAD:
|
|
||||||
retval = cctl_bbrread(fd, target, lun, initid, argc, argv,
|
|
||||||
combinedopt);
|
|
||||||
break;
|
|
||||||
case CTLADM_CMD_LUNLIST:
|
case CTLADM_CMD_LUNLIST:
|
||||||
retval = cctl_lunlist(fd);
|
retval = cctl_lunlist(fd);
|
||||||
break;
|
break;
|
||||||
|
@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <cam/scsi/scsi_message.h>
|
#include <cam/scsi/scsi_message.h>
|
||||||
#include <cam/ctl/ctl.h>
|
#include <cam/ctl/ctl.h>
|
||||||
#include <cam/ctl/ctl_io.h>
|
#include <cam/ctl/ctl_io.h>
|
||||||
#include <cam/ctl/ctl_frontend_internal.h>
|
|
||||||
#include <cam/ctl/ctl_backend.h>
|
#include <cam/ctl/ctl_backend.h>
|
||||||
#include <cam/ctl/ctl_ioctl.h>
|
#include <cam/ctl/ctl_ioctl.h>
|
||||||
#include <cam/ctl/ctl_backend_block.h>
|
#include <cam/ctl/ctl_backend_block.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user