[stgt] [BUG] [tgt-setup-lun] - adding inaccurate LUN to existing target will remove the target itself
Max Benenson
mbenenso at redhat.com
Mon Feb 7 16:17:48 CET 2011
Description of problem:
=======================
If you try to add a new LUN (and pass not existing device and the target name that already exists) the operation will fail since the target with the same name already exists and then the utility will suggest to the user to add this 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 will remove the target itself (a kind of rollback).
Steps to reproduce:
===================
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
the last line will produce the following output:
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
Actual result:
==============
The target with id 1 was removed from the targets.conf file.
Expected result:
================
The rollback action should consider the presence of existing target and should NOT remove it.
Environment details:
====================
[root at auto-filer01 tgt]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.0 (Santiago)
[root at 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 at 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 at 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
Resolution:
===========
IMHO the fix should be in err_exit() method which should verify (using additional function)
LUN presence in the target before performing "tgtadm --lld $lld_name --op delete --mode target --tid $tid".
Something like (I am using Python syntax):
if not hasAttachedLUN($tid):
tgtadm --lld $lld_name --op delete --mode target --tid $tid
Regards,
Max
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list