|
|
71285d |
From f06103354394ffa86817696a37edb7ddd351bc10 Mon Sep 17 00:00:00 2001
|
|
|
71285d |
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
71285d |
Date: Fri, 9 Feb 2018 17:20:26 +0530
|
|
|
71285d |
Subject: [PATCH] create: remove stale hba-only dir
|
|
|
71285d |
|
|
|
71285d |
curretly if there exist any stale hba-only directories,
|
|
|
71285d |
|
|
|
71285d |
$ ls /sys/kernel/config/target/core/user_0/
|
|
|
71285d |
hba_info hba_mode
|
|
|
71285d |
|
|
|
71285d |
Then backend creation fails,
|
|
|
71285d |
|
|
|
71285d |
$ targetcli /backstores/fileio create block file 1M
|
|
|
71285d |
This _Backstore already exists in configFS
|
|
|
71285d |
|
|
|
71285d |
We will have to restart target.service or restore the configuration
|
|
|
71285d |
again to clear the stale hba-only dirs.
|
|
|
71285d |
|
|
|
71285d |
This patch checks for hba directory before creating one,
|
|
|
71285d |
if it is already existing and found to be stale then removes it.
|
|
|
71285d |
|
|
|
71285d |
Thanks to "Maurizio Lombardi <mlombard@redhat.com>" for debugging along
|
|
|
71285d |
|
|
|
71285d |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
71285d |
---
|
|
|
71285d |
rtslib/node.py | 11 +++++++++--
|
|
|
71285d |
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
71285d |
|
|
|
71285d |
diff --git a/rtslib/node.py b/rtslib/node.py
|
|
|
71285d |
index c0092fc..1d77cd1 100644
|
|
|
71285d |
--- a/rtslib/node.py
|
|
|
71285d |
+++ b/rtslib/node.py
|
|
|
71285d |
@@ -52,9 +52,16 @@ class CFSNode(object):
|
|
|
71285d |
'''
|
|
|
71285d |
if mode not in ['any', 'lookup', 'create']:
|
|
|
71285d |
raise RTSLibError("Invalid mode: %s" % mode)
|
|
|
71285d |
+
|
|
|
71285d |
if self.exists and mode == 'create':
|
|
|
71285d |
- raise RTSLibError("This %s already exists in configFS"
|
|
|
71285d |
- % self.__class__.__name__)
|
|
|
71285d |
+ # ensure that self.path is not stale hba-only dir
|
|
|
71285d |
+ if os.path.samefile(os.path.dirname(self.path), self.configfs_dir+'/core') \
|
|
|
71285d |
+ and not next(os.walk(self.path))[1]:
|
|
|
71285d |
+ os.rmdir(self.path)
|
|
|
71285d |
+ else:
|
|
|
71285d |
+ raise RTSLibError("This %s already exists in configFS"
|
|
|
71285d |
+ % self.__class__.__name__)
|
|
|
71285d |
+
|
|
|
71285d |
elif not self.exists and mode == 'lookup':
|
|
|
71285d |
raise RTSLibNotInCFS("No such %s in configfs: %s"
|
|
|
71285d |
% (self.__class__.__name__, self.path))
|
|
|
71285d |
--
|
|
|
71285d |
1.8.3.1
|
|
|
71285d |
|