Spdk/module/bdev/ocf/stats.c
Marcin Dziegielewski 20894340f2 lib/bdev/ocf: update of ocf library to version 19.06
This path updates ocf library to version 19.06 and also introduces
all necessary changes required to integrate ocf bdev adapter with
new version of ocf.

Summary of changes introduces with new OCF in ocf bdev:
- ocf_env.h increased limit for memory operations, changed behaviour
of strncpy to less restrictive, both changes are required to run new OCF
- ctx.c changed functions to new from new OCF
- added new cache mode "write only"
- added missed cache modes wa and wi to RPC scripts
- rewritten spdk_rpc_bdev_ocf_get_stats function to use asynhronus
ocf_mngt_cache_read_lock
- used new asynhronus ocf_mngt_cache_flush instead of waiting for request
- removed no longer valid filed - cfg->device.min_free_ram
- changed expected result in metadata_probe_cb

Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com>
Change-Id: I83e4335e16600e4d22e6bb517931102de42d39e9
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468132
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-22 17:22:41 +00:00

110 lines
4.6 KiB
C

/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ctx.h"
#include "stats.h"
int
vbdev_ocf_stats_get(ocf_cache_t cache, ocf_core_id_t core_id, struct vbdev_ocf_stats *stats)
{
int status;
ocf_core_t core;
status = ocf_core_get(cache, core_id, &core);
if (status) {
return status;
}
return ocf_stats_collect_core(core, &stats->usage, &stats->reqs, &stats->blocks, &stats->errors);
}
#define WJSON_STAT(w, stats, group, field, units) \
spdk_json_write_named_object_begin(w, #field); \
spdk_json_write_named_uint64(w, "count", stats->group.field.value); \
spdk_json_write_named_string_fmt(w, "percentage", "%lu.%lu", \
stats->group.field.percent / 10, stats->group.field.percent % 10); \
spdk_json_write_named_string(w, "units", units); \
spdk_json_write_object_end(w);
void
vbdev_ocf_stats_write_json(struct spdk_json_write_ctx *w, struct vbdev_ocf_stats *stats)
{
spdk_json_write_object_begin(w);
spdk_json_write_named_object_begin(w, "usage");
WJSON_STAT(w, stats, usage, occupancy, "4KiB blocks");
WJSON_STAT(w, stats, usage, free, "4KiB blocks");
WJSON_STAT(w, stats, usage, clean, "4KiB blocks");
WJSON_STAT(w, stats, usage, dirty, "4KiB blocks");
spdk_json_write_object_end(w);
spdk_json_write_named_object_begin(w, "requests");
WJSON_STAT(w, stats, reqs, rd_hits, "Requests");
WJSON_STAT(w, stats, reqs, rd_partial_misses, "Requests");
WJSON_STAT(w, stats, reqs, rd_full_misses, "Requests");
WJSON_STAT(w, stats, reqs, rd_total, "Requests");
WJSON_STAT(w, stats, reqs, wr_hits, "Requests");
WJSON_STAT(w, stats, reqs, wr_partial_misses, "Requests");
WJSON_STAT(w, stats, reqs, wr_full_misses, "Requests");
WJSON_STAT(w, stats, reqs, wr_total, "Requests");
WJSON_STAT(w, stats, reqs, rd_pt, "Requests");
WJSON_STAT(w, stats, reqs, wr_pt, "Requests");
WJSON_STAT(w, stats, reqs, serviced, "Requests");
WJSON_STAT(w, stats, reqs, total, "Requests");
spdk_json_write_object_end(w);
spdk_json_write_named_object_begin(w, "blocks");
WJSON_STAT(w, stats, blocks, core_volume_rd, "4KiB blocks");
WJSON_STAT(w, stats, blocks, core_volume_wr, "4KiB blocks");
WJSON_STAT(w, stats, blocks, core_volume_total, "4KiB blocks");
WJSON_STAT(w, stats, blocks, cache_volume_rd, "4KiB blocks");
WJSON_STAT(w, stats, blocks, cache_volume_wr, "4KiB blocks");
WJSON_STAT(w, stats, blocks, cache_volume_total, "4KiB blocks");
WJSON_STAT(w, stats, blocks, volume_rd, "4KiB blocks");
WJSON_STAT(w, stats, blocks, volume_wr, "4KiB blocks");
WJSON_STAT(w, stats, blocks, volume_total, "4KiB blocks");
spdk_json_write_object_end(w);
spdk_json_write_named_object_begin(w, "errors");
WJSON_STAT(w, stats, errors, core_volume_rd, "Requests");
WJSON_STAT(w, stats, errors, core_volume_wr, "Requests");
WJSON_STAT(w, stats, errors, core_volume_total, "Requests");
WJSON_STAT(w, stats, errors, cache_volume_rd, "Requests");
WJSON_STAT(w, stats, errors, cache_volume_wr, "Requests");
WJSON_STAT(w, stats, errors, cache_volume_total, "Requests");
WJSON_STAT(w, stats, errors, total, "Requests");
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
}