Deleted Added
full compact
ctl_backend_block.c (275881) ctl_backend_block.c (275892)
1/*-
2 * Copyright (c) 2003 Silicon Graphics International Corp.
3 * Copyright (c) 2009-2011 Spectra Logic Corporation
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.

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

35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $
36 */
37/*
38 * CAM Target Layer driver backend for block devices.
39 *
40 * Author: Ken Merry <ken@FreeBSD.org>
41 */
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Silicon Graphics International Corp.
3 * Copyright (c) 2009-2011 Spectra Logic Corporation
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.

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

35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $
36 */
37/*
38 * CAM Target Layer driver backend for block devices.
39 *
40 * Author: Ken Merry <ken@FreeBSD.org>
41 */
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_backend_block.c 275881 2014-12-18 08:25:00Z mav $");
43__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_backend_block.c 275892 2014-12-18 08:38:07Z mav $");
44
45#include <opt_kdtrace.h>
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/kernel.h>
50#include <sys/types.h>
51#include <sys/kthread.h>

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

65#include <sys/buf.h>
66#include <sys/taskqueue.h>
67#include <sys/vnode.h>
68#include <sys/namei.h>
69#include <sys/mount.h>
70#include <sys/disk.h>
71#include <sys/fcntl.h>
72#include <sys/filedesc.h>
44
45#include <opt_kdtrace.h>
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/kernel.h>
50#include <sys/types.h>
51#include <sys/kthread.h>

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

65#include <sys/buf.h>
66#include <sys/taskqueue.h>
67#include <sys/vnode.h>
68#include <sys/namei.h>
69#include <sys/mount.h>
70#include <sys/disk.h>
71#include <sys/fcntl.h>
72#include <sys/filedesc.h>
73#include <sys/filio.h>
73#include <sys/proc.h>
74#include <sys/pcpu.h>
75#include <sys/module.h>
76#include <sys/sdt.h>
77#include <sys/devicestat.h>
78#include <sys/sysctl.h>
79
80#include <geom/geom.h>

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

160 char lunname[32];
161 char *dev_path;
162 ctl_be_block_type dev_type;
163 struct vnode *vn;
164 union ctl_be_block_bedata backend;
165 cbb_dispatch_t dispatch;
166 cbb_dispatch_t lun_flush;
167 cbb_dispatch_t unmap;
74#include <sys/proc.h>
75#include <sys/pcpu.h>
76#include <sys/module.h>
77#include <sys/sdt.h>
78#include <sys/devicestat.h>
79#include <sys/sysctl.h>
80
81#include <geom/geom.h>

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

161 char lunname[32];
162 char *dev_path;
163 ctl_be_block_type dev_type;
164 struct vnode *vn;
165 union ctl_be_block_bedata backend;
166 cbb_dispatch_t dispatch;
167 cbb_dispatch_t lun_flush;
168 cbb_dispatch_t unmap;
169 cbb_dispatch_t get_lba_status;
168 cbb_getattr_t getattr;
169 uma_zone_t lun_zone;
170 uint64_t size_blocks;
171 uint64_t size_bytes;
172 uint32_t blocksize;
173 int blocksize_shift;
174 uint16_t pblockexp;
175 uint16_t pblockoff;
176 struct ctl_be_block_softc *softc;
177 struct devstat *disk_stats;
178 ctl_be_block_lun_flags flags;
179 STAILQ_ENTRY(ctl_be_block_lun) links;
180 struct ctl_be_lun ctl_be_lun;
181 struct taskqueue *io_taskqueue;
182 struct task io_task;
183 int num_threads;
184 STAILQ_HEAD(, ctl_io_hdr) input_queue;
170 cbb_getattr_t getattr;
171 uma_zone_t lun_zone;
172 uint64_t size_blocks;
173 uint64_t size_bytes;
174 uint32_t blocksize;
175 int blocksize_shift;
176 uint16_t pblockexp;
177 uint16_t pblockoff;
178 struct ctl_be_block_softc *softc;
179 struct devstat *disk_stats;
180 ctl_be_block_lun_flags flags;
181 STAILQ_ENTRY(ctl_be_block_lun) links;
182 struct ctl_be_lun ctl_be_lun;
183 struct taskqueue *io_taskqueue;
184 struct task io_task;
185 int num_threads;
186 STAILQ_HEAD(, ctl_io_hdr) input_queue;
187 STAILQ_HEAD(, ctl_io_hdr) config_read_queue;
185 STAILQ_HEAD(, ctl_io_hdr) config_write_queue;
186 STAILQ_HEAD(, ctl_io_hdr) datamove_queue;
187 struct mtx_padalign io_lock;
188 struct mtx_padalign queue_lock;
189};
190
191/*
192 * Overall softc structure for the block backend module.

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

235static void ctl_free_beio(struct ctl_be_block_io *beio);
236static void ctl_complete_beio(struct ctl_be_block_io *beio);
237static int ctl_be_block_move_done(union ctl_io *io);
238static void ctl_be_block_biodone(struct bio *bio);
239static void ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun,
240 struct ctl_be_block_io *beio);
241static void ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
242 struct ctl_be_block_io *beio);
188 STAILQ_HEAD(, ctl_io_hdr) config_write_queue;
189 STAILQ_HEAD(, ctl_io_hdr) datamove_queue;
190 struct mtx_padalign io_lock;
191 struct mtx_padalign queue_lock;
192};
193
194/*
195 * Overall softc structure for the block backend module.

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

238static void ctl_free_beio(struct ctl_be_block_io *beio);
239static void ctl_complete_beio(struct ctl_be_block_io *beio);
240static int ctl_be_block_move_done(union ctl_io *io);
241static void ctl_be_block_biodone(struct bio *bio);
242static void ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun,
243 struct ctl_be_block_io *beio);
244static void ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
245 struct ctl_be_block_io *beio);
246static void ctl_be_block_gls_file(struct ctl_be_block_lun *be_lun,
247 struct ctl_be_block_io *beio);
243static void ctl_be_block_flush_dev(struct ctl_be_block_lun *be_lun,
244 struct ctl_be_block_io *beio);
245static void ctl_be_block_unmap_dev(struct ctl_be_block_lun *be_lun,
246 struct ctl_be_block_io *beio);
247static void ctl_be_block_dispatch_dev(struct ctl_be_block_lun *be_lun,
248 struct ctl_be_block_io *beio);
249static uint64_t ctl_be_block_getattr_dev(struct ctl_be_block_lun *be_lun,
250 const char *attrname);
248static void ctl_be_block_flush_dev(struct ctl_be_block_lun *be_lun,
249 struct ctl_be_block_io *beio);
250static void ctl_be_block_unmap_dev(struct ctl_be_block_lun *be_lun,
251 struct ctl_be_block_io *beio);
252static void ctl_be_block_dispatch_dev(struct ctl_be_block_lun *be_lun,
253 struct ctl_be_block_io *beio);
254static uint64_t ctl_be_block_getattr_dev(struct ctl_be_block_lun *be_lun,
255 const char *attrname);
256static void ctl_be_block_cr_dispatch(struct ctl_be_block_lun *be_lun,
257 union ctl_io *io);
251static void ctl_be_block_cw_dispatch(struct ctl_be_block_lun *be_lun,
252 union ctl_io *io);
253static void ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun,
254 union ctl_io *io);
255static void ctl_be_block_worker(void *context, int pending);
256static int ctl_be_block_submit(union ctl_io *io);
257static int ctl_be_block_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
258 int flag, struct thread *td);

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

751#ifdef CTL_TIME_IO
752 getbintime(&io->io_hdr.dma_start_bt);
753#endif
754 ctl_datamove(io);
755 }
756}
757
758static void
258static void ctl_be_block_cw_dispatch(struct ctl_be_block_lun *be_lun,
259 union ctl_io *io);
260static void ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun,
261 union ctl_io *io);
262static void ctl_be_block_worker(void *context, int pending);
263static int ctl_be_block_submit(union ctl_io *io);
264static int ctl_be_block_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
265 int flag, struct thread *td);

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

758#ifdef CTL_TIME_IO
759 getbintime(&io->io_hdr.dma_start_bt);
760#endif
761 ctl_datamove(io);
762 }
763}
764
765static void
766ctl_be_block_gls_file(struct ctl_be_block_lun *be_lun,
767 struct ctl_be_block_io *beio)
768{
769 union ctl_io *io = beio->io;
770 struct ctl_lba_len_flags *lbalen = ARGS(io);
771 struct scsi_get_lba_status_data *data;
772 off_t roff, off;
773 int error, status;
774
775 DPRINTF("entered\n");
776
777 off = roff = ((off_t)lbalen->lba) << be_lun->blocksize_shift;
778 vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
779 error = VOP_IOCTL(be_lun->vn, FIOSEEKHOLE, &off,
780 0, curthread->td_ucred, curthread);
781 if (error == 0 && off > roff)
782 status = 0; /* mapped up to off */
783 else {
784 error = VOP_IOCTL(be_lun->vn, FIOSEEKDATA, &off,
785 0, curthread->td_ucred, curthread);
786 if (error == 0 && off > roff)
787 status = 1; /* deallocated up to off */
788 else {
789 status = 0; /* unknown up to the end */
790 off = be_lun->size_bytes;
791 }
792 }
793 VOP_UNLOCK(be_lun->vn, 0);
794
795 off >>= be_lun->blocksize_shift;
796 data = (struct scsi_get_lba_status_data *)io->scsiio.kern_data_ptr;
797 scsi_u64to8b(lbalen->lba, data->descr[0].addr);
798 scsi_ulto4b(MIN(UINT32_MAX, off - lbalen->lba),
799 data->descr[0].length);
800 data->descr[0].status = status;
801
802 ctl_complete_beio(beio);
803}
804
805static void
759ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun,
760 struct ctl_be_block_io *beio)
761{
762 struct ctl_be_block_devdata *dev_data;
763 union ctl_io *io;
764 struct uio xuio;
765 struct iovec *xiovec;
766 int flags;

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

843#ifdef CTL_TIME_IO
844 getbintime(&io->io_hdr.dma_start_bt);
845#endif
846 ctl_datamove(io);
847 }
848}
849
850static void
806ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun,
807 struct ctl_be_block_io *beio)
808{
809 struct ctl_be_block_devdata *dev_data;
810 union ctl_io *io;
811 struct uio xuio;
812 struct iovec *xiovec;
813 int flags;

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

890#ifdef CTL_TIME_IO
891 getbintime(&io->io_hdr.dma_start_bt);
892#endif
893 ctl_datamove(io);
894 }
895}
896
897static void
898ctl_be_block_gls_zvol(struct ctl_be_block_lun *be_lun,
899 struct ctl_be_block_io *beio)
900{
901 struct ctl_be_block_devdata *dev_data = &be_lun->backend.dev;
902 union ctl_io *io = beio->io;
903 struct ctl_lba_len_flags *lbalen = ARGS(io);
904 struct scsi_get_lba_status_data *data;
905 off_t roff, off;
906 int error, status;
907
908 DPRINTF("entered\n");
909
910 off = roff = ((off_t)lbalen->lba) << be_lun->blocksize_shift;
911 error = (*dev_data->csw->d_ioctl)(dev_data->cdev, FIOSEEKHOLE,
912 (caddr_t)&off, FREAD, curthread);
913 if (error == 0 && off > roff)
914 status = 0; /* mapped up to off */
915 else {
916 error = (*dev_data->csw->d_ioctl)(dev_data->cdev, FIOSEEKDATA,
917 (caddr_t)&off, FREAD, curthread);
918 if (error == 0 && off > roff)
919 status = 1; /* deallocated up to off */
920 else {
921 status = 0; /* unknown up to the end */
922 off = be_lun->size_bytes;
923 }
924 }
925
926 off >>= be_lun->blocksize_shift;
927 data = (struct scsi_get_lba_status_data *)io->scsiio.kern_data_ptr;
928 scsi_u64to8b(lbalen->lba, data->descr[0].addr);
929 scsi_ulto4b(MIN(UINT32_MAX, off - lbalen->lba),
930 data->descr[0].length);
931 data->descr[0].status = status;
932
933 ctl_complete_beio(beio);
934}
935
936static void
851ctl_be_block_flush_dev(struct ctl_be_block_lun *be_lun,
852 struct ctl_be_block_io *beio)
853{
854 struct bio *bio;
855 union ctl_io *io;
856 struct ctl_be_block_devdata *dev_data;
857
858 dev_data = &be_lun->backend.dev;

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

1215 beio->ds_trans_type = DEVSTAT_FREE;
1216
1217 DPRINTF("UNMAP\n");
1218
1219 be_lun->unmap(be_lun, beio);
1220}
1221
1222static void
937ctl_be_block_flush_dev(struct ctl_be_block_lun *be_lun,
938 struct ctl_be_block_io *beio)
939{
940 struct bio *bio;
941 union ctl_io *io;
942 struct ctl_be_block_devdata *dev_data;
943
944 dev_data = &be_lun->backend.dev;

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

1301 beio->ds_trans_type = DEVSTAT_FREE;
1302
1303 DPRINTF("UNMAP\n");
1304
1305 be_lun->unmap(be_lun, beio);
1306}
1307
1308static void
1309ctl_be_block_cr_done(struct ctl_be_block_io *beio)
1310{
1311 union ctl_io *io;
1312
1313 io = beio->io;
1314 ctl_free_beio(beio);
1315 ctl_config_read_done(io);
1316}
1317
1318static void
1319ctl_be_block_cr_dispatch(struct ctl_be_block_lun *be_lun,
1320 union ctl_io *io)
1321{
1322 struct ctl_be_block_io *beio;
1323 struct ctl_be_block_softc *softc;
1324
1325 DPRINTF("entered\n");
1326
1327 softc = be_lun->softc;
1328 beio = ctl_alloc_beio(softc);
1329 beio->io = io;
1330 beio->lun = be_lun;
1331 beio->beio_cont = ctl_be_block_cr_done;
1332 PRIV(io)->ptr = (void *)beio;
1333
1334 switch (io->scsiio.cdb[0]) {
1335 case SERVICE_ACTION_IN: /* GET LBA STATUS */
1336 beio->bio_cmd = -1;
1337 beio->ds_trans_type = DEVSTAT_NO_DATA;
1338 beio->ds_tag_type = DEVSTAT_TAG_ORDERED;
1339 beio->io_len = 0;
1340 if (be_lun->get_lba_status)
1341 be_lun->get_lba_status(be_lun, beio);
1342 else
1343 ctl_be_block_cr_done(beio);
1344 break;
1345 default:
1346 panic("Unhandled CDB type %#x", io->scsiio.cdb[0]);
1347 break;
1348 }
1349}
1350
1351static void
1223ctl_be_block_cw_done(struct ctl_be_block_io *beio)
1224{
1225 union ctl_io *io;
1226
1227 io = beio->io;
1228 ctl_free_beio(beio);
1229 ctl_config_write_done(io);
1230}

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

1449
1450 be_lun->dispatch(be_lun, beio);
1451
1452 mtx_lock(&be_lun->queue_lock);
1453 continue;
1454 }
1455 io = (union ctl_io *)STAILQ_FIRST(&be_lun->config_write_queue);
1456 if (io != NULL) {
1352ctl_be_block_cw_done(struct ctl_be_block_io *beio)
1353{
1354 union ctl_io *io;
1355
1356 io = beio->io;
1357 ctl_free_beio(beio);
1358 ctl_config_write_done(io);
1359}

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

1578
1579 be_lun->dispatch(be_lun, beio);
1580
1581 mtx_lock(&be_lun->queue_lock);
1582 continue;
1583 }
1584 io = (union ctl_io *)STAILQ_FIRST(&be_lun->config_write_queue);
1585 if (io != NULL) {
1457
1458 DPRINTF("config write queue\n");
1586 DPRINTF("config write queue\n");
1459
1460 STAILQ_REMOVE(&be_lun->config_write_queue, &io->io_hdr,
1461 ctl_io_hdr, links);
1587 STAILQ_REMOVE(&be_lun->config_write_queue, &io->io_hdr,
1588 ctl_io_hdr, links);
1462
1463 mtx_unlock(&be_lun->queue_lock);
1589 mtx_unlock(&be_lun->queue_lock);
1464
1465 ctl_be_block_cw_dispatch(be_lun, io);
1590 ctl_be_block_cw_dispatch(be_lun, io);
1466
1467 mtx_lock(&be_lun->queue_lock);
1468 continue;
1469 }
1591 mtx_lock(&be_lun->queue_lock);
1592 continue;
1593 }
1594 io = (union ctl_io *)STAILQ_FIRST(&be_lun->config_read_queue);
1595 if (io != NULL) {
1596 DPRINTF("config read queue\n");
1597 STAILQ_REMOVE(&be_lun->config_read_queue, &io->io_hdr,
1598 ctl_io_hdr, links);
1599 mtx_unlock(&be_lun->queue_lock);
1600 ctl_be_block_cr_dispatch(be_lun, io);
1601 mtx_lock(&be_lun->queue_lock);
1602 continue;
1603 }
1470 io = (union ctl_io *)STAILQ_FIRST(&be_lun->input_queue);
1471 if (io != NULL) {
1472 DPRINTF("input queue\n");
1473
1474 STAILQ_REMOVE(&be_lun->input_queue, &io->io_hdr,
1475 ctl_io_hdr, links);
1476 mtx_unlock(&be_lun->queue_lock);
1477

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

1587
1588 error = 0;
1589 file_data = &be_lun->backend.file;
1590 params = &be_lun->params;
1591
1592 be_lun->dev_type = CTL_BE_BLOCK_FILE;
1593 be_lun->dispatch = ctl_be_block_dispatch_file;
1594 be_lun->lun_flush = ctl_be_block_flush_file;
1604 io = (union ctl_io *)STAILQ_FIRST(&be_lun->input_queue);
1605 if (io != NULL) {
1606 DPRINTF("input queue\n");
1607
1608 STAILQ_REMOVE(&be_lun->input_queue, &io->io_hdr,
1609 ctl_io_hdr, links);
1610 mtx_unlock(&be_lun->queue_lock);
1611

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

1721
1722 error = 0;
1723 file_data = &be_lun->backend.file;
1724 params = &be_lun->params;
1725
1726 be_lun->dev_type = CTL_BE_BLOCK_FILE;
1727 be_lun->dispatch = ctl_be_block_dispatch_file;
1728 be_lun->lun_flush = ctl_be_block_flush_file;
1729 be_lun->get_lba_status = ctl_be_block_gls_file;
1595
1596 error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred);
1597 if (error != 0) {
1598 snprintf(req->error_str, sizeof(req->error_str),
1599 "error calling VOP_GETATTR() for file %s",
1600 be_lun->dev_path);
1601 return (error);
1602 }

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

1673 params = &be_lun->params;
1674
1675 be_lun->dev_type = CTL_BE_BLOCK_DEV;
1676 be_lun->backend.dev.cdev = be_lun->vn->v_rdev;
1677 be_lun->backend.dev.csw = dev_refthread(be_lun->backend.dev.cdev,
1678 &be_lun->backend.dev.dev_ref);
1679 if (be_lun->backend.dev.csw == NULL)
1680 panic("Unable to retrieve device switch");
1730
1731 error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred);
1732 if (error != 0) {
1733 snprintf(req->error_str, sizeof(req->error_str),
1734 "error calling VOP_GETATTR() for file %s",
1735 be_lun->dev_path);
1736 return (error);
1737 }

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

