From a5e93d46b000b80bfb801203ca242b4094289f8d Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 5 Jan 2018 05:02:32 +0000 Subject: [PATCH 1/2] scst: fix displaying "mgmt" sysfs help information git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7327 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 5 +++++ scst/src/dev_handlers/scst_user.c | 1 + scst/src/dev_handlers/scst_vdisk.c | 2 +- scst/src/scst_sysfs.c | 12 ++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index e08d52a2a..916dd7658 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1354,6 +1354,11 @@ struct scst_dev_type { */ unsigned auto_cm_assignment_possible:1; + /* + * Set if this handler does not have run time devices management + */ + unsigned no_mgmt:1; + /* * Called to parse CDB from the cmd and initialize * cmd->bufflen and cmd->data_direction (both - REQUIRED). diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index c2dd44aec..7e9962bcf 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -234,6 +234,7 @@ static const struct file_operations dev_user_fops = { }; static struct scst_dev_type dev_user_devtype = { + .no_mgmt = 1, .name = DEV_USER_NAME, .type = -1, .parse = dev_usr_parse, diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 3eb0199a7..3b3047d7c 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -865,7 +865,7 @@ static struct scst_dev_type vdisk_null_devtype = { "blocksize, " "dif_mode, " "dif_type, " - "dif_static_app_tag, ", + "dif_static_app_tag, " "dummy, " "numa_node_id, " "cluster_mode, " diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index be1edab25..ba163fc73 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -903,7 +903,7 @@ static ssize_t scst_tgtt_mgmt_show(struct kobject *kobj, "\n" "where parameters are one or more " "param_name=value pairs separated by ';'\n\n" - "%s%s%s%s%s%s%s%s\n"; + "%s%s%s%s%s%s%s%s%s%s\n"; struct scst_tgt_template *tgtt; tgtt = container_of(kobj, struct scst_tgt_template, tgtt_kobj); @@ -916,10 +916,12 @@ static ssize_t scst_tgtt_mgmt_show(struct kobject *kobj, " echo \"add_target_attribute target_name \" >mgmt\n" " echo \"del_target_attribute target_name \" >mgmt\n" : "", (tgtt->mgmt_cmd_help) ? tgtt->mgmt_cmd_help : "", + (tgtt->mgmt_cmd_help) ? "\n" : "", (tgtt->add_target_parameters != NULL) ? "The following parameters available: " : "", (tgtt->add_target_parameters != NULL) ? tgtt->add_target_parameters : "", + (tgtt->add_target_parameters != NULL) ? "\n" : "", (tgtt->tgtt_optional_attributes != NULL) ? "The following target driver attributes available: " : "", (tgtt->tgtt_optional_attributes != NULL) ? @@ -5935,7 +5937,7 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj, "\n" "where parameters are one or more " "param_name=value pairs separated by ';'\n\n" - "%s%s%s%s%s%s%s%s\n"; + "%s%s%s%s%s%s%s%s%s%s\n"; struct scst_dev_type *devt; devt = container_of(kobj, struct scst_dev_type, devt_kobj); @@ -5945,13 +5947,15 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj, " echo \"add_attribute \" >mgmt\n" " echo \"del_attribute \" >mgmt\n" : "", (devt->dev_optional_attributes != NULL) ? - " echo \"add_device_attribute device_name \" >mgmt" + " echo \"add_device_attribute device_name \" >mgmt\n" " echo \"del_device_attribute device_name \" >mgmt\n" : "", (devt->mgmt_cmd_help) ? devt->mgmt_cmd_help : "", + (devt->mgmt_cmd_help) ? "\n" : "", (devt->add_device_parameters != NULL) ? "The following parameters available: " : "", (devt->add_device_parameters != NULL) ? devt->add_device_parameters : "", + (devt->add_device_parameters != NULL) ? "\n" : "", (devt->devt_optional_attributes != NULL) ? "The following dev handler attributes available: " : "", (devt->devt_optional_attributes != NULL) ? @@ -6250,7 +6254,7 @@ int scst_devt_sysfs_create(struct scst_dev_type *devt) if (devt->add_device != NULL) { res = sysfs_create_file(&devt->devt_kobj, &scst_devt_mgmt.attr); - } else { + } else if (!devt->no_mgmt) { res = sysfs_create_file(&devt->devt_kobj, &scst_devt_pass_through_mgmt.attr); } From cbc53b12c8ace08a407809e6502b7faf441c438b Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 5 Jan 2018 05:14:03 +0000 Subject: [PATCH 2/2] scst_vdisk: lower severity of message about not supported fallocate(FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE) and print it only once git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7328 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_debug.h | 9 +++++++++ scst/src/dev_handlers/scst_vdisk.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index de8f50d7e..9c075c3f0 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -399,4 +399,13 @@ do { \ #define SCST_SLAB_FLAGS 0L #endif +#define PRINT_WARNING_ONCE(format, args...) \ +do { \ + static bool __warned; \ + if (!__warned) { \ + __warned = true; \ + PRINT_WARNING(format, ## args); \ + } \ +} while(0) + #endif /* __SCST_DEBUG_H */ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 3b3047d7c..031c0b972 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3847,7 +3847,7 @@ static int vdisk_unmap_file_range(struct scst_cmd *cmd, res = fd->f_op->fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, len); if (unlikely(res != 0)) { - PRINT_ERROR("fallocate() for %lld, len %lld " + PRINT_WARNING_ONCE("fallocate() for %lld, len %lld " "failed: %d", (unsigned long long)off, (unsigned long long)len, res); scst_set_cmd_error(cmd,