diff options
author | Konstantin Shelekhin <k.shelekhin@yadro.com> | 2021-03-22 23:09:37 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-04-06 06:26:38 +0300 |
commit | 0aecfa662e4312046ece56bb5666796412abe8cb (patch) | |
tree | 02474599ceaf724cc0c20181b6e7ebed629ec7ab /drivers/target | |
parent | bc3f2b42b70eb1b8576e753e7d0e117bbb674496 (diff) | |
download | linux-0aecfa662e4312046ece56bb5666796412abe8cb.tar.xz |
scsi: target: Add the DUMMY flag to rd_mcp
This commit adds the DUMMY flag to the rd_mcp backend that forces a logical
unit to report itself as not connected device of an unknown type.
Essentially this allows users to create devices identical to the device for
the virtual LUN 0, making it possible to explicitly create a LUN 0 device
and configure its WWNs (e.g. vendor or product name).
Link: https://lore.kernel.org/r/20210322200938.53300-2-k.shelekhin@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_rd.c | 27 | ||||
-rw-r--r-- | drivers/target/target_core_rd.h | 1 |
2 files changed, 24 insertions, 4 deletions
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index bf936bbeccfe..6648c1c90e19 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -530,12 +530,13 @@ rd_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, } enum { - Opt_rd_pages, Opt_rd_nullio, Opt_err + Opt_rd_pages, Opt_rd_nullio, Opt_rd_dummy, Opt_err }; static match_table_t tokens = { {Opt_rd_pages, "rd_pages=%d"}, {Opt_rd_nullio, "rd_nullio=%d"}, + {Opt_rd_dummy, "rd_dummy=%d"}, {Opt_err, NULL} }; @@ -574,6 +575,14 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, pr_debug("RAMDISK: Setting NULLIO flag: %d\n", arg); rd_dev->rd_flags |= RDF_NULLIO; break; + case Opt_rd_dummy: + match_int(args, &arg); + if (arg != 1) + break; + + pr_debug("RAMDISK: Setting DUMMY flag: %d\n", arg); + rd_dev->rd_flags |= RDF_DUMMY; + break; default: break; } @@ -590,12 +599,22 @@ static ssize_t rd_show_configfs_dev_params(struct se_device *dev, char *b) ssize_t bl = sprintf(b, "TCM RamDisk ID: %u RamDisk Makeup: rd_mcp\n", rd_dev->rd_dev_id); bl += sprintf(b + bl, " PAGES/PAGE_SIZE: %u*%lu" - " SG_table_count: %u nullio: %d\n", rd_dev->rd_page_count, + " SG_table_count: %u nullio: %d dummy: %d\n", + rd_dev->rd_page_count, PAGE_SIZE, rd_dev->sg_table_count, - !!(rd_dev->rd_flags & RDF_NULLIO)); + !!(rd_dev->rd_flags & RDF_NULLIO), + !!(rd_dev->rd_flags & RDF_DUMMY)); return bl; } +static u32 rd_get_device_type(struct se_device *dev) +{ + if (RD_DEV(dev)->rd_flags & RDF_DUMMY) + return 0x3f; /* Unknown device type, not connected */ + else + return sbc_get_device_type(dev); +} + static sector_t rd_get_blocks(struct se_device *dev) { struct rd_dev *rd_dev = RD_DEV(dev); @@ -647,7 +666,7 @@ static const struct target_backend_ops rd_mcp_ops = { .parse_cdb = rd_parse_cdb, .set_configfs_dev_params = rd_set_configfs_dev_params, .show_configfs_dev_params = rd_show_configfs_dev_params, - .get_device_type = sbc_get_device_type, + .get_device_type = rd_get_device_type, .get_blocks = rd_get_blocks, .init_prot = rd_init_prot, .free_prot = rd_free_prot, diff --git a/drivers/target/target_core_rd.h b/drivers/target/target_core_rd.h index 8b88f9b14c3f..9ffda5c4b584 100644 --- a/drivers/target/target_core_rd.h +++ b/drivers/target/target_core_rd.h @@ -28,6 +28,7 @@ struct rd_dev_sg_table { #define RDF_HAS_PAGE_COUNT 0x01 #define RDF_NULLIO 0x02 +#define RDF_DUMMY 0x04 struct rd_dev { struct se_device dev; |