1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*******************************************************************************
3 * Filename: target_core_iblock.c
5 * This file contains the Storage Engine <-> Linux BlockIO transport
8 * (c) Copyright 2003-2013 Datera, Inc.
12 ******************************************************************************/
14 #include <linux/string.h>
15 #include <linux/parser.h>
16 #include <linux/timer.h>
18 #include <linux/blkdev.h>
19 #include <linux/blk-integrity.h>
20 #include <linux/slab.h>
21 #include <linux/spinlock.h>
22 #include <linux/bio.h>
23 #include <linux/file.h>
24 #include <linux/module.h>
25 #include <linux/scatterlist.h>
26 #include <scsi/scsi_proto.h>
27 #include <asm/unaligned.h>
29 #include <target/target_core_base.h>
30 #include <target/target_core_backend.h>
32 #include "target_core_iblock.h"
34 #define IBLOCK_MAX_BIO_PER_TASK 32 /* max # of bios to submit at a time */
35 #define IBLOCK_BIO_POOL_SIZE 128
37 static inline struct iblock_dev *IBLOCK_DEV(struct se_device *dev)
39 return container_of(dev, struct iblock_dev, dev);
43 static int iblock_attach_hba(struct se_hba *hba, u32 host_id)
45 pr_debug("CORE_HBA[%d] - TCM iBlock HBA Driver %s on"
46 " Generic Target Core Stack %s\n", hba->hba_id,
47 IBLOCK_VERSION, TARGET_CORE_VERSION);
51 static void iblock_detach_hba(struct se_hba *hba)
55 static struct se_device *iblock_alloc_device(struct se_hba *hba, const char *name)
57 struct iblock_dev *ib_dev = NULL;
59 ib_dev = kzalloc(sizeof(struct iblock_dev), GFP_KERNEL);
61 pr_err("Unable to allocate struct iblock_dev\n");
65 ib_dev->ibd_plug = kcalloc(nr_cpu_ids, sizeof(*ib_dev->ibd_plug),
67 if (!ib_dev->ibd_plug)
70 pr_debug( "IBLOCK: Allocated ib_dev for %s\n", name);
79 static bool iblock_configure_unmap(struct se_device *dev)
81 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
83 return target_configure_unmap_from_queue(&dev->dev_attrib,
87 static int iblock_configure_device(struct se_device *dev)
89 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
90 struct request_queue *q;
91 struct block_device *bd = NULL;
92 struct blk_integrity *bi;
94 unsigned int max_write_zeroes_sectors;
97 if (!(ib_dev->ibd_flags & IBDF_HAS_UDEV_PATH)) {
98 pr_err("Missing udev_path= parameters for IBLOCK\n");
102 ret = bioset_init(&ib_dev->ibd_bio_set, IBLOCK_BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
104 pr_err("IBLOCK: Unable to create bioset\n");
108 pr_debug( "IBLOCK: Claiming struct block_device: %s\n",
109 ib_dev->ibd_udev_path);
111 mode = FMODE_READ|FMODE_EXCL;
112 if (!ib_dev->ibd_readonly)
115 dev->dev_flags |= DF_READ_ONLY;
117 bd = blkdev_get_by_path(ib_dev->ibd_udev_path, mode, ib_dev);
120 goto out_free_bioset;
124 q = bdev_get_queue(bd);
126 dev->dev_attrib.hw_block_size = bdev_logical_block_size(bd);
127 dev->dev_attrib.hw_max_sectors = mult_frac(queue_max_hw_sectors(q),
129 dev->dev_attrib.hw_block_size);
130 dev->dev_attrib.hw_queue_depth = q->nr_requests;
133 * Enable write same emulation for IBLOCK and use 0xFFFF as
134 * the smaller WRITE_SAME(10) only has a two-byte block count.
136 max_write_zeroes_sectors = bdev_write_zeroes_sectors(bd);
137 if (max_write_zeroes_sectors)
138 dev->dev_attrib.max_write_same_len = max_write_zeroes_sectors;
140 dev->dev_attrib.max_write_same_len = 0xFFFF;
143 dev->dev_attrib.is_nonrot = 1;
145 bi = bdev_get_integrity(bd);
147 struct bio_set *bs = &ib_dev->ibd_bio_set;
149 if (!strcmp(bi->profile->name, "T10-DIF-TYPE3-IP") ||
150 !strcmp(bi->profile->name, "T10-DIF-TYPE1-IP")) {
151 pr_err("IBLOCK export of blk_integrity: %s not"
152 " supported\n", bi->profile->name);
157 if (!strcmp(bi->profile->name, "T10-DIF-TYPE3-CRC")) {
158 dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE3_PROT;
159 } else if (!strcmp(bi->profile->name, "T10-DIF-TYPE1-CRC")) {
160 dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE1_PROT;
163 if (dev->dev_attrib.pi_prot_type) {
164 if (bioset_integrity_create(bs, IBLOCK_BIO_POOL_SIZE) < 0) {
165 pr_err("Unable to allocate bioset for PI\n");
169 pr_debug("IBLOCK setup BIP bs->bio_integrity_pool: %p\n",
170 &bs->bio_integrity_pool);
172 dev->dev_attrib.hw_pi_prot_type = dev->dev_attrib.pi_prot_type;
178 blkdev_put(ib_dev->ibd_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
180 bioset_exit(&ib_dev->ibd_bio_set);
185 static void iblock_dev_call_rcu(struct rcu_head *p)
187 struct se_device *dev = container_of(p, struct se_device, rcu_head);
188 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
190 kfree(ib_dev->ibd_plug);
194 static void iblock_free_device(struct se_device *dev)
196 call_rcu(&dev->rcu_head, iblock_dev_call_rcu);
199 static void iblock_destroy_device(struct se_device *dev)
201 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
203 if (ib_dev->ibd_bd != NULL)
204 blkdev_put(ib_dev->ibd_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
205 bioset_exit(&ib_dev->ibd_bio_set);
208 static struct se_dev_plug *iblock_plug_device(struct se_device *se_dev)
210 struct iblock_dev *ib_dev = IBLOCK_DEV(se_dev);
211 struct iblock_dev_plug *ib_dev_plug;
214 * Each se_device has a per cpu work this can be run from. We
215 * shouldn't have multiple threads on the same cpu calling this
218 ib_dev_plug = &ib_dev->ibd_plug[raw_smp_processor_id()];
219 if (test_and_set_bit(IBD_PLUGF_PLUGGED, &ib_dev_plug->flags))
222 blk_start_plug(&ib_dev_plug->blk_plug);
223 return &ib_dev_plug->se_plug;
226 static void iblock_unplug_device(struct se_dev_plug *se_plug)
228 struct iblock_dev_plug *ib_dev_plug = container_of(se_plug,
229 struct iblock_dev_plug, se_plug);
231 blk_finish_plug(&ib_dev_plug->blk_plug);
232 clear_bit(IBD_PLUGF_PLUGGED, &ib_dev_plug->flags);
235 static sector_t iblock_get_blocks(struct se_device *dev)
237 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
238 u32 block_size = bdev_logical_block_size(ib_dev->ibd_bd);
239 unsigned long long blocks_long =
240 div_u64(bdev_nr_bytes(ib_dev->ibd_bd), block_size) - 1;
242 if (block_size == dev->dev_attrib.block_size)
245 switch (block_size) {
247 switch (dev->dev_attrib.block_size) {
262 switch (dev->dev_attrib.block_size) {
277 switch (dev->dev_attrib.block_size) {
292 switch (dev->dev_attrib.block_size) {
313 static void iblock_complete_cmd(struct se_cmd *cmd)
315 struct iblock_req *ibr = cmd->priv;
318 if (!refcount_dec_and_test(&ibr->pending))
321 if (atomic_read(&ibr->ib_bio_err_cnt))
322 status = SAM_STAT_CHECK_CONDITION;
324 status = SAM_STAT_GOOD;
326 target_complete_cmd(cmd, status);
330 static void iblock_bio_done(struct bio *bio)
332 struct se_cmd *cmd = bio->bi_private;
333 struct iblock_req *ibr = cmd->priv;
335 if (bio->bi_status) {
336 pr_err("bio error: %p, err: %d\n", bio, bio->bi_status);
338 * Bump the ib_bio_err_cnt and release bio.
340 atomic_inc(&ibr->ib_bio_err_cnt);
341 smp_mb__after_atomic();
346 iblock_complete_cmd(cmd);
349 static struct bio *iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num,
352 struct iblock_dev *ib_dev = IBLOCK_DEV(cmd->se_dev);
356 * Only allocate as many vector entries as the bio code allows us to,
357 * we'll loop later on until we have handled the whole request.
359 bio = bio_alloc_bioset(ib_dev->ibd_bd, bio_max_segs(sg_num), opf,
360 GFP_NOIO, &ib_dev->ibd_bio_set);
362 pr_err("Unable to allocate memory for bio\n");
366 bio->bi_private = cmd;
367 bio->bi_end_io = &iblock_bio_done;
368 bio->bi_iter.bi_sector = lba;
373 static void iblock_submit_bios(struct bio_list *list)
375 struct blk_plug plug;
378 * The block layer handles nested plugs, so just plug/unplug to handle
379 * fabric drivers that didn't support batching and multi bio cmds.
381 blk_start_plug(&plug);
382 while ((bio = bio_list_pop(list)))
384 blk_finish_plug(&plug);
387 static void iblock_end_io_flush(struct bio *bio)
389 struct se_cmd *cmd = bio->bi_private;
392 pr_err("IBLOCK: cache flush failed: %d\n", bio->bi_status);
396 target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION);
398 target_complete_cmd(cmd, SAM_STAT_GOOD);
405 * Implement SYCHRONIZE CACHE. Note that we can't handle lba ranges and must
406 * always flush the whole cache.
408 static sense_reason_t
409 iblock_execute_sync_cache(struct se_cmd *cmd)
411 struct iblock_dev *ib_dev = IBLOCK_DEV(cmd->se_dev);
412 int immed = (cmd->t_task_cdb[1] & 0x2);
416 * If the Immediate bit is set, queue up the GOOD response
417 * for this SYNCHRONIZE_CACHE op.
420 target_complete_cmd(cmd, SAM_STAT_GOOD);
422 bio = bio_alloc(ib_dev->ibd_bd, 0, REQ_OP_WRITE | REQ_PREFLUSH,
424 bio->bi_end_io = iblock_end_io_flush;
426 bio->bi_private = cmd;
431 static sense_reason_t
432 iblock_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
434 struct block_device *bdev = IBLOCK_DEV(cmd->se_dev)->ibd_bd;
435 struct se_device *dev = cmd->se_dev;
438 ret = blkdev_issue_discard(bdev,
439 target_to_linux_sector(dev, lba),
440 target_to_linux_sector(dev, nolb),
443 pr_err("blkdev_issue_discard() failed: %d\n", ret);
444 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
450 static sense_reason_t
451 iblock_execute_zero_out(struct block_device *bdev, struct se_cmd *cmd)
453 struct se_device *dev = cmd->se_dev;
454 struct scatterlist *sg = &cmd->t_data_sg[0];
455 unsigned char *buf, *not_zero;
458 buf = kmap(sg_page(sg)) + sg->offset;
460 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
462 * Fall back to block_execute_write_same() slow-path if
463 * incoming WRITE_SAME payload does not contain zeros.
465 not_zero = memchr_inv(buf, 0x00, cmd->data_length);
469 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
471 ret = blkdev_issue_zeroout(bdev,
472 target_to_linux_sector(dev, cmd->t_task_lba),
473 target_to_linux_sector(dev,
474 sbc_get_write_same_sectors(cmd)),
475 GFP_KERNEL, BLKDEV_ZERO_NOUNMAP);
477 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
479 target_complete_cmd(cmd, SAM_STAT_GOOD);
483 static sense_reason_t
484 iblock_execute_write_same(struct se_cmd *cmd)
486 struct block_device *bdev = IBLOCK_DEV(cmd->se_dev)->ibd_bd;
487 struct iblock_req *ibr;
488 struct scatterlist *sg;
490 struct bio_list list;
491 struct se_device *dev = cmd->se_dev;
492 sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
493 sector_t sectors = target_to_linux_sector(dev,
494 sbc_get_write_same_sectors(cmd));
497 pr_err("WRITE_SAME: Protection information with IBLOCK"
498 " backends not supported\n");
499 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
502 if (!cmd->t_data_nents)
503 return TCM_INVALID_CDB_FIELD;
505 sg = &cmd->t_data_sg[0];
507 if (cmd->t_data_nents > 1 ||
508 sg->length != cmd->se_dev->dev_attrib.block_size) {
509 pr_err("WRITE_SAME: Illegal SGL t_data_nents: %u length: %u"
510 " block_size: %u\n", cmd->t_data_nents, sg->length,
511 cmd->se_dev->dev_attrib.block_size);
512 return TCM_INVALID_CDB_FIELD;
515 if (bdev_write_zeroes_sectors(bdev)) {
516 if (!iblock_execute_zero_out(bdev, cmd))
520 ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL);
525 bio = iblock_get_bio(cmd, block_lba, 1, REQ_OP_WRITE);
529 bio_list_init(&list);
530 bio_list_add(&list, bio);
532 refcount_set(&ibr->pending, 1);
535 while (bio_add_page(bio, sg_page(sg), sg->length, sg->offset)
538 bio = iblock_get_bio(cmd, block_lba, 1, REQ_OP_WRITE);
542 refcount_inc(&ibr->pending);
543 bio_list_add(&list, bio);
546 /* Always in 512 byte units for Linux/Block */
547 block_lba += sg->length >> SECTOR_SHIFT;
548 sectors -= sg->length >> SECTOR_SHIFT;
551 iblock_submit_bios(&list);
555 while ((bio = bio_list_pop(&list)))
560 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
564 Opt_udev_path, Opt_readonly, Opt_force, Opt_err
567 static match_table_t tokens = {
568 {Opt_udev_path, "udev_path=%s"},
569 {Opt_readonly, "readonly=%d"},
570 {Opt_force, "force=%d"},
574 static ssize_t iblock_set_configfs_dev_params(struct se_device *dev,
575 const char *page, ssize_t count)
577 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
578 char *orig, *ptr, *arg_p, *opts;
579 substring_t args[MAX_OPT_ARGS];
581 unsigned long tmp_readonly;
583 opts = kstrdup(page, GFP_KERNEL);
589 while ((ptr = strsep(&opts, ",\n")) != NULL) {
593 token = match_token(ptr, tokens, args);
596 if (ib_dev->ibd_bd) {
597 pr_err("Unable to set udev_path= while"
598 " ib_dev->ibd_bd exists\n");
602 if (match_strlcpy(ib_dev->ibd_udev_path, &args[0],
603 SE_UDEV_PATH_LEN) == 0) {
607 pr_debug("IBLOCK: Referencing UDEV path: %s\n",
608 ib_dev->ibd_udev_path);
609 ib_dev->ibd_flags |= IBDF_HAS_UDEV_PATH;
612 arg_p = match_strdup(&args[0]);
617 ret = kstrtoul(arg_p, 0, &tmp_readonly);
620 pr_err("kstrtoul() failed for"
624 ib_dev->ibd_readonly = tmp_readonly;
625 pr_debug("IBLOCK: readonly: %d\n", ib_dev->ibd_readonly);
636 return (!ret) ? count : ret;
639 static ssize_t iblock_show_configfs_dev_params(struct se_device *dev, char *b)
641 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
642 struct block_device *bd = ib_dev->ibd_bd;
646 bl += sprintf(b + bl, "iBlock device: %pg", bd);
647 if (ib_dev->ibd_flags & IBDF_HAS_UDEV_PATH)
648 bl += sprintf(b + bl, " UDEV PATH: %s",
649 ib_dev->ibd_udev_path);
650 bl += sprintf(b + bl, " readonly: %d\n", ib_dev->ibd_readonly);
652 bl += sprintf(b + bl, " ");
654 bl += sprintf(b + bl, "Major: %d Minor: %d %s\n",
655 MAJOR(bd->bd_dev), MINOR(bd->bd_dev),
658 bl += sprintf(b + bl, "Major: 0 Minor: 0\n");
665 iblock_alloc_bip(struct se_cmd *cmd, struct bio *bio,
666 struct sg_mapping_iter *miter)
668 struct se_device *dev = cmd->se_dev;
669 struct blk_integrity *bi;
670 struct bio_integrity_payload *bip;
671 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
675 bi = bdev_get_integrity(ib_dev->ibd_bd);
677 pr_err("Unable to locate bio_integrity\n");
681 bip = bio_integrity_alloc(bio, GFP_NOIO, bio_max_segs(cmd->t_prot_nents));
683 pr_err("Unable to allocate bio_integrity_payload\n");
687 bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio));
688 /* virtual start sector must be in integrity interval units */
689 bip_set_seed(bip, bio->bi_iter.bi_sector >>
690 (bi->interval_exp - SECTOR_SHIFT));
692 pr_debug("IBLOCK BIP Size: %u Sector: %llu\n", bip->bip_iter.bi_size,
693 (unsigned long long)bip->bip_iter.bi_sector);
695 resid = bip->bip_iter.bi_size;
696 while (resid > 0 && sg_miter_next(miter)) {
698 len = min_t(size_t, miter->length, resid);
699 rc = bio_integrity_add_page(bio, miter->page, len,
700 offset_in_page(miter->addr));
702 pr_err("bio_integrity_add_page() failed; %d\n", rc);
703 sg_miter_stop(miter);
707 pr_debug("Added bio integrity page: %p length: %zu offset: %lu\n",
708 miter->page, len, offset_in_page(miter->addr));
711 if (len < miter->length)
712 miter->consumed -= miter->length - len;
714 sg_miter_stop(miter);
719 static sense_reason_t
720 iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
721 enum dma_data_direction data_direction)
723 struct se_device *dev = cmd->se_dev;
724 sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
725 struct iblock_req *ibr;
727 struct bio_list list;
728 struct scatterlist *sg;
729 u32 sg_num = sgl_nents;
733 struct sg_mapping_iter prot_miter;
734 unsigned int miter_dir;
736 if (data_direction == DMA_TO_DEVICE) {
737 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
739 * Force writethrough using REQ_FUA if a volatile write cache
740 * is not enabled, or if initiator set the Force Unit Access bit.
743 miter_dir = SG_MITER_TO_SG;
744 if (bdev_fua(ib_dev->ibd_bd)) {
745 if (cmd->se_cmd_flags & SCF_FUA)
747 else if (!bdev_write_cache(ib_dev->ibd_bd))
752 miter_dir = SG_MITER_FROM_SG;
755 ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL);
761 refcount_set(&ibr->pending, 1);
762 iblock_complete_cmd(cmd);
766 bio = iblock_get_bio(cmd, block_lba, sgl_nents, opf);
770 bio_list_init(&list);
771 bio_list_add(&list, bio);
773 refcount_set(&ibr->pending, 2);
776 if (cmd->prot_type && dev->dev_attrib.pi_prot_type)
777 sg_miter_start(&prot_miter, cmd->t_prot_sg, cmd->t_prot_nents,
780 for_each_sg(sgl, sg, sgl_nents, i) {
782 * XXX: if the length the device accepts is shorter than the
783 * length of the S/G list entry this will cause and
784 * endless loop. Better hope no driver uses huge pages.
786 while (bio_add_page(bio, sg_page(sg), sg->length, sg->offset)
788 if (cmd->prot_type && dev->dev_attrib.pi_prot_type) {
789 rc = iblock_alloc_bip(cmd, bio, &prot_miter);
794 if (bio_cnt >= IBLOCK_MAX_BIO_PER_TASK) {
795 iblock_submit_bios(&list);
799 bio = iblock_get_bio(cmd, block_lba, sg_num, opf);
803 refcount_inc(&ibr->pending);
804 bio_list_add(&list, bio);
808 /* Always in 512 byte units for Linux/Block */
809 block_lba += sg->length >> SECTOR_SHIFT;
813 if (cmd->prot_type && dev->dev_attrib.pi_prot_type) {
814 rc = iblock_alloc_bip(cmd, bio, &prot_miter);
819 iblock_submit_bios(&list);
820 iblock_complete_cmd(cmd);
824 while ((bio = bio_list_pop(&list)))
829 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
832 static sector_t iblock_get_alignment_offset_lbas(struct se_device *dev)
834 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
835 struct block_device *bd = ib_dev->ibd_bd;
838 ret = bdev_alignment_offset(bd);
842 /* convert offset-bytes to offset-lbas */
843 return ret / bdev_logical_block_size(bd);
846 static unsigned int iblock_get_lbppbe(struct se_device *dev)
848 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
849 struct block_device *bd = ib_dev->ibd_bd;
850 unsigned int logs_per_phys =
851 bdev_physical_block_size(bd) / bdev_logical_block_size(bd);
853 return ilog2(logs_per_phys);
856 static unsigned int iblock_get_io_min(struct se_device *dev)
858 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
859 struct block_device *bd = ib_dev->ibd_bd;
861 return bdev_io_min(bd);
864 static unsigned int iblock_get_io_opt(struct se_device *dev)
866 struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
867 struct block_device *bd = ib_dev->ibd_bd;
869 return bdev_io_opt(bd);
872 static struct sbc_ops iblock_sbc_ops = {
873 .execute_rw = iblock_execute_rw,
874 .execute_sync_cache = iblock_execute_sync_cache,
875 .execute_write_same = iblock_execute_write_same,
876 .execute_unmap = iblock_execute_unmap,
879 static sense_reason_t
880 iblock_parse_cdb(struct se_cmd *cmd)
882 return sbc_parse_cdb(cmd, &iblock_sbc_ops);
885 static bool iblock_get_write_cache(struct se_device *dev)
887 return bdev_write_cache(IBLOCK_DEV(dev)->ibd_bd);
890 static const struct target_backend_ops iblock_ops = {
892 .inquiry_prod = "IBLOCK",
893 .inquiry_rev = IBLOCK_VERSION,
894 .owner = THIS_MODULE,
895 .attach_hba = iblock_attach_hba,
896 .detach_hba = iblock_detach_hba,
897 .alloc_device = iblock_alloc_device,
898 .configure_device = iblock_configure_device,
899 .destroy_device = iblock_destroy_device,
900 .free_device = iblock_free_device,
901 .configure_unmap = iblock_configure_unmap,
902 .plug_device = iblock_plug_device,
903 .unplug_device = iblock_unplug_device,
904 .parse_cdb = iblock_parse_cdb,
905 .set_configfs_dev_params = iblock_set_configfs_dev_params,
906 .show_configfs_dev_params = iblock_show_configfs_dev_params,
907 .get_device_type = sbc_get_device_type,
908 .get_blocks = iblock_get_blocks,
909 .get_alignment_offset_lbas = iblock_get_alignment_offset_lbas,
910 .get_lbppbe = iblock_get_lbppbe,
911 .get_io_min = iblock_get_io_min,
912 .get_io_opt = iblock_get_io_opt,
913 .get_write_cache = iblock_get_write_cache,
914 .tb_dev_attrib_attrs = sbc_attrib_attrs,
917 static int __init iblock_module_init(void)
919 return transport_backend_register(&iblock_ops);
922 static void __exit iblock_module_exit(void)
924 target_backend_unregister(&iblock_ops);
927 MODULE_DESCRIPTION("TCM IBLOCK subsystem plugin");
929 MODULE_LICENSE("GPL");
931 module_init(iblock_module_init);
932 module_exit(iblock_module_exit);