pyocf: reintroduce trace device
@@ -473,6 +473,56 @@ class ErrorDevice(Volume):
return self.vol.get_copy()
+class TraceDevice(Volume):
+ class IoType(IntEnum):
+ Data = 1
+ Flush = 2
+ Discard = 3
+
+ def __init__(self, vol, trace_fcn=None, uuid=None):
+ self.vol = vol
+ super().__init__(uuid)
+ self.trace_fcn = trace_fcn
+
+ def _trace(self, io, io_type):
+ submit = True
+
+ if self.trace_fcn:
+ submit = self.trace_fcn(self, io, io_type)
+
+ return submit
+
+ def do_submit_io(self, io):
+ submit = self._trace(io, TraceDevice.IoType.Data)
+
+ if submit:
+ self.vol.do_submit_io(io)
+
+ def do_submit_flush(self, io):
+ submit = self._trace(io, TraceDevice.IoType.Flush)
+
+ if submit:
+ self.vol.do_submit_flush(io)
+
+ def get_length(self):
+ return self.vol.get_length()
+
+ def get_max_io_size(self):
+ return self.vol.get_max_io_size()
+
+ def do_submit_discard(self, discard):
+ return self.vol.do_submit_discard(discard)
+
+ def dump(self, offset=0, size=0, ignore=VOLUME_POISON, **kwargs):
+ return self.vol.dump(offset, size, ignore=ignore, **kwargs)
+
+ def md5(self):
+ return self.vol.md5()
+
+ def get_copy(self):
+ return self.vol.get_copy()
+
+
lib = OcfLib.getInstance()
lib.ocf_io_get_priv.restype = POINTER(VolumeIoPriv)
lib.ocf_io_get_volume.argtypes = [c_void_p]
