Merge pull request #531 from arutk/fix_remove_dirty

fix removing dirty core
This commit is contained in:
Robert Baldyga 2021-06-29 09:36:45 +02:00 committed by GitHub
commit 43a142ccdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 2 deletions

View File

@ -224,6 +224,9 @@ void ocf_lru_init_cline(ocf_cache_t cache, ocf_cache_line_t cline)
static struct ocf_lru_list *ocf_lru_get_list(struct ocf_part *part,
uint32_t lru_idx, bool clean)
{
if (part->id == PARTITION_FREELIST)
clean = true;
return clean ? &part->runtime->lru[lru_idx].clean :
&part->runtime->lru[lru_idx].dirty;
}
@ -289,8 +292,6 @@ void ocf_lru_rm_cline(ocf_cache_t cache, ocf_cache_line_t cline)
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, cline);
struct ocf_part *part = &cache->user_parts[part_id].part;
ENV_BUG_ON(metadata_test_dirty(cache, cline));
ocf_lru_repart(cache, cline, part, &cache->free);
}

View File

@ -64,6 +64,30 @@ def test_removing_core(pyocf_ctx, cache_mode, cls):
assert stats["conf"]["core_count"] == 0
@pytest.mark.parametrize("cache_mode", [CacheMode.WB])
@pytest.mark.parametrize("cls", CacheLineSize)
def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(30))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)
# Prepare data
core_size = core.get_stats()["size"]
data = Data(core_size.B)
_io_to_core(core, data)
# Remove core from cache
cache.remove_core(core)
def test_30add_remove(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(30))
@ -276,3 +300,16 @@ def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
cache.add_core(core_devices[2])
stats = cache.get_stats()
assert stats["conf"]["core_count"] == core_amount
def _io_to_core(exported_obj: Core, data: Data):
io = exported_obj.new_io(exported_obj.cache.get_default_queue(), 0, data.size,
IoDir.WRITE, 0, 0)
io.set_data(data)
completion = OcfCompletion([("err", c_int)])
io.callback = completion.callback
io.submit()
completion.wait()
assert completion.results["err"] == 0, "IO to exported object completion"