Problem: 'vol_destroy' call will failed with error -303 indicating the requested volume is masked if that volume was masked to any access group.
Root cause: The 'destroy()' method use tpg.luns to check whether certain volume is still masked/exported/mapped to any initiator or access group. The 'access_group_map_destroy()' does not remove StorageObject and LUN instances which cause this false alarm.
Fix: Remove the StorageObject and LUN instances if that lun is not masked to any initiator in access_group_map_destroy() method.
Tested: Tested both for access group volume mapping and initiator volume mapping.
Signed-off-by: Gris Ge fge@redhat.com --- targetd/block.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/targetd/block.py b/targetd/block.py index 888e6e4..2d7d1e1 100644 --- a/targetd/block.py +++ b/targetd/block.py @@ -582,4 +582,11 @@ def access_group_map_destroy(req, pool_name, vol_name, ag_name): if map_group.tpg_lun == tpg_lun: map_group.delete()
+ if not len(list(tpg_lun.mapped_luns)): + # If LUN is not masked to any access group or initiator + # remove LUN instance. + lun_so = tpg_lun.storage_object + tpg_lun.delete() + lun_so.delete() + RTSRoot().save_to_file()
targetd-devel@lists.fedorahosted.org