diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 11:30:18 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 11:30:18 +0000 |
commit | 3e85febb126fcf3fc33ad9460816254312716ff6 (patch) | |
tree | 92e9b1a78fb5ea854e3363a3c1ee70c0de6022ac /usr.sbin | |
parent | c019c6978215679df0e5954ea514dbe52fb17c8e (diff) | |
download | FreeBSD-src-3e85febb126fcf3fc33ad9460816254312716ff6.zip FreeBSD-src-3e85febb126fcf3fc33ad9460816254312716ff6.tar.gz |
MFC r288310: Add to CTL initial support for CDROMs and removable devices.
Relnotes: yes
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ctladm/ctladm.8 | 7 | ||||
-rw-r--r-- | usr.sbin/ctld/ctl.conf.5 | 6 | ||||
-rw-r--r-- | usr.sbin/ctld/ctld.c | 7 | ||||
-rw-r--r-- | usr.sbin/ctld/ctld.h | 2 | ||||
-rw-r--r-- | usr.sbin/ctld/kernel.c | 6 | ||||
-rw-r--r-- | usr.sbin/ctld/parse.y | 31 | ||||
-rw-r--r-- | usr.sbin/ctld/token.l | 1 |
7 files changed, 53 insertions, 7 deletions
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8 index ba582b7..7ff0c8d 100644 --- a/usr.sbin/ctladm/ctladm.8 +++ b/usr.sbin/ctladm/ctladm.8 @@ -717,11 +717,10 @@ Specify the serial number to be used in the INQUIRY VPD page 0x80 data. .It Fl t Ar device_type Specify the numeric SCSI device type to use when creating the LUN. -For example, the Direct Access type is 0. If this flag is not used, the type of LUN created is backend-specific. Not all LUN types are supported. -Currently CTL only supports Direct Access (type 0) and Processor (type 3) -LUNs. +Currently CTL supports Direct Access (type 0), Processor (type 3) +and CD/DVD (type 5) LUNs. The backend requested may or may not support all of the LUN types that CTL supports. .El @@ -876,6 +875,8 @@ Set to "off", disables read caching for the LUN, if supported by the backend. .It Va readonly Set to "on", blocks all media write operations to the LUN, reporting it as write protected. +.It Va removable +Set to "on", makes LUN removable. .It Va reordering Set to "unrestricted", allows target to process commands with SIMPLE task attribute in arbitrary order. Any data integrity exposures related to diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 index a05f89d..ce8df67a 100644 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2015 +.Dd September 27, 2015 .Dt CTL.CONF 5 .Os .Sh NAME @@ -371,6 +371,10 @@ By default CTL allocates those IDs dynamically, but explicit specification may be needed for consistency in HA configurations. .It Ic device-id Ar string The SCSI Device Identification string presented to the initiator. +.It Ic device-type Ar type +Specify the SCSI device type to use when creating the LUN. +Currently CTL supports Direct Access (type 0), Processor (type 3) +and CD/DVD (type 5) LUNs. .It Ic option Ar name Ar value The CTL-specific options passed to the kernel. All CTL-specific options are documented in the diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 8b13bce..741a713 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1439,6 +1439,13 @@ lun_set_blocksize(struct lun *lun, size_t value) } void +lun_set_device_type(struct lun *lun, uint8_t value) +{ + + lun->l_device_type = value; +} + +void lun_set_device_id(struct lun *lun, const char *value) { free(lun->l_device_id); diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h index 8faa556..3e26237 100644 --- a/usr.sbin/ctld/ctld.h +++ b/usr.sbin/ctld/ctld.h @@ -163,6 +163,7 @@ struct lun { TAILQ_HEAD(, lun_option) l_options; char *l_name; char *l_backend; + uint8_t l_device_type; int l_blocksize; char *l_device_id; char *l_path; @@ -371,6 +372,7 @@ struct lun *lun_new(struct conf *conf, const char *name); void lun_delete(struct lun *lun); struct lun *lun_find(const struct conf *conf, const char *name); void lun_set_backend(struct lun *lun, const char *value); +void lun_set_device_type(struct lun *lun, uint8_t value); void lun_set_blocksize(struct lun *lun, size_t value); void lun_set_device_id(struct lun *lun, const char *value); void lun_set_path(struct lun *lun, const char *value); diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index d9cf54f..dea1917 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -108,6 +108,7 @@ struct cctl_lun_nv { struct cctl_lun { uint64_t lun_id; char *backend_type; + uint8_t device_type; uint64_t size_blocks; uint32_t blocksize; char *serial_number; @@ -221,6 +222,8 @@ cctl_end_element(void *user_data, const char *name) if (strcmp(name, "backend_type") == 0) { cur_lun->backend_type = str; str = NULL; + } else if (strcmp(name, "lun_type") == 0) { + cur_lun->device_type = strtoull(str, NULL, 0); } else if (strcmp(name, "size") == 0) { cur_lun->size_blocks = strtoull(str, NULL, 0); } else if (strcmp(name, "blocksize") == 0) { @@ -610,6 +613,7 @@ retry_port: continue; } lun_set_backend(cl, lun->backend_type); + lun_set_device_type(cl, lun->device_type); lun_set_blocksize(cl, lun->blocksize); lun_set_device_id(cl, lun->device_id); lun_set_serial(cl, lun->serial_number); @@ -668,7 +672,7 @@ kernel_lun_add(struct lun *lun) } req.reqdata.create.flags |= CTL_LUN_FLAG_DEV_TYPE; - req.reqdata.create.device_type = T_DIRECT; + req.reqdata.create.device_type = lun->l_device_type; if (lun->l_serial != NULL) { strncpy(req.reqdata.create.serial_num, lun->l_serial, diff --git a/usr.sbin/ctld/parse.y b/usr.sbin/ctld/parse.y index 92d4d3e..1e40dd8 100644 --- a/usr.sbin/ctld/parse.y +++ b/usr.sbin/ctld/parse.y @@ -57,8 +57,8 @@ extern void yyrestart(FILE *); %} %token ALIAS AUTH_GROUP AUTH_TYPE BACKEND BLOCKSIZE CHAP CHAP_MUTUAL -%token CLOSING_BRACKET CTL_LUN DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP -%token DISCOVERY_FILTER FOREIGN +%token CLOSING_BRACKET CTL_LUN DEBUG DEVICE_ID DEVICE_TYPE +%token DISCOVERY_AUTH_GROUP DISCOVERY_FILTER FOREIGN %token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT %token LISTEN LISTEN_ISER LUN MAXPROC OPENING_BRACKET OPTION %token PATH PIDFILE PORT PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR @@ -842,6 +842,8 @@ lun_entry: | lun_device_id | + lun_device_type + | lun_ctl_lun | lun_option @@ -901,6 +903,31 @@ lun_device_id: DEVICE_ID STR } ; +lun_device_type: DEVICE_TYPE STR + { + uint64_t tmp; + + if (strcasecmp($2, "disk") == 0 || + strcasecmp($2, "direct") == 0) + tmp = 0; + else if (strcasecmp($2, "processor") == 0) + tmp = 3; + else if (strcasecmp($2, "cd") == 0 || + strcasecmp($2, "cdrom") == 0 || + strcasecmp($2, "dvd") == 0 || + strcasecmp($2, "dvdrom") == 0) + tmp = 5; + else if (expand_number($2, &tmp) != 0 || + tmp > 15) { + yyerror("invalid numeric value"); + free($2); + return (1); + } + + lun_set_device_type(lun, tmp); + } + ; + lun_ctl_lun: CTL_LUN STR { uint64_t tmp; diff --git a/usr.sbin/ctld/token.l b/usr.sbin/ctld/token.l index ce95e62..e23385f 100644 --- a/usr.sbin/ctld/token.l +++ b/usr.sbin/ctld/token.l @@ -57,6 +57,7 @@ chap-mutual { return CHAP_MUTUAL; } ctl-lun { return CTL_LUN; } debug { return DEBUG; } device-id { return DEVICE_ID; } +device-type { return DEVICE_TYPE; } discovery-auth-group { return DISCOVERY_AUTH_GROUP; } discovery-filter { return DISCOVERY_FILTER; } foreign { return FOREIGN; } |