diff options
| author | Tregaron Bayly <tregaron@baylys.org> | 2013-01-31 17:30:24 -0500 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-02-13 14:27:58 -0500 |
| commit | adfa9570a56c3dbfc2a28baab77ff6f0b8f480d3 (patch) | |
| tree | 3d0fcb992e2cf56c8a88cac6861c276f4ad7b088 | |
| parent | 0e48e7a5a345a727d5fd7a06bd6a9e6a67eae2bd (diff) | |
target: Add device attribute to expose config_item_name for INQUIRY model
This patch changes LIO to use the configfs backend device name as the
model if you echo '1' to an individual device's emulate_model_alias attribute.
This is a valid operation only on devices with an export count of 0.
Signed-off-by: Tregaron Bayly <tbayly@bluehost.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
| -rw-r--r-- | drivers/target/target_core_configfs.c | 4 | ||||
| -rw-r--r-- | drivers/target/target_core_device.c | 39 | ||||
| -rw-r--r-- | drivers/target/target_core_internal.h | 1 | ||||
| -rw-r--r-- | include/target/target_core_base.h | 3 |
4 files changed, 47 insertions, 0 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 4efb61b8d001..43b7ac6c5b1c 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
| @@ -609,6 +609,9 @@ static struct target_core_dev_attrib_attribute \ | |||
| 609 | __CONFIGFS_EATTR_RO(_name, \ | 609 | __CONFIGFS_EATTR_RO(_name, \ |
| 610 | target_core_dev_show_attr_##_name); | 610 | target_core_dev_show_attr_##_name); |
| 611 | 611 | ||
| 612 | DEF_DEV_ATTRIB(emulate_model_alias); | ||
| 613 | SE_DEV_ATTR(emulate_model_alias, S_IRUGO | S_IWUSR); | ||
| 614 | |||
| 612 | DEF_DEV_ATTRIB(emulate_dpo); | 615 | DEF_DEV_ATTRIB(emulate_dpo); |
| 613 | SE_DEV_ATTR(emulate_dpo, S_IRUGO | S_IWUSR); | 616 | SE_DEV_ATTR(emulate_dpo, S_IRUGO | S_IWUSR); |
| 614 | 617 | ||
| @@ -681,6 +684,7 @@ SE_DEV_ATTR(max_write_same_len, S_IRUGO | S_IWUSR); | |||
| 681 | CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); | 684 | CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); |
| 682 | 685 | ||
| 683 | static struct configfs_attribute *target_core_dev_attrib_attrs[] = { | 686 | static struct configfs_attribute *target_core_dev_attrib_attrs[] = { |
| 687 | &target_core_dev_attrib_emulate_model_alias.attr, | ||
| 684 | &target_core_dev_attrib_emulate_dpo.attr, | 688 | &target_core_dev_attrib_emulate_dpo.attr, |
| 685 | &target_core_dev_attrib_emulate_fua_write.attr, | 689 | &target_core_dev_attrib_emulate_fua_write.attr, |
| 686 | &target_core_dev_attrib_emulate_fua_read.attr, | 690 | &target_core_dev_attrib_emulate_fua_read.attr, |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index d10cbed23472..6fb82f1abe5c 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
| @@ -713,6 +713,44 @@ int se_dev_set_max_write_same_len( | |||
| 713 | return 0; | 713 | return 0; |
| 714 | } | 714 | } |
| 715 | 715 | ||
| 716 | static void dev_set_t10_wwn_model_alias(struct se_device *dev) | ||
| 717 | { | ||
| 718 | const char *configname; | ||
| 719 | |||
| 720 | configname = config_item_name(&dev->dev_group.cg_item); | ||
| 721 | if (strlen(configname) >= 16) { | ||
| 722 | pr_warn("dev[%p]: Backstore name '%s' is too long for " | ||
| 723 | "INQUIRY_MODEL, truncating to 16 bytes\n", dev, | ||
| 724 | configname); | ||
| 725 | } | ||
| 726 | snprintf(&dev->t10_wwn.model[0], 16, "%s", configname); | ||
| 727 | } | ||
| 728 | |||
| 729 | int se_dev_set_emulate_model_alias(struct se_device *dev, int flag) | ||
| 730 | { | ||
| 731 | if (dev->export_count) { | ||
| 732 | pr_err("dev[%p]: Unable to change model alias" | ||
| 733 | " while export_count is %d\n", | ||
| 734 | dev, dev->export_count); | ||
| 735 | return -EINVAL; | ||
| 736 | } | ||
| 737 | |||
| 738 | if (flag != 0 && flag != 1) { | ||
| 739 | pr_err("Illegal value %d\n", flag); | ||
| 740 | return -EINVAL; | ||
| 741 | } | ||
| 742 | |||
| 743 | if (flag) { | ||
| 744 | dev_set_t10_wwn_model_alias(dev); | ||
| 745 | } else { | ||
| 746 | strncpy(&dev->t10_wwn.model[0], | ||
| 747 | dev->transport->inquiry_prod, 16); | ||
| 748 | } | ||
| 749 | dev->dev_attrib.emulate_model_alias = flag; | ||
| 750 | |||
| 751 | return 0; | ||
| 752 | } | ||
| 753 | |||
| 716 | int se_dev_set_emulate_dpo(struct se_device *dev, int flag) | 754 | int se_dev_set_emulate_dpo(struct se_device *dev, int flag) |
| 717 | { | 755 | { |
| 718 | if (flag != 0 && flag != 1) { | 756 | if (flag != 0 && flag != 1) { |
| @@ -1396,6 +1434,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) | |||
| 1396 | dev->t10_alua.t10_dev = dev; | 1434 | dev->t10_alua.t10_dev = dev; |
| 1397 | 1435 | ||
| 1398 | dev->dev_attrib.da_dev = dev; | 1436 | dev->dev_attrib.da_dev = dev; |
| 1437 | dev->dev_attrib.emulate_model_alias = DA_EMULATE_MODEL_ALIAS; | ||
| 1399 | dev->dev_attrib.emulate_dpo = DA_EMULATE_DPO; | 1438 | dev->dev_attrib.emulate_dpo = DA_EMULATE_DPO; |
| 1400 | dev->dev_attrib.emulate_fua_write = DA_EMULATE_FUA_WRITE; | 1439 | dev->dev_attrib.emulate_fua_write = DA_EMULATE_FUA_WRITE; |
| 1401 | dev->dev_attrib.emulate_fua_read = DA_EMULATE_FUA_READ; | 1440 | dev->dev_attrib.emulate_fua_read = DA_EMULATE_FUA_READ; |
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 93e9c1f580b0..fdc51f8301a1 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h | |||
| @@ -25,6 +25,7 @@ int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); | |||
| 25 | int se_dev_set_unmap_granularity(struct se_device *, u32); | 25 | int se_dev_set_unmap_granularity(struct se_device *, u32); |
| 26 | int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); | 26 | int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); |
| 27 | int se_dev_set_max_write_same_len(struct se_device *, u32); | 27 | int se_dev_set_max_write_same_len(struct se_device *, u32); |
| 28 | int se_dev_set_emulate_model_alias(struct se_device *, int); | ||
| 28 | int se_dev_set_emulate_dpo(struct se_device *, int); | 29 | int se_dev_set_emulate_dpo(struct se_device *, int); |
| 29 | int se_dev_set_emulate_fua_write(struct se_device *, int); | 30 | int se_dev_set_emulate_fua_write(struct se_device *, int); |
| 30 | int se_dev_set_emulate_fua_read(struct se_device *, int); | 31 | int se_dev_set_emulate_fua_read(struct se_device *, int); |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 199b0ad1a55e..df14dce59191 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
| @@ -75,6 +75,8 @@ | |||
| 75 | #define DA_MAX_WRITE_SAME_LEN 0 | 75 | #define DA_MAX_WRITE_SAME_LEN 0 |
| 76 | /* Default max transfer length */ | 76 | /* Default max transfer length */ |
| 77 | #define DA_FABRIC_MAX_SECTORS 8192 | 77 | #define DA_FABRIC_MAX_SECTORS 8192 |
| 78 | /* Use a model alias based on the configfs backend device name */ | ||
| 79 | #define DA_EMULATE_MODEL_ALIAS 0 | ||
| 78 | /* Emulation for Direct Page Out */ | 80 | /* Emulation for Direct Page Out */ |
| 79 | #define DA_EMULATE_DPO 0 | 81 | #define DA_EMULATE_DPO 0 |
| 80 | /* Emulation for Forced Unit Access WRITEs */ | 82 | /* Emulation for Forced Unit Access WRITEs */ |
| @@ -591,6 +593,7 @@ struct se_dev_entry { | |||
| 591 | }; | 593 | }; |
| 592 | 594 | ||
| 593 | struct se_dev_attrib { | 595 | struct se_dev_attrib { |
| 596 | int emulate_model_alias; | ||
| 594 | int emulate_dpo; | 597 | int emulate_dpo; |
| 595 | int emulate_fua_write; | 598 | int emulate_fua_write; |
| 596 | int emulate_fua_read; | 599 | int emulate_fua_read; |
