Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/ctl/ctl_backend_ramdisk.c
Context not available. | |||||
#include <sys/ioccom.h> | #include <sys/ioccom.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/nv.h> | |||||
#include <sys/dnv.h> | |||||
#include <cam/scsi/scsi_all.h> | #include <cam/scsi/scsi_all.h> | ||||
#include <cam/scsi/scsi_da.h> | #include <cam/scsi/scsi_da.h> | ||||
Context not available. | |||||
if (retval == 0) { | if (retval == 0) { | ||||
taskqueue_drain_all(be_lun->io_taskqueue); | taskqueue_drain_all(be_lun->io_taskqueue); | ||||
taskqueue_free(be_lun->io_taskqueue); | taskqueue_free(be_lun->io_taskqueue); | ||||
ctl_free_opts(&be_lun->cbe_lun.options); | nvlist_destroy(be_lun->cbe_lun.options); | ||||
free(be_lun->zero_page, M_RAMDISK); | free(be_lun->zero_page, M_RAMDISK); | ||||
ctl_backend_ramdisk_freeallpages(be_lun->pages, be_lun->indir); | ctl_backend_ramdisk_freeallpages(be_lun->pages, be_lun->indir); | ||||
sx_destroy(&be_lun->page_lock); | sx_destroy(&be_lun->page_lock); | ||||
Context not available. | |||||
struct ctl_be_ramdisk_lun *be_lun; | struct ctl_be_ramdisk_lun *be_lun; | ||||
struct ctl_be_lun *cbe_lun; | struct ctl_be_lun *cbe_lun; | ||||
struct ctl_lun_create_params *params; | struct ctl_lun_create_params *params; | ||||
char *value; | const char *value; | ||||
char tmpstr[32]; | char tmpstr[32]; | ||||
uint64_t t; | uint64_t t; | ||||
int retval; | int retval; | ||||
Context not available. | |||||
be_lun = malloc(sizeof(*be_lun), M_RAMDISK, M_ZERO | M_WAITOK); | be_lun = malloc(sizeof(*be_lun), M_RAMDISK, M_ZERO | M_WAITOK); | ||||
cbe_lun = &be_lun->cbe_lun; | cbe_lun = &be_lun->cbe_lun; | ||||
cbe_lun->be_lun = be_lun; | cbe_lun->be_lun = be_lun; | ||||
cbe_lun->options = nvlist_clone(req->args_nvl); | |||||
be_lun->params = req->reqdata.create; | be_lun->params = req->reqdata.create; | ||||
be_lun->softc = softc; | be_lun->softc = softc; | ||||
sprintf(be_lun->lunname, "cram%d", softc->num_luns); | sprintf(be_lun->lunname, "cram%d", softc->num_luns); | ||||
ctl_init_opts(&cbe_lun->options, req->num_be_args, req->kern_be_args); | |||||
if (params->flags & CTL_LUN_FLAG_DEV_TYPE) | if (params->flags & CTL_LUN_FLAG_DEV_TYPE) | ||||
cbe_lun->lun_type = params->device_type; | cbe_lun->lun_type = params->device_type; | ||||
Context not available. | |||||
cbe_lun->lun_type = T_DIRECT; | cbe_lun->lun_type = T_DIRECT; | ||||
be_lun->flags = CTL_BE_RAMDISK_LUN_UNCONFIGURED; | be_lun->flags = CTL_BE_RAMDISK_LUN_UNCONFIGURED; | ||||
cbe_lun->flags = 0; | cbe_lun->flags = 0; | ||||
value = ctl_get_opt(&cbe_lun->options, "ha_role"); | value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
if (strcmp(value, "primary") == 0) | if (strcmp(value, "primary") == 0) | ||||
cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | ||||
Context not available. | |||||
cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | ||||
be_lun->pblocksize = PAGE_SIZE; | be_lun->pblocksize = PAGE_SIZE; | ||||
value = ctl_get_opt(&cbe_lun->options, "pblocksize"); | value = dnvlist_get_string(cbe_lun->options, "pblocksize", NULL); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
ctl_expand_number(value, &t); | ctl_expand_number(value, &t); | ||||
be_lun->pblocksize = t; | be_lun->pblocksize = t; | ||||
Context not available. | |||||
cbe_lun->ublockoff = 0; | cbe_lun->ublockoff = 0; | ||||
cbe_lun->atomicblock = be_lun->pblocksize; | cbe_lun->atomicblock = be_lun->pblocksize; | ||||
cbe_lun->opttxferlen = SGPP * be_lun->pblocksize; | cbe_lun->opttxferlen = SGPP * be_lun->pblocksize; | ||||
value = ctl_get_opt(&cbe_lun->options, "capacity"); | value = dnvlist_get_string(cbe_lun->options, "capacity", NULL); | ||||
if (value != NULL) | if (value != NULL) | ||||
ctl_expand_number(value, &be_lun->cap_bytes); | ctl_expand_number(value, &be_lun->cap_bytes); | ||||
} else { | } else { | ||||
Context not available. | |||||
params->blocksize_bytes = cbe_lun->blocksize; | params->blocksize_bytes = cbe_lun->blocksize; | ||||
params->lun_size_bytes = be_lun->size_bytes; | params->lun_size_bytes = be_lun->size_bytes; | ||||
value = ctl_get_opt(&cbe_lun->options, "unmap"); | value = dnvlist_get_string(cbe_lun->options, "unmap", NULL); | ||||
if (value == NULL || strcmp(value, "off") != 0) | if (value != NULL && strcmp(value, "off") != 0) | ||||
cbe_lun->flags |= CTL_LUN_FLAG_UNMAP; | cbe_lun->flags |= CTL_LUN_FLAG_UNMAP; | ||||
value = ctl_get_opt(&cbe_lun->options, "readonly"); | value = dnvlist_get_string(cbe_lun->options, "readonly", NULL); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
if (strcmp(value, "on") == 0) | if (strcmp(value, "on") == 0) | ||||
cbe_lun->flags |= CTL_LUN_FLAG_READONLY; | cbe_lun->flags |= CTL_LUN_FLAG_READONLY; | ||||
Context not available. | |||||
} else if (cbe_lun->lun_type != T_DIRECT) | } else if (cbe_lun->lun_type != T_DIRECT) | ||||
cbe_lun->flags |= CTL_LUN_FLAG_READONLY; | cbe_lun->flags |= CTL_LUN_FLAG_READONLY; | ||||
cbe_lun->serseq = CTL_LUN_SERSEQ_OFF; | cbe_lun->serseq = CTL_LUN_SERSEQ_OFF; | ||||
value = ctl_get_opt(&cbe_lun->options, "serseq"); | value = dnvlist_get_string(cbe_lun->options, "serseq", NULL); | ||||
if (value != NULL && strcmp(value, "on") == 0) | if (value != NULL && strcmp(value, "on") == 0) | ||||
cbe_lun->serseq = CTL_LUN_SERSEQ_ON; | cbe_lun->serseq = CTL_LUN_SERSEQ_ON; | ||||
else if (value != NULL && strcmp(value, "read") == 0) | else if (value != NULL && strcmp(value, "read") == 0) | ||||
Context not available. | |||||
if (be_lun != NULL) { | if (be_lun != NULL) { | ||||
if (be_lun->io_taskqueue != NULL) | if (be_lun->io_taskqueue != NULL) | ||||
taskqueue_free(be_lun->io_taskqueue); | taskqueue_free(be_lun->io_taskqueue); | ||||
ctl_free_opts(&cbe_lun->options); | nvlist_destroy(cbe_lun->options); | ||||
free(be_lun->zero_page, M_RAMDISK); | free(be_lun->zero_page, M_RAMDISK); | ||||
ctl_backend_ramdisk_freeallpages(be_lun->pages, be_lun->indir); | ctl_backend_ramdisk_freeallpages(be_lun->pages, be_lun->indir); | ||||
sx_destroy(&be_lun->page_lock); | sx_destroy(&be_lun->page_lock); | ||||
Context not available. | |||||
struct ctl_be_ramdisk_lun *be_lun; | struct ctl_be_ramdisk_lun *be_lun; | ||||
struct ctl_be_lun *cbe_lun; | struct ctl_be_lun *cbe_lun; | ||||
struct ctl_lun_modify_params *params; | struct ctl_lun_modify_params *params; | ||||
char *value; | const char *value; | ||||
uint32_t blocksize; | uint32_t blocksize; | ||||
int wasprim; | int wasprim; | ||||
Context not available. | |||||
if (params->lun_size_bytes != 0) | if (params->lun_size_bytes != 0) | ||||
be_lun->params.lun_size_bytes = params->lun_size_bytes; | be_lun->params.lun_size_bytes = params->lun_size_bytes; | ||||
ctl_update_opts(&cbe_lun->options, req->num_be_args, req->kern_be_args); | |||||
nvlist_destroy(cbe_lun->options); | |||||
cbe_lun->options = nvlist_clone(req->args_nvl); | |||||
wasprim = (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY); | wasprim = (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY); | ||||
value = ctl_get_opt(&cbe_lun->options, "ha_role"); | value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
if (strcmp(value, "primary") == 0) | if (strcmp(value, "primary") == 0) | ||||
cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY; | ||||
Context not available. |