Skip to content

Commit

Permalink
Add ability to invalidate caches
Browse files Browse the repository at this point in the history
For efficiency, rtslib may have caches (today for the data
in configfs).  A client may need to clear out these caches
such as via the refresh option in targetcli.

* Add new invalidate_caches method to RTSRoot.  While this only
has a single cache today, it gives the ability to extend to
any future caches.
* While bs_cache really should be private, it probably
shouldn't be changed given that this is a library and may be
used elsewhere.

Signed-off-by: Amartey Pearson <apearson@us.ibm.com>
  • Loading branch information
apearson-ibm committed Feb 7, 2017
2 parents 2c65d97 + 6453b0d commit e54d50d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rtslib/root.py
Expand Up @@ -25,7 +25,7 @@
from .node import CFSNode
from .target import Target
from .fabric import FabricModule
from .tcm import so_mapping, StorageObject
from .tcm import so_mapping, bs_cache, StorageObject
from .utils import RTSLibError, RTSLibALUANotSupported, modprobe, mount_configfs
from .utils import dict_remove, set_attributes
from .alua import ALUATargetPortGroup
Expand Down Expand Up @@ -290,6 +290,12 @@ def restore_from_file(self, restore_file=None, clear_existing=True, abort_on_err
return self.restore(config, clear_existing=clear_existing,
abort_on_error=abort_on_error)

def invalidate_caches(self):
'''
Invalidate any caches used throughout the hierarchy
'''
bs_cache.clear()

targets = property(_list_targets,
doc="Get the list of Target objects.")
tpgs = property(_list_tpgs,
Expand Down

0 comments on commit e54d50d

Please sign in to comment.