RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 676337 - [tgt-setup-lun] - adding inaccurate LUN to existing target will remove the target itself
Summary: [tgt-setup-lun] - adding inaccurate LUN to existing target will remove the ta...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: scsi-target-utils
Version: 6.0
Hardware: Unspecified
OS: Linux
medium
urgent
Target Milestone: rc
: ---
Assignee: Andy Grover
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks: 695867
TreeView+ depends on / blocked
 
Reported: 2011-02-09 15:06 UTC by Max Benenson
Modified: 2015-09-28 02:08 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
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.
Clone Of:
: 695867 (view as bug list)
Environment:
Last Closed: 2011-05-19 14:15:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
fix (703 bytes, patch)
2011-03-08 19:24 UTC, Andy Grover
no flags Details | Diff
revised fix (1.09 KB, patch)
2011-03-08 21:00 UTC, Andy Grover
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0734 0 normal SHIPPED_LIVE scsi-target-utils bug fix and enhancement update 2011-05-18 18:31:39 UTC

Description Max Benenson 2011-02-09 15:06:23 UTC
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

Comment 2 Mike Christie 2011-02-14 21:09:05 UTC
Did you send some patches to the upstream tgt list for this?

Comment 3 Max Benenson 2011-02-15 19:00:04 UTC
(In reply to comment #2)
> Did you send some patches to the upstream tgt list for this?
No, I did not.

Comment 4 Andy Grover 2011-03-08 19:24:56 UTC
Created attachment 482991 [details]
fix

proposed fix attached.

Comment 5 Mike Christie 2011-03-08 20:37:36 UTC
Hey, I do not think Erez works at Voltaire anymore.

Comment 6 Andy Grover 2011-03-08 21:00:48 UTC
Created attachment 483013 [details]
revised fix

Comment 7 Andy Grover 2011-03-17 22:21:34 UTC
fix in upstream git.

Comment 9 Barry Donahue 2011-04-19 19:46:33 UTC
Verified on 2.6.32-131.0.1.el6.x86_64.

Comment 10 Laura Bailey 2011-05-05 05:11:17 UTC
    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.

Comment 11 errata-xmlrpc 2011-05-19 14:15:02 UTC
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


Note You need to log in before you can comment on or make changes to this bug.