|
1 | 1 | /* |
2 | 2 | * Copyright(c) 2012-2022 Intel Corporation |
| 3 | +* Copyright(c) 2022 David Lee <live4thee@gmail.com> |
3 | 4 | * Copyright(c) 2024 Huawei Technologies |
4 | 5 | * SPDX-License-Identifier: BSD-3-Clause |
5 | 6 | */ |
@@ -730,6 +731,9 @@ static struct cas_param cas_cache_params[] = { |
730 | 731 | [cache_param_cleaning_alru_activity_threshold] = { |
731 | 732 | .name = "Activity threshold [ms]" , |
732 | 733 | }, |
| 734 | + [cache_param_cleaning_alru_max_dirty_ratio] = { |
| 735 | + .name = "Maximum dirty ratio [percent]", |
| 736 | + }, |
733 | 737 |
|
734 | 738 | /* Cleaning policy ACP params */ |
735 | 739 | [cache_param_cleaning_acp_wake_up_time] = { |
@@ -774,6 +778,8 @@ static struct cas_param cas_cache_params[] = { |
774 | 778 | " <%d-%d> (default: %d)" |
775 | 779 | #define CLEANING_ALRU_ACTIVITY_THRESHOLD_DESC "Cache idle time before flushing thread can start <%d-%d>[ms]" \ |
776 | 780 | " (default: %d ms)" |
| 781 | +#define CLEANING_ALRU_MAX_DIRTY_RATIO_DESC "Maximum dirty ratio of the cache device" \ |
| 782 | + " <%d-%d> (default: %d)" |
777 | 783 |
|
778 | 784 | #define CLEANING_ACP_WAKE_UP_DESC "Time between ACP cleaning thread iterations <%d-%d>[ms] (default: %d ms)" |
779 | 785 | #define CLEANING_ACP_MAX_BUFFERS_DESC "Number of cache lines flushed in single ACP cleaning thread iteration" \ |
@@ -834,6 +840,10 @@ static cli_namespace set_param_namespace = { |
834 | 840 | CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT, |
835 | 841 | OCF_ALRU_MIN_ACTIVITY_THRESHOLD, OCF_ALRU_MAX_ACTIVITY_THRESHOLD, |
836 | 842 | OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD}, |
| 843 | + {'d', "max-dirty-ratio", CLEANING_ALRU_MAX_DIRTY_RATIO_DESC, 1, "NUMBER", |
| 844 | + CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT, |
| 845 | + OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO, |
| 846 | + OCF_ALRU_DEFAULT_MAX_DIRTY_RATIO}, |
837 | 847 | CACHE_PARAMS_NS_END() |
838 | 848 |
|
839 | 849 | CACHE_PARAMS_NS_BEGIN("cleaning-acp", "Cleaning policy ACP parameters") |
@@ -945,6 +955,14 @@ int set_param_cleaning_alru_handle_option(char *opt, const char **arg) |
945 | 955 |
|
946 | 956 | SET_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold, |
947 | 957 | strtoul(arg[0], NULL, 10)); |
| 958 | + } else if (!strcmp(opt, "max-dirty-ratio")) { |
| 959 | + if (validate_str_num(arg[0], "max dirty ratio", |
| 960 | + OCF_ALRU_MIN_MAX_DIRTY_RATIO, OCF_ALRU_MAX_MAX_DIRTY_RATIO)) { |
| 961 | + return FAILURE; |
| 962 | + } |
| 963 | + |
| 964 | + SET_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio, |
| 965 | + strtoul(arg[0], NULL, 10)); |
948 | 966 | } else { |
949 | 967 | return FAILURE; |
950 | 968 | } |
@@ -1125,6 +1143,7 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a |
1125 | 1143 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_stale_buffer_time); |
1126 | 1144 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_flush_max_buffers); |
1127 | 1145 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold); |
| 1146 | + SELECT_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio); |
1128 | 1147 | return cache_param_handle_option_generic(opt, arg, |
1129 | 1148 | get_param_handle_option); |
1130 | 1149 | } else if (!strcmp(namespace, "cleaning-acp")) { |
|
0 commit comments