|
1 | 1 | /* |
2 | 2 | * Copyright(c) 2012-2022 Intel Corporation |
| 3 | +* Copyright(c) 2022 David Lee <live4thee@gmail.com> |
3 | 4 | * SPDX-License-Identifier: BSD-3-Clause |
4 | 5 | */ |
5 | 6 |
|
@@ -703,6 +704,9 @@ static struct cas_param cas_cache_params[] = { |
703 | 704 | [cache_param_cleaning_alru_activity_threshold] = { |
704 | 705 | .name = "Activity threshold [ms]" , |
705 | 706 | }, |
| 707 | + [cache_param_cleaning_alru_max_dirty_ratio] = { |
| 708 | + .name = "Maximum dirty ratio [percent]", |
| 709 | + }, |
706 | 710 |
|
707 | 711 | /* Cleaning policy ACP params */ |
708 | 712 | [cache_param_cleaning_acp_wake_up_time] = { |
@@ -747,6 +751,8 @@ static struct cas_param cas_cache_params[] = { |
747 | 751 | " <%d-%d> (default: %d)" |
748 | 752 | #define CLEANING_ALRU_ACTIVITY_THRESHOLD_DESC "Cache idle time before flushing thread can start <%d-%d>[ms]" \ |
749 | 753 | " (default: %d ms)" |
| 754 | +#define CLEANING_ALRU_MAX_DIRTY_RATIO_DESC "Maximum dirty ratio of the cache device" \ |
| 755 | + " <%d-%d> (default: %d)" |
750 | 756 |
|
751 | 757 | #define CLEANING_ACP_WAKE_UP_DESC "Time between ACP cleaning thread iterations <%d-%d>[ms] (default: %d ms)" |
752 | 758 | #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 = { |
807 | 813 | CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT, |
808 | 814 | OCF_ALRU_MIN_ACTIVITY_THRESHOLD, OCF_ALRU_MAX_ACTIVITY_THRESHOLD, |
809 | 815 | 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}, |
810 | 820 | CACHE_PARAMS_NS_END() |
811 | 821 |
|
812 | 822 | 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) |
918 | 928 |
|
919 | 929 | SET_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold, |
920 | 930 | 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)); |
921 | 939 | } else { |
922 | 940 | return FAILURE; |
923 | 941 | } |
@@ -1098,6 +1116,7 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a |
1098 | 1116 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_stale_buffer_time); |
1099 | 1117 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_flush_max_buffers); |
1100 | 1118 | SELECT_CACHE_PARAM(cache_param_cleaning_alru_activity_threshold); |
| 1119 | + SELECT_CACHE_PARAM(cache_param_cleaning_alru_max_dirty_ratio); |
1101 | 1120 | return cache_param_handle_option_generic(opt, arg, |
1102 | 1121 | get_param_handle_option); |
1103 | 1122 | } else if (!strcmp(namespace, "cleaning-acp")) { |
|
0 commit comments