1808 params = &be_lun->params;
1809
1810 be_lun->dev_type = CTL_BE_BLOCK_DEV;
1811 be_lun->backend.dev.cdev = be_lun->vn->v_rdev;
1812 be_lun->backend.dev.csw = dev_refthread(be_lun->backend.dev.cdev,
1813 &be_lun->backend.dev.dev_ref);
1814 if (be_lun->backend.dev.csw == NULL)
1815 panic("Unable to retrieve device switch");
1681 if (strcmp(be_lun->backend.dev.csw->d_name, "zvol") == 0)
1816 if (strcmp(be_lun->backend.dev.csw->d_name, "zvol") == 0) {
1682 be_lun->dispatch = ctl_be_block_dispatch_zvol;
1817 be_lun->dispatch = ctl_be_block_dispatch_zvol;
1683 else
1818 be_lun->get_lba_status = ctl_be_block_gls_zvol;
1819 } else
1684 be_lun->dispatch = ctl_be_block_dispatch_dev;
1685 be_lun->lun_flush = ctl_be_block_flush_dev;
1686 be_lun->unmap = ctl_be_block_unmap_dev;
1687 be_lun->getattr = ctl_be_block_getattr_dev;
1688
1689 error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED);
1690 if (error) {
1691 snprintf(req->error_str, sizeof(req->error_str),

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

1950
1951 num_threads = cbb_num_threads;
1952
1953 be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK);
1954
1955 be_lun->params = req->reqdata.create;
1956 be_lun->softc = softc;
1957 STAILQ_INIT(&be_lun->input_queue);
1820 be_lun->dispatch = ctl_be_block_dispatch_dev;
1821 be_lun->lun_flush = ctl_be_block_flush_dev;
1822 be_lun->unmap = ctl_be_block_unmap_dev;
1823 be_lun->getattr = ctl_be_block_getattr_dev;
1824
1825 error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED);
1826 if (error) {
1827 snprintf(req->error_str, sizeof(req->error_str),

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

2086
2087 num_threads = cbb_num_threads;
2088
2089 be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK);
2090
2091 be_lun->params = req->reqdata.create;
2092 be_lun->softc = softc;
2093 STAILQ_INIT(&be_lun->input_queue);
2094 STAILQ_INIT(&be_lun->config_read_queue);
1958 STAILQ_INIT(&be_lun->config_write_queue);
1959 STAILQ_INIT(&be_lun->datamove_queue);
1960 sprintf(be_lun->lunname, "cblk%d", softc->num_luns);
1961 mtx_init(&be_lun->io_lock, "cblk io lock", NULL, MTX_DEF);
1962 mtx_init(&be_lun->queue_lock, "cblk queue lock", NULL, MTX_DEF);
1963 ctl_init_opts(&be_lun->ctl_be_lun.options,
1964 req->num_be_args, req->kern_be_args);
1965

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

2580 default:
2581 ctl_set_invalid_opcode(&io->scsiio);
2582 ctl_config_write_done(io);
2583 retval = CTL_RETVAL_COMPLETE;
2584 break;
2585 }
2586
2587 return (retval);
2095 STAILQ_INIT(&be_lun->config_write_queue);
2096 STAILQ_INIT(&be_lun->datamove_queue);
2097 sprintf(be_lun->lunname, "cblk%d", softc->num_luns);
2098 mtx_init(&be_lun->io_lock, "cblk io lock", NULL, MTX_DEF);
2099 mtx_init(&be_lun->queue_lock, "cblk queue lock", NULL, MTX_DEF);
2100 ctl_init_opts(&be_lun->ctl_be_lun.options,
2101 req->num_be_args, req->kern_be_args);
2102

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

