Deleted Added
full compact
kernel.c (288259) kernel.c (288310)
1/*-
2 * Copyright (c) 2003, 2004 Silicon Graphics International Corp.
3 * Copyright (c) 1997-2007 Kenneth D. Merry
4 * Copyright (c) 2012 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Edward Tomasz Napierala
8 * under sponsorship from the FreeBSD Foundation.

--- 21 unchanged lines hidden (view full) ---

30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGES.
34 *
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003, 2004 Silicon Graphics International Corp.
3 * Copyright (c) 1997-2007 Kenneth D. Merry
4 * Copyright (c) 2012 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Edward Tomasz Napierala
8 * under sponsorship from the FreeBSD Foundation.

--- 21 unchanged lines hidden (view full) ---

30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGES.
34 *
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/usr.sbin/ctld/kernel.c 288259 2015-09-26 11:28:45Z mav $");
38__FBSDID("$FreeBSD: head/usr.sbin/ctld/kernel.c 288310 2015-09-27 13:47:28Z mav $");
39
40#include <sys/ioctl.h>
41#include <sys/types.h>
42#include <sys/stat.h>
43#include <sys/param.h>
44#include <sys/linker.h>
45#include <sys/queue.h>
46#include <sys/callout.h>

--- 56 unchanged lines hidden (view full) ---

103};
104
105/*
106 * Backend LUN information.
107 */
108struct cctl_lun {
109 uint64_t lun_id;
110 char *backend_type;
39
40#include <sys/ioctl.h>
41#include <sys/types.h>
42#include <sys/stat.h>
43#include <sys/param.h>
44#include <sys/linker.h>
45#include <sys/queue.h>
46#include <sys/callout.h>

--- 56 unchanged lines hidden (view full) ---

103};
104
105/*
106 * Backend LUN information.
107 */
108struct cctl_lun {
109 uint64_t lun_id;
110 char *backend_type;
111 uint8_t device_type;
111 uint64_t size_blocks;
112 uint32_t blocksize;
113 char *serial_number;
114 char *device_id;
115 char *ctld_name;
116 STAILQ_HEAD(,cctl_lun_nv) attr_list;
117 STAILQ_ENTRY(cctl_lun) links;
118};

--- 97 unchanged lines hidden (view full) ---

216
217 sbuf_delete(devlist->cur_sb[devlist->level]);
218 devlist->cur_sb[devlist->level] = NULL;
219 devlist->level--;
220
221 if (strcmp(name, "backend_type") == 0) {
222 cur_lun->backend_type = str;
223 str = NULL;
112 uint64_t size_blocks;
113 uint32_t blocksize;
114 char *serial_number;
115 char *device_id;
116 char *ctld_name;
117 STAILQ_HEAD(,cctl_lun_nv) attr_list;
118 STAILQ_ENTRY(cctl_lun) links;
119};

--- 97 unchanged lines hidden (view full) ---

217
218 sbuf_delete(devlist->cur_sb[devlist->level]);
219 devlist->cur_sb[devlist->level] = NULL;
220 devlist->level--;
221
222 if (strcmp(name, "backend_type") == 0) {
223 cur_lun->backend_type = str;
224 str = NULL;
225 } else if (strcmp(name, "lun_type") == 0) {
226 cur_lun->device_type = strtoull(str, NULL, 0);
224 } else if (strcmp(name, "size") == 0) {
225 cur_lun->size_blocks = strtoull(str, NULL, 0);
226 } else if (strcmp(name, "blocksize") == 0) {
227 cur_lun->blocksize = strtoul(str, NULL, 0);
228 } else if (strcmp(name, "serial_number") == 0) {
229 cur_lun->serial_number = str;
230 str = NULL;
231 } else if (strcmp(name, "device_id") == 0) {

--- 373 unchanged lines hidden (view full) ---

605 (uintmax_t)lun->lun_id, lun->ctld_name);
606
607 cl = lun_new(conf, lun->ctld_name);
608 if (cl == NULL) {
609 log_warnx("lun_new failed");
610 continue;
611 }
612 lun_set_backend(cl, lun->backend_type);
227 } else if (strcmp(name, "size") == 0) {
228 cur_lun->size_blocks = strtoull(str, NULL, 0);
229 } else if (strcmp(name, "blocksize") == 0) {
230 cur_lun->blocksize = strtoul(str, NULL, 0);
231 } else if (strcmp(name, "serial_number") == 0) {
232 cur_lun->serial_number = str;
233 str = NULL;
234 } else if (strcmp(name, "device_id") == 0) {

--- 373 unchanged lines hidden (view full) ---

608 (uintmax_t)lun->lun_id, lun->ctld_name);
609
610 cl = lun_new(conf, lun->ctld_name);
611 if (cl == NULL) {
612 log_warnx("lun_new failed");
613 continue;
614 }
615 lun_set_backend(cl, lun->backend_type);
616 lun_set_device_type(cl, lun->device_type);
613 lun_set_blocksize(cl, lun->blocksize);
614 lun_set_device_id(cl, lun->device_id);
615 lun_set_serial(cl, lun->serial_number);
616 lun_set_size(cl, lun->size_blocks * cl->l_blocksize);
617 lun_set_ctl_lun(cl, lun->lun_id);
618
619 STAILQ_FOREACH(nv, &lun->attr_list, links) {
620 if (strcmp(nv->name, "file") == 0 ||

--- 42 unchanged lines hidden (view full) ---

663 req.reqdata.create.lun_size_bytes = lun->l_size;
664
665 if (lun->l_ctl_lun >= 0) {
666 req.reqdata.create.req_lun_id = lun->l_ctl_lun;
667 req.reqdata.create.flags |= CTL_LUN_FLAG_ID_REQ;
668 }
669
670 req.reqdata.create.flags |= CTL_LUN_FLAG_DEV_TYPE;
617 lun_set_blocksize(cl, lun->blocksize);
618 lun_set_device_id(cl, lun->device_id);
619 lun_set_serial(cl, lun->serial_number);
620 lun_set_size(cl, lun->size_blocks * cl->l_blocksize);
621 lun_set_ctl_lun(cl, lun->lun_id);
622
623 STAILQ_FOREACH(nv, &lun->attr_list, links) {
624 if (strcmp(nv->name, "file") == 0 ||

--- 42 unchanged lines hidden (view full) ---

667 req.reqdata.create.lun_size_bytes = lun->l_size;
668
669 if (lun->l_ctl_lun >= 0) {
670 req.reqdata.create.req_lun_id = lun->l_ctl_lun;
671 req.reqdata.create.flags |= CTL_LUN_FLAG_ID_REQ;
672 }
673
674 req.reqdata.create.flags |= CTL_LUN_FLAG_DEV_TYPE;
671 req.reqdata.create.device_type = T_DIRECT;
675 req.reqdata.create.device_type = lun->l_device_type;
672
673 if (lun->l_serial != NULL) {
674 strncpy(req.reqdata.create.serial_num, lun->l_serial,
675 sizeof(req.reqdata.create.serial_num));
676 req.reqdata.create.flags |= CTL_LUN_FLAG_SERIAL_NUM;
677 }
678
679 if (lun->l_device_id != NULL) {

--- 584 unchanged lines hidden ---
676
677 if (lun->l_serial != NULL) {
678 strncpy(req.reqdata.create.serial_num, lun->l_serial,
679 sizeof(req.reqdata.create.serial_num));
680 req.reqdata.create.flags |= CTL_LUN_FLAG_SERIAL_NUM;
681 }
682
683 if (lun->l_device_id != NULL) {

--- 584 unchanged lines hidden ---