From 699fed4a2d8e32d77d64928e570d7ffd93a62fdf Mon Sep 17 00:00:00 2001 From: Sudarsana Reddy Kalluru Date: Thu, 16 Apr 2020 01:43:10 -0700 Subject: scsi: qed: Send BW update notifications to the protocol drivers Management firmware (MFW) sends a notification whenever there is a change in the bandwidth values. Add driver support for sending this notification to the upper layer drivers (e.g., qedf). Link: https://lore.kernel.org/r/20200416084314.18851-6-skashyap@marvell.com Signed-off-by: Sudarsana Reddy Kalluru Signed-off-by: Saurav Kashyap Signed-off-by: Martin K. Petersen --- include/linux/qed/qed_if.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h index 8f29e0d8a7b3..c4956374a444 100644 --- a/include/linux/qed/qed_if.h +++ b/include/linux/qed/qed_if.h @@ -817,6 +817,7 @@ struct qed_common_cb_ops { void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type); void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data); void (*get_protocol_tlv_data)(void *dev, void *data); + void (*bw_update)(void *dev); }; struct qed_selftest_ops { -- cgit v1.2.3-59-g8ed1b From 7c59dace7e8e8cc75815f11882805368e5d2a807 Mon Sep 17 00:00:00 2001 From: Maurizio Lombardi Date: Fri, 24 Apr 2020 13:39:13 +0200 Subject: scsi: target: iscsi: Remove the iscsi_data_count structure This patch removes the iscsi_data_count structure and the iscsit_do_rx_data() function because they are used only by rx_data() Link: https://lore.kernel.org/r/20200424113913.17237-1-mlombard@redhat.com Reviewed-by: Mike Christie Signed-off-by: Maurizio Lombardi Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target_util.c | 30 ++++++------------------------ include/target/iscsi/iscsi_target_core.h | 10 ---------- 2 files changed, 6 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 89183b3b178f..45ba07c6ec27 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1228,18 +1228,20 @@ void iscsit_print_session_params(struct iscsi_session *sess) iscsi_dump_sess_ops(sess->sess_ops); } -static int iscsit_do_rx_data( +int rx_data( struct iscsi_conn *conn, - struct iscsi_data_count *count) + struct kvec *iov, + int iov_count, + int data) { - int data = count->data_length, rx_loop = 0, total_rx = 0; + int rx_loop = 0, total_rx = 0; struct msghdr msg; if (!conn || !conn->sock || !conn->conn_ops) return -1; memset(&msg, 0, sizeof(struct msghdr)); - iov_iter_kvec(&msg.msg_iter, READ, count->iov, count->iov_count, data); + iov_iter_kvec(&msg.msg_iter, READ, iov, iov_count, data); while (msg_data_left(&msg)) { rx_loop = sock_recvmsg(conn->sock, &msg, MSG_WAITALL); @@ -1256,26 +1258,6 @@ static int iscsit_do_rx_data( return total_rx; } -int rx_data( - struct iscsi_conn *conn, - struct kvec *iov, - int iov_count, - int data) -{ - struct iscsi_data_count c; - - if (!conn || !conn->sock || !conn->conn_ops) - return -1; - - memset(&c, 0, sizeof(struct iscsi_data_count)); - c.iov = iov; - c.iov_count = iov_count; - c.data_length = data; - c.type = ISCSI_RX_DATA; - - return iscsit_do_rx_data(conn, &c); -} - int tx_data( struct iscsi_conn *conn, struct kvec *iov, diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 591cd9e4692c..4fda324f4b35 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -301,16 +301,6 @@ struct iscsi_queue_req { struct list_head qr_list; }; -struct iscsi_data_count { - int data_length; - int sync_and_steering; - enum data_count_type type; - u32 iov_count; - u32 ss_iov_count; - u32 ss_marker_count; - struct kvec *iov; -}; - struct iscsi_param_list { bool iser; struct list_head param_list; -- cgit v1.2.3-59-g8ed1b From 646d4b507626f4c19d2d256ef5fc14a8d52521c6 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 7 May 2020 08:26:42 +0200 Subject: scsi: core: Remove 'list' entry from struct scsi_cmnd Leftover from cmd_list removal. Link: https://lore.kernel.org/r/20200507062642.100612-1-hare@suse.de Fixes: c5a9707672fe ("scsi: core: Remove cmd_list functionality") Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 1 - include/scsi/scsi_cmnd.h | 1 - 2 files changed, 2 deletions(-) (limited to 'include') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index eb72ac8136c3..2b868f8db8ff 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -814,7 +814,6 @@ int aac_probe_container(struct aac_dev *dev, int cid) kfree(scsidev); return -ENOMEM; } - scsicmd->list.next = NULL; scsicmd->scsi_done = aac_probe_container_scsi_done; scsicmd->device = scsidev; diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 80ac89e47b47..7f047fdd34ac 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -68,7 +68,6 @@ struct scsi_pointer { struct scsi_cmnd { struct scsi_request req; struct scsi_device *device; - struct list_head list; /* scsi_cmnd participates in queue lists */ struct list_head eh_entry; /* entry for the host eh_cmd_q */ struct delayed_work abort_work; -- cgit v1.2.3-59-g8ed1b From 4703b6252b338eb312ba61c5129d872cfe58759f Mon Sep 17 00:00:00 2001 From: Bodo Stroesser Date: Mon, 27 Apr 2020 17:08:21 +0200 Subject: scsi: target: tcmu: Add attributes enforce_pr_isids and force_pr_aptpl tcmu has not set TRANSPORT_FLAG_PASSTHROUGH_PGR. Therefore the in-core pr emulation is active by default, but there are some attributes for configuration missing. Add them. Link: https://lore.kernel.org/r/20200427150823.15350-3-bstroesser@ts.fujitsu.com Reviewed-by: Mike Christie Signed-off-by: Bodo Stroesser Signed-off-by: Martin K. Petersen --- drivers/target/target_core_configfs.c | 11 +++++++++++ drivers/target/target_core_user.c | 19 +++++++++---------- include/target/target_core_backend.h | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index d8589bb39c53..efa92d836946 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1210,6 +1210,17 @@ struct configfs_attribute *passthrough_attrib_attrs[] = { }; EXPORT_SYMBOL(passthrough_attrib_attrs); +/* + * pr related dev_attrib attributes for devices passing through CDBs, + * but allowing in core pr emulation. + */ +struct configfs_attribute *passthrough_pr_attrib_attrs[] = { + &attr_enforce_pr_isids, + &attr_force_pr_aptpl, + NULL, +}; +EXPORT_SYMBOL(passthrough_pr_attrib_attrs); + TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL); TB_CIT_SETUP_DRV(dev_action, NULL, NULL); diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 0b9dfa6b17bc..4b190d600d2f 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2752,12 +2752,12 @@ static int __init tcmu_module_init(void) goto out_unreg_device; } - for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) len += sizeof(struct configfs_attribute *); - } - for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_pr_attrib_attrs[i] != NULL; i++) + len += sizeof(struct configfs_attribute *); + for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) len += sizeof(struct configfs_attribute *); - } len += sizeof(struct configfs_attribute *); tcmu_attrs = kzalloc(len, GFP_KERNEL); @@ -2766,13 +2766,12 @@ static int __init tcmu_module_init(void) goto out_unreg_genl; } - for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) tcmu_attrs[i] = passthrough_attrib_attrs[i]; - } - for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) { - tcmu_attrs[i] = tcmu_attrib_attrs[k]; - i++; - } + for (k = 0; passthrough_pr_attrib_attrs[k] != NULL; k++) + tcmu_attrs[i++] = passthrough_pr_attrib_attrs[k]; + for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) + tcmu_attrs[i++] = tcmu_attrib_attrs[k]; tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs; ret = transport_backend_register(&tcmu_ops); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 1b752d8ea529..8177667eba6d 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -94,6 +94,7 @@ int transport_set_vpd_ident(struct t10_vpd *, unsigned char *); extern struct configfs_attribute *sbc_attrib_attrs[]; extern struct configfs_attribute *passthrough_attrib_attrs[]; +extern struct configfs_attribute *passthrough_pr_attrib_attrs[]; /* core helpers also used by command snooping in pscsi */ void *transport_kmap_data_sg(struct se_cmd *); -- cgit v1.2.3-59-g8ed1b From 69088a049488171bc05394799b048c8536e7dbab Mon Sep 17 00:00:00 2001 From: Bodo Stroesser Date: Mon, 27 Apr 2020 17:08:22 +0200 Subject: scsi: target: Make transport_flags per device pgr_support and alua_support device attributes show the inverted value of the transport_flags: * TRANSPORT_FLAG_PASSTHROUGH_PGR * TRANSPORT_FLAG_PASSTHROUGH_ALUA These attributes are per device, while the flags are per backend. Rename the transport_flags in backend/transport to transport_flags_default and use this value to initialize the new transport_flags field in the se_device structure. Now data and attribute both are per se_device. Link: https://lore.kernel.org/r/20200427150823.15350-4-bstroesser@ts.fujitsu.com Reviewed-by: Mike Christie Signed-off-by: Bodo Stroesser Signed-off-by: Martin K. Petersen --- drivers/target/target_core_alua.c | 10 +++++----- drivers/target/target_core_configfs.c | 14 +++++++------- drivers/target/target_core_device.c | 3 ++- drivers/target/target_core_pr.c | 2 +- drivers/target/target_core_pscsi.c | 6 +++--- drivers/target/target_core_tpg.c | 3 +-- drivers/target/target_core_transport.c | 6 +++--- drivers/target/target_core_user.c | 2 +- include/target/target_core_backend.h | 2 +- include/target/target_core_base.h | 1 + 10 files changed, 25 insertions(+), 24 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 385e4cf9cfa6..6b72afee2f8b 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -677,7 +677,7 @@ target_alua_state_check(struct se_cmd *cmd) if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) return 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) return 0; /* @@ -1090,7 +1090,7 @@ int core_alua_do_port_transition( struct t10_alua_tg_pt_gp *tg_pt_gp; int primary, valid_states, rc = 0; - if (l_dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) + if (l_dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) return -ENODEV; valid_states = l_tg_pt_gp->tg_pt_gp_alua_supported_states; @@ -1920,7 +1920,7 @@ ssize_t core_alua_store_tg_pt_gp_info( unsigned char buf[TG_PT_GROUP_NAME_BUF]; int move = 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) return -ENODEV; @@ -2177,7 +2177,7 @@ ssize_t core_alua_store_offline_bit( unsigned long tmp; int ret; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) return -ENODEV; @@ -2263,7 +2263,7 @@ ssize_t core_alua_store_secondary_write_metadata( int core_setup_alua(struct se_device *dev) { - if (!(dev->transport->transport_flags & + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) && !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { struct t10_alua_lu_gp_member *lu_gp_mem; diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index efa92d836946..279989e32e64 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1099,7 +1099,7 @@ static ssize_t block_size_store(struct config_item *item, static ssize_t alua_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); - u8 flags = da->da_dev->transport->transport_flags; + u8 flags = da->da_dev->transport_flags; return snprintf(page, PAGE_SIZE, "%d\n", flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1); @@ -1108,7 +1108,7 @@ static ssize_t alua_support_show(struct config_item *item, char *page) static ssize_t pgr_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); - u8 flags = da->da_dev->transport->transport_flags; + u8 flags = da->da_dev->transport_flags; return snprintf(page, PAGE_SIZE, "%d\n", flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1); @@ -1654,7 +1654,7 @@ static ssize_t target_pr_res_holder_show(struct config_item *item, char *page) if (!dev->dev_attrib.emulate_pr) return sprintf(page, "SPC_RESERVATIONS_DISABLED\n"); - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return sprintf(page, "Passthrough\n"); spin_lock(&dev->dev_reservation_lock); @@ -1796,7 +1796,7 @@ static ssize_t target_pr_res_type_show(struct config_item *item, char *page) if (!dev->dev_attrib.emulate_pr) return sprintf(page, "SPC_RESERVATIONS_DISABLED\n"); - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return sprintf(page, "SPC_PASSTHROUGH\n"); if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) return sprintf(page, "SPC2_RESERVATIONS\n"); @@ -1810,7 +1810,7 @@ static ssize_t target_pr_res_aptpl_active_show(struct config_item *item, struct se_device *dev = pr_to_dev(item); if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return 0; return sprintf(page, "APTPL Bit Status: %s\n", @@ -1823,7 +1823,7 @@ static ssize_t target_pr_res_aptpl_metadata_show(struct config_item *item, struct se_device *dev = pr_to_dev(item); if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return 0; return sprintf(page, "Ready to process PR APTPL metadata..\n"); @@ -1870,7 +1870,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, u8 type = 0; if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return count; if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) return count; diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 4cee1138284b..d5800cf22df7 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -732,6 +732,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) dev->se_hba = hba; dev->transport = hba->backend->ops; + dev->transport_flags = dev->transport->transport_flags_default; dev->prot_length = sizeof(struct t10_pi_tuple); dev->hba_index = hba->hba_index; @@ -1100,7 +1101,7 @@ passthrough_parse_cdb(struct se_cmd *cmd, * emulate the response, since tcmu does not have the information * required to process these commands. */ - if (!(dev->transport->transport_flags & + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) { if (cdb[0] == PERSISTENT_RESERVE_IN) { cmd->execute_cmd = target_scsi3_emulate_pr_in; diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 5e931690e697..91e41cc55704 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -4086,7 +4086,7 @@ target_check_reservation(struct se_cmd *cmd) return 0; if (!dev->dev_attrib.emulate_pr) return 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return 0; spin_lock(&dev->dev_reservation_lock); diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index c9d92b3e777d..4e37fa9b409d 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -1070,9 +1070,9 @@ static void pscsi_req_done(struct request *req, blk_status_t status) static const struct target_backend_ops pscsi_ops = { .name = "pscsi", .owner = THIS_MODULE, - .transport_flags = TRANSPORT_FLAG_PASSTHROUGH | - TRANSPORT_FLAG_PASSTHROUGH_ALUA | - TRANSPORT_FLAG_PASSTHROUGH_PGR, + .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH | + TRANSPORT_FLAG_PASSTHROUGH_ALUA | + TRANSPORT_FLAG_PASSTHROUGH_PGR, .attach_hba = pscsi_attach_hba, .detach_hba = pscsi_detach_hba, .pmode_enable_hba = pscsi_pmode_enable_hba, diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index d24e0a3ba3ff..62aa5fa63ac0 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -582,8 +582,7 @@ int core_tpg_add_lun( if (ret) goto out_kill_ref; - if (!(dev->transport->transport_flags & - TRANSPORT_FLAG_PASSTHROUGH_ALUA) && + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) && !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) target_attach_tg_pt_gp(lun, dev->t10_alua.default_tg_pt_gp); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 594b724bbf79..e6b448f43071 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1397,7 +1397,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd) * Check if SAM Task Attribute emulation is enabled for this * struct se_device storage object */ - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return 0; if (cmd->sam_task_attr == TCM_ACA_TAG) { @@ -2012,7 +2012,7 @@ static bool target_handle_task_attr(struct se_cmd *cmd) { struct se_device *dev = cmd->se_dev; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return false; cmd->se_cmd_flags |= SCF_TASK_ATTR_SET; @@ -2126,7 +2126,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) { struct se_device *dev = cmd->se_dev; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return; if (!(cmd->se_cmd_flags & SCF_TASK_ATTR_SET)) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 4b190d600d2f..cb388b28f27e 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2616,7 +2616,7 @@ static struct configfs_attribute *tcmu_action_attrs[] = { static struct target_backend_ops tcmu_ops = { .name = "user", .owner = THIS_MODULE, - .transport_flags = TRANSPORT_FLAG_PASSTHROUGH, + .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH, .attach_hba = tcmu_attach_hba, .detach_hba = tcmu_detach_hba, .alloc_device = tcmu_alloc_device, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 8177667eba6d..959163504f82 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -23,7 +23,7 @@ struct target_backend_ops { char inquiry_rev[4]; struct module *owner; - u8 transport_flags; + u8 transport_flags_default; int (*attach_hba)(struct se_hba *, u32); void (*detach_hba)(struct se_hba *); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 6d4a694f6ea7..18c3f277b770 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -772,6 +772,7 @@ struct se_device { #define DF_USING_UDEV_PATH 0x00000008 #define DF_USING_ALIAS 0x00000010 #define DF_READ_ONLY 0x00000020 + u8 transport_flags; /* Physical device queue depth */ u32 queue_depth; /* Used for SPC-2 reservations enforce of ISIDs */ -- cgit v1.2.3-59-g8ed1b From 356ba2a8bc8d9f9bd2ee969df0e07b285aebb559 Mon Sep 17 00:00:00 2001 From: Bodo Stroesser Date: Mon, 27 Apr 2020 17:08:23 +0200 Subject: scsi: target: tcmu: Make pgr_support and alua_support attributes writable Currently in tcmu reservation commands are handled by core's pr implementation (default) or completely rejected (emulate_pr set to 0). We additionally want to be able to do full reservation handling in userspace. Therefore we need a way to set TRANSPORT_FLAG_PASSTHROUGH_PGR. The inverted flag is displayed by attribute pgr_support. Since we moved the flag from transport/backend to se_device in the previous commit, we now can make it changeable per device by allowing to write the attribute. The new field transport_flags_changeable in transport/backend is used to reject writing if not allowed for a backend. Regarding ALUA we also want to be able to passthrough commands to userspace in tcmu. Therefore we need TRANSPORT_FLAG_PASSTHROUGH_ALUA to be changeable, because by setting it we can switch off all ALUA checks in core. So we also set TRANSPORT_FLAG_PASSTHROUGH_ALUA in tcmu's transport_flags_changeable. Of course, ALUA and reservation handling in userspace will work only, if session/nexus information is sent to userspace along with every command. This will be object of a patch series announced by Mike Christie. Link: https://lore.kernel.org/r/20200427150823.15350-5-bstroesser@ts.fujitsu.com Reviewed-by: Mike Christie Signed-off-by: Bodo Stroesser Signed-off-by: Martin K. Petersen --- drivers/target/target_core_configfs.c | 56 +++++++++++++++++++++++++++++++++-- drivers/target/target_core_user.c | 2 ++ include/target/target_core_backend.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 279989e32e64..f04352285155 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1105,6 +1105,32 @@ static ssize_t alua_support_show(struct config_item *item, char *page) flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1); } +static ssize_t alua_support_store(struct config_item *item, + const char *page, size_t count) +{ + struct se_dev_attrib *da = to_attrib(item); + struct se_device *dev = da->da_dev; + bool flag; + int ret; + + if (!(dev->transport->transport_flags_changeable & + TRANSPORT_FLAG_PASSTHROUGH_ALUA)) { + pr_err("dev[%p]: Unable to change SE Device alua_support:" + " alua_support has fixed value\n", dev); + return -EINVAL; + } + + ret = strtobool(page, &flag); + if (ret < 0) + return ret; + + if (flag) + dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_ALUA; + else + dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_ALUA; + return count; +} + static ssize_t pgr_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); @@ -1114,6 +1140,32 @@ static ssize_t pgr_support_show(struct config_item *item, char *page) flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1); } +static ssize_t pgr_support_store(struct config_item *item, + const char *page, size_t count) +{ + struct se_dev_attrib *da = to_attrib(item); + struct se_device *dev = da->da_dev; + bool flag; + int ret; + + if (!(dev->transport->transport_flags_changeable & + TRANSPORT_FLAG_PASSTHROUGH_PGR)) { + pr_err("dev[%p]: Unable to change SE Device pgr_support:" + " pgr_support has fixed value\n", dev); + return -EINVAL; + } + + ret = strtobool(page, &flag); + if (ret < 0) + return ret; + + if (flag) + dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_PGR; + else + dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_PGR; + return count; +} + CONFIGFS_ATTR(, emulate_model_alias); CONFIGFS_ATTR(, emulate_dpo); CONFIGFS_ATTR(, emulate_fua_write); @@ -1146,8 +1198,8 @@ CONFIGFS_ATTR(, unmap_granularity); CONFIGFS_ATTR(, unmap_granularity_alignment); CONFIGFS_ATTR(, unmap_zeroes_data); CONFIGFS_ATTR(, max_write_same_len); -CONFIGFS_ATTR_RO(, alua_support); -CONFIGFS_ATTR_RO(, pgr_support); +CONFIGFS_ATTR(, alua_support); +CONFIGFS_ATTR(, pgr_support); /* * dev_attrib attributes for devices using the target core SBC/SPC diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index cb388b28f27e..72ffd359fc4d 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2617,6 +2617,8 @@ static struct target_backend_ops tcmu_ops = { .name = "user", .owner = THIS_MODULE, .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH, + .transport_flags_changeable = TRANSPORT_FLAG_PASSTHROUGH_PGR | + TRANSPORT_FLAG_PASSTHROUGH_ALUA, .attach_hba = tcmu_attach_hba, .detach_hba = tcmu_detach_hba, .alloc_device = tcmu_alloc_device, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 959163504f82..f51452e3b984 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -24,6 +24,7 @@ struct target_backend_ops { struct module *owner; u8 transport_flags_default; + u8 transport_flags_changeable; int (*attach_hba)(struct se_hba *, u32); void (*detach_hba)(struct se_hba *); -- cgit v1.2.3-59-g8ed1b From 00b42b70ae521e6ccc86ed403e2d101616689bdc Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 7 May 2020 14:21:47 -0500 Subject: scsi: libsas: Replace zero-length array with flexible-array The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] sizeof(flexible-array-member) triggers a warning because flexible array members have incomplete type[1]. There are some instances of code in which the sizeof operator is being incorrectly/erroneously applied to zero-length arrays and the result is zero. Such instances may be hiding some bugs. So, this work (flexible-array member conversions) will also help to get completely rid of those sorts of issues. This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Link: https://lore.kernel.org/r/20200507192147.GA16206@embeddedor Reviewed-by: John Garry Reviewed-by: Jason Yan Signed-off-by: Gustavo A. R. Silva Signed-off-by: Martin K. Petersen --- drivers/scsi/aic94xx/aic94xx_sds.c | 14 +++++++------- include/scsi/sas.h | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c index 3ddc8852bc32..105adba559a1 100644 --- a/drivers/scsi/aic94xx/aic94xx_sds.c +++ b/drivers/scsi/aic94xx/aic94xx_sds.c @@ -406,7 +406,7 @@ struct asd_manuf_sec { u8 sas_addr[SAS_ADDR_SIZE]; u8 pcba_sn[ASD_PCBA_SN_SIZE]; /* Here start the other segments */ - u8 linked_list[0]; + u8 linked_list[]; } __attribute__ ((packed)); struct asd_manuf_phy_desc { @@ -449,7 +449,7 @@ struct asd_ms_sb_desc { u8 type; u8 node_desc_index; u8 conn_desc_index; - u8 _recvd[0]; + u8 _recvd[]; } __attribute__ ((packed)); #if 0 @@ -478,12 +478,12 @@ struct asd_ms_conn_desc { u8 size_sideband_desc; u32 _resvd; u8 name[16]; - struct asd_ms_sb_desc sb_desc[0]; + struct asd_ms_sb_desc sb_desc[]; } __attribute__ ((packed)); struct asd_nd_phy_desc { u8 vp_attch_type; - u8 attch_specific[0]; + u8 attch_specific[]; } __attribute__ ((packed)); #if 0 @@ -503,7 +503,7 @@ struct asd_ms_node_desc { u8 size_phy_desc; u8 _resvd; u8 name[16]; - struct asd_nd_phy_desc phy_desc[0]; + struct asd_nd_phy_desc phy_desc[]; } __attribute__ ((packed)); struct asd_ms_conn_map { @@ -518,7 +518,7 @@ struct asd_ms_conn_map { u8 usage_model_id; u32 _resvd; struct asd_ms_conn_desc conn_desc[0]; - struct asd_ms_node_desc node_desc[0]; + struct asd_ms_node_desc node_desc[]; } __attribute__ ((packed)); struct asd_ctrla_phy_entry { @@ -542,7 +542,7 @@ struct asd_ll_el { u8 id0; u8 id1; __le16 next; - u8 something_here[0]; + u8 something_here[]; } __attribute__ ((packed)); static int asd_poll_flash(struct asd_ha_struct *asd_ha) diff --git a/include/scsi/sas.h b/include/scsi/sas.h index a5d8ae49198c..4726c1bbec65 100644 --- a/include/scsi/sas.h +++ b/include/scsi/sas.h @@ -324,7 +324,7 @@ struct ssp_response_iu { __be32 response_data_len; u8 resp_data[0]; - u8 sense_data[0]; + u8 sense_data[]; } __attribute__ ((packed)); struct ssp_command_iu { @@ -346,7 +346,7 @@ struct ssp_command_iu { u8 add_cdb_len:6; u8 cdb[16]; - u8 add_cdb[0]; + u8 add_cdb[]; } __attribute__ ((packed)); struct xfer_rdy_iu { @@ -555,7 +555,7 @@ struct ssp_response_iu { __be32 response_data_len; u8 resp_data[0]; - u8 sense_data[0]; + u8 sense_data[]; } __attribute__ ((packed)); struct ssp_command_iu { @@ -577,7 +577,7 @@ struct ssp_command_iu { u8 _r_c:2; u8 cdb[16]; - u8 add_cdb[0]; + u8 add_cdb[]; } __attribute__ ((packed)); struct xfer_rdy_iu { -- cgit v1.2.3-59-g8ed1b From fbbc95a49d5b00a66d82ea34b7f029963b6c91f3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 18 May 2020 14:16:59 -0700 Subject: scsi: qla2xxx: Suppress two recently introduced compiler warnings Suppress the following two compiler warnings because these are not useful: In file included from ./include/trace/define_trace.h:102, from ./include/trace/events/qla.h:39, from drivers/scsi/qla2xxx/qla_dbg.c:77: ./include/trace/events/qla.h: In function 'trace_event_raw_event_qla_log_event': ./include/trace/trace_events.h:691:9: warning: function 'trace_event_raw_event_qla_log_event' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] 691 | struct trace_event_raw_##call *entry; \ | ^~~~~~~~~~~~~~~~ ./include/trace/events/qla.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS' 12 | DECLARE_EVENT_CLASS(qla_log_event, | ^~~~~~~~~~~~~~~~~~~ In file included from ./include/trace/define_trace.h:103, from ./include/trace/events/qla.h:39, from drivers/scsi/qla2xxx/qla_dbg.c:77: ./include/trace/events/qla.h: In function 'perf_trace_qla_log_event': ./include/trace/perf.h:41:9: warning: function 'perf_trace_qla_log_event' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] 41 | struct hlist_head *head; \ | ^~~~~~~~~~ ./include/trace/events/qla.h:12:1: note: in expansion of macro 'DECLARE_EVENT_CLASS' Link: https://lore.kernel.org/r/20200518211712.11395-3-bvanassche@acm.org Fixes: 598a90f2002c ("scsi: qla2xxx: add ring buffer for tracing debug logs") Cc: Rajan Shanmugavelu Cc: Joe Jin Cc: Nilesh Javali Cc: Quinn Tran Cc: Martin Wilck Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Reviewed-by: Arun Easi Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- include/trace/events/qla.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/trace/events/qla.h b/include/trace/events/qla.h index b71f680968eb..5857cf682ee7 100644 --- a/include/trace/events/qla.h +++ b/include/trace/events/qla.h @@ -9,6 +9,11 @@ #define QLA_MSG_MAX 256 +#pragma GCC diagnostic push +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" +#endif + DECLARE_EVENT_CLASS(qla_log_event, TP_PROTO(const char *buf, struct va_format *vaf), @@ -27,6 +32,8 @@ DECLARE_EVENT_CLASS(qla_log_event, TP_printk("%s %s", __get_str(buf), __get_str(msg)) ); +#pragma GCC diagnostic pop + DEFINE_EVENT(qla_log_event, ql_dbg_log, TP_PROTO(const char *buf, struct va_format *vaf), TP_ARGS(buf, vaf) -- cgit v1.2.3-59-g8ed1b