2717 default:
2718 ctl_set_invalid_opcode(&io->scsiio);
2719 ctl_config_write_done(io);
2720 retval = CTL_RETVAL_COMPLETE;
2721 break;
2722 }
2723
2724 return (retval);
2588
2589}
2590
2591static int
2592ctl_be_block_config_read(union ctl_io *io)
2593{
2725}
2726
2727static int
2728ctl_be_block_config_read(union ctl_io *io)
2729{
2594 return (0);
2730 struct ctl_be_block_lun *be_lun;
2731 struct ctl_be_lun *ctl_be_lun;
2732 int retval = 0;
2733
2734 DPRINTF("entered\n");
2735
2736 ctl_be_lun = (struct ctl_be_lun *)io->io_hdr.ctl_private[
2737 CTL_PRIV_BACKEND_LUN].ptr;
2738 be_lun = (struct ctl_be_block_lun *)ctl_be_lun->be_lun;
2739
2740 switch (io->scsiio.cdb[0]) {
2741 case SERVICE_ACTION_IN:
2742 if (io->scsiio.cdb[1] == SGLS_SERVICE_ACTION) {
2743 mtx_lock(&be_lun->queue_lock);
2744 STAILQ_INSERT_TAIL(&be_lun->config_read_queue,
2745 &io->io_hdr, links);
2746 mtx_unlock(&be_lun->queue_lock);
2747 taskqueue_enqueue(be_lun->io_taskqueue,
2748 &be_lun->io_task);
2749 retval = CTL_RETVAL_QUEUED;
2750 break;
2751 }
2752 ctl_set_invalid_field(&io->scsiio,
2753 /*sks_valid*/ 1,
2754 /*command*/ 1,
2755 /*field*/ 1,
2756 /*bit_valid*/ 1,
2757 /*bit*/ 4);
2758 ctl_config_read_done(io);
2759 retval = CTL_RETVAL_COMPLETE;
2760 break;
2761 default:
2762 ctl_set_invalid_opcode(&io->scsiio);
2763 ctl_config_read_done(io);
2764 retval = CTL_RETVAL_COMPLETE;
2765 break;
2766 }
2767
2768 return (retval);
2595}
2596
2597static int
2598ctl_be_block_lun_info(void *be_lun, struct sbuf *sb)
2599{
2600 struct ctl_be_block_lun *lun;
2601 int retval;
2602

--- 47 unchanged lines hidden ---
2769}
2770
2771static int
2772ctl_be_block_lun_info(void *be_lun, struct sbuf *sb)
2773{
2774 struct ctl_be_block_lun *lun;
2775 int retval;
2776

--- 47 unchanged lines hidden ---