From f8bfa638b692f322196822e1b08e02feb217664e Mon Sep 17 00:00:00 2001 From: Tony Battersby Date: Mon, 8 Sep 2025 16:10:42 +0300 Subject: [PATCH] scst: Export scst_tgt->sg_tablesize via sysfs This value is available in initiator mode via /sys/class/scsi_host/hostN/sg_tablesize; make it available in target mode as well. Userspace code may use it when making decisions about buffer sizes. Signed-off-by: Tony Battersby --- scst/src/scst_sysfs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 340e73520..131f1b1a5 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -2718,6 +2718,26 @@ out: static struct kobj_attribute scst_tgt_comment = __ATTR(comment, 0644, scst_tgt_comment_show, scst_tgt_comment_store); + +static ssize_t scst_tgt_sg_tablesize_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct scst_tgt *tgt; + int ret; + + TRACE_ENTRY(); + + tgt = container_of(kobj, struct scst_tgt, tgt_kobj); + + ret = sysfs_emit(buf, "%d\n", tgt->sg_tablesize); + + TRACE_EXIT_RES(ret); + return ret; +} + +static struct kobj_attribute scst_tgt_sg_tablesize = + __ATTR(sg_tablesize, 0444, scst_tgt_sg_tablesize_show, NULL); + /* * Creates an attribute entry for one target. Allows for target driver to * create an attribute that is not for every target. @@ -2910,6 +2930,7 @@ static struct attribute *scst_tgt_attrs[] = { &scst_tgt_aen_disabled.attr, &scst_tgt_forwarding.attr, &scst_tgt_comment.attr, + &scst_tgt_sg_tablesize.attr, &scst_tgt_addr_method.attr, &scst_tgt_io_grouping_type.attr, &scst_tgt_black_hole.attr,