pyocf: Move poison out of Volume class
.. so that abstract Volume does not need to be imported to access the poison value. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
232133302b
commit
9975706488
@ -74,8 +74,10 @@ class VolumeIoPriv(Structure):
|
|||||||
_fields_ = [("_data", c_void_p), ("_offset", c_uint64)]
|
_fields_ = [("_data", c_void_p), ("_offset", c_uint64)]
|
||||||
|
|
||||||
|
|
||||||
|
VOLUME_POISON = 0x13
|
||||||
|
|
||||||
|
|
||||||
class Volume(Structure):
|
class Volume(Structure):
|
||||||
VOLUME_POISON = 0x13
|
|
||||||
|
|
||||||
_fields_ = [("_storage", c_void_p)]
|
_fields_ = [("_storage", c_void_p)]
|
||||||
_instances_ = weakref.WeakValueDictionary()
|
_instances_ = weakref.WeakValueDictionary()
|
||||||
@ -98,7 +100,7 @@ class Volume(Structure):
|
|||||||
type(self)._uuid_[self.uuid] = self
|
type(self)._uuid_[self.uuid] = self
|
||||||
|
|
||||||
self.data = create_string_buffer(int(self.size))
|
self.data = create_string_buffer(int(self.size))
|
||||||
memset(self.data, self.VOLUME_POISON, self.size)
|
memset(self.data, VOLUME_POISON, self.size)
|
||||||
self._storage = cast(self.data, c_void_p)
|
self._storage = cast(self.data, c_void_p)
|
||||||
|
|
||||||
self.reset_stats()
|
self.reset_stats()
|
||||||
@ -259,7 +261,7 @@ class Volume(Structure):
|
|||||||
def resize(self, size):
|
def resize(self, size):
|
||||||
self.size = size
|
self.size = size
|
||||||
self.data = create_string_buffer(int(self.size))
|
self.data = create_string_buffer(int(self.size))
|
||||||
memset(self.data, self.VOLUME_POISON, self.size)
|
memset(self.data, VOLUME_POISON, self.size)
|
||||||
self._storage = cast(self.data, c_void_p)
|
self._storage = cast(self.data, c_void_p)
|
||||||
|
|
||||||
def get_max_io_size(self):
|
def get_max_io_size(self):
|
||||||
|
@ -17,7 +17,7 @@ from pyocf.types.cache import (
|
|||||||
)
|
)
|
||||||
from pyocf.types.data import Data
|
from pyocf.types.data import Data
|
||||||
from pyocf.types.core import Core
|
from pyocf.types.core import Core
|
||||||
from pyocf.types.volume import ErrorDevice, Volume
|
from pyocf.types.volume import ErrorDevice, Volume, VOLUME_POISON
|
||||||
from pyocf.types.io import IoDir
|
from pyocf.types.io import IoDir
|
||||||
from pyocf.types.ioclass import IoClassesInfo, IoClassInfo
|
from pyocf.types.ioclass import IoClassesInfo, IoClassInfo
|
||||||
from pyocf.utils import Size as S
|
from pyocf.utils import Size as S
|
||||||
@ -252,7 +252,7 @@ def test_surprise_shutdown_swap_core_with_data(pyocf_ctx):
|
|||||||
assert core2.device.uuid == "dev2"
|
assert core2.device.uuid == "dev2"
|
||||||
assert (
|
assert (
|
||||||
ocf_read(cache, core2, mngmt_op_surprise_shutdown_test_io_offset)
|
ocf_read(cache, core2, mngmt_op_surprise_shutdown_test_io_offset)
|
||||||
== Volume.VOLUME_POISON
|
== VOLUME_POISON
|
||||||
)
|
)
|
||||||
|
|
||||||
mngmt_op_surprise_shutdown_test(pyocf_ctx, tested_func, prepare, check_func)
|
mngmt_op_surprise_shutdown_test(pyocf_ctx, tested_func, prepare, check_func)
|
||||||
@ -353,7 +353,7 @@ def test_surprise_shutdown_stop_cache(pyocf_ctx):
|
|||||||
device.disarm()
|
device.disarm()
|
||||||
cache = None
|
cache = None
|
||||||
|
|
||||||
assert core_device.get_bytes()[io_offset] == Volume.VOLUME_POISON
|
assert core_device.get_bytes()[io_offset] == VOLUME_POISON
|
||||||
|
|
||||||
cache = Cache.load_from_device(device, open_cores=False)
|
cache = Cache.load_from_device(device, open_cores=False)
|
||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
@ -394,7 +394,7 @@ def test_surprise_shutdown_cache_reinit(pyocf_ctx):
|
|||||||
|
|
||||||
cache.stop()
|
cache.stop()
|
||||||
|
|
||||||
assert core_device.get_bytes()[io_offset] == Volume.VOLUME_POISON
|
assert core_device.get_bytes()[io_offset] == VOLUME_POISON
|
||||||
|
|
||||||
# start error injection
|
# start error injection
|
||||||
device.arm()
|
device.arm()
|
||||||
@ -432,7 +432,7 @@ def test_surprise_shutdown_cache_reinit(pyocf_ctx):
|
|||||||
if stats["conf"]["core_count"] == 0:
|
if stats["conf"]["core_count"] == 0:
|
||||||
assert stats["usage"]["occupancy"]["value"] == 0
|
assert stats["usage"]["occupancy"]["value"] == 0
|
||||||
cache.add_core(core)
|
cache.add_core(core)
|
||||||
assert ocf_read(cache, core, io_offset) == Volume.VOLUME_POISON
|
assert ocf_read(cache, core, io_offset) == VOLUME_POISON
|
||||||
|
|
||||||
cache.stop()
|
cache.stop()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user