open-iscsi / rtslib-fb

Python library for configuring the Linux kernel-based multiprotocol SCSI target (LIO)
Apache License 2.0
73 stars 90 forks source link

RTSLibNotInCFS: Storage object user/app2 not found #142

Closed NUABO closed 5 years ago

NUABO commented 5 years ago

hi,after using targetcli to delete two targets in succession, re-create one. At this time, use rtslib-fb to view the target information error.

logging.error("size %s" % lun.storage_object.size) File "/usr/lib/python2.7/site-packages/rtslib_fb/target.py", line 565, in _get_storage_object return tcm.StorageObject.so_from_path(alias_path) File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 129, in so_from_path return so_mappingso_type File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 828, in init super(UserBackedStorageObject, self).init(name, 'lookup') File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 66, in init self._backstore = _Backstore(name, type(self), mode) File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 971, in init (self._plugin, name)) RTSLibNotInCFS: Storage object user/app2 not found

[ERROR] <class 'rtslib_fb.utils.RTSLibNotInCFS'>:No such _Backstore in configfs: /sys/kernel/config/target/core/user_2 [ERROR] <class 'rtslib_fb.utils.RTSLibNotInCFS'>:Storage object user/app2 not found

But at this time in sysfs, you can view user/app2

[root@node3 ssan-dms]# ll /sys/kernel/config/target/core/user_0 total 0 drwxr-xr-x 8 root root 0 Jan 5 10:24 app2 -r--r--r-- 1 root root 4096 Jan 5 10:37 hba_info -rw-r--r-- 1 root root 4096 Jan 5 10:37 hba_mode [root@node3 ssan-dms]# ll /sys/kernel/config/target/core/user_2 total 0 drwxr-xr-x 8 root root 0 Jan 5 10:24 app3 -r--r--r-- 1 root root 4096 Jan 5 10:37 hba_info -rw-r--r-- 1 root root 4096 Jan 5 10:37 hba_mode [root@node3 ssan-dms]# ll /sys/kernel/config/target/core/ total 0 drwxr-xr-x 3 root root 0 Jan 2 09:53 alua drwxr-xr-x 3 root root 0 Jan 5 10:37 user_0 drwxr-xr-x 3 root root 0 Jan 5 10:37 user_2 drwxr-xr-x 3 root root 0 Jan 5 10:35 user_3

As shown in the figure, app2 is now in the user_0 path, but the error message is in No such _Backstore in configfs: /sys/kernel/config/target/core/user_2

Rtslib-fb will automatically find the new path traversal, why is it always [ERROR] <class 'rtslib_fb.utils.RTSLibNotInCFS'>:Storage object user/app2 not found?

mikechristie commented 5 years ago

I think you need to invalidate the cache or not use the cache at all and/or update rtslib.

In this patch https://github.com/open-iscsi/rtslib-fb/commit/f7fc7a7f96d66b222388bae8f783885ad534114c we now skip the cache when scanning from sysfs so this fixes bugs when looping over devices.

You might also need to do an invalidate call in your app or manage your own ID space. In this patch for the ceph tools I just added an invalidate call during device creation:

https://github.com/ceph/ceph-iscsi-config/pull/95/files#diff-48d98f32cf5a5a487e05c20521d55b0eR747

NUABO commented 5 years ago

hi @mikechristie, thanks for your help, i will try :smile: