Hide Forgot
Description of problem: If you try to add a new LUN based on non existing device and provide the target name that already exists, the operation will fail since the target with the same name already exists. Then the utility will suggest to the user to add new LUN to this existing target and if the user will select to proceed it will fail since the device does not exist and as the result, the rollback action will remove the target itself. Version-Release number of selected component (if applicable): scsi-target-utils-1.0.4-3.el6.x86_64 How reproducible: Always Steps to Reproduce (/dev/vg_autofiler01/max_lv02 doesn't exist): 1. lvcreate -L 10G -n /dev/vg_autofiler01/max_lv01 2. tgt-setup-lun -n target1 -d /dev/vg_autofiler01/max_lv01 -t iscsi 3. tgt-setup-lun -n target1 -d /dev/vg_autofiler01/max_lv02 -t iscsi Actual results: Using transport: iscsi Error: target named iqn.2001-04.com.auto-filer01-target1 already exists Add a new lun to the existing target? (yes/NO): yes Adding a logical unit (/dev/vg_autofiler01/max_lv02) to target, tid=1 tgtadm: invalid request Error: failed to add a logical unit (/dev/vg_autofiler01/max_lv02) to target, tid=1 Deleting new target, tid=1 The target with id 1 was removed from the targets.conf file. Expected results: The rollback action should consider the presence of existing target and should NOT remove it. Additional info: [root@auto-filer01 tgt]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.0 (Santiago) [root@auto-filer01 tgt]# rpm -qa | grep kernel dracut-kernel-004-33.2.el6_0.noarch abrt-addon-kerneloops-1.1.13-4.el6.x86_64 kernel-firmware-2.6.32-71.14.1.el6.noarch kernel-2.6.32-71.14.1.el6.x86_64 kernel-2.6.32-71.el6.x86_64 [root@auto-filer01 tgt]# rpm -qa | grep lvm lvm2-2.02.72-8.el6_0.4.x86_64 lvm2-libs-2.02.72-8.el6_0.4.x86_64 [root@auto-filer01 tgt]# less /var/log/messages Jan 31 17:43:09 auto-filer01 tgtd: backed_file_open(92) Could not open /dev/vg_autofiler01/max_lv02, No such file or directory IMHO, there are few fixes: 1. Add new function that validates if a target is empty 2. Fix err_exit() function to use the function from 1 above before remove any target 3. Remove the validation if target already exists during 'add new LUN' sequence
Did you send some patches to the upstream tgt list for this?
(In reply to comment #2) > Did you send some patches to the upstream tgt list for this? No, I did not.
Created attachment 482991 [details] fix proposed fix attached.
Hey, I do not think Erez works at Voltaire anymore.
Created attachment 483013 [details] revised fix
fix in upstream git.
Verified on 2.6.32-131.0.1.el6.x86_64.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Providing an existing target name to tgt-setup-lun when attempting to add a new LUN based on a nonexistant device correctly resulted in failure because a target with the same name already existed. If the user then followed the utility's suggestion to add the new LUN to the existing target, the operation failed (again, correctly) because the device did not exist. However, the rollback action associated with this second failure resulted in the target being removed. The rollback action now checks whether the target pre-existed the failed actions, so the target is not removed in this circumstance.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0734.html