From ab0d13c09c40b4f99012b11980fe998a95139619 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 20 Apr 2010 13:20:47 +0000 Subject: [PATCH] Uniform virtual and pass-through dev handlers for simplicity. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1632 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 9 ++--- scst/README_in-tree | 9 ++--- scst/SysfsRules | 56 +++++++++----------------- scst/include/scst.h | 3 -- scst/src/dev_handlers/scst_cdrom.c | 1 - scst/src/dev_handlers/scst_changer.c | 1 - scst/src/dev_handlers/scst_disk.c | 2 - scst/src/dev_handlers/scst_modisk.c | 2 - scst/src/dev_handlers/scst_processor.c | 1 - scst/src/dev_handlers/scst_raid.c | 1 - scst/src/dev_handlers/scst_tape.c | 2 - scst/src/scst_sysfs.c | 48 ++++++++-------------- 12 files changed, 41 insertions(+), 94 deletions(-) diff --git a/scst/README b/scst/README index 758c365c3..cd2bac352 100644 --- a/scst/README +++ b/scst/README @@ -665,9 +665,6 @@ Standard SCST dev handlers have at least the following common entries: SCSI devices to/from this dev handler (for pass-through dev handlers). - - pass_through - if exists, it contains 1 and this dev handler is a - pass-through dev handler. - - trace_level - allows to enable and disable various tracing facilities. See content of this file for help how to use it. @@ -1388,14 +1385,14 @@ Each pass-through dev handler has in its root subdirectory /sys/kernel/scst_tgt/handlers/dev_disk, "mgmt" file. It allows the following commands. They can be sent to it using, e.g., echo command. - - "assign" - this command assigns SCSI device with + - "add_device" - this command assigns SCSI device with host:channel:id:lun numbers to this dev handler. -echo "assign 1:0:0:0" >mgmt +echo "add_device 1:0:0:0" >mgmt will assign SCSI device 1:0:0:0 to this dev handler. - - "unassign" - this command unassigns SCSI device with + - "del_device" - this command unassigns SCSI device with host:channel:id:lun numbers from this dev handler. As usually, on read the "mgmt" file returns small help about available diff --git a/scst/README_in-tree b/scst/README_in-tree index ba955b5aa..7dc79c345 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -348,9 +348,6 @@ Standard SCST dev handlers have at least the following common entries: SCSI devices to/from this dev handler (for pass-through dev handlers). - - pass_through - if exists, it contains 1 and this dev handler is a - pass-through dev handler. - - trace_level - allows to enable and disable various tracing facilities. See content of this file for help how to use it. @@ -975,14 +972,14 @@ Each pass-through dev handler has in its root subdirectory /sys/kernel/scst_tgt/handlers/dev_disk, "mgmt" file. It allows the following commands. They can be sent to it using, e.g., echo command. - - "assign" - this command assigns SCSI device with + - "add_device" - this command assigns SCSI device with host:channel:id:lun numbers to this dev handler. -echo "assign 1:0:0:0" >mgmt +echo "add_device 1:0:0:0" >mgmt will assign SCSI device 1:0:0:0 to this dev handler. - - "unassign" - this command unassigns SCSI device with + - "del_device" - this command unassigns SCSI device with host:channel:id:lun numbers from this dev handler. As usually, on read the "mgmt" file returns small help about available diff --git a/scst/SysfsRules b/scst/SysfsRules index 347f2f8c0..649a41e6d 100644 --- a/scst/SysfsRules +++ b/scst/SysfsRules @@ -281,9 +281,6 @@ handlers. Further in this document children dev handlers or parent dev handlers, which don't support children, will be called "end level dev handlers". -Each end level dev handler MUST be either for pass-through, or for -virtual devices. - End level dev handlers can be recognized by existence of the "mgmt" attribute. @@ -294,13 +291,9 @@ scst_device.virt_name (called "device_name" further in this document). Attributes for dev handlers --------------------------- -Each pass-through dev handler MUST have in its root subdirectory -"pass-through" and "mgmt" attributes and the "mgmt" attribute MUST -support "assign" and "unassign" commands as described below. - -Each virtual devices dev handler MUST have it in its root subdirectory -"mgmt" attribute, which MUST support "add_device" and "del_device" -attributes as described below. +Each dev handler MUST have it in its root subdirectory "mgmt" attribute, +which MUST support "add_device" and "del_device" attributes as described +below. Parent dev handlers and end level dev handlers without parents MAY support in its root subdirectory the following optional attributes. They @@ -445,38 +438,35 @@ Attribute "mgmt" for pass-through devices dev handlers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For pass-through devices dev handlers "mgmt" attribute MUST allow to -assign and unassign this dev handler to existing SCSI devices. +assign and unassign this dev handler to existing SCSI devices via +"add_device" and "del_device" commands correspondingly. On read it MUST return a help string describing available commands and parameters. For example: -Usage: echo "assign H:C:I:L" >mgmt - echo "unassign H:C:I:L" >mgmt +Usage: echo "add_device H:C:I:L" >mgmt + echo "del_device H:C:I:L" >mgmt -1. "assign" - this command MUST assign SCSI device with +1. "add_device" - this command MUST assign SCSI device with host:channel:id:lun numbers to this dev handler. All pass-through dev handlers MUST support this command. For example: -echo "assign 1:0:0:0" >mgmt +echo "add_device 1:0:0:0" >mgmt will assign SCSI device 1:0:0:0 to this dev handler. -2. "unassign" - this command MUST unassign SCSI device with +2. "del_device" - this command MUST unassign SCSI device with host:channel:id:lun numbers from this dev handler. SCST core will automatically create for all dev handlers the following attributes: -1. "pass_through" - if the dev handler is a handler for pass-through -devices, SCST core create this attribute. This attribute will have value -1. - -2. "type" - SCSI type of device this dev handler can handle. +1. "type" - SCSI type of device this dev handler can handle. See SCST core's README for more info about those attributes. @@ -545,29 +535,24 @@ For devices and dev handlers: 1. Each dev handler in its root subdirectory MUST have "mgmt" attribute. -2. All pass-through dev handlers MUST have "pass_through" attribute. +2. Each dev handler MUST support "add_device" and "del_device" commands +to the "mgmt" attribute as specified above. -3. Each virtual devices dev handler MUST support "add_device" and -"del_device" commands to the "mgmt" attribute as specified above. - -4. Each pass-through dev handler MUST support "assign" and "unassign" -commands to the "mgmt" attribute as specified above. - -5. If dev handler driver supports run time adding new key attributes, it +3. If dev handler driver supports run time adding new key attributes, it MUST support "add_attribute" and "del_attribute" commands to the "mgmt" attribute as specified above. -6. All device handlers have links in the root subdirectory pointing to +4. All device handlers have links in the root subdirectory pointing to their devices. -7. If device has read-only key attributes, the "add_device" command MUST +5. If device has read-only key attributes, the "add_device" command MUST support them as parameters. -8. If device supports run time adding new key attributes, its dev +6. If device supports run time adding new key attributes, its dev handler MUST support "add_device_attribute" and "del_device_attribute" commands to the "mgmt" attribute as specified above. -9. Each device has "handler" link to its dev handler's root +7. Each device has "handler" link to its dev handler's root subdirectory. Algorithm to convert current SCST configuration to config file @@ -681,7 +666,7 @@ only attributes as parameters. 2.4. For pass-through dev handlers for each stores device: 2.4.1. Assign the corresponding pass-through device to this dev handler -using "assign" command, if it isn't already auto assigned to it. +using "add_device" command, if it isn't already auto assigned to it. 3. For each target driver: @@ -755,9 +740,6 @@ not needed any more attributes using "del_device_attribute" command. 2.3.2. If any read only key attribute for virtual device should be changed, delete the devices and recreate it. -2.3.3. For pass-through devices dev handlers reassign handlers if -necessary. - 3. Go through all subdirectories in /sys/kernel/scst_tgt/targets. For each target driver: diff --git a/scst/include/scst.h b/scst/include/scst.h index d7a0a8c3e..cd3329a0c 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -966,9 +966,6 @@ struct scst_dev_type { /* SCSI type of the supported device. MUST HAVE */ int type; - /* True, if this dev handler is a pass-through dev handler */ - unsigned pass_through:1; - /* * True, if corresponding function supports execution in * the atomic (non-sleeping) context diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index 3f5b914d6..447c85bde 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -42,7 +42,6 @@ static int cdrom_done(struct scst_cmd *); static struct scst_dev_type cdrom_devtype = { .name = CDROM_NAME, .type = TYPE_ROM, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .attach = cdrom_attach, diff --git a/scst/src/dev_handlers/scst_changer.c b/scst/src/dev_handlers/scst_changer.c index 832af6ada..1786fcb62 100644 --- a/scst/src/dev_handlers/scst_changer.c +++ b/scst/src/dev_handlers/scst_changer.c @@ -38,7 +38,6 @@ static int changer_parse(struct scst_cmd *); static struct scst_dev_type changer_devtype = { .name = CHANGER_NAME, .type = TYPE_MEDIUM_CHANGER, - .pass_through = 1, .parse_atomic = 1, /* .dev_done_atomic = 1, */ .attach = changer_attach, diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index b57cb6f7d..d4c4c3df5 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -48,7 +48,6 @@ static int disk_exec(struct scst_cmd *cmd); static struct scst_dev_type disk_devtype = { .name = DISK_NAME, .type = TYPE_DISK, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, @@ -65,7 +64,6 @@ static struct scst_dev_type disk_devtype = { static struct scst_dev_type disk_devtype_perf = { .name = DISK_PERF_NAME, .type = TYPE_DISK, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index ef288f420..1eb9f574a 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -48,7 +48,6 @@ static int modisk_exec(struct scst_cmd *); static struct scst_dev_type modisk_devtype = { .name = MODISK_NAME, .type = TYPE_MOD, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, @@ -65,7 +64,6 @@ static struct scst_dev_type modisk_devtype = { static struct scst_dev_type modisk_devtype_perf = { .name = MODISK_PERF_NAME, .type = TYPE_MOD, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, diff --git a/scst/src/dev_handlers/scst_processor.c b/scst/src/dev_handlers/scst_processor.c index 1db54c172..0a2668099 100644 --- a/scst/src/dev_handlers/scst_processor.c +++ b/scst/src/dev_handlers/scst_processor.c @@ -38,7 +38,6 @@ static int processor_parse(struct scst_cmd *); static struct scst_dev_type processor_devtype = { .name = PROCESSOR_NAME, .type = TYPE_PROCESSOR, - .pass_through = 1, .parse_atomic = 1, /* .dev_done_atomic = 1,*/ .attach = processor_attach, diff --git a/scst/src/dev_handlers/scst_raid.c b/scst/src/dev_handlers/scst_raid.c index e13e3dfe4..91aaa5b11 100644 --- a/scst/src/dev_handlers/scst_raid.c +++ b/scst/src/dev_handlers/scst_raid.c @@ -38,7 +38,6 @@ static int raid_parse(struct scst_cmd *); static struct scst_dev_type raid_devtype = { .name = RAID_NAME, .type = TYPE_RAID, - .pass_through = 1, .parse_atomic = 1, /* .dev_done_atomic = 1,*/ .attach = raid_attach, diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index ce597b39b..78638f32c 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -53,7 +53,6 @@ static int tape_exec(struct scst_cmd *); static struct scst_dev_type tape_devtype = { .name = TAPE_NAME, .type = TYPE_TAPE, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, @@ -70,7 +69,6 @@ static struct scst_dev_type tape_devtype = { static struct scst_dev_type tape_devtype_perf = { .name = TAPE_PERF_NAME, .type = TYPE_TAPE, - .pass_through = 1, .parse_atomic = 1, .dev_done_atomic = 1, .exec_atomic = 1, diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 4ecfc8100..f1d0f5ee0 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -3533,20 +3533,11 @@ static struct kobj_attribute scst_devt_mgmt = __ATTR(mgmt, S_IRUGO | S_IWUSR, scst_devt_mgmt_show, scst_devt_mgmt_store); -static ssize_t scst_devt_pass_through_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - return sprintf(buf, "1"); -} - -static struct kobj_attribute scst_devt_pass_through = - __ATTR(pass_through, S_IRUGO, scst_devt_pass_through_show, NULL); - static ssize_t scst_devt_pass_through_mgmt_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - char *help = "Usage: echo \"assign H:C:I:L\" >mgmt\n" - " echo \"unassign H:C:I:L\" >mgmt\n"; + char *help = "Usage: echo \"add_device H:C:I:L\" >mgmt\n" + " echo \"del_device H:C:I:L\" >mgmt\n"; return sprintf(buf, help); } @@ -3641,9 +3632,12 @@ static ssize_t scst_devt_pass_through_mgmt_store(struct kobject *kobj, goto out_unlock; } - if (strcasecmp("assign", action) == 0) + if (strcasecmp("add_device", action) == 0) { res = scst_assign_dev_handler(dev, devt); - else if (strcasecmp("deassign", action) == 0) { + if (res == 0) + PRINT_INFO("Device %s assigned to dev handler %s", + dev->virt_name, devt->name); + } else if (strcasecmp("del_device", action) == 0) { if (dev->handler != devt) { PRINT_ERROR("Device %s is not assigned to handler %s", dev->virt_name, devt->name); @@ -3651,6 +3645,9 @@ static ssize_t scst_devt_pass_through_mgmt_store(struct kobject *kobj, goto out_unlock; } res = scst_assign_dev_handler(dev, &scst_null_devtype); + if (res == 0) + PRINT_INFO("Device %s unassigned from dev handler %s", + dev->virt_name, devt->name); } else { PRINT_ERROR("Unknown action \"%s\"", action); res = -EINVAL; @@ -3712,27 +3709,14 @@ int scst_create_devt_sysfs(struct scst_dev_type *devt) if (devt->add_device != NULL) { retval = sysfs_create_file(&devt->devt_kobj, &scst_devt_mgmt.attr); - if (retval != 0) { - PRINT_ERROR("Can't add mgmt attr for dev handler %s", - devt->name); - goto out; - } - } else if (devt->pass_through) { + } else { retval = sysfs_create_file(&devt->devt_kobj, &scst_devt_pass_through_mgmt.attr); - if (retval != 0) { - PRINT_ERROR("Can't add mgmt attr for dev handler %s", - devt->name); - goto out; - } - - retval = sysfs_create_file(&devt->devt_kobj, - &scst_devt_pass_through.attr); - if (retval != 0) { - PRINT_ERROR("Can't add pass_through attr for dev " - "handler %s", devt->name); - goto out; - } + } + if (retval != 0) { + PRINT_ERROR("Can't add mgmt attr for dev handler %s", + devt->name); + goto out; } pattr = devt->devt_attrs;