]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: target: Allow userspace to set the completion type
authorMike Christie <michael.christie@oracle.com>
Sun, 22 Feb 2026 23:27:03 +0000 (17:27 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sun, 1 Mar 2026 02:04:03 +0000 (21:04 -0500)
This allows userspace to request if we complete in the backend context
or the frontend driver. It works the same as submission where you can
write 0 to 2 to complete_type:

 0 - Use the fabric driver's preference.

 1 - Complete from the backend calling context if the fabric supports
     it.

 2 - Queue the completion to LIO's completion workqueue.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://patch.msgid.link/20260222232946.7637-4-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_configfs.c
drivers/target/target_core_fabric_configfs.c

index 17608ea39d5ae82d33a7f8d46a6bda87b9449cb0..f514fa2e80ddf08a9cc25314b2349c2c1bf0e121 100644 (file)
@@ -578,6 +578,7 @@ DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data);
 DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len);
 DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc);
 DEF_CONFIGFS_ATTRIB_SHOW(submit_type);
+DEF_CONFIGFS_ATTRIB_SHOW(complete_type);
 DEF_CONFIGFS_ATTRIB_SHOW(atomic_max_len);
 DEF_CONFIGFS_ATTRIB_SHOW(atomic_alignment);
 DEF_CONFIGFS_ATTRIB_SHOW(atomic_granularity);
@@ -1269,6 +1270,24 @@ static ssize_t submit_type_store(struct config_item *item, const char *page,
        return count;
 }
 
+static ssize_t complete_type_store(struct config_item *item, const char *page,
+                                  size_t count)
+{
+       struct se_dev_attrib *da = to_attrib(item);
+       int ret;
+       u8 val;
+
+       ret = kstrtou8(page, 0, &val);
+       if (ret < 0)
+               return ret;
+
+       if (val > TARGET_QUEUE_COMPL)
+               return -EINVAL;
+
+       da->complete_type = val;
+       return count;
+}
+
 CONFIGFS_ATTR(, emulate_model_alias);
 CONFIGFS_ATTR(, emulate_dpo);
 CONFIGFS_ATTR(, emulate_fua_write);
@@ -1305,6 +1324,7 @@ CONFIGFS_ATTR(, max_write_same_len);
 CONFIGFS_ATTR(, alua_support);
 CONFIGFS_ATTR(, pgr_support);
 CONFIGFS_ATTR(, submit_type);
+CONFIGFS_ATTR(, complete_type);
 CONFIGFS_ATTR_RO(, atomic_max_len);
 CONFIGFS_ATTR_RO(, atomic_alignment);
 CONFIGFS_ATTR_RO(, atomic_granularity);
@@ -1353,6 +1373,7 @@ struct configfs_attribute *sbc_attrib_attrs[] = {
        &attr_pgr_support,
        &attr_emulate_rsoc,
        &attr_submit_type,
+       &attr_complete_type,
        &attr_atomic_alignment,
        &attr_atomic_max_len,
        &attr_atomic_granularity,
@@ -1376,6 +1397,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
        &attr_alua_support,
        &attr_pgr_support,
        &attr_submit_type,
+       &attr_complete_type,
        NULL,
 };
 EXPORT_SYMBOL(passthrough_attrib_attrs);
index 331689b30f8540c8e78de3eae32c1f8cd4906213..166dbf4c40616ecf1100c74d7ea0c25de17140e9 100644 (file)
@@ -1065,6 +1065,28 @@ 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_complete_type_show(struct config_item *item,
+                                            char *page)
+{
+       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
+                                         param_group);
+       return sysfs_emit(page, "%u\n",
+                         wwn->wwn_tf->tf_ops->default_compl_type);
+}
+CONFIGFS_ATTR_RO(target_fabric_wwn_, default_complete_type);
+
+static ssize_t
+target_fabric_wwn_direct_complete_supported_show(struct config_item *item,
+                                                char *page)
+{
+       struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn,
+                                         param_group);
+       return sysfs_emit(page, "%u\n",
+                         wwn->wwn_tf->tf_ops->direct_compl_supp);
+}
+CONFIGFS_ATTR_RO(target_fabric_wwn_, direct_complete_supported);
+
 static ssize_t
 target_fabric_wwn_default_submit_type_show(struct config_item *item,
                                           char *page)
@@ -1089,6 +1111,8 @@ 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_complete_type,
+       &target_fabric_wwn_attr_direct_complete_supported,
        &target_fabric_wwn_attr_default_submit_type,
        &target_fabric_wwn_attr_direct_submit_supported,
        NULL,