[stgt] [BUG] [tgt-setup-lun] - adding inaccurate LUN to existing target will remove the target itself

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Tue Feb 8 00:44:58 CET 2011


On Mon, 7 Feb 2011 10:17:48 -0500 (EST)
Max Benenson <mbenenso at redhat.com> wrote:

> 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

Your proposal looks ok to me but in the first place, why does the
script checks if the target already exists before adding the lu?
--
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