hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RGGC CVE: NA
-----------------------------------------------
Add a sysfs attribute to SCSI hosts for configuring fair tag sharing.
Originally-from: Bart Van Assche bvanassche@acm.org Link: https://lore.kernel.org/all/20231130193139.880955-4-bvanassche@acm.org/ Signed-off-by: Yu Kuai yukuai3@huawei.com --- drivers/scsi/scsi_sysfs.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 24f6eefb6803..61602cf8d7a2 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -403,6 +403,43 @@ show_nr_hw_queues(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR(nr_hw_queues, S_IRUGO, show_nr_hw_queues, NULL);
+static ssize_t +fair_sharing_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct blk_mq_tag_set *tag_set = &shost->tag_set; + + return sprintf(buf, "%d\n", !tag_set->disable_fair_tag_sharing); +} + +static ssize_t +fair_sharing_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct blk_mq_tag_set *tag_set = &shost->tag_set; + bool enable; + int res = kstrtobool(buf, &enable); + + if (res < 0) + return res; + + if (tag_set->disable_fair_tag_sharing == !enable) + return count; + + mutex_lock(&tag_set->tag_list_lock); + if (tag_set->disable_fair_tag_sharing == !enable) + goto out_unlock; + + tag_set->disable_fair_tag_sharing = !enable; + blk_mq_update_fair_tag_sharing(tag_set); + +out_unlock: + mutex_unlock(&tag_set->tag_list_lock); + return count; +} +static DEVICE_ATTR_RW(fair_sharing); + static struct attribute *scsi_sysfs_shost_attrs[] = { &dev_attr_use_blk_mq.attr, &dev_attr_unique_id.attr, @@ -421,6 +458,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { &dev_attr_host_reset.attr, &dev_attr_eh_deadline.attr, &dev_attr_nr_hw_queues.attr, + &dev_attr_fair_sharing.attr, NULL };