Bug 1025672

Summary: targetcli: scsi_debug is not unregistered properly after configuring pscsi backstore
Product: Red Hat Enterprise Linux 7 Reporter: Bruno Goncalves <bgoncalv>
Component: targetcliAssignee: Andy Grover <agrover>
Status: CLOSED DUPLICATE QA Contact: Bruno Goncalves <bgoncalv>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: agrover, mhoyer
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1006283 Environment:
Last Closed: 2015-09-01 16:04:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bruno Goncalves 2013-11-01 08:52:25 UTC
+++ This bug was initially created as a clone of Bug #1006283 +++

Description of problem:
After configuring a pscsi backstore using scsi_debug device, it seems the targetcli clearconfig does not remove all information. And then, rmmod scsi_debug does not actually unregister the module.

[root@dell-pem605-01 ~]# rmmod scsi_debug
[root@dell-pem605-01 ~]# ls /proc/scsi/
device_info  mptsas  scsi  scsi_debug  sg  usb-storage

It does not happen with block backstore.

Version-Release number of selected component (if applicable):
uname -r
2.6.32-417.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1.modprobe scsi_debug

2.multipath -l
mpathb (35333333000001f40) dm-3 Linux,scsi_debug
size=8.0M features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=0 status=active
  `- 3:0:0:0 sdc 8:32 active undef running

3.multipath -f mpathb

4. targetcli /backstores/pscsi create pscsi_dev /dev/sdc
Note: block backstore recommended for SCSI block devices
Created pscsi storage object pscsi_dev using /dev/sdc

5. [root@dell-pem605-01 ~]# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................... [0 Storage Object]
  | o- fileio ................................................................................................... [0 Storage Object]
  | o- pscsi .................................................................................................... [1 Storage Object]
  |   o- pscsi_dev .......................................................................................... [/dev/sdc deactivated]
  o- loopback .......................................................................................................... [0 Targets]


6. targetcli clearconfig True
All configuration cleared

7.  targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................... [0 Storage Object]
  | o- fileio ................................................................................................... [0 Storage Object]
  | o- pscsi .................................................................................................... [0 Storage Object]
  o- loopback .......................................................................................................... [0 Targets]

8.  rmmod scsi_debug

9. ls /proc/scsi/
device_info  mptsas  scsi  scsi_debug  sg  usb-storage

Actual results:
rmmod does not clean up all the information

Expected results:


Additional info:
Trying to load the module again causes Call Trace:

------------[ cut here ]------------
WARNING: at fs/proc/generic.c:591 proc_register+0xb9/0x170() (Not tainted)
Hardware name: PowerEdge M605
proc_dir_entry 'scsi/scsi_debug' already registered
Modules linked in: scsi_debug(+) dm_round_robin target_core_iblock target_core_file target_core_pscsi target_core_mod configfs bnx2fc cnic uio fcoe libfcoe 8021q garp libfc stp scsi_transport_fc llc scsi_tgt cp]
Pid: 2209, comm: modprobe Not tainted 2.6.32-417.el6.x86_64 #1
Call Trace:
 [<ffffffff81071f47>] ? warn_slowpath_common+0x87/0xc0
 [<ffffffff81072036>] ? warn_slowpath_fmt+0x46/0x50
 [<ffffffff811fa069>] ? proc_register+0xb9/0x170
 [<ffffffff811fa352>] ? proc_mkdir_mode+0x42/0x60
 [<ffffffff811fa386>] ? proc_mkdir+0x16/0x20
 [<ffffffff81391373>] ? scsi_proc_hostdir_add+0x63/0x90
 [<ffffffff813824f1>] ? scsi_host_alloc+0x2e1/0x330
 [<ffffffffa04c9d22>] ? sdebug_driver_probe+0x32/0x2a0 [scsi_debug]
 [<ffffffff8136da12>] ? driver_sysfs_add+0x62/0x90
 [<ffffffff8136dbb0>] ? driver_probe_device+0xa0/0x2a0
 [<ffffffff8136de60>] ? __device_attach+0x0/0x60
 [<ffffffff8136deb3>] ? __device_attach+0x53/0x60
 [<ffffffff8136cde4>] ? bus_for_each_drv+0x64/0x90
 [<ffffffff8136df94>] ? device_attach+0xa4/0xc0
 [<ffffffff8136cb8d>] ? bus_probe_device+0x2d/0x50
 [<ffffffff8136ae47>] ? device_add+0x527/0x650
 [<ffffffff81373c5b>] ? pm_runtime_init+0xcb/0xe0
 [<ffffffff8136af8e>] ? device_register+0x1e/0x30
 [<ffffffffa04ca3a7>] ? sdebug_add_adapter+0xf7/0x1b0 [scsi_debug]
 [<ffffffff8152a547>] ? _spin_unlock_irqrestore+0x17/0x20
 [<ffffffffa04db7d2>] ? scsi_debug_init+0x7d2/0x864 [scsi_debug]
 [<ffffffff810a1905>] ? __blocking_notifier_call_chain+0x65/0x80
 [<ffffffffa04db000>] ? scsi_debug_init+0x0/0x864 [scsi_debug]
 [<ffffffff8100204c>] ? do_one_initcall+0x3c/0x1d0
 [<ffffffff810bc6d1>] ? sys_init_module+0xe1/0x250
 [<ffffffff8100b072>] ? system_call_fastpath+0x16/0x1b
---[ end trace 6310543367f3c613 ]---

Comment 1 Bruno Goncalves 2013-11-01 08:53:24 UTC
RHEL7 Call Trace using targetcli-2.1.fb30-1.el7.noarch, 3.10.0-33.el7.x86_64.

[  532.739481] ------------[ cut here ]------------
[  532.764107] WARNING: at fs/proc/generic.c:356 proc_register+0xc0/0x140()
[  532.799152] proc_dir_entry 'scsi/scsi_debug' already registered
[  532.828955] Modules linked in: scsi_debug(+) target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod dm_service_time sg coretemp kvm_intel kvm crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd iTCO_wdt bnx2x iTCO_vendor_support mdio hpwdt hpilo sb_edac ntb ioatdma lpc_ich microcode serio_raw pcspkr edac_core mfd_core dca shpchp acpi_power_meter mperf nfsd auth_rpcgss nfs_acl lockd sunrpc dm_multipath xfs libcrc32c mgag200 syscopyarea sysfillrect sysimgblt i2c_algo_bit drm_kms_helper sd_mod ttm crc_t10dif drm i2c_core hpsa dm_mirror dm_region_hash dm_log dm_mod [last unloaded: scsi_debug]
[  533.133482] CPU: 41 PID: 3681 Comm: modprobe Tainted: G        W   --------------   3.10.0-33.el7.x86_64 #1
[  533.183529] Hardware name: HP ProLiant DL560 Gen8, BIOS P77 05/30/2012
[  533.216979]  0000000000000009 ffff881024451a48 ffffffff815fdacb ffff881024451a80
[  533.253856]  ffffffff81058c61 ffff8810277dd500 ffff88081c7a0675 ffff88081c7a0600
[  533.292451]  ffff880c29aecb00 ffff8810277dd500 ffff881024451ae0 ffffffff81058ccc
[  533.330540] Call Trace:
[  533.342898]  [<ffffffff815fdacb>] dump_stack+0x19/0x1b
[  533.368365]  [<ffffffff81058c61>] warn_slowpath_common+0x61/0x80
[  533.399409]  [<ffffffff81058ccc>] warn_slowpath_fmt+0x4c/0x50
[  533.428426]  [<ffffffff81201e76>] ? proc_alloc_inum+0x36/0x140
[  533.459296]  [<ffffffff81202040>] proc_register+0xc0/0x140
[  533.486726]  [<ffffffff812021c2>] proc_mkdir_data+0x52/0x80
[  533.516066]  [<ffffffff81202225>] proc_mkdir+0x15/0x20
[  533.541907]  [<ffffffff81413413>] scsi_proc_hostdir_add+0x63/0x90
[  533.573572]  [<ffffffff81405e45>] scsi_host_alloc+0x2e5/0x350
[  533.604692]  [<ffffffffa02f4ac6>] sdebug_driver_probe+0x36/0x2b0 [scsi_debug]
[  533.642250]  [<ffffffff813de062>] ? driver_sysfs_add+0x82/0xb0
[  533.671790]  [<ffffffff813de727>] driver_probe_device+0x87/0x390
[  533.702666]  [<ffffffff813dea30>] ? driver_probe_device+0x390/0x390
[  533.733651]  [<ffffffff813dea6b>] __device_attach+0x3b/0x40
[  533.762589]  [<ffffffff813dc723>] bus_for_each_drv+0x63/0xa0
[  533.791943]  [<ffffffff813de628>] device_attach+0x88/0xa0
[  533.820296]  [<ffffffff813dd998>] bus_probe_device+0x98/0xc0
[  533.848898]  [<ffffffff813db634>] device_add+0x4c4/0x7a0
[  533.876368]  [<ffffffff813db92a>] device_register+0x1a/0x20
[  533.904687]  [<ffffffffa02f5fc4>] sdebug_add_adapter+0xf4/0x1a0 [scsi_debug]
[  533.941239]  [<ffffffffa02cc7f2>] scsi_debug_init+0x7f2/0x1000 [scsi_debug]
[  533.976396]  [<ffffffffa02cc000>] ? 0xffffffffa02cbfff
[  534.003249]  [<ffffffff810020e2>] do_one_initcall+0xe2/0x190
[  534.031935]  [<ffffffff810be3dc>] load_module+0x13fc/0x19f0
[  534.060241]  [<ffffffff8130b4b0>] ? ddebug_proc_write+0xf0/0xf0
[  534.090153]  [<ffffffff810bad34>] ? copy_module_from_fd.isra.42+0x44/0x140
[  534.125293]  [<ffffffff810beb46>] SyS_finit_module+0x86/0xb0
[  534.155017]  [<ffffffff8160cf99>] system_call_fastpath+0x16/0x1b
[  534.185144] ---[ end trace 3aa5242266fae25e ]---

Comment 2 Andy Grover 2013-11-04 22:28:50 UTC
Setting to ASSIGNED for clearconfig part. The oops on rmmod might be worthy of a separate bug.

Comment 4 Ludek Smid 2014-06-26 10:48:40 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

Comment 5 Ludek Smid 2014-06-26 11:16:42 UTC
The comment above is incorrect. The correct version is bellow.
I'm sorry for any inconvenience.
---------------------------------------------------------------

This request was NOT resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you need
to escalate this bug.

Comment 6 Bruno Goncalves 2014-10-31 08:59:30 UTC
Still reproducible on 3.10.0-195.el7

Oct 30 14:59:27 hp-nehalem-01 kernel: ------------[ cut here ]------------
Oct 30 14:59:27 hp-nehalem-01 kernel: WARNING: at fs/proc/generic.c:356 proc_register+0xc0/0x140()
Oct 30 14:59:27 hp-nehalem-01 kernel: proc_dir_entry 'scsi/scsi_debug' already registered
Oct 30 14:59:28 hp-nehalem-01 kernel: Modules linked in: scsi_debug(+) dm_crypt xts gf128mul target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod iptable_filter ip_tables ext4 mbcache jbd2 dm_service_time iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi nfsv3 nfs_acl rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd sunrpc fscache cfg80211 rfkill iTCO_wdt iTCO_vendor_support coretemp hpilo hpwdt i7core_edac kvm_intel lpc_ich kvm ipmi_si crc32c_intel pcspkr serio_raw mfd_core edac_core shpchp ipmi_msghandler acpi_power_meter pcc_cpufreq dm_multipath xfs libcrc32c sr_mod cdrom sd_mod ata_generic crc_t10dif crct10dif_common pata_acpi radeon i2c_algo_bit drm_kms_helper ttm ata_piix drm libata i2c_core hpsa netxen_nic dm_mirror dm_region_hash dm_log dm_mod [last unloaded: scsi_debug]
Oct 30 14:59:28 hp-nehalem-01 kernel: 
Oct 30 14:59:28 hp-nehalem-01 kernel: CPU: 14 PID: 14183 Comm: modprobe Not tainted 3.10.0-195.el7.x86_64 #1
Oct 30 14:59:28 hp-nehalem-01 kernel: Hardware name: HP ProLiant DL580 G7, BIOS P65 12/01/2011
Oct 30 14:59:28 hp-nehalem-01 kernel: ffff880238017a40 0000000069395bd5 ffff8802380179f8 ffffffff81603757
Oct 30 14:59:28 hp-nehalem-01 kernel: ffff880238017a30 ffffffff8106e241 ffff880238834900 ffff880437b20d35
Oct 30 14:59:28 hp-nehalem-01 kernel: ffff880437b20cc0 ffff880239e3e000 ffff880238834900 ffff880238017a98
Oct 30 14:59:28 hp-nehalem-01 kernel: Call Trace:
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff81603757>] dump_stack+0x19/0x1b
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff8106e241>] warn_slowpath_common+0x61/0x80
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff8106e2bc>] warn_slowpath_fmt+0x5c/0x80
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff812320f6>] ? proc_alloc_inum+0x46/0x160
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff812322d0>] proc_register+0xc0/0x140
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff81232452>] proc_mkdir_data+0x52/0x80
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff812324b5>] proc_mkdir+0x15/0x20
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff813ff443>] scsi_proc_hostdir_add+0x63/0x90
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffff813f05a7>] scsi_host_alloc+0x387/0x470
Oct 30 14:59:28 hp-nehalem-01 kernel: [<ffffffffa051fe16>] sdebug_driver_probe+0x46/0x2c0 [scsi_debug]
Oct 30 14:59:29 hp-nehalem-01 sh: abrt-dump-oops: Found oopses: 1
Oct 30 14:59:29 hp-nehalem-01 sh: abrt-dump-oops: Creating problem directories
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d1a52>] ? driver_sysfs_add+0x82/0xb0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d2137>] driver_probe_device+0x87/0x390
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d2440>] ? driver_probe_device+0x390/0x390
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d247b>] __device_attach+0x3b/0x40
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813cff9b>] bus_for_each_drv+0x6b/0xb0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d2038>] device_attach+0x88/0xa0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813d1338>] bus_probe_device+0x98/0xc0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813cede4>] device_add+0x4c4/0x7a0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff813cf0da>] device_register+0x1a/0x20
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffffa0521574>] sdebug_add_adapter+0xf4/0x1a0 [scsi_debug]
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffffa05345e9>] scsi_debug_init+0x5e9/0x1000 [scsi_debug]
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffffa0534000>] ? 0xffffffffa0533fff
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff810020b8>] do_one_initcall+0xb8/0x230
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff810dcf5a>] load_module+0x131a/0x1b20
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff812f6400>] ? ddebug_proc_write+0xf0/0xf0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff810d94f3>] ? copy_module_from_fd.isra.43+0x53/0x150
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff810dd916>] SyS_finit_module+0xa6/0xd0
Oct 30 14:59:29 hp-nehalem-01 kernel: [<ffffffff81613769>] system_call_fastpath+0x16/0x1b
Oct 30 14:59:29 hp-nehalem-01 kernel: ---[ end trace b9a86033d4c0b2db ]---

Comment 13 Bruno Goncalves 2015-08-12 13:15:32 UTC
I get an error creating pscsi using scsi_debug device, is this expected on newer version?
Note that pscsi device is shown on targetcli

# lsscsi
[0:0:0:0]    disk    ATA      ST9250610NS      AA09  /dev/sda 
[7:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdb 

#  targetcli /backstores/pscsi create pscsi_dev /dev/sdb
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
Note: block backstore recommended for SCSI block devices
'export_backstore_name_as_model' is set but emulate_model_alias
  not supported by kernel.

# echo $?
1

# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 1]
  | | o- pscsi_dev .......................................................................................... [/dev/sdb deactivated]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 0]
  o- loopback ......................................................................................................... [Targets: 0]


kernel 3.10.0-302.el7.x86_64
targetcli-2.1.fb41-2.el7.noarch

Comment 15 Andy Grover 2015-08-18 15:55:00 UTC
fixed in targetcli-2.1.fb41-3

Comment 16 Bruno Goncalves 2015-08-20 11:09:43 UTC
verified using:

targetcli-2.1.fb41-3.el7.noarch

# uname -r
3.10.0-304.el7.x86_64

##############################

# modprobe scsi_debug

# multipath -l
mpatha (35333333000002710) dm-3 Linux   ,scsi_debug      
size=8.0M features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=0 status=active
  `- 4:0:0:0 sdb 8:16 active undef running

# multipath -f mpatha
#
#  targetcli /backstores/pscsi create pscsi_dev /dev/sdb 
Note: block backstore recommended for SCSI block devices
Created pscsi storage object pscsi_dev using /dev/sdb

# targetcli ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 1]
  | | o- pscsi_dev ...................................... [/dev/sdb deactivated]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]

# targetcli clearconfig True
All configuration cleared

# targetcli ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]


# ls /proc/scsi/
device_info  scsi  scsi_debug  sg

# rmmod scsi_debug
#

# ls /proc/scsi/
device_info  scsi  sg

Comment 17 Andy Grover 2015-09-01 16:04:07 UTC
this was fixed by the lio rebase, marking closed.

*** This bug has been marked as a duplicate of bug 1136558 ***