Skip to content

Commit 47473cf

Browse files
committed
casadm: add max_dirty_ratio' for alru'
Signed-off-by: Qun Li <qun.li@zstack.io>
1 parent 0738ce6 commit 47473cf

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

casadm/cas_main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* SPDX-License-Identifier: BSD-3-Clause
45
*/
56

@@ -703,6 +704,9 @@ static struct cas_param cas_cache_params[] = {
703704
[cache_param_cleaning_alru_activity_threshold] = {
704705
.name = "Activity threshold [ms]" ,
705706
},
707+
[cache_param_cleaning_alru_max_dirty_ratio] = {
708+
.name = "Maximum dirty ratio [percent]",
709+
},
706710

707711
/* Cleaning policy ACP params */
708712
[cache_param_cleaning_acp_wake_up_time] = {
@@ -747,6 +751,8 @@ static struct cas_param cas_cache_params[] = {
747751
" <%d-%d> (default: %d)"
748752
#define CLEANING_ALRU_ACTIVITY_THRESHOLD_DESC "Cache idle time before flushing thread can start <%d-%d>[ms]" \
749753
" (default: %d ms)"
754+
#define CLEANING_ALRU_MAX_DIRTY_RATIO_DESC "Maximum dirty ratio of the cache device" \
755+
" <%d-%d> (default: %d)"
750756

751757
#define CLEANING_ACP_WAKE_UP_DESC "Time between ACP cleaning thread iterations <%d-%d>[ms] (default: %d ms)"
752758
#define CLEANING_ACP_MAX_BUFFERS_DESC "Number of cache lines flushed in single ACP cleaning thread iteration" \
@@ -807,6 +813,10 @@ static cli_namespace set_param_namespace = {
807813
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
808814
OCF_ALRU_MIN_ACTIVITY_THRESHOLD, OCF_ALRU_MAX_ACTIVITY_THRESHOLD,
809815
OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD},
816+
{'d', "max-dirty-ratio", CLEANING_ALRU_MAX_DIRTY_RATIO_DESC, 1, "NUMBER",
817+
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
818+
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO,
819+
OCF_ALRU_DEFAULT_MAX_DIRTY_RATIO},
810820
CACHE_PARAMS_NS_END()
811821

812822
CACHE_PARAMS_NS_BEGIN("cleaning-acp", "Cleaning policy ACP parameters")
@@ -918,6 +928,14 @@ int set_param_cleaning_alru_handle_option(char *opt, const char **arg)
918928

919929
SET_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold,
920930
strtoul(arg[0], NULL, 10));
931+
} else if (!strcmp(opt, "max-dirty-ratio")) {
932+
if (validate_str_num(arg[0], "max dirty ratio",
933+
OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO)) {
934+
return FAILURE;
935+
}
936+
937+
SET_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio,
938+
strtoul(arg[0], NULL, 10));
921939
} else {
922940
return FAILURE;
923941
}
@@ -1098,6 +1116,7 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a
10981116
SELECT_CACHE_PARAM(cache_param_cleaning_alru_stale_buffer_time);
10991117
SELECT_CACHE_PARAM(cache_param_cleaning_alru_flush_max_buffers);
11001118
SELECT_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold);
1119+
SELECT_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio);
11011120
return cache_param_handle_option_generic(opt, arg,
11021121
get_param_handle_option);
11031122
} else if (!strcmp(namespace, "cleaning-acp")) {

modules/cas_cache/layer_cache_management.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* SPDX-License-Identifier: BSD-3-Clause
45
*/
56

@@ -3338,6 +3339,11 @@ int cache_mngt_set_cache_params(struct kcas_set_cache_param *info)
33383339
ocf_cleaning_alru, ocf_alru_activity_threshold,
33393340
info->param_value);
33403341
break;
3342+
case cache_param_cleaning_alru_max_dirty_ratio:
3343+
result = cache_mngt_set_cleaning_param(cache,
3344+
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
3345+
info->param_value);
3346+
break;
33413347

33423348
case cache_param_cleaning_acp_wake_up_time:
33433349
result = cache_mngt_set_cleaning_param(cache,
@@ -3402,6 +3408,11 @@ int cache_mngt_get_cache_params(struct kcas_get_cache_param *info)
34023408
ocf_cleaning_alru, ocf_alru_activity_threshold,
34033409
&info->param_value);
34043410
break;
3411+
case cache_param_cleaning_alru_max_dirty_ratio:
3412+
result = cache_mngt_get_cleaning_param(cache,
3413+
ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
3414+
&info->param_value);
3415+
break;
34053416

34063417
case cache_param_cleaning_acp_wake_up_time:
34073418
result = cache_mngt_get_cleaning_param(cache,

modules/include/cas_ioctl_codes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3+
* Copyright(c) 2022 David Lee <live4thee@gmail.com>
34
* SPDX-License-Identifier: BSD-3-Clause
45
*/
56

@@ -331,6 +332,7 @@ enum kcas_cache_param_id {
331332
cache_param_cleaning_alru_stale_buffer_time,
332333
cache_param_cleaning_alru_flush_max_buffers,
333334
cache_param_cleaning_alru_activity_threshold,
335+
cache_param_cleaning_alru_max_dirty_ratio,
334336
cache_param_cleaning_acp_wake_up_time,
335337
cache_param_cleaning_acp_flush_max_buffers,
336338
cache_param_promotion_policy_type,

0 commit comments

Comments
 (0)