casadm: Fix seq cutoff min threshold calculation

Min seq cutoff threshold value is defined in bytes and if it's lower than
1 KiB, then dividing it by KiB will give 0, which is potentially lower than
the real min value. Use DIV_ROUND_UP() to address this issue.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2022-08-29 17:41:55 +02:00
parent 0a4d86e3fe
commit 7260d29714

View File

@ -23,6 +23,8 @@
#include <cas_ioctl_codes.h> #include <cas_ioctl_codes.h>
#include "statistics_view.h" #include "statistics_view.h"
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#define HELP_HEADER OCF_PREFIX_LONG #define HELP_HEADER OCF_PREFIX_LONG
#define WRONG_DEVICE_ERROR "Specified caching device '%s' is not supported.\n" #define WRONG_DEVICE_ERROR "Specified caching device '%s' is not supported.\n"
@ -826,7 +828,7 @@ int set_param_seq_cutoff_handle_option(char *opt, const char **arg)
{ {
if (!strcmp(opt, "threshold")) { if (!strcmp(opt, "threshold")) {
if (validate_str_num(arg[0], "sequential cutoff threshold", if (validate_str_num(arg[0], "sequential cutoff threshold",
OCF_SEQ_CUTOFF_MIN_THRESHOLD / KiB, DIV_ROUND_UP(OCF_SEQ_CUTOFF_MIN_THRESHOLD, KiB),
OCF_SEQ_CUTOFF_MAX_THRESHOLD / KiB) == FAILURE) OCF_SEQ_CUTOFF_MAX_THRESHOLD / KiB) == FAILURE)
return FAILURE; return FAILURE;