Merge pull request #730 from jfckm/metadata-helpers
pyocf: Extend metadata helpers to work for all metadata segments
This commit is contained in:
commit
a1e9303189
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright(c) 2022-2022 Intel Corporation
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ocf/ocf_io.h"
|
|
||||||
#include "ocf/ocf_cache.h"
|
|
||||||
#include "../src/ocf/ocf_cache_priv.h"
|
|
||||||
#include "../src/ocf/metadata/metadata_raw.h"
|
|
||||||
#include "../src/ocf/metadata/metadata_internal.h"
|
|
||||||
|
|
||||||
// get collision metadata segment start and size (excluding padding)
|
|
||||||
uint64_t ocf_get_collision_start_page_helper(ocf_cache_t cache)
|
|
||||||
{
|
|
||||||
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
|
||||||
struct ocf_metadata_raw *raw = &ctrl->raw_desc[metadata_segment_collision];
|
|
||||||
|
|
||||||
return raw->ssd_pages_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t ocf_get_collision_page_count_helper(ocf_cache_t cache)
|
|
||||||
{
|
|
||||||
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
|
||||||
struct ocf_metadata_raw *raw = &ctrl->raw_desc[metadata_segment_collision];
|
|
||||||
|
|
||||||
return raw->ssd_pages;
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright(c) 2022-2022 Intel Corporation
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
uint64_t ocf_get_collision_start_page_helper(ocf_cache_t cache);
|
|
||||||
uint64_t ocf_get_collision_page_count_helper(ocf_cache_t cache);
|
|
58
tests/functional/pyocf/c/helpers/metadata_helpers.c
Normal file
58
tests/functional/pyocf/c/helpers/metadata_helpers.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(c) 2022-2022 Intel Corporation
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ocf/ocf_io.h"
|
||||||
|
#include "ocf/ocf_cache.h"
|
||||||
|
#include "../src/ocf/ocf_cache_priv.h"
|
||||||
|
#include "../src/ocf/metadata/metadata_raw.h"
|
||||||
|
#include "../src/ocf/metadata/metadata_internal.h"
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_start_page(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->ssd_pages_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_page_count(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->ssd_pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_elems_count(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_elems_per_page(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->entries_in_page;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_elem_size(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->entry_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ocf_get_metadata_segment_is_flapped(ocf_cache_t cache, int segment)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_ctrl *ctrl = cache->metadata.priv;
|
||||||
|
struct ocf_metadata_raw *raw = &ctrl->raw_desc[segment];
|
||||||
|
|
||||||
|
return raw->flapping;
|
||||||
|
}
|
13
tests/functional/pyocf/c/helpers/metadata_helpers.h
Normal file
13
tests/functional/pyocf/c/helpers/metadata_helpers.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(c) 2022 Intel Corporation
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
uint64_t ocf_get_metadata_segment_start_page(ocf_cache_t cache, int segment);
|
||||||
|
uint64_t ocf_get_metadata_segment_page_count(ocf_cache_t cache, int segment);
|
||||||
|
uint64_t ocf_get_metadata_segment_elems_count(ocf_cache_t cache, int segment);
|
||||||
|
uint64_t ocf_get_metadata_segment_elems_per_page(ocf_cache_t cache, int segment);
|
||||||
|
uint64_t ocf_get_metadata_segment_elem_size(ocf_cache_t cache, int segment);
|
||||||
|
bool ocf_get_metadata_segment_is_flapped(ocf_cache_t cache, int segment);
|
@ -6,11 +6,31 @@
|
|||||||
from .ocf import OcfLib
|
from .ocf import OcfLib
|
||||||
|
|
||||||
|
|
||||||
def get_collision_segment_page_location(cache):
|
def get_metadata_segment_page_location(cache, segment):
|
||||||
lib = OcfLib.getInstance()
|
lib = OcfLib.getInstance()
|
||||||
return int(lib.ocf_get_collision_start_page_helper(cache))
|
return int(lib.ocf_get_metadata_segment_start_page(cache, segment))
|
||||||
|
|
||||||
|
|
||||||
def get_collision_segment_size(cache):
|
def get_metadata_segment_size(cache, segment):
|
||||||
lib = OcfLib.getInstance()
|
lib = OcfLib.getInstance()
|
||||||
return int(lib.ocf_get_collision_page_count_helper(cache))
|
return int(lib.ocf_get_metadata_segment_page_count(cache, segment))
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata_segment_elems_count(cache, segment):
|
||||||
|
lib = OcfLib.getInstance()
|
||||||
|
return int(lib.ocf_get_metadata_segment_elems_count(cache, segment))
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata_segment_elems_per_page(cache, segment):
|
||||||
|
lib = OcfLib.getInstance()
|
||||||
|
return int(lib.ocf_get_metadata_segment_elems_per_page(cache, segment))
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata_segment_elem_size(cache, segment):
|
||||||
|
lib = OcfLib.getInstance()
|
||||||
|
return int(lib.ocf_get_metadata_segment_elem_size(cache, segment))
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata_segment_is_flapped(cache, segment):
|
||||||
|
lib = OcfLib.getInstance()
|
||||||
|
return bool(lib.ocf_get_metadata_segment_is_flapped(cache, segment))
|
||||||
|
@ -18,8 +18,9 @@ from ctypes import (
|
|||||||
cast,
|
cast,
|
||||||
create_string_buffer,
|
create_string_buffer,
|
||||||
)
|
)
|
||||||
from enum import IntEnum
|
from enum import IntEnum, auto
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import re
|
||||||
|
|
||||||
from ..ocf import OcfLib
|
from ..ocf import OcfLib
|
||||||
from .shared import (
|
from .shared import (
|
||||||
@ -46,6 +47,48 @@ class Backfill(Structure):
|
|||||||
_fields_ = [("_max_queue_size", c_uint32), ("_queue_unblock_size", c_uint32)]
|
_fields_ = [("_max_queue_size", c_uint32), ("_queue_unblock_size", c_uint32)]
|
||||||
|
|
||||||
|
|
||||||
|
class CacheMetadataSegment(IntEnum):
|
||||||
|
_ignore_ = "name_mapping"
|
||||||
|
SB_CONFIG = 0
|
||||||
|
SB_RUNTIME = auto()
|
||||||
|
RESERVED = auto()
|
||||||
|
PART_CONFIG = auto()
|
||||||
|
PART_RUNTIME = auto()
|
||||||
|
CORE_CONFIG = auto()
|
||||||
|
CORE_RUNTIME = auto()
|
||||||
|
CORE_UUID = auto()
|
||||||
|
CLEANING = auto()
|
||||||
|
LRU = auto()
|
||||||
|
COLLISION = auto()
|
||||||
|
LIST_INFO = auto()
|
||||||
|
HASH = auto()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def segment_in_text(cls, log):
|
||||||
|
name_mapping = {
|
||||||
|
"Super block config": cls.SB_CONFIG,
|
||||||
|
"Super block runtime": cls.SB_RUNTIME,
|
||||||
|
"Reserved": cls.RESERVED,
|
||||||
|
"Part config": cls.PART_CONFIG,
|
||||||
|
"Part runtime": cls.PART_RUNTIME,
|
||||||
|
"Core config": cls.CORE_CONFIG,
|
||||||
|
"Core runtime": cls.CORE_RUNTIME,
|
||||||
|
"Core UUID": cls.CORE_UUID,
|
||||||
|
"Cleaning": cls.CLEANING,
|
||||||
|
"LRU": cls.LRU,
|
||||||
|
"Collision": cls.COLLISION,
|
||||||
|
"List info": cls.LIST_INFO,
|
||||||
|
"Hash": cls.HASH,
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, segment in name_mapping.items():
|
||||||
|
match = re.search(name, log)
|
||||||
|
if match:
|
||||||
|
return segment
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class CacheConfig(Structure):
|
class CacheConfig(Structure):
|
||||||
MAX_CACHE_NAME_SIZE = 32
|
MAX_CACHE_NAME_SIZE = 32
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
|
@ -8,16 +8,13 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from pyocf.types.volume import RamVolume
|
from pyocf.types.volume import RamVolume
|
||||||
from pyocf.types.volume_cache import CacheVolume
|
from pyocf.types.volume_cache import CacheVolume
|
||||||
from pyocf.types.cache import Cache
|
from pyocf.types.cache import Cache, CacheMetadataSegment
|
||||||
from pyocf.types.queue import Queue
|
from pyocf.types.queue import Queue
|
||||||
from pyocf.utils import Size
|
from pyocf.utils import Size
|
||||||
from pyocf.types.shared import CacheLineSize
|
from pyocf.types.shared import CacheLineSize
|
||||||
from pyocf.types.ctx import OcfCtx
|
from pyocf.types.ctx import OcfCtx
|
||||||
from pyocf.rio import Rio, ReadWrite
|
from pyocf.rio import Rio, ReadWrite
|
||||||
from pyocf.helpers import (
|
from pyocf.helpers import get_metadata_segment_page_location, get_metadata_segment_size
|
||||||
get_collision_segment_page_location,
|
|
||||||
get_collision_segment_size,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("cacheline_size", CacheLineSize)
|
@pytest.mark.parametrize("cacheline_size", CacheLineSize)
|
||||||
@ -71,8 +68,8 @@ def test_test_standby_io_metadata(pyocf_ctx, cacheline_size):
|
|||||||
|
|
||||||
cache.standby_attach(cache_vol)
|
cache.standby_attach(cache_vol)
|
||||||
|
|
||||||
start = get_collision_segment_page_location(cache)
|
start = get_metadata_segment_page_location(cache, CacheMetadataSegment.COLLISION)
|
||||||
count = get_collision_segment_size(cache)
|
count = get_metadata_segment_size(cache, CacheMetadataSegment.COLLISION)
|
||||||
io_offset = Size.from_page(start)
|
io_offset = Size.from_page(start)
|
||||||
io_size = Size.from_page(count)
|
io_size = Size.from_page(count)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user