pyocf: add option to load cache without openning cores
... this is useful to workaround current pyocf limitations and load cache with manual core insertion Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
58dac85f7b
commit
683174c78f
@ -426,7 +426,12 @@ class Cache:
|
|||||||
raise OcfError("Error adding partition to cache", status)
|
raise OcfError("Error adding partition to cache", status)
|
||||||
|
|
||||||
def configure_device(
|
def configure_device(
|
||||||
self, device, force=False, perform_test=True, cache_line_size=None
|
self,
|
||||||
|
device,
|
||||||
|
force=False,
|
||||||
|
perform_test=True,
|
||||||
|
cache_line_size=None,
|
||||||
|
open_cores=True,
|
||||||
):
|
):
|
||||||
self.device = device
|
self.device = device
|
||||||
self.device_name = device.uuid
|
self.device_name = device.uuid
|
||||||
@ -448,15 +453,22 @@ class Cache:
|
|||||||
_cache_line_size=cache_line_size
|
_cache_line_size=cache_line_size
|
||||||
if cache_line_size
|
if cache_line_size
|
||||||
else self.cache_line_size,
|
else self.cache_line_size,
|
||||||
_open_cores=True,
|
_open_cores=open_cores,
|
||||||
_force=force,
|
_force=force,
|
||||||
_discard_on_start=False,
|
_discard_on_start=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def attach_device(
|
def attach_device(
|
||||||
self, device, force=False, perform_test=False, cache_line_size=None
|
self,
|
||||||
|
device,
|
||||||
|
force=False,
|
||||||
|
perform_test=False,
|
||||||
|
cache_line_size=None,
|
||||||
|
open_cores=True,
|
||||||
):
|
):
|
||||||
self.configure_device(device, force, perform_test, cache_line_size)
|
self.configure_device(
|
||||||
|
device, force, perform_test, cache_line_size, open_cores=open_cores
|
||||||
|
)
|
||||||
self.write_lock()
|
self.write_lock()
|
||||||
|
|
||||||
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
||||||
@ -484,8 +496,8 @@ class Cache:
|
|||||||
if c.results["error"]:
|
if c.results["error"]:
|
||||||
raise OcfError("Attaching cache device failed", c.results["error"])
|
raise OcfError("Attaching cache device failed", c.results["error"])
|
||||||
|
|
||||||
def load_cache(self, device):
|
def load_cache(self, device, open_cores=True):
|
||||||
self.configure_device(device)
|
self.configure_device(device, open_cores=open_cores)
|
||||||
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
||||||
device.owner.lib.ocf_mngt_cache_load(
|
device.owner.lib.ocf_mngt_cache_load(
|
||||||
self.cache_handle, byref(self.dev_cfg), c, None
|
self.cache_handle, byref(self.dev_cfg), c, None
|
||||||
@ -496,12 +508,12 @@ class Cache:
|
|||||||
raise OcfError("Loading cache device failed", c.results["error"])
|
raise OcfError("Loading cache device failed", c.results["error"])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_from_device(cls, device, name="cache"):
|
def load_from_device(cls, device, name="cache", open_cores=True):
|
||||||
c = cls(name=name, owner=device.owner)
|
c = cls(name=name, owner=device.owner)
|
||||||
|
|
||||||
c.start_cache()
|
c.start_cache()
|
||||||
try:
|
try:
|
||||||
c.load_cache(device)
|
c.load_cache(device, open_cores=open_cores)
|
||||||
except: # noqa E722
|
except: # noqa E722
|
||||||
c.stop()
|
c.stop()
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user