Lines Matching defs:cbe_lun

157 	struct ctl_be_lun cbe_lun;		/* Must be first element. */
279 static void ctl_be_block_lun_shutdown(struct ctl_be_lun *cbe_lun);
282 static int ctl_be_block_lun_info(struct ctl_be_lun *cbe_lun, struct sbuf *sb);
283 static uint64_t ctl_be_block_lun_attr(struct ctl_be_lun *cbe_lun, const char *attrname);
495 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
578 if (cbe_lun->serseq >= CTL_LUN_SERSEQ_SOFT)
639 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
684 cbe_lun->serseq == CTL_LUN_SERSEQ_SOFT)
793 if (cbe_lun->serseq > CTL_LUN_SERSEQ_SOFT)
812 off = roff = ((off_t)lbalen->lba) * be_lun->cbe_lun.blocksize;
832 scsi_ulto4b(MIN(UINT32_MAX, off / be_lun->cbe_lun.blocksize -
854 val = vattr.va_bytes / be_lun->cbe_lun.blocksize;
861 be_lun->cbe_lun.blocksize;
871 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
915 cbe_lun->serseq == CTL_LUN_SERSEQ_SOFT)
964 if (cbe_lun->serseq > CTL_LUN_SERSEQ_SOFT)
991 off = roff = ((off_t)lbalen->lba) * be_lun->cbe_lun.blocksize;
1011 scsi_ulto4b(MIN(UINT32_MAX, off / be_lun->cbe_lun.blocksize -
1073 maxlen = LONG_MAX - (LONG_MAX % be_lun->cbe_lun.blocksize);
1083 bio->bio_pblkno = off / be_lun->cbe_lun.blocksize;
1128 be_lun->cbe_lun.blocksize;
1131 scsi_8btou64(buf->lba) * be_lun->cbe_lun.blocksize,
1185 bio->bio_pblkno = cur_offset / be_lun->cbe_lun.blocksize;
1243 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
1251 beio->io_len = lbalen->len * cbe_lun->blocksize;
1252 beio->io_offset = lbalen->lba * cbe_lun->blocksize;
1282 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
1309 beio->io_offset = lbalen->lba * cbe_lun->blocksize;
1310 beio->io_len = (uint64_t)lbalen->len * cbe_lun->blocksize;
1324 pb = cbe_lun->blocksize << be_lun->cbe_lun.pblockexp;
1325 if (be_lun->cbe_lun.pblockoff > 0)
1326 pbo = pb - cbe_lun->blocksize * be_lun->cbe_lun.pblockoff;
1329 len_left = (uint64_t)lbalen->len * cbe_lun->blocksize;
1335 if (pb > cbe_lun->blocksize) {
1336 adj = ((lbalen->lba + lba) * cbe_lun->blocksize +
1341 seglen -= seglen % cbe_lun->blocksize;
1343 seglen -= seglen % cbe_lun->blocksize;
1354 for (; buf < end; buf += cbe_lun->blocksize) {
1356 memset(buf, 0, cbe_lun->blocksize);
1359 cbe_lun->blocksize);
1367 beio->io_offset = lbalen->lba * cbe_lun->blocksize;
1368 beio->io_len = lba * cbe_lun->blocksize;
1547 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
1604 lbas = MIN(lbalen->len - bptrlen->len, lbas / cbe_lun->blocksize);
1605 beio->io_offset = (lbalen->lba + bptrlen->len) * cbe_lun->blocksize;
1606 beio->io_len = lbas * cbe_lun->blocksize;
1664 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
1682 if (cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) {
1695 if (cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) {
1708 if (cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) {
1721 if (cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) {
1810 struct ctl_be_lun *cbe_lun;
1818 cbe_lun = &be_lun->cbe_lun;
1828 cbe_lun->flags &= ~CTL_LUN_FLAG_UNMAP;
1851 cbe_lun->blocksize = params->blocksize_bytes;
1852 else if (cbe_lun->lun_type == T_CDROM)
1853 cbe_lun->blocksize = 2048;
1855 cbe_lun->blocksize = 512;
1856 be_lun->size_blocks = be_lun->size_bytes / cbe_lun->blocksize;
1857 cbe_lun->maxlba = (be_lun->size_blocks == 0) ?
1863 value = dnvlist_get_string(cbe_lun->options, "pblocksize", NULL);
1866 value = dnvlist_get_string(cbe_lun->options, "pblockoffset", NULL);
1869 pss = ps / cbe_lun->blocksize;
1870 pos = po / cbe_lun->blocksize;
1871 if ((pss > 0) && (pss * cbe_lun->blocksize == ps) && (pss >= pos) &&
1872 ((pss & (pss - 1)) == 0) && (pos * cbe_lun->blocksize == po)) {
1873 cbe_lun->pblockexp = fls(pss) - 1;
1874 cbe_lun->pblockoff = (pss - pos) % pss;
1877 value = dnvlist_get_string(cbe_lun->options, "ublocksize", NULL);
1880 value = dnvlist_get_string(cbe_lun->options, "ublockoffset", NULL);
1883 uss = us / cbe_lun->blocksize;
1884 uos = uo / cbe_lun->blocksize;
1885 if ((uss > 0) && (uss * cbe_lun->blocksize == us) && (uss >= uos) &&
1886 ((uss & (uss - 1)) == 0) && (uos * cbe_lun->blocksize == uo)) {
1887 cbe_lun->ublockexp = fls(uss) - 1;
1888 cbe_lun->ublockoff = (uss - uos) % uss;
1895 if (be_lun->size_bytes < cbe_lun->blocksize) {
1899 (uintmax_t)be_lun->size_bytes, cbe_lun->blocksize);
1902 cbe_lun->opttxferlen = CTLBLK_MAX_IO_SIZE / cbe_lun->blocksize;
1909 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
1967 cbe_lun->blocksize = params->blocksize_bytes;
1982 } else if (cbe_lun->lun_type == T_CDROM)
1983 cbe_lun->blocksize = MAX(tmp, 2048);
1985 cbe_lun->blocksize = tmp;
2012 be_lun->size_blocks = be_lun->size_bytes / cbe_lun->blocksize;
2013 cbe_lun->maxlba = (be_lun->size_blocks == 0) ?
2029 value = dnvlist_get_string(cbe_lun->options, "pblocksize", NULL);
2032 value = dnvlist_get_string(cbe_lun->options, "pblockoffset", NULL);
2035 pss = ps / cbe_lun->blocksize;
2036 pos = po / cbe_lun->blocksize;
2037 if ((pss > 0) && (pss * cbe_lun->blocksize == ps) && (pss >= pos) &&
2038 ((pss & (pss - 1)) == 0) && (pos * cbe_lun->blocksize == po)) {
2039 cbe_lun->pblockexp = fls(pss) - 1;
2040 cbe_lun->pblockoff = (pss - pos) % pss;
2043 value = dnvlist_get_string(cbe_lun->options, "ublocksize", NULL);
2046 value = dnvlist_get_string(cbe_lun->options, "ublockoffset", NULL);
2049 uss = us / cbe_lun->blocksize;
2050 uos = uo / cbe_lun->blocksize;
2051 if ((uss > 0) && (uss * cbe_lun->blocksize == us) && (uss >= uos) &&
2052 ((uss & (uss - 1)) == 0) && (uos * cbe_lun->blocksize == uo)) {
2053 cbe_lun->ublockexp = fls(uss) - 1;
2054 cbe_lun->ublockoff = (uss - uos) % uss;
2057 cbe_lun->atomicblock = atomic / cbe_lun->blocksize;
2058 cbe_lun->opttxferlen = maxio / cbe_lun->blocksize;
2071 value = dnvlist_get_string(cbe_lun->options, "unmap", NULL);
2075 cbe_lun->flags |= CTL_LUN_FLAG_UNMAP;
2077 cbe_lun->flags &= ~CTL_LUN_FLAG_UNMAP;
2086 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
2091 if ((cbe_lun->flags & CTL_LUN_FLAG_READONLY) == 0)
2119 struct ctl_be_lun *cbe_lun = &be_lun->cbe_lun;
2132 value = dnvlist_get_string(cbe_lun->options, "file", NULL);
2142 value = dnvlist_get_string(cbe_lun->options, "readonly", NULL);
2146 } else if (cbe_lun->lun_type == T_DIRECT)
2177 cbe_lun->flags &= ~CTL_LUN_FLAG_READONLY;
2179 cbe_lun->flags |= CTL_LUN_FLAG_READONLY;
2198 cbe_lun->serseq = CTL_LUN_SERSEQ_OFF;
2200 cbe_lun->serseq = CTL_LUN_SERSEQ_SOFT;
2201 value = dnvlist_get_string(cbe_lun->options, "serseq", NULL);
2203 cbe_lun->serseq = CTL_LUN_SERSEQ_ON;
2205 cbe_lun->serseq = CTL_LUN_SERSEQ_READ;
2207 cbe_lun->serseq = CTL_LUN_SERSEQ_SOFT;
2209 cbe_lun->serseq = CTL_LUN_SERSEQ_OFF;
2216 struct ctl_be_lun *cbe_lun;
2230 cbe_lun = &be_lun->cbe_lun;
2239 cbe_lun->options = nvlist_clone(req->args_nvl);
2242 cbe_lun->lun_type = params->device_type;
2244 cbe_lun->lun_type = T_DIRECT;
2246 cbe_lun->flags = 0;
2247 value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL);
2250 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
2252 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
2254 if (cbe_lun->lun_type == T_DIRECT ||
2255 cbe_lun->lun_type == T_CDROM) {
2258 cbe_lun->blocksize = params->blocksize_bytes;
2259 else if (cbe_lun->lun_type == T_CDROM)
2260 cbe_lun->blocksize = 2048;
2262 cbe_lun->blocksize = 512;
2263 be_lun->size_blocks = be_lun->size_bytes / cbe_lun->blocksize;
2264 cbe_lun->maxlba = (be_lun->size_blocks == 0) ?
2267 if ((cbe_lun->flags & CTL_LUN_FLAG_PRIMARY) ||
2280 value = dnvlist_get_string(cbe_lun->options, "num_threads", NULL);
2299 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2302 params->blocksize_bytes = cbe_lun->blocksize;
2304 cbe_lun->req_lun_id = params->req_lun_id;
2305 cbe_lun->flags |= CTL_LUN_FLAG_ID_REQ;
2307 cbe_lun->req_lun_id = 0;
2309 cbe_lun->lun_shutdown = ctl_be_block_lun_shutdown;
2310 cbe_lun->be = &ctl_be_block_driver;
2315 strncpy((char *)cbe_lun->serial_num, tmpstr,
2316 MIN(sizeof(cbe_lun->serial_num), sizeof(tmpstr)));
2322 strncpy((char *)cbe_lun->serial_num, params->serial_num,
2323 MIN(sizeof(cbe_lun->serial_num),
2328 strncpy((char *)cbe_lun->device_id, tmpstr,
2329 MIN(sizeof(cbe_lun->device_id), sizeof(tmpstr)));
2335 strncpy((char *)cbe_lun->device_id, params->device_id,
2336 MIN(sizeof(cbe_lun->device_id),
2376 retval = ctl_add_lun(&be_lun->cbe_lun);
2385 be_lun->disk_stats = devstat_new_entry("cbb", cbe_lun->lun_id,
2386 cbe_lun->blocksize,
2388 cbe_lun->lun_type
2397 params->req_lun_id = cbe_lun->lun_id;
2409 nvlist_destroy(cbe_lun->options);
2422 struct ctl_be_lun *cbe_lun;
2430 if (be_lun->cbe_lun.lun_id == params->lun_id) {
2445 cbe_lun = &be_lun->cbe_lun;
2448 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2449 ctl_lun_no_media(cbe_lun);
2458 retval = ctl_remove_lun(cbe_lun);
2497 struct ctl_be_lun *cbe_lun;
2507 if (be_lun->cbe_lun.lun_id == params->lun_id)
2517 cbe_lun = &be_lun->cbe_lun;
2523 nvlist_destroy(cbe_lun->options);
2524 cbe_lun->options = nvlist_clone(req->args_nvl);
2527 wasprim = (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY);
2528 value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL);
2531 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
2533 cbe_lun->flags &= ~CTL_LUN_FLAG_PRIMARY;
2535 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
2537 cbe_lun->flags &= ~CTL_LUN_FLAG_PRIMARY;
2538 if (wasprim != (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY)) {
2539 if (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY)
2540 ctl_lun_primary(cbe_lun);
2542 ctl_lun_secondary(cbe_lun);
2546 if ((cbe_lun->flags & CTL_LUN_FLAG_PRIMARY) ||
2558 if ((cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) &&
2560 cbe_lun->flags &= ~CTL_LUN_FLAG_NO_MEDIA;
2561 ctl_lun_has_media(cbe_lun);
2562 } else if ((cbe_lun->flags & CTL_LUN_FLAG_NO_MEDIA) == 0 &&
2564 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2565 ctl_lun_no_media(cbe_lun);
2567 cbe_lun->flags &= ~CTL_LUN_FLAG_EJECTED;
2570 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2571 ctl_lun_no_media(cbe_lun);
2578 ctl_lun_capacity_changed(cbe_lun);
2594 ctl_be_block_lun_shutdown(struct ctl_be_lun *cbe_lun)
2596 struct ctl_be_block_lun *be_lun = (struct ctl_be_block_lun *)cbe_lun;
2603 nvlist_destroy(be_lun->cbe_lun.options);
2621 struct ctl_be_lun *cbe_lun;
2626 cbe_lun = CTL_BACKEND_LUN(io);
2627 be_lun = (struct ctl_be_block_lun *)cbe_lun;
2663 cbe_lun->flags &= ~CTL_LUN_FLAG_EJECTED;
2665 cbe_lun->flags &= ~CTL_LUN_FLAG_NO_MEDIA;
2666 ctl_lun_has_media(cbe_lun);
2668 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2669 ctl_lun_no_media(cbe_lun);
2672 ctl_start_lun(cbe_lun);
2674 ctl_stop_lun(cbe_lun);
2676 cbe_lun->flags |= CTL_LUN_FLAG_NO_MEDIA;
2677 cbe_lun->flags |= CTL_LUN_FLAG_EJECTED;
2678 ctl_lun_ejected(cbe_lun);
2744 ctl_be_block_lun_info(struct ctl_be_lun *cbe_lun, struct sbuf *sb)
2746 struct ctl_be_block_lun *lun = (struct ctl_be_block_lun *)cbe_lun;
2762 ctl_be_block_lun_attr(struct ctl_be_lun *cbe_lun, const char *attrname)
2764 struct ctl_be_block_lun *lun = (struct ctl_be_block_lun *)cbe_lun;
2805 ctl_remove_lun(&lun->cbe_lun);