summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-05-10 12:14:57 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-06-01 03:25:36 -0400
commit5873c4d157400ade4052e9d7b6259fa592e1ddbf (patch)
tree3e8f9d0a3bde7659a1b3169158b68108ee55ca7f /drivers/target
parent0a06d4309dc168dfa70cec3cf0cd9eb7fc15a2fd (diff)
target: consolidate backend attribute implementations
Provide a common sets of dev_attrib attributes for all devices using the generic SPC/SBC parsers, and a second one with the minimal required read-only attributes for passthrough devices. The later is only used by pscsi for now, but will be wired up for the full-passthrough TCMU use case as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_configfs.c169
-rw-r--r--drivers/target/target_core_file.c38
-rw-r--r--drivers/target/target_core_iblock.c38
-rw-r--r--drivers/target/target_core_pscsi.c23
-rw-r--r--drivers/target/target_core_rd.c38
-rw-r--r--drivers/target/target_core_user.c23
6 files changed, 174 insertions, 155 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 57c099dd9da5..dbf91f02ee5c 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -471,10 +471,179 @@ EXPORT_SYMBOL(target_unregister_template);
471//############################################################################*/ 471//############################################################################*/
472 472
473/* Start functions for struct config_item_type tb_dev_attrib_cit */ 473/* Start functions for struct config_item_type tb_dev_attrib_cit */
474#define DEF_TB_DEV_ATTRIB_SHOW(_backend, _name) \
475static ssize_t _backend##_dev_show_attr_##_name( \
476 struct se_dev_attrib *da, \
477 char *page) \
478{ \
479 return snprintf(page, PAGE_SIZE, "%u\n", \
480 (u32)da->da_dev->dev_attrib._name); \
481}
482
483#define DEF_TB_DEV_ATTRIB_STORE(_backend, _name) \
484static ssize_t _backend##_dev_store_attr_##_name( \
485 struct se_dev_attrib *da, \
486 const char *page, \
487 size_t count) \
488{ \
489 unsigned long val; \
490 int ret; \
491 \
492 ret = kstrtoul(page, 0, &val); \
493 if (ret < 0) { \
494 pr_err("kstrtoul() failed with ret: %d\n", ret); \
495 return -EINVAL; \
496 } \
497 ret = se_dev_set_##_name(da->da_dev, (u32)val); \
498 \
499 return (!ret) ? count : -EINVAL; \
500}
501
502#define DEF_TB_DEV_ATTRIB(_backend, _name) \
503DEF_TB_DEV_ATTRIB_SHOW(_backend, _name); \
504DEF_TB_DEV_ATTRIB_STORE(_backend, _name);
505
506#define DEF_TB_DEV_ATTRIB_RO(_backend, name) \
507DEF_TB_DEV_ATTRIB_SHOW(_backend, name);
508
509CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib);
510#define TB_DEV_ATTR(_backend, _name, _mode) \
511static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \
512 __CONFIGFS_EATTR(_name, _mode, \
513 _backend##_dev_show_attr_##_name, \
514 _backend##_dev_store_attr_##_name);
515
516#define TB_DEV_ATTR_RO(_backend, _name) \
517static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \
518 __CONFIGFS_EATTR_RO(_name, \
519 _backend##_dev_show_attr_##_name);
520
521DEF_TB_DEV_ATTRIB(target_core, emulate_model_alias);
522DEF_TB_DEV_ATTRIB(target_core, emulate_dpo);
523DEF_TB_DEV_ATTRIB(target_core, emulate_fua_write);
524DEF_TB_DEV_ATTRIB(target_core, emulate_fua_read);
525DEF_TB_DEV_ATTRIB(target_core, emulate_write_cache);
526DEF_TB_DEV_ATTRIB(target_core, emulate_ua_intlck_ctrl);
527DEF_TB_DEV_ATTRIB(target_core, emulate_tas);
528DEF_TB_DEV_ATTRIB(target_core, emulate_tpu);
529DEF_TB_DEV_ATTRIB(target_core, emulate_tpws);
530DEF_TB_DEV_ATTRIB(target_core, emulate_caw);
531DEF_TB_DEV_ATTRIB(target_core, emulate_3pc);
532DEF_TB_DEV_ATTRIB(target_core, pi_prot_type);
533DEF_TB_DEV_ATTRIB_RO(target_core, hw_pi_prot_type);
534DEF_TB_DEV_ATTRIB(target_core, pi_prot_format);
535DEF_TB_DEV_ATTRIB(target_core, enforce_pr_isids);
536DEF_TB_DEV_ATTRIB(target_core, is_nonrot);
537DEF_TB_DEV_ATTRIB(target_core, emulate_rest_reord);
538DEF_TB_DEV_ATTRIB(target_core, force_pr_aptpl);
539DEF_TB_DEV_ATTRIB_RO(target_core, hw_block_size);
540DEF_TB_DEV_ATTRIB(target_core, block_size);
541DEF_TB_DEV_ATTRIB_RO(target_core, hw_max_sectors);
542DEF_TB_DEV_ATTRIB(target_core, optimal_sectors);
543DEF_TB_DEV_ATTRIB_RO(target_core, hw_queue_depth);
544DEF_TB_DEV_ATTRIB(target_core, queue_depth);
545DEF_TB_DEV_ATTRIB(target_core, max_unmap_lba_count);
546DEF_TB_DEV_ATTRIB(target_core, max_unmap_block_desc_count);
547DEF_TB_DEV_ATTRIB(target_core, unmap_granularity);
548DEF_TB_DEV_ATTRIB(target_core, unmap_granularity_alignment);
549DEF_TB_DEV_ATTRIB(target_core, max_write_same_len);
550
551TB_DEV_ATTR(target_core, emulate_model_alias, S_IRUGO | S_IWUSR);
552TB_DEV_ATTR(target_core, emulate_dpo, S_IRUGO | S_IWUSR);
553TB_DEV_ATTR(target_core, emulate_fua_write, S_IRUGO | S_IWUSR);
554TB_DEV_ATTR(target_core, emulate_fua_read, S_IRUGO | S_IWUSR);
555TB_DEV_ATTR(target_core, emulate_write_cache, S_IRUGO | S_IWUSR);
556TB_DEV_ATTR(target_core, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR);
557TB_DEV_ATTR(target_core, emulate_tas, S_IRUGO | S_IWUSR);
558TB_DEV_ATTR(target_core, emulate_tpu, S_IRUGO | S_IWUSR);
559TB_DEV_ATTR(target_core, emulate_tpws, S_IRUGO | S_IWUSR);
560TB_DEV_ATTR(target_core, emulate_caw, S_IRUGO | S_IWUSR);
561TB_DEV_ATTR(target_core, emulate_3pc, S_IRUGO | S_IWUSR);
562TB_DEV_ATTR(target_core, pi_prot_type, S_IRUGO | S_IWUSR);
563TB_DEV_ATTR_RO(target_core, hw_pi_prot_type);
564TB_DEV_ATTR(target_core, pi_prot_format, S_IRUGO | S_IWUSR);
565TB_DEV_ATTR(target_core, enforce_pr_isids, S_IRUGO | S_IWUSR);
566TB_DEV_ATTR(target_core, is_nonrot, S_IRUGO | S_IWUSR);
567TB_DEV_ATTR(target_core, emulate_rest_reord, S_IRUGO | S_IWUSR);
568TB_DEV_ATTR(target_core, force_pr_aptpl, S_IRUGO | S_IWUSR)
569TB_DEV_ATTR_RO(target_core, hw_block_size);
570TB_DEV_ATTR(target_core, block_size, S_IRUGO | S_IWUSR)
571TB_DEV_ATTR_RO(target_core, hw_max_sectors);
572TB_DEV_ATTR(target_core, optimal_sectors, S_IRUGO | S_IWUSR);
573TB_DEV_ATTR_RO(target_core, hw_queue_depth);
574TB_DEV_ATTR(target_core, queue_depth, S_IRUGO | S_IWUSR);
575TB_DEV_ATTR(target_core, max_unmap_lba_count, S_IRUGO | S_IWUSR);
576TB_DEV_ATTR(target_core, max_unmap_block_desc_count, S_IRUGO | S_IWUSR);
577TB_DEV_ATTR(target_core, unmap_granularity, S_IRUGO | S_IWUSR);
578TB_DEV_ATTR(target_core, unmap_granularity_alignment, S_IRUGO | S_IWUSR);
579TB_DEV_ATTR(target_core, max_write_same_len, S_IRUGO | S_IWUSR);
474 580
475CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib); 581CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib);
476CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); 582CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group);
477 583
584/*
585 * dev_attrib attributes for devices using the target core SBC/SPC
586 * interpreter. Any backend using spc_parse_cdb should be using
587 * these.
588 */
589struct configfs_attribute *sbc_attrib_attrs[] = {
590 &target_core_dev_attrib_emulate_model_alias.attr,
591 &target_core_dev_attrib_emulate_dpo.attr,
592 &target_core_dev_attrib_emulate_fua_write.attr,
593 &target_core_dev_attrib_emulate_fua_read.attr,
594 &target_core_dev_attrib_emulate_write_cache.attr,
595 &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr,
596 &target_core_dev_attrib_emulate_tas.attr,
597 &target_core_dev_attrib_emulate_tpu.attr,
598 &target_core_dev_attrib_emulate_tpws.attr,
599 &target_core_dev_attrib_emulate_caw.attr,
600 &target_core_dev_attrib_emulate_3pc.attr,
601 &target_core_dev_attrib_pi_prot_type.attr,
602 &target_core_dev_attrib_hw_pi_prot_type.attr,
603 &target_core_dev_attrib_pi_prot_format.attr,
604 &target_core_dev_attrib_enforce_pr_isids.attr,
605 &target_core_dev_attrib_is_nonrot.attr,
606 &target_core_dev_attrib_emulate_rest_reord.attr,
607 &target_core_dev_attrib_force_pr_aptpl.attr,
608 &target_core_dev_attrib_hw_block_size.attr,
609 &target_core_dev_attrib_block_size.attr,
610 &target_core_dev_attrib_hw_max_sectors.attr,
611 &target_core_dev_attrib_optimal_sectors.attr,
612 &target_core_dev_attrib_hw_queue_depth.attr,
613 &target_core_dev_attrib_queue_depth.attr,
614 &target_core_dev_attrib_max_unmap_lba_count.attr,
615 &target_core_dev_attrib_max_unmap_block_desc_count.attr,
616 &target_core_dev_attrib_unmap_granularity.attr,
617 &target_core_dev_attrib_unmap_granularity_alignment.attr,
618 &target_core_dev_attrib_max_write_same_len.attr,
619 NULL,
620};
621EXPORT_SYMBOL(sbc_attrib_attrs);
622
623DEF_TB_DEV_ATTRIB_RO(target_pt, hw_pi_prot_type);
624DEF_TB_DEV_ATTRIB_RO(target_pt, hw_block_size);
625DEF_TB_DEV_ATTRIB_RO(target_pt, hw_max_sectors);
626DEF_TB_DEV_ATTRIB_RO(target_pt, hw_queue_depth);
627
628TB_DEV_ATTR_RO(target_pt, hw_pi_prot_type);
629TB_DEV_ATTR_RO(target_pt, hw_block_size);
630TB_DEV_ATTR_RO(target_pt, hw_max_sectors);
631TB_DEV_ATTR_RO(target_pt, hw_queue_depth);
632
633/*
634 * Minimal dev_attrib attributes for devices passing through CDBs.
635 * In this case we only provide a few read-only attributes for
636 * backwards compatibility.
637 */
638struct configfs_attribute *passthrough_attrib_attrs[] = {
639 &target_pt_dev_attrib_hw_pi_prot_type.attr,
640 &target_pt_dev_attrib_hw_block_size.attr,
641 &target_pt_dev_attrib_hw_max_sectors.attr,
642 &target_pt_dev_attrib_hw_queue_depth.attr,
643 NULL,
644};
645EXPORT_SYMBOL(passthrough_attrib_attrs);
646
478static struct configfs_item_operations target_core_dev_attrib_ops = { 647static struct configfs_item_operations target_core_dev_attrib_ops = {
479 .show_attribute = target_core_dev_attrib_attr_show, 648 .show_attribute = target_core_dev_attrib_attr_show,
480 .store_attribute = target_core_dev_attrib_attr_store, 649 .store_attribute = target_core_dev_attrib_attr_store,
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 7c5b1ef57d34..948b61f59a55 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -37,7 +37,6 @@
37 37
38#include <target/target_core_base.h> 38#include <target/target_core_base.h>
39#include <target/target_core_backend.h> 39#include <target/target_core_backend.h>
40#include <target/target_core_backend_configfs.h>
41 40
42#include "target_core_file.h" 41#include "target_core_file.h"
43 42
@@ -842,41 +841,6 @@ fd_parse_cdb(struct se_cmd *cmd)
842 return sbc_parse_cdb(cmd, &fd_sbc_ops); 841 return sbc_parse_cdb(cmd, &fd_sbc_ops);
843} 842}
844 843
845DEF_TB_DEFAULT_ATTRIBS(fileio);
846
847static struct configfs_attribute *fileio_backend_dev_attrs[] = {
848 &fileio_dev_attrib_emulate_model_alias.attr,
849 &fileio_dev_attrib_emulate_dpo.attr,
850 &fileio_dev_attrib_emulate_fua_write.attr,
851 &fileio_dev_attrib_emulate_fua_read.attr,
852 &fileio_dev_attrib_emulate_write_cache.attr,
853 &fileio_dev_attrib_emulate_ua_intlck_ctrl.attr,
854 &fileio_dev_attrib_emulate_tas.attr,
855 &fileio_dev_attrib_emulate_tpu.attr,
856 &fileio_dev_attrib_emulate_tpws.attr,
857 &fileio_dev_attrib_emulate_caw.attr,
858 &fileio_dev_attrib_emulate_3pc.attr,
859 &fileio_dev_attrib_pi_prot_type.attr,
860 &fileio_dev_attrib_hw_pi_prot_type.attr,
861 &fileio_dev_attrib_pi_prot_format.attr,
862 &fileio_dev_attrib_enforce_pr_isids.attr,
863 &fileio_dev_attrib_is_nonrot.attr,
864 &fileio_dev_attrib_emulate_rest_reord.attr,
865 &fileio_dev_attrib_force_pr_aptpl.attr,
866 &fileio_dev_attrib_hw_block_size.attr,
867 &fileio_dev_attrib_block_size.attr,
868 &fileio_dev_attrib_hw_max_sectors.attr,
869 &fileio_dev_attrib_optimal_sectors.attr,
870 &fileio_dev_attrib_hw_queue_depth.attr,
871 &fileio_dev_attrib_queue_depth.attr,
872 &fileio_dev_attrib_max_unmap_lba_count.attr,
873 &fileio_dev_attrib_max_unmap_block_desc_count.attr,
874 &fileio_dev_attrib_unmap_granularity.attr,
875 &fileio_dev_attrib_unmap_granularity_alignment.attr,
876 &fileio_dev_attrib_max_write_same_len.attr,
877 NULL,
878};
879
880static const struct target_backend_ops fileio_ops = { 844static const struct target_backend_ops fileio_ops = {
881 .name = "fileio", 845 .name = "fileio",
882 .inquiry_prod = "FILEIO", 846 .inquiry_prod = "FILEIO",
@@ -895,7 +859,7 @@ static const struct target_backend_ops fileio_ops = {
895 .init_prot = fd_init_prot, 859 .init_prot = fd_init_prot,
896 .format_prot = fd_format_prot, 860 .format_prot = fd_format_prot,
897 .free_prot = fd_free_prot, 861 .free_prot = fd_free_prot,
898 .tb_dev_attrib_attrs = fileio_backend_dev_attrs, 862 .tb_dev_attrib_attrs = sbc_attrib_attrs,
899}; 863};
900 864
901static int __init fileio_module_init(void) 865static int __init fileio_module_init(void)
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 79f651fb98fb..6d4738252564 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -41,7 +41,6 @@
41 41
42#include <target/target_core_base.h> 42#include <target/target_core_base.h>
43#include <target/target_core_backend.h> 43#include <target/target_core_backend.h>
44#include <target/target_core_backend_configfs.h>
45 44
46#include "target_core_iblock.h" 45#include "target_core_iblock.h"
47 46
@@ -858,41 +857,6 @@ static bool iblock_get_write_cache(struct se_device *dev)
858 return q->flush_flags & REQ_FLUSH; 857 return q->flush_flags & REQ_FLUSH;
859} 858}
860 859
861DEF_TB_DEFAULT_ATTRIBS(iblock);
862
863static struct configfs_attribute *iblock_backend_dev_attrs[] = {
864 &iblock_dev_attrib_emulate_model_alias.attr,
865 &iblock_dev_attrib_emulate_dpo.attr,
866 &iblock_dev_attrib_emulate_fua_write.attr,
867 &iblock_dev_attrib_emulate_fua_read.attr,
868 &iblock_dev_attrib_emulate_write_cache.attr,
869 &iblock_dev_attrib_emulate_ua_intlck_ctrl.attr,
870 &iblock_dev_attrib_emulate_tas.attr,
871 &iblock_dev_attrib_emulate_tpu.attr,
872 &iblock_dev_attrib_emulate_tpws.attr,
873 &iblock_dev_attrib_emulate_caw.attr,
874 &iblock_dev_attrib_emulate_3pc.attr,
875 &iblock_dev_attrib_pi_prot_type.attr,
876 &iblock_dev_attrib_hw_pi_prot_type.attr,
877 &iblock_dev_attrib_pi_prot_format.attr,
878 &iblock_dev_attrib_enforce_pr_isids.attr,
879 &iblock_dev_attrib_is_nonrot.attr,
880 &iblock_dev_attrib_emulate_rest_reord.attr,
881 &iblock_dev_attrib_force_pr_aptpl.attr,
882 &iblock_dev_attrib_hw_block_size.attr,
883 &iblock_dev_attrib_block_size.attr,
884 &iblock_dev_attrib_hw_max_sectors.attr,
885 &iblock_dev_attrib_optimal_sectors.attr,
886 &iblock_dev_attrib_hw_queue_depth.attr,
887 &iblock_dev_attrib_queue_depth.attr,
888 &iblock_dev_attrib_max_unmap_lba_count.attr,
889 &iblock_dev_attrib_max_unmap_block_desc_count.attr,
890 &iblock_dev_attrib_unmap_granularity.attr,
891 &iblock_dev_attrib_unmap_granularity_alignment.attr,
892 &iblock_dev_attrib_max_write_same_len.attr,
893 NULL,
894};
895
896static const struct target_backend_ops iblock_ops = { 860static const struct target_backend_ops iblock_ops = {
897 .name = "iblock", 861 .name = "iblock",
898 .inquiry_prod = "IBLOCK", 862 .inquiry_prod = "IBLOCK",
@@ -913,7 +877,7 @@ static const struct target_backend_ops iblock_ops = {
913 .get_io_min = iblock_get_io_min, 877 .get_io_min = iblock_get_io_min,
914 .get_io_opt = iblock_get_io_opt, 878 .get_io_opt = iblock_get_io_opt,
915 .get_write_cache = iblock_get_write_cache, 879 .get_write_cache = iblock_get_write_cache,
916 .tb_dev_attrib_attrs = iblock_backend_dev_attrs, 880 .tb_dev_attrib_attrs = sbc_attrib_attrs,
917}; 881};
918 882
919static int __init iblock_module_init(void) 883static int __init iblock_module_init(void)
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 2e3a0b004f9a..afb87a8d5668 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -44,7 +44,6 @@
44 44
45#include <target/target_core_base.h> 45#include <target/target_core_base.h>
46#include <target/target_core_backend.h> 46#include <target/target_core_backend.h>
47#include <target/target_core_backend_configfs.h>
48 47
49#include "target_core_alua.h" 48#include "target_core_alua.h"
50#include "target_core_internal.h" 49#include "target_core_internal.h"
@@ -1119,26 +1118,6 @@ static void pscsi_req_done(struct request *req, int uptodate)
1119 kfree(pt); 1118 kfree(pt);
1120} 1119}
1121 1120
1122DEF_TB_DEV_ATTRIB_RO(pscsi, hw_pi_prot_type);
1123TB_DEV_ATTR_RO(pscsi, hw_pi_prot_type);
1124
1125DEF_TB_DEV_ATTRIB_RO(pscsi, hw_block_size);
1126TB_DEV_ATTR_RO(pscsi, hw_block_size);
1127
1128DEF_TB_DEV_ATTRIB_RO(pscsi, hw_max_sectors);
1129TB_DEV_ATTR_RO(pscsi, hw_max_sectors);
1130
1131DEF_TB_DEV_ATTRIB_RO(pscsi, hw_queue_depth);
1132TB_DEV_ATTR_RO(pscsi, hw_queue_depth);
1133
1134static struct configfs_attribute *pscsi_backend_dev_attrs[] = {
1135 &pscsi_dev_attrib_hw_pi_prot_type.attr,
1136 &pscsi_dev_attrib_hw_block_size.attr,
1137 &pscsi_dev_attrib_hw_max_sectors.attr,
1138 &pscsi_dev_attrib_hw_queue_depth.attr,
1139 NULL,
1140};
1141
1142static const struct target_backend_ops pscsi_ops = { 1121static const struct target_backend_ops pscsi_ops = {
1143 .name = "pscsi", 1122 .name = "pscsi",
1144 .owner = THIS_MODULE, 1123 .owner = THIS_MODULE,
@@ -1155,7 +1134,7 @@ static const struct target_backend_ops pscsi_ops = {
1155 .show_configfs_dev_params = pscsi_show_configfs_dev_params, 1134 .show_configfs_dev_params = pscsi_show_configfs_dev_params,
1156 .get_device_type = pscsi_get_device_type, 1135 .get_device_type = pscsi_get_device_type,
1157 .get_blocks = pscsi_get_blocks, 1136 .get_blocks = pscsi_get_blocks,
1158 .tb_dev_attrib_attrs = pscsi_backend_dev_attrs, 1137 .tb_dev_attrib_attrs = passthrough_attrib_attrs,
1159}; 1138};
1160 1139
1161static int __init pscsi_module_init(void) 1140static int __init pscsi_module_init(void)
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index cf443a8a3cbe..55dd73e7f213 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -34,7 +34,6 @@
34 34
35#include <target/target_core_base.h> 35#include <target/target_core_base.h>
36#include <target/target_core_backend.h> 36#include <target/target_core_backend.h>
37#include <target/target_core_backend_configfs.h>
38 37
39#include "target_core_rd.h" 38#include "target_core_rd.h"
40 39
@@ -696,41 +695,6 @@ rd_parse_cdb(struct se_cmd *cmd)
696 return sbc_parse_cdb(cmd, &rd_sbc_ops); 695 return sbc_parse_cdb(cmd, &rd_sbc_ops);
697} 696}
698 697
699DEF_TB_DEFAULT_ATTRIBS(rd_mcp);
700
701static struct configfs_attribute *rd_mcp_backend_dev_attrs[] = {
702 &rd_mcp_dev_attrib_emulate_model_alias.attr,
703 &rd_mcp_dev_attrib_emulate_dpo.attr,
704 &rd_mcp_dev_attrib_emulate_fua_write.attr,
705 &rd_mcp_dev_attrib_emulate_fua_read.attr,
706 &rd_mcp_dev_attrib_emulate_write_cache.attr,
707 &rd_mcp_dev_attrib_emulate_ua_intlck_ctrl.attr,
708 &rd_mcp_dev_attrib_emulate_tas.attr,
709 &rd_mcp_dev_attrib_emulate_tpu.attr,
710 &rd_mcp_dev_attrib_emulate_tpws.attr,
711 &rd_mcp_dev_attrib_emulate_caw.attr,
712 &rd_mcp_dev_attrib_emulate_3pc.attr,
713 &rd_mcp_dev_attrib_pi_prot_type.attr,
714 &rd_mcp_dev_attrib_hw_pi_prot_type.attr,
715 &rd_mcp_dev_attrib_pi_prot_format.attr,
716 &rd_mcp_dev_attrib_enforce_pr_isids.attr,
717 &rd_mcp_dev_attrib_is_nonrot.attr,
718 &rd_mcp_dev_attrib_emulate_rest_reord.attr,
719 &rd_mcp_dev_attrib_force_pr_aptpl.attr,
720 &rd_mcp_dev_attrib_hw_block_size.attr,
721 &rd_mcp_dev_attrib_block_size.attr,
722 &rd_mcp_dev_attrib_hw_max_sectors.attr,
723 &rd_mcp_dev_attrib_optimal_sectors.attr,
724 &rd_mcp_dev_attrib_hw_queue_depth.attr,
725 &rd_mcp_dev_attrib_queue_depth.attr,
726 &rd_mcp_dev_attrib_max_unmap_lba_count.attr,
727 &rd_mcp_dev_attrib_max_unmap_block_desc_count.attr,
728 &rd_mcp_dev_attrib_unmap_granularity.attr,
729 &rd_mcp_dev_attrib_unmap_granularity_alignment.attr,
730 &rd_mcp_dev_attrib_max_write_same_len.attr,
731 NULL,
732};
733
734static const struct target_backend_ops rd_mcp_ops = { 698static const struct target_backend_ops rd_mcp_ops = {
735 .name = "rd_mcp", 699 .name = "rd_mcp",
736 .inquiry_prod = "RAMDISK-MCP", 700 .inquiry_prod = "RAMDISK-MCP",
@@ -747,7 +711,7 @@ static const struct target_backend_ops rd_mcp_ops = {
747 .get_blocks = rd_get_blocks, 711 .get_blocks = rd_get_blocks,
748 .init_prot = rd_init_prot, 712 .init_prot = rd_init_prot,
749 .free_prot = rd_free_prot, 713 .free_prot = rd_free_prot,
750 .tb_dev_attrib_attrs = rd_mcp_backend_dev_attrs, 714 .tb_dev_attrib_attrs = sbc_attrib_attrs,
751}; 715};
752 716
753int __init rd_module_init(void) 717int __init rd_module_init(void)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index fb67e313dc4f..aebaad55e23f 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -29,7 +29,6 @@
29#include <target/target_core_base.h> 29#include <target/target_core_base.h>
30#include <target/target_core_fabric.h> 30#include <target/target_core_fabric.h>
31#include <target/target_core_backend.h> 31#include <target/target_core_backend.h>
32#include <target/target_core_backend_configfs.h>
33 32
34#include <linux/target_core_user.h> 33#include <linux/target_core_user.h>
35 34
@@ -1095,26 +1094,6 @@ tcmu_parse_cdb(struct se_cmd *cmd)
1095 return passthrough_parse_cdb(cmd, tcmu_pass_op); 1094 return passthrough_parse_cdb(cmd, tcmu_pass_op);
1096} 1095}
1097 1096
1098DEF_TB_DEV_ATTRIB_RO(tcmu, hw_pi_prot_type);
1099TB_DEV_ATTR_RO(tcmu, hw_pi_prot_type);
1100
1101DEF_TB_DEV_ATTRIB_RO(tcmu, hw_block_size);
1102TB_DEV_ATTR_RO(tcmu, hw_block_size);
1103
1104DEF_TB_DEV_ATTRIB_RO(tcmu, hw_max_sectors);
1105TB_DEV_ATTR_RO(tcmu, hw_max_sectors);
1106
1107DEF_TB_DEV_ATTRIB_RO(tcmu, hw_queue_depth);
1108TB_DEV_ATTR_RO(tcmu, hw_queue_depth);
1109
1110static struct configfs_attribute *tcmu_backend_dev_attrs[] = {
1111 &tcmu_dev_attrib_hw_pi_prot_type.attr,
1112 &tcmu_dev_attrib_hw_block_size.attr,
1113 &tcmu_dev_attrib_hw_max_sectors.attr,
1114 &tcmu_dev_attrib_hw_queue_depth.attr,
1115 NULL,
1116};
1117
1118static const struct target_backend_ops tcmu_ops = { 1097static const struct target_backend_ops tcmu_ops = {
1119 .name = "user", 1098 .name = "user",
1120 .inquiry_prod = "USER", 1099 .inquiry_prod = "USER",
@@ -1131,7 +1110,7 @@ static const struct target_backend_ops tcmu_ops = {
1131 .show_configfs_dev_params = tcmu_show_configfs_dev_params, 1110 .show_configfs_dev_params = tcmu_show_configfs_dev_params,
1132 .get_device_type = sbc_get_device_type, 1111 .get_device_type = sbc_get_device_type,
1133 .get_blocks = tcmu_get_blocks, 1112 .get_blocks = tcmu_get_blocks,
1134 .tb_dev_attrib_attrs = tcmu_backend_dev_attrs, 1113 .tb_dev_attrib_attrs = passthrough_attrib_attrs,
1135}; 1114};
1136 1115
1137static int __init tcmu_module_init(void) 1116static int __init tcmu_module_init(void)