pyocf: Rename Volume to RamVolume
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright(c) 2021 Intel Corporation
|
||||
# Copyright(c) 2022 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@@ -13,7 +13,7 @@ from threading import Thread, Condition, Event
|
||||
from copy import deepcopy
|
||||
|
||||
from pyocf.utils import Size
|
||||
from pyocf.types.volume import Volume
|
||||
from pyocf.types.volume import RamVolume
|
||||
from pyocf.types.io import Io, IoDir
|
||||
from pyocf.types.data import Data
|
||||
|
||||
@@ -67,7 +67,7 @@ class JobSpec:
|
||||
qd: int = 1
|
||||
size: Size = Size(0)
|
||||
io_size: Size = Size(0)
|
||||
target: Volume = None
|
||||
target: RamVolume = None
|
||||
time_based: bool = False
|
||||
time: timedelta = None
|
||||
continue_on_error: bool = False
|
||||
@@ -211,7 +211,7 @@ class Rio:
|
||||
self.global_jobspec.qd = qd
|
||||
return self
|
||||
|
||||
def target(self, target: Volume):
|
||||
def target(self, target: RamVolume):
|
||||
self.global_jobspec.target = target
|
||||
return self
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ from .stats.cache import CacheInfo
|
||||
from .ioclass import IoClassesInfo, IoClassInfo
|
||||
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
|
||||
from .ctx import OcfCtx
|
||||
from .volume import Volume
|
||||
from .volume import RamVolume
|
||||
|
||||
|
||||
class Backfill(Structure):
|
||||
@@ -603,7 +603,7 @@ class Cache:
|
||||
raise OcfError("Failed getting core by name", result)
|
||||
|
||||
uuid = self.owner.lib.ocf_core_get_uuid_wrapper(core_handle)
|
||||
device = Volume.get_by_uuid(uuid.contents._data.decode("ascii"))
|
||||
device = RamVolume.get_by_uuid(uuid.contents._data.decode("ascii"))
|
||||
core = Core(device)
|
||||
core.cache = self
|
||||
core.handle = core_handle
|
||||
|
||||
@@ -29,7 +29,7 @@ from .queue import Queue
|
||||
from .shared import Uuid, OcfCompletion, OcfError, SeqCutOffPolicy
|
||||
from .stats.core import CoreInfo
|
||||
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
|
||||
from .volume import Volume
|
||||
from .volume import RamVolume
|
||||
from ..ocf import OcfLib
|
||||
from ..utils import Size, struct_to_dict
|
||||
|
||||
@@ -58,7 +58,7 @@ class Core:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
device: Volume,
|
||||
device: RamVolume,
|
||||
name: str = "core",
|
||||
seq_cutoff_threshold: int = DEFAULT_SEQ_CUTOFF_THRESHOLD,
|
||||
seq_cutoff_promotion_count: int = DEFAULT_SEQ_CUTOFF_PROMOTION_COUNT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@@ -12,7 +12,7 @@ from .cleaner import CleanerOps, Cleaner
|
||||
from .shared import OcfError
|
||||
from ..ocf import OcfLib
|
||||
from .queue import Queue
|
||||
from .volume import Volume
|
||||
from .volume import RamVolume
|
||||
|
||||
|
||||
class OcfCtxOps(Structure):
|
||||
@@ -84,7 +84,7 @@ class OcfCtx:
|
||||
byref(self.volume_types[self.volume_types_count].get_props()),
|
||||
)
|
||||
if result != 0:
|
||||
raise OcfError("Volume type registration failed", result)
|
||||
raise OcfError("RamVolume type registration failed", result)
|
||||
|
||||
self.volume_types_count += 1
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class VolumeIoPriv(Structure):
|
||||
VOLUME_POISON = 0x13
|
||||
|
||||
|
||||
class Volume():
|
||||
class RamVolume():
|
||||
_instances_ = weakref.WeakValueDictionary()
|
||||
_uuid_ = weakref.WeakValueDictionary()
|
||||
|
||||
@@ -89,7 +89,7 @@ class Volume():
|
||||
if uuid:
|
||||
if uuid in type(self)._uuid_:
|
||||
raise Exception(
|
||||
"Volume with uuid {} already created".format(uuid)
|
||||
"RamVolume with uuid {} already created".format(uuid)
|
||||
)
|
||||
self.uuid = uuid
|
||||
else:
|
||||
@@ -105,7 +105,7 @@ class Volume():
|
||||
self.opened = False
|
||||
|
||||
def get_copy(self):
|
||||
new_volume = Volume(self.size)
|
||||
new_volume = RamVolume(self.size)
|
||||
memmove(new_volume.data, self.data, self.size)
|
||||
return new_volume
|
||||
|
||||
@@ -152,7 +152,7 @@ class Volume():
|
||||
@VolumeOps.SUBMIT_IO
|
||||
def _submit_io(io):
|
||||
io_structure = cast(io, POINTER(Io))
|
||||
volume = Volume.get_instance(
|
||||
volume = RamVolume.get_instance(
|
||||
OcfLib.getInstance().ocf_io_get_volume(io_structure)
|
||||
)
|
||||
|
||||
@@ -162,7 +162,7 @@ class Volume():
|
||||
@VolumeOps.SUBMIT_FLUSH
|
||||
def _submit_flush(flush):
|
||||
io_structure = cast(flush, POINTER(Io))
|
||||
volume = Volume.get_instance(
|
||||
volume = RamVolume.get_instance(
|
||||
OcfLib.getInstance().ocf_io_get_volume(io_structure)
|
||||
)
|
||||
|
||||
@@ -177,7 +177,7 @@ class Volume():
|
||||
@VolumeOps.SUBMIT_DISCARD
|
||||
def _submit_discard(discard):
|
||||
io_structure = cast(discard, POINTER(Io))
|
||||
volume = Volume.get_instance(
|
||||
volume = RamVolume.get_instance(
|
||||
OcfLib.getInstance().ocf_io_get_volume(io_structure)
|
||||
)
|
||||
|
||||
@@ -196,35 +196,35 @@ class Volume():
|
||||
)
|
||||
uuid = str(uuid_ptr.contents._data, encoding="ascii")
|
||||
try:
|
||||
volume = Volume.get_by_uuid(uuid)
|
||||
volume = RamVolume.get_by_uuid(uuid)
|
||||
except: # noqa E722 TODO:Investigate whether this really should be so broad
|
||||
print("Tried to access unallocated volume {}".format(uuid))
|
||||
print("{}".format(Volume._uuid_))
|
||||
print("{}".format(RamVolume._uuid_))
|
||||
return -1
|
||||
|
||||
if volume.opened:
|
||||
return -OcfErrorCode.OCF_ERR_NOT_OPEN_EXC
|
||||
|
||||
Volume._instances_[ref] = volume
|
||||
RamVolume._instances_[ref] = volume
|
||||
|
||||
return volume.open()
|
||||
|
||||
@staticmethod
|
||||
@VolumeOps.CLOSE
|
||||
def _close(ref):
|
||||
volume = Volume.get_instance(ref)
|
||||
volume = RamVolume.get_instance(ref)
|
||||
volume.close()
|
||||
volume.opened = False
|
||||
|
||||
@staticmethod
|
||||
@VolumeOps.GET_MAX_IO_SIZE
|
||||
def _get_max_io_size(ref):
|
||||
return Volume.get_instance(ref).get_max_io_size()
|
||||
return RamVolume.get_instance(ref).get_max_io_size()
|
||||
|
||||
@staticmethod
|
||||
@VolumeOps.GET_LENGTH
|
||||
def _get_length(ref):
|
||||
return Volume.get_instance(ref).get_length()
|
||||
return RamVolume.get_instance(ref).get_length()
|
||||
|
||||
@staticmethod
|
||||
@IoOps.SET_DATA
|
||||
@@ -322,7 +322,7 @@ class Volume():
|
||||
return string_at(self.data_ptr, self.size)
|
||||
|
||||
|
||||
class ErrorDevice(Volume):
|
||||
class ErrorDevice(RamVolume):
|
||||
def __init__(
|
||||
self,
|
||||
size,
|
||||
@@ -384,7 +384,7 @@ class ErrorDevice(Volume):
|
||||
self.stats["errors"] = {IoDir.WRITE: 0, IoDir.READ: 0}
|
||||
|
||||
|
||||
class TraceDevice(Volume):
|
||||
class TraceDevice(RamVolume):
|
||||
def __init__(self, size, trace_fcn=None, uuid=None):
|
||||
super().__init__(size, uuid)
|
||||
self.trace_fcn = trace_fcn
|
||||
|
||||
Reference in New Issue
Block a user