diff mbox series

[5/5] scsi: target: Export fabric driver direct submit settings

Message ID 20230710214442.6718-6-michael.christie@oracle.com
State Superseded
Headers show
Series scsi: target: Allow userspace to config cmd submission | expand

Commit Message

Mike Christie July 10, 2023, 9:44 p.m. UTC
This exports the fabric driver's direct submit settings, so users know
what the driver supports. It will be helpful when they are exporting
a device through different targets and one doesn't support direct
submission.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/target/target_core_fabric_configfs.c | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Konstantin Shelekhin July 13, 2023, 1:06 p.m. UTC | #1
On Mon, Jul 10, 2023 at 04:44:42PM -0500, Mike Christie wrote:
> +static ssize_t
> +target_fabric_wwn_default_to_direct_submit_show(struct config_item *item,
> +                                               char *page)
> +{
> +       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
> +                                         param_group);
> +       return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->default_direct_submit);

I belive we should do the right thing and use sysfs_emit() here. We
already have a bunch of issues with bad sprintf() usage and I think it
would be wise to promote safer interfaces.

> +static ssize_t
> +target_fabric_wwn_direct_submit_supported_show(struct config_item *item,
> +                                              char *page)
> +{
> +       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
> +                                         param_group);
> +       return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->direct_submit_supp);

Same.
Mike Christie July 13, 2023, 3:50 p.m. UTC | #2
On 7/13/23 8:06 AM, Konstantin Shelekhin wrote:
> On Mon, Jul 10, 2023 at 04:44:42PM -0500, Mike Christie wrote:
>> +static ssize_t
>> +target_fabric_wwn_default_to_direct_submit_show(struct config_item *item,
>> +                                               char *page)
>> +{
>> +       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
>> +                                         param_group);
>> +       return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->default_direct_submit);
> 
> I belive we should do the right thing and use sysfs_emit() here. We
> already have a bunch of issues with bad sprintf() usage and I think it
> would be wise to promote safer interfaces.

You're right. Forgot about that function. Will fix. Thanks.

> 
>> +static ssize_t
>> +target_fabric_wwn_direct_submit_supported_show(struct config_item *item,
>> +                                              char *page)
>> +{
>> +       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
>> +                                         param_group);
>> +       return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->direct_submit_supp);
> 
> Same.
diff mbox series

Patch

diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index b7c637644cd4..6fd6a9135dca 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -1065,8 +1065,30 @@  target_fabric_wwn_cmd_completion_affinity_store(struct config_item *item,
 }
 CONFIGFS_ATTR(target_fabric_wwn_, cmd_completion_affinity);
 
+static ssize_t
+target_fabric_wwn_default_to_direct_submit_show(struct config_item *item,
+						char *page)
+{
+	struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
+					  param_group);
+	return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->default_direct_submit);
+}
+CONFIGFS_ATTR_RO(target_fabric_wwn_, default_to_direct_submit);
+
+static ssize_t
+target_fabric_wwn_direct_submit_supported_show(struct config_item *item,
+					       char *page)
+{
+	struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
+					  param_group);
+	return sprintf(page, "%u\n", wwn->wwn_tf->tf_ops->direct_submit_supp);
+}
+CONFIGFS_ATTR_RO(target_fabric_wwn_, direct_submit_supported);
+
 static struct configfs_attribute *target_fabric_wwn_param_attrs[] = {
 	&target_fabric_wwn_attr_cmd_completion_affinity,
+	&target_fabric_wwn_attr_default_to_direct_submit,
+	&target_fabric_wwn_attr_direct_submit_supported,
 	NULL,
 };