return (int)floor(log2(num));
}
-/* Returns the size of the device in bytes if successful; otherwise, 0.
- *
- * @device_path: The path of the device.
- */
-uint64_t ls3_stats_get_dev_size(const char* device_path)
-{
- int device_fd = open(device_path, O_RDONLY);
-
- if (device_fd >= 0) {
- uint64_t dev_size;
- int res;
-
- res = ioctl(device_fd, BLKGETSIZE64, &dev_size);
- if (res >= 0)
- return dev_size;
- else
- LS3_ERROR("error obtaining device size: %s\n",
- strerror(errno));
-
- close(device_fd);
- } else {
- LS3_ERROR("error opening device %s for read size: %s\n",
- device_path, strerror(errno));
- }
-
- return 0;
-}
-
/* ls3_stats_get_day_diff - Calculates the time difference in
* days between a given timestamp and the current real-time.
*
static void ls3_stats_change_extension_in_file(int bit_extension)
{
- const ls3_stats_extension_mapping *map_ext = ext_mappings;
+ const ls3_stats_extension_mapping *ext = ext_mappings;
- for (map_ext = ext_mappings; map_ext->extension_name != NULL; ++map_ext) {
- if (map_ext->extension_value & bit_extension) {
+ for (ext = ext_mappings; ext->extension_name != NULL; ++ext) {
+ if (ext->extension_value & bit_extension) {
char buffer[256];
snprintf(buffer, sizeof(buffer), "%s.%s",
reports_with_stats->report_file_name,
- map_ext->extension_name);
+ ext->extension_name);
if (reports_with_stats->format_report_file_name)
free(reports_with_stats->format_report_file_name);
static void ls3_stats_get_report_extension(char *fileName)
{
- const ls3_stats_extension_mapping *map_ext = ext_mappings;
+ const ls3_stats_extension_mapping *ext = ext_mappings;
char *dot = strrchr(fileName, '.');
- char extension[5]; /* Don't need more 5 symbols */
+ char extension[5]; /* Don't need more 5 symbols */
bool marker;
int i;
/* By default if filename not have extension */
reports_with_stats->report_extension |=
LS3_STATS_FILE_EXTENSION_ALL;
- return;
+ return;
}
strncpy(extension, dot+1, sizeof(extension)-1);
for(i = 0; extension[i]; i++)
extension[i] = tolower((unsigned char)extension[i]);
- for (map_ext = ext_mappings; map_ext->extension_name != NULL; ++map_ext) {
- if (strcmp(extension, map_ext->extension_name) == 0) {
+ for (ext = ext_mappings; ext->extension_name != NULL; ++ext) {
+ if (strcmp(extension, ext->extension_name) == 0) {
reports_with_stats->report_extension |=
- map_ext->extension_value;
+ ext->extension_value;
marker = true;
break;
}
static FILE* ls3_stats_open_file(char *file_name)
{
FILE *file = fopen(file_name, "w");
+
if (file == NULL)
LS3_FATAL("error opening file for save stats: %s\n", file_name);
strftime(file_name_buffer, sizeof(file_name_buffer),
DEFAULT_DIR_FOR_REPORTS
"file_size_report.%Y-%m-%d-%H:%M:%S.out", timeinfo);
- reports_with_stats->report_file_name = xstrdup(file_name_buffer);
+ reports_with_stats->report_file_name =
+ xstrdup(file_name_buffer);
}
ls3_stats_get_report_extension(reports_with_stats->report_file_name);
{
switch (report_type)
{
- case LS3_STATS_FILES_SIZE:
- case LS3_STATS_CAPACITY_USED:
- case LS3_STATS_DIRECTORY_SIZE_KB:
- case LS3_STATS_EQUAL_OVERHEAD:
- case LS3_STATS_STORAGE_SET_SIZE_BY_USER:
- case LS3_STATS_STORAGE_SET_SIZE_BY_GROUP:
- case LS3_STATS_STORAGE_SET_SIZE_BY_PROJID:
- case LS3_STATS_STRIPE_SIZE:
- return LS3_STATS_VALUE_TYPE_KB;
- case LS3_STATS_TIME_SINCE_LAST_MOD_RF:
- case LS3_STATS_TIME_SINCE_LAST_CREATION_RF:
- case LS3_STATS_TIME_SINCE_LAST_ACCESS_RF:
- case LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF:
- return LS3_STATS_VALUE_TYPE_DAYS;
- case LS3_STATS_FILENAME_LENGTH:
- return LS3_STATS_VALUE_TYPE_CHARS;
- case LS3_STATS_DIRECTORY_SIZE_ENTRIES:
- return LS3_STATS_VALUE_TYPE_ENTRIES;
- case LS3_STATS_FILES_EMPLOYING_DOM:
- case LS3_STATS_TOTAL_COUNT_REPORT:
- return LS3_STATS_VALUE_TYPE_ERROR;
- case LS3_STATS_POSITIVE_OVERHEAD:
- case LS3_STATS_NEGATIVE_OVERHEAD:
- return LS3_STATS_VALUE_TYPE_BYTES;
- case LS3_STATS_LINK_COUNT:
- return LS3_STATS_VALUE_TYPE_LINKS;
- case LS3_STATS_STRIPE_COUNT:
- return LS3_STATS_VALUE_TYPE_STRIPE;
- case LS3_STATS_MIRROR_COUNT:
- return LS3_STATS_VALUE_TYPE_MIRROR;
+ case LS3_STATS_TYPE_FILES_SIZE:
+ case LS3_STATS_TYPE_CAPACITY_USED:
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_KB:
+ case LS3_STATS_TYPE_EQUAL_OVERHEAD:
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_USER:
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_GROUP:
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_PROJID:
+ case LS3_STATS_TYPE_COMPRESSION_RATIO:
+ case LS3_STATS_TYPE_STRIPE_SIZE:
+ case LS3_STATS_TYPE_POSITIVE_OVERHEAD:
+ case LS3_STATS_TYPE_NEGATIVE_OVERHEAD:
+ return LS3_STATS_VALUE_TYPE_KB;
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF:
+ return LS3_STATS_VALUE_TYPE_DAYS;
+ case LS3_STATS_TYPE_FILENAME_LENGTH:
+ case LS3_STATS_TYPE_SYMLINK_TARGET_LENGTH:
+ return LS3_STATS_VALUE_TYPE_CHARS;
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_ENTRIES:
+ return LS3_STATS_VALUE_TYPE_ENTRIES;
+ case LS3_STATS_TYPE_FILES_EMPLOYING_DOM:
+ case LS3_STATS_TYPE_TOTAL_COUNT_REPORT:
+ return LS3_STATS_VALUE_TYPE_ERROR;
+/* case LS3_STATS_TYPE_POSITIVE_OVERHEAD:
+ case LS3_STATS_TYPE_NEGATIVE_OVERHEAD:
+ return LS3_STATS_VALUE_TYPE_BYTES; */
+ case LS3_STATS_TYPE_LINK_COUNT:
+ return LS3_STATS_VALUE_TYPE_LINKS;
+ case LS3_STATS_TYPE_STRIPE_COUNT:
+ return LS3_STATS_VALUE_TYPE_STRIPE;
+ case LS3_STATS_TYPE_MIRROR_COUNT:
+ return LS3_STATS_VALUE_TYPE_MIRROR;
}
return LS3_STATS_VALUE_TYPE_ERROR;
{
switch (num_type)
{
- case LS3_STATS_VALUE_TYPE_ERROR:
- case LS3_STATS_VALUE_TYPE_EMPTY:
- return "";
- case LS3_STATS_VALUE_TYPE_KB:
- return "KB";
- case LS3_STATS_VALUE_TYPE_ENTRIES:
- return "Entries";
- case LS3_STATS_VALUE_TYPE_CHARS:
- return "Chars";
- case LS3_STATS_VALUE_TYPE_LINKS:
- return "Links";
- case LS3_STATS_VALUE_TYPE_DAYS:
- return "Days";
- case LS3_STATS_VALUE_TYPE_BYTES:
- return "Bytes";
- case LS3_STATS_VALUE_TYPE_STRIPE:
- return "Stripe";
- case LS3_STATS_VALUE_TYPE_MIRROR:
- return "Mirror";
+ case LS3_STATS_VALUE_TYPE_ERROR:
+ case LS3_STATS_VALUE_TYPE_EMPTY:
+ return "";
+ case LS3_STATS_VALUE_TYPE_KB:
+ return "KB";
+ case LS3_STATS_VALUE_TYPE_ENTRIES:
+ return "Entries";
+ case LS3_STATS_VALUE_TYPE_CHARS:
+ return "Chars";
+ case LS3_STATS_VALUE_TYPE_LINKS:
+ return "Links";
+ case LS3_STATS_VALUE_TYPE_DAYS:
+ return "Days";
+ case LS3_STATS_VALUE_TYPE_BYTES:
+ return "Bytes";
+ case LS3_STATS_VALUE_TYPE_STRIPE:
+ return "Stripe";
+ case LS3_STATS_VALUE_TYPE_MIRROR:
+ return "Mirror";
}
return "";
{
switch (report_type)
{
- case LS3_STATS_FILES_SIZE:
- return "Files Size";
- case LS3_STATS_CAPACITY_USED:
- return "Capacity used (Regualr file's space used on disk)";
- case LS3_STATS_EQUAL_OVERHEAD:
- return "Equal overhead (Files whose capacity used is"
- " equal to their size)";
- case LS3_STATS_POSITIVE_OVERHEAD:
- return "Positive overhead (Files whose capacity used is"
- " larger than or equal to its size)";
- case LS3_STATS_NEGATIVE_OVERHEAD:
- return "Negative overhead (Files whose size is larger"
- " than capacity used.)";
- case LS3_STATS_DIRECTORY_SIZE_KB:
- return "Directory size (KB's)";
- case LS3_STATS_TIME_SINCE_LAST_CREATION_RF:
- return "Time since creation [crtime](Regular files)";
- case LS3_STATS_TIME_SINCE_LAST_MOD_RF:
- return "Time since last modification [mtime](Regular files)";
- case LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF:
- return "Time since last metadata modification [ctime]";
- case LS3_STATS_TIME_SINCE_LAST_ACCESS_RF:
- return "Time since last access [atime](Regular files)";
- case LS3_STATS_FILENAME_LENGTH:
- return "Filename length (Includes regular files, "
- "dirs, symlinks and special files)";
- case LS3_STATS_DIRECTORY_SIZE_ENTRIES:
- return "Directory size (entries)";
- case LS3_STATS_FILES_EMPLOYING_DOM:
- return "Files employing DoM";
- case LS3_STATS_STORAGE_SET_SIZE_BY_USER:
- return "Storage size (all directories and files) by user";
- case LS3_STATS_STORAGE_SET_SIZE_BY_GROUP:
- return "Storage size (all directories and files) by group";
- case LS3_STATS_STORAGE_SET_SIZE_BY_PROJID:
- return "Storage size (all directories and files)"
- " by project ID";
- case LS3_STATS_LINK_COUNT:
- return "Link count (of regular files)";
- case LS3_STATS_STRIPE_COUNT:
- return "Stripe count (of regular files)";
- case LS3_STATS_STRIPE_SIZE:
- return "Stripe size (of regular files)";
- case LS3_STATS_MIRROR_COUNT:
- return "Mirror count (of regular files)";
- case LS3_STATS_TOTAL_COUNT_REPORT:
- return "";
+ case LS3_STATS_TYPE_FILES_SIZE:
+ return "Files Size";
+ case LS3_STATS_TYPE_CAPACITY_USED:
+ return "Capacity used (Regular file's space used on disk)";
+ case LS3_STATS_TYPE_EQUAL_OVERHEAD:
+ return "Equal overhead (Files whose capacity used is "
+ "equal to their size)";
+ case LS3_STATS_TYPE_POSITIVE_OVERHEAD:
+ return "Positive overhead (Files whose capacity used is "
+ "larger than or equal to its size)";
+ case LS3_STATS_TYPE_NEGATIVE_OVERHEAD:
+ return "Negative overhead (Files whose size is larger "
+ "than capacity used.)";
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_KB:
+ return "Directory size (KB)";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF:
+ return "Time since creation [crtime](Regular files)";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF:
+ return "Time since last modification [mtime](Regular files)";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF:
+ return "Time since last metadata modification [ctime]";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF:
+ return "Time since last access [atime](Regular files)";
+ case LS3_STATS_TYPE_FILENAME_LENGTH:
+ return "Filename length (Includes regular files, "
+ "dirs, symlinks and special files)";
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_ENTRIES:
+ return "Directory size (entries)";
+ case LS3_STATS_TYPE_FILES_EMPLOYING_DOM:
+ return "Files employing DoM";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_USER:
+ return "Storage size (all directories and files) by user";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_GROUP:
+ return "Storage size (all directories and files) by group";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_PROJID:
+ return "Storage size (all directories and files) by project ID";
+ case LS3_STATS_TYPE_LINK_COUNT:
+ return "Link count (of regular files)";
+ case LS3_STATS_TYPE_STRIPE_COUNT:
+ return "Stripe count (of regular files)";
+ case LS3_STATS_TYPE_STRIPE_SIZE:
+ return "Stripe size (of regular files)";
+ case LS3_STATS_TYPE_MIRROR_COUNT:
+ return "Mirror count (of regular files)";
+ case LS3_STATS_TYPE_COMPRESSION_RATIO:
+ return "Compress ratio (of regular files)";
+ case LS3_STATS_TYPE_SYMLINK_TARGET_LENGTH:
+ return "Symlink target length";
+ case LS3_STATS_TYPE_TOTAL_COUNT_REPORT:
+ return "";
}
return "";
{
switch (report_type)
{
- case LS3_STATS_FILES_SIZE:
- return "\n\nFiles Size:\n"
- "0 - Size range;\n1 - Count of files in range;\n2 -"
- " Number of files in range as a percent of total"
- " number of files;\n3 - Number of files in this"
- " range or smaller as a % of total # of files;\n"
- "4 - Total size of files in range;\n5 - Total size of"
- " files in range as a % of total size of files;\n"
- "6 - Total size of files in this range or smaller"
- " as a % of total size of files;\n7 - Minimum value "
- "in range;\n8 - Maximum value in range.\n";
- case LS3_STATS_CAPACITY_USED:
- return "\n\nCapacity used (Regualr file's space used on disk):\n"
- "0 - Size range;\n1 - Count of files in range;\n2 - Number of"
- " files in range as a percent of total number of"
- " files;\n3 - Number of files in this range or smaller"
- " as a % of total # of file;\n4 - Total capacity used"
- " in range;\n5 - Total capacity used in range as"
- " a % of total capacity used;\n6 - Total capacity"
- " used in this range or smaller as a % of"
- " total capacity;\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_EQUAL_OVERHEAD:
- return "\n\nEqual overhead (Files whose usable capacity is"
- " equal to their size):\n0 - Size range;\n"
- "1 - Count of files in range;\n2 - Number"
- " of files in range as a percent of total number of"
- " files;\n3 - Number of files in this range or"
- " smaller as a % of total # of files;\n4 - Total"
- " kilobytes that overflowed in range;\n5 - Total kilobytes"
- " that overflowed in this range as a % of total"
- " kilobytes that overflowed;\n6 - Total kilobytes that"
- " overflowed in this range or smaller as a % of"
- " total kilobytes that overflowed;\n7 - Minimum value "
- "in range;\n8 - Maximum value in range.\n";
- case LS3_STATS_POSITIVE_OVERHEAD:
- return "\n\nPositive overhead (Files whose capacity used is"
- " larger than to its size):\n0 - Range of difference"
- " sizes;\n1 - Count of files in range;\n2 - Number"
- " of files in range as a percent of total number of"
- " files;\n3 - Number of files in this range or"
- " smaller as a % of total # of files;\n4 - Total"
- " bytes that overflowed in range;\n5 - Total bytes"
- " that overflowed in this range as a % of total"
- " bytes that overflowed;\n6 - Total bytes that"
- " overflowed in this range or smaller as a % of"
- " total bytes that overflowed;\n7 - Minimum value "
- "in range;\n8 - Maximum value in range.\n";
- case LS3_STATS_NEGATIVE_OVERHEAD:
- return "\n\nNegative overhead (Files whose size is larger"
- " than capacity used.):\n0 - Range of difference"
- " sizes;\n1 - Count of files in range;\n2 - Number"
- " of files in range as a percent of total number of"
- " files;\n3 - Number of files in this range or"
- " smaller as a % of total # of files;\n4 - Total"
- " bytes that underflowed in range;\n5 - Total bytes"
- " that underflowed in this range as a % of total"
- " bytes that underflowed;\n6 - Total bytes that"
- " underflowed in this range or smaller as a % of"
- " total bytes that underflowed;\n7 - Minimum value "
- "in range;\n8 - Maximum value in range.\n";
- case LS3_STATS_DIRECTORY_SIZE_KB:
- return "\n\nDirectory size (KB's):\n0 - Range of dir sizes;"
- " \n1 - Count of directories in range;\n2 - Number"
- " of files in dirs as a percent of total number of"
- " dirs;\n3 - Number of dirs in this range or"
- " smaller as a % of total # of dirs;\n4 - Total size of"
- " dirs in range;\n5 - Total size of dirs in range as a"
- " % of total size of dirs;\n6 - Total size of dirs in"
- " this range or smaller as a % of total size of dirs;"
- "\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_TIME_SINCE_LAST_CREATION_RF:
- return "\n\nTime since creation [crtime](Regular files):\n"
- "0 - Range in days;\n1 - Count of files in range;\n"
- "2 - Number of files in range as a % of total"
- " number of files;\n3 - Number of files in this"
- " range or smaller as a % of total number of"
- " files;\n4 - Total kilobytes that underflowed in range;\n"
- "5 - Total of age in range, total age in range as"
- " a % of total age of all files;\n6 - total age in"
- " this range or smaller as a % of total age of"
- " all files;\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_TIME_SINCE_LAST_MOD_RF:
- return "\n\nTime since last modification [mtime](Regular files):\n"
- "0 - Range in days;\n1 - Count of files in range;\n"
- "2 - Number of files in range as a % of total"
- " number of files;\n3 - Number of files in this"
- " range or smaller as a % of total number of"
- " files;\n4 - Total kilobytes that underflowed in range;\n"
- "5 - Total of age in range, total age in range as"
- " a % of total age of all files;\n6 - total age in"
- " this range or smaller as a % of total age of"
- " all files;\n7 - Minimum value in range;\n8 -"
- " Maximum value in range.\n";
- case LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF:
- return "\n\nTime since last metadata modification [ctime]"
- " (Regular files):\n0 - Range in days;\n1 - Count"
- " of files in range;\n2 - Number of files in range"
- " as a % of total number of files;\n3 - Number of"
- " files in this range or smaller as a % of total number of"
- " files;\n4 - Total kilobytes that underflowed in range;\n"
- "5 - Total of age in range, total age in range as"
- " a % of total age of all files;\n6 - total age in"
- " this range or smaller as a % of total age of"
- " all files;\n7 - Minimum value in range;\n8 -"
- " Maximum value in range.\n";
- case LS3_STATS_TIME_SINCE_LAST_ACCESS_RF:
- return "\n\nTime since last access [atime](Regular files):\n"
- "0 - Range in days;\n1 - Count of files in range;\n"
- "2 - Number of files in range as a % of total"
- " number of files;\n3 - Number of files in this"
- " range or smaller as a % of total number of"
- " files;\n4 - Total kilobytes that underflowed in range;\n"
- "5 - Total of age in range, total age in range as"
- " a % of total age of all files;\n6 - total age in"
- " this range or smaller as a % of total age of"
- " all files;\n7 - Minimum value in range;\n8 -"
- " Maximum value in range.\n";
- case LS3_STATS_FILENAME_LENGTH:
- return "\n\nFilename length (Includes regular files,"
- " dirs, symlinks and special files):\n0 - Range"
- " of filename lengths;\n1 - Count of files in range;\n"
- "2 - Count of files in range as a % of total number"
- " of files;\n3 - Number of files in this range or"
- " smaller as a % of total # of files;\n"
- "4 - Total chars of filenames in range;\n"
- "5 - Total chars of filenames in range as a % of"
- " total number of chars of filenames;\n6 - Total"
- " number of chars of filenames in this range or"
- " smaller as a % of total number bytes of filenames;\n"
- "7 - Minimum value in range;\n8 -"
- " Maximum value in range.\n";
- case LS3_STATS_DIRECTORY_SIZE_ENTRIES:
- return "\n\nDirectory size (entries):\n0 - Range of entries;\n"
- "1 - Count of directories in range;\n2 - Number of dirs in"
- " range as a % of total num of dirs;\n3 - Number of dirs"
- " in this range or smaller as a % total number of dirs;\n"
- "4 - Total entries in range;\n5 - Number of entries in"
- " range as a % of total number of entries;\n6 - Number of"
- " entries in this range or smaller as a % of total number"
- " of entries;\n7 - Minimum value in range;\n8 -"
- " Maximum value in range.\n";
- case LS3_STATS_STORAGE_SET_SIZE_BY_USER:
- return "\n\nStorage size by user (all directories and"
- " files):\n0 - User ID (name);\n1 - Count of files for user"
- ";\n2 - Number of files for user as a percent of total"
- " number of files;\n3 - Number of files for user as a % of"
- " total # of files;\n4 - Total size of files for user;\n5"
- " - Total size of files for user as a % of total size of"
- " files;\n6 - Total size of files for user or smaller"
- " as a % of total size of files;\n7 - Minimum size "
- "for user;\n8 - Maximum size for user.\n";
- case LS3_STATS_STORAGE_SET_SIZE_BY_GROUP:
- return "\n\nStorage size by group (all directories and"
- " files):\n0 - Group ID (name);\n1 - Count of files for group"
- ";\n2 - Number of files for group as a percent of total"
- " number of files;\n3 - Number of files for group as a % of"
- " total # of files;\n4 - Total size of files for group;\n5"
- " - Total size of files for group as a % of total size of"
- " files;\n6 - Total size of files for group or smaller"
- " as a % of total size of files;\n7 - Minimum size "
- "for group;\n8 - Maximum size for group.\n";
- case LS3_STATS_STORAGE_SET_SIZE_BY_PROJID:
- return "\n\nStorage size by projid (all directories and"
- " files):\n0 - Project ID;\n1 - Count of files for projid"
- ";\n2 - Number of files for projid as a percent of total"
- " number of files;\n3 - Number of files for projid as a % of"
- " total # of files;\n4 - Total size of files for projid;\n5"
- " - Total size of files for projid as a % of total size of"
- " files;\n6 - Total size of files for projid or smaller"
- " as a % of total size of files;\n7 - Minimum size "
- "for projid;\n8 - Maximum size for projid.\n";
- case LS3_STATS_LINK_COUNT:
- return "\n\nLink count (of regular files):\n0 - Range of link"
- " counts;\n1 - Count of files in range;\n2 - Number of files"
- " in range as a % of total files;\n3 - Number of files in"
- " this range or smaller as a % of total files;\n4 - Total"
- " links in range;\n5 - Total links in range as a % of total"
- " links;\n6 - Total links in this range or smaller as a % of"
- " total links;\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_STRIPE_COUNT:
- return "\n\nStripe count (of regular files):\n0 - Range of stripe"
- " count;\n1 - Count of files in range;\n2 - Number of files"
- " in range as a % of total files;\n3 - Number of files in"
- " this range as a % of total files;\n4 - Total"
- " stripe in range;\n5 - Total stripe in range as a % of total"
- " stripe;\n6 - Total stripe in this range as a"
- " % of total stripe;\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_STRIPE_SIZE:
- return "\n\nStripe size (of regular files):\n0 - Stripe"
- " size;\n1 - Count of files with stripe size;\n2 - Number"
- " of files with stripe size as a % of total files;\n3"
- " - Number of files with this stripe size as a % of"
- " total files;\n4 - Total file size with this stripe"
- " size;\n5 - Total file size with stripe size as a % of"
- " total size;\n6 - Total file size with this stripe size or"
- " smaller as a % of total file;\n7 - Minimum value with this"
- " stripe size;\n8 - Maximum value with this stripe size.\n";
- case LS3_STATS_MIRROR_COUNT:
- return "\n\nMirror count (of regular files):\n0 - Range of mirror"
- " count;\n1 - Count of files in range;\n2 - Number of files"
- " in range as a % of total files;\n3 - Number of files in"
- " this range as a % of total files;\n4 - Total"
- " mirror in range;\n5 - Total mirror in range as a % of total"
- " mirror;\n6 - Total mirror in this range as a"
- " % of total mirror;\n7 - Minimum value in range;\n"
- "8 - Maximum value in range.\n";
- case LS3_STATS_FILES_EMPLOYING_DOM:
- case LS3_STATS_TOTAL_COUNT_REPORT:
- return "";
+ case LS3_STATS_TYPE_FILES_SIZE:
+ return "\n\nFiles Size:\n"
+ "0 - Size range;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a percent of total "
+ "number of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total # of files;\n"
+ "4 - Total size of files in range;\n"
+ "5 - Total size of files in range as a % of total "
+ "size of files;\n"
+ "6 - Total size of files in this range or smaller as "
+ "a % of total size of files;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_CAPACITY_USED:
+ return "\n\nCapacity used (Regular files space used on disk):\n"
+ "0 - Size range;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a percent of total "
+ "number of files;\n"
+ "3 - Number of files in this range or smaller as a % of "
+ "total # of file;\n"
+ "4 - Total capacity used in range;\n"
+ "5 - Total capacity used in range as a % of total "
+ "capacity used;\n"
+ "6 - Total capacity used in this range or smaller as "
+ "a % of total capacity;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_EQUAL_OVERHEAD:
+ return "\n\nEqual overhead (Files whose usable capacity is "
+ "equal to their size):\n"
+ "0 - Size range;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a percent of total "
+ "number of files;\n"
+ "3 - Number of files in this range or smaller as a % of "
+ "total # of files;\n"
+ "4 - Total kilobytes that overflowed in range;\n"
+ "5 - Total kilobytes that overflowed in this range as "
+ "a % of total kilobytes that overflowed;\n"
+ "6 - Total kilobytes that overflowed in this range or "
+ "smaller as a % of total kilobytes "
+ "that overflowed;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_POSITIVE_OVERHEAD:
+ return "\n\nPositive overhead (Files whose capacity used is "
+ "larger than to its size):\n"
+ "0 - Range of difference sizes;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a percent of total "
+ "number of files;\n"
+ "3 - Number of files in this range or smaller as a % of "
+ "total # of files;\n"
+ "4 - Total bytes that overflowed in range;\n"
+ "5 - Total bytes that overflowed in this range as a % "
+ "of total bytes that overflowed;\n"
+ "6 - Total bytes that overflowed in this range or "
+ "smaller as a % of total bytes that overflowed;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_NEGATIVE_OVERHEAD:
+ return "\n\nNegative overhead (Files whose size is larger than "
+ "capacity used.):\n"
+ "0 - Range of difference sizes;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a percent of total "
+ "number of files;\n"
+ "3 - Number of files in this range or smaller as a % of "
+ "total # of files;\n"
+ "4 - Total bytes that underflowed in range;\n"
+ "5 - Total bytes that underflowed in this range as a % "
+ "of total bytes that underflowed;\n"
+ "6 - Total bytes that underflowed in this range or "
+ "smaller as a % of total bytes that underflowed;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_KB:
+ return "\n\nDirectory size (KB):\n"
+ "0 - Range of dir sizes;\n"
+ "1 - Count of directories in range;\n"
+ "2 - Number of files in dirs as a percent of total "
+ "number of dirs;\n"
+ "3 - Number of dirs in this range or smaller as a % of "
+ "total # of dirs;\n"
+ "4 - Total size of dirs in range;\n"
+ "5 - Total size of dirs in range as a % of total size "
+ "of dirs;\n"
+ "6 - Total size of dirs in this range or smaller as a % "
+ "of total size of dirs;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF:
+ return "\n\nTime since creation [crtime](Regular files):\n"
+ "0 - Range in days;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total number "
+ "of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total number of files;\n"
+ "4 - Total kilobytes that underflowed in range;\n"
+ "5 - Total of age in range, total age in range as a % "
+ "of total age of all files;\n"
+ "6 - total age in this range or smaller as a % of "
+ "total age of all files;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF:
+ return "\n\nTime since last modification [mtime] "
+ "(Regular files):\n"
+ "0 - Range in days;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total number "
+ "of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total number of files;\n"
+ "4 - Total kilobytes that underflowed in range;\n"
+ "5 - Total of age in range, total age in range as a % "
+ "of total age of all files;\n"
+ "6 - total age in this range or smaller as a % of total "
+ "age of all files;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF:
+ return "\n\nTime since last metadata modification [ctime] "
+ "(Regular files):\n"
+ "0 - Range in days;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total number "
+ "of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total number of files;\n"
+ "4 - Total kilobytes that underflowed in range;\n"
+ "5 - Total of age in range, total age in range as a % "
+ "of total age of all files;\n"
+ "6 - total age in this range or smaller as a % of total "
+ "age of all files;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF:
+ return "\n\nTime since last access [atime](Regular files):\n"
+ "0 - Range in days;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total number "
+ "of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total number of files;\n"
+ "4 - Total kilobytes that underflowed in range;\n"
+ "5 - Total of age in range, total age in range as a % "
+ "of total age of all files;\n"
+ "6 - total age in this range or smaller as a % of total "
+ "age of all files;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_FILENAME_LENGTH:
+ return "\n\nFilename length (Includes regular files, dirs, "
+ "symlinks and special files):\n"
+ "0 - Range of filename lengths;\n"
+ "1 - Count of files in range;\n"
+ "2 - Count of files in range as a % of total number "
+ "of files;\n"
+ "3 - Number of files in this range or smaller as a % "
+ "of total # of files;\n"
+ "4 - Total chars of filenames in range;\n"
+ "5 - Total chars of filenames in range as a % of total "
+ "number of chars of filenames;\n"
+ "6 - Total number of chars of filenames in this range "
+ "or smaller as a % of total number bytes "
+ "of filenames;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_DIRECTORY_SIZE_ENTRIES:
+ return "\n\nDirectory size (entries):\n"
+ "0 - Range of entries;\n"
+ "1 - Count of directories in range;\n"
+ "2 - Number of dirs in range as a % of total "
+ "num of dirs;\n"
+ "3 - Number of dirs in this range or smaller as "
+ "a % total number of dirs;\n"
+ "4 - Total entries in range;\n"
+ "5 - Number of entries in range as a % of total number "
+ "of entries;\n"
+ "6 - Number of entries in this range or smaller as a % "
+ "of total number of entries;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_USER:
+ return "\n\nStorage size by user (Regular files):\n"
+ "0 - User ID (name);\n"
+ "1 - Count of files for user;\n"
+ "2 - Number of files for user as a percent of total "
+ "number of files;\n"
+ "3 - Number of files for user as a % of total # "
+ "of files;\n"
+ "4 - Total size of files for user;\n"
+ "5 - Total size of files for user as a % of total size "
+ "of files;\n"
+ "6 - Total size of files for user or smaller as a % of "
+ "total size of files;\n"
+ "7 - Minimum size for user;\n"
+ "8 - Maximum size for user.\n";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_GROUP:
+ return "\n\nStorage size by group (Regular files):\n"
+ "0 - Group ID (name);\n"
+ "1 - Count of files for group;\n"
+ "2 - Number of files for group as a percent of total "
+ "number of files;\n"
+ "3 - Number of files for group as a % of "
+ "total # of files;\n"
+ "4 - Total size of files for group;\n"
+ "5 - Total size of files for group as a % of total "
+ "size of files;\n"
+ "6 - Total size of files for group or smaller as "
+ "a % of total size of files;\n"
+ "7 - Minimum size for group;\n"
+ "8 - Maximum size for group.\n";
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_PROJID:
+ return "\n\nStorage size by projid (Regular files):\n"
+ "0 - Project ID;\n"
+ "1 - Count of files for projid;\n"
+ "2 - Number of files for projid as a percent of total "
+ "number of files;\n"
+ "3 - Number of files for projid as a % of "
+ "total # of files;\n"
+ "4 - Total size of files for projid;\n"
+ "5 - Total size of files for projid as a % of total "
+ "size of files;\n"
+ "6 - Total size of files for projid or smaller as a % "
+ "of total size of files;\n"
+ "7 - Minimum size for projid;\n"
+ "8 - Maximum size for projid.\n";
+ case LS3_STATS_TYPE_LINK_COUNT:
+ return "\n\nLink count (of regular files):\n"
+ "0 - Range of link counts;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total files;\n"
+ "3 - Number of files in this range or smaller as "
+ "a % of total files;\n"
+ "4 - Total links in range;\n"
+ "5 - Total links in range as a % of total links;\n"
+ "6 - Total links in this range or smaller as "
+ "a % of total links;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_STRIPE_COUNT:
+ return "\n\nStripe count (of regular files):\n"
+ "0 - Range of stripe count;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total files;\n"
+ "3 - Number of files in this range as a % of "
+ "total files;\n"
+ "4 - Total stripe in range;\n"
+ "5 - Total stripe in range as a % of total stripe;\n"
+ "6 - Total stripe in this range as a % "
+ "of total stripe;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_STRIPE_SIZE:
+ return "\n\nStripe size (of regular files):\n"
+ "0 - Stripe size;\n"
+ "1 - Count of files with stripe size;\n"
+ "2 - Number of files with stripe size as a % "
+ "of total files;\n"
+ "3 - Number of files with this stripe size as a % "
+ "of total files;\n"
+ "4 - Total file size with this stripe size;\n"
+ "5 - Total file size with stripe size as a % "
+ "of total size;\n"
+ "6 - Total file size with this stripe size or smaller "
+ "as a % of total file;\n"
+ "7 - Minimum value with this stripe size;\n"
+ "8 - Maximum value with this stripe size.\n";
+ case LS3_STATS_TYPE_MIRROR_COUNT:
+ return "\n\nMirror count (of regular files):\n"
+ "0 - Range of mirror count;\n"
+ "1 - Count of files in range;\n"
+ "2 - Number of files in range as a % of total files;\n"
+ "3 - Number of files in this range as a % "
+ "of total files;\n"
+ "4 - Total mirror in range;\n"
+ "5 - Total mirror in range as a % of total mirror;\n"
+ "6 - Total mirror in this range as a % of "
+ "total mirror;\n"
+ "7 - Minimum value in range;\n"
+ "8 - Maximum value in range.\n";
+ case LS3_STATS_TYPE_FILES_EMPLOYING_DOM:
+ case LS3_STATS_TYPE_SYMLINK_TARGET_LENGTH:
+ case LS3_STATS_TYPE_COMPRESSION_RATIO:
+ case LS3_STATS_TYPE_TOTAL_COUNT_REPORT:
+ return "";
}
return "";
}
static void ls3_stats_get_range_str(struct range_report_template *range_ptr,
- char str[30], int range, ls3_stats_report_type r_type, char *value_ts)
+ char *str, size_t strlen, int range, ls3_stats_report_type r_type,
+ char *value_ts)
{
- int size_str = 30;
-
/* Different type of "range" field */
switch (r_type)
{
- case LS3_STATS_STORAGE_SET_SIZE_BY_USER:
- snprintf(str, size_str,
- "%10lu (%14s)", range_ptr->rrt_id,
- ls3_stats_get_username_from_uid(range_ptr->rrt_id));
- break;
- case LS3_STATS_STORAGE_SET_SIZE_BY_GROUP:
- snprintf(str, size_str,
- "%10lu (%14s)", range_ptr->rrt_id,
- ls3_stats_get_groupname_from_gid(range_ptr->rrt_id));
- break;
- case LS3_STATS_STORAGE_SET_SIZE_BY_PROJID:
- snprintf(str, size_str, "%26lu ", range_ptr->rrt_id);
- break;
- case LS3_STATS_STRIPE_SIZE:
- snprintf(str, size_str, "%18lu %7s ", range_ptr->rrt_id,
- value_ts);
- break;
- case LS3_STATS_MIRROR_COUNT:
- snprintf(str, size_str, "%26lu ", range_ptr->rrt_id);
- break;
- case LS3_STATS_TIME_SINCE_LAST_ACCESS_RF:
- case LS3_STATS_TIME_SINCE_LAST_CREATION_RF:
- case LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF:
- case LS3_STATS_TIME_SINCE_LAST_MOD_RF:
- if (range_ptr->range_start >= 16384)
- snprintf(str, size_str,
- " Never changed ");
- else
- snprintf(str, size_str,
- "%8lu - %8lu %7s",
- range_ptr->range_start,
- range_ptr->range_end, value_ts);
- break;
- default:
- snprintf(str, size_str,
- "%8lu - %8lu %7s", range_ptr->range_start,
- range_ptr->range_end, value_ts);
- break;
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_USER:
+ snprintf(str, strlen,
+ "%10lu (%14s)", range_ptr->rrt_id,
+ ls3_stats_get_username_from_uid(range_ptr->rrt_id));
+ break;
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_GROUP:
+ snprintf(str, strlen,
+ "%10lu (%14s)", range_ptr->rrt_id,
+ ls3_stats_get_groupname_from_gid(range_ptr->rrt_id));
+ break;
+ case LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_PROJID:
+ snprintf(str, strlen, "%26lu ", range_ptr->rrt_id);
+ break;
+ case LS3_STATS_TYPE_STRIPE_SIZE:
+ snprintf(str, strlen, "%18lu %7s ", range_ptr->rrt_id,
+ value_ts);
+ break;
+ case LS3_STATS_TYPE_MIRROR_COUNT:
+ snprintf(str, strlen, "%26lu ", range_ptr->rrt_id);
+ break;
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF:
+ if (range_ptr->range_start >= 16384)
+ snprintf(str, strlen,
+ " Never changed ");
+ else
+ snprintf(str, strlen,
+ "%8lu - %8lu %7s",
+ range_ptr->range_start,
+ range_ptr->range_end, value_ts);
+ break;
+ default:
+ snprintf(str, strlen,
+ "%8lu - %8lu %7s", range_ptr->range_start,
+ range_ptr->range_end, value_ts);
+ break;
}
}
* @param buffer Output buffer to store the resulting date-time string.
* @param seconds Number of seconds since the epoch.
*/
-static void ls3_stats_get_time_str(char *buffer, uint64_t seconds)
+static void ls3_stats_get_time_str(char *buffer, size_t buff_len,
+ uint64_t seconds)
{
time_t l_access;
struct tm* la_time;
- int buffer_size = 20;
l_access = (time_t)seconds;
la_time = localtime(&l_access);
if (seconds == 0)
- strncpy(buffer, "Files never opened", buffer_size);
+ strncpy(buffer, "Files never opened", buff_len);
else
- strftime(buffer, buffer_size, "%Y-%m-%d-%H:%M:%S", la_time);
+ strftime(buffer, buff_len, "%Y-%m-%d-%H:%M:%S", la_time);
}
static char* ls3_stats_get_title_for_user_report(ls3_stats_users_reports rtype)
{
switch (rtype)
{
- case LS3_STATS_USERS_REPORTS_MOD_RF:
- return "Time since last modification (mtime)";
- case LS3_STATS_USERS_REPORTS_MD_MOD_RF:
- return "Time since last metadata modification (ctime)";
- case LS3_STATS_USERS_REPORTS_CREATION_RF:
- return "Time since creation (crtime)";
- case LS3_STATS_USERS_REPORTS_ACCESS_RF:
- return "Time since last access (atime)";
- case LS3_STATS_USERS_REPORTS_COUNTER:
- default:
- return "";
+ case LS3_STATS_USERS_REPORTS_MOD_RF:
+ return "Time since last modification (mtime)";
+ case LS3_STATS_USERS_REPORTS_MD_MOD_RF:
+ return "Time since last metadata modification (ctime)";
+ case LS3_STATS_USERS_REPORTS_CREATION_RF:
+ return "Time since creation (crtime)";
+ case LS3_STATS_USERS_REPORTS_ACCESS_RF:
+ return "Time since last access (atime)";
+ case LS3_STATS_USERS_REPORTS_COUNTER:
+ default:
+ return "";
}
}
int i, j, k;
json_object_object_add(jobj_main, "LIPEStatsVersion",
- json_object_new_double(LS3_STATS_VERSION));
+ json_object_new_double(LS3_STATS_VERSION));
+
json_object_object_add(jobj_main, "CreateTime",
- json_object_new_string(f_time));
+ json_object_new_string(f_time));
+
json_object_object_add(jobj_main, "ProcessedFiles",
- json_object_new_int64(reports_with_stats->total_count_files));
+ json_object_new_int64(reports_with_stats->total_count_files));
+
json_object_object_add(jobj_main, "ProcessingTimeSecs",
- json_object_new_double(e_time));
+ json_object_new_double(e_time));
+
json_object_object_add(jobj_main, "DevicePath",
- json_object_new_string(reports_with_stats->device_path));
+ json_object_new_string(reports_with_stats->device_path));
+
json_object_object_add(jobj_main, "DeviceName",
- json_object_new_string(reports_with_stats->device_name));
+ json_object_new_string(reports_with_stats->device_name));
+
json_object_object_add(jobj_main, "DeviceType",
- json_object_new_string(reports_with_stats->device_is_mdt ?
- "MDT" : "OST"));
- json_object_object_add(jobj_main, "DeviceSizeInKB",
- json_object_new_int64(reports_with_stats->device_size >> 10));
+ json_object_new_string(reports_with_stats->device_is_mdt ?
+ "MDT" : "OST"));
+
+ json_object_object_add(jobj_main, "InodesCountOnDevice",
+ json_object_new_int(reports_with_stats->inodes_count));
+
+ json_object_object_add(jobj_main, "FreeInodesCountOnDevice",
+ json_object_new_int(reports_with_stats->free_inodes_count));
+
json_object_object_add(jobj_main, "ClientMountPath",
- json_object_new_string(reports_with_stats->client_mount_path));
+ json_object_new_string(reports_with_stats->client_mount_path));
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
struct json_object *jobj_report;
struct json_object *jobj_general;
struct json_object *jobj_ranges;
LS3_FATAL("Unable to access the report data: %d\n", i);
if (report_ptr->files_count == 0)
- continue; /* Nothing for print */
+ continue; /* Nothing for print */
- value_ts = ls3_stats_get_str_value_type(report_ptr->value_type);
- second_value_ts = ls3_stats_get_str_value_type(report_ptr->second_value_type);
+ value_ts =
+ ls3_stats_get_str_value_type(report_ptr->value_type);
+ second_value_ts =
+ ls3_stats_get_str_value_type(report_ptr->second_value_type);
title_text = ls3_stats_get_title_text(i);
jobj_report = json_object_new_object();
jobj_ranges = json_object_new_array();
json_object_object_add(jobj_general, "Title",
- json_object_new_string(title_text));
+ json_object_new_string(title_text));
+
json_object_object_add(jobj_general, "Count",
json_object_new_int64(report_ptr->files_count));
+
json_add_field_with_value(jobj_general, "Min",
- report_ptr->min, value_ts, LS3_STATS_EMPTY_VALUE);
+ report_ptr->rt_min, value_ts, LS3_STATS_EMPTY_VALUE);
+
json_add_field_with_value(jobj_general, "Max",
- report_ptr->max, value_ts, LS3_STATS_EMPTY_VALUE);
+ report_ptr->rt_max, value_ts, LS3_STATS_EMPTY_VALUE);
+
json_add_field_with_value(jobj_general, "Avg",
- report_ptr->avg, value_ts, LS3_STATS_EMPTY_VALUE);
+ report_ptr->rt_avg, value_ts, LS3_STATS_EMPTY_VALUE);
+
json_add_field_with_value(jobj_general, "Total",
report_ptr->total_value,
(second_value_ts[0] != '\0') ?
second_value_ts : value_ts, LS3_STATS_EMPTY_VALUE);
for (j = 0; j < report_ptr->count_ranges; j++) {
- struct json_object *jobj_range = json_object_new_object();
- char range_t[30];
+ struct json_object *jobj_range =
+ json_object_new_object();
+ char range_t[30]; /* size in 30 byte enough */
range_ptr = report_ptr->fs_ranges[j];
if (range_ptr == NULL)
if (range_ptr->count_in_range == 0)
continue; /* Nothing for print */
- ls3_stats_get_range_str(range_ptr, range_t, j, i, value_ts);
+ ls3_stats_get_range_str(range_ptr, range_t,
+ sizeof(range_t), j, i,value_ts);
json_object_object_add(jobj_range, "RangeID",
json_object_new_int(j));
json_object_new_string(range_t));
json_object_object_add(jobj_range, "CountInRange",
- json_object_new_int64(
- range_ptr->count_in_range));
+ json_object_new_int64(range_ptr->count_in_range));
- json_add_field_with_value(jobj_range, "PercentageInRange",
- LS3_STATS_EMPTY_VALUE ,
- "", range_ptr->percentage);
+ json_add_field_with_value(jobj_range,
+ "PercentageInRange",
+ LS3_STATS_EMPTY_VALUE, "",
+ range_ptr->percentage);
json_add_field_with_value(jobj_range,
"CumulativePercentageInRange",
second_value_ts : value_ts,
LS3_STATS_EMPTY_VALUE);
- json_add_field_with_value(jobj_range, "PercentTotalInRange",
- LS3_STATS_EMPTY_VALUE ,
- "", range_ptr->percent_in_range);
+ json_add_field_with_value(jobj_range,
+ "PercentTotalInRange",
+ LS3_STATS_EMPTY_VALUE, "",
+ range_ptr->percent_in_range);
json_add_field_with_value(jobj_range,
"PercentCumulativeTotalInRange",
range_ptr->percent_cumulative_in_range);
json_add_field_with_value(jobj_range, "MinValueInRange",
- range_ptr->min, value_ts,
+ range_ptr->rrt_min, value_ts,
LS3_STATS_EMPTY_VALUE);
json_add_field_with_value(jobj_range, "MaxValueInRange",
- range_ptr->max, value_ts,
+ range_ptr->rrt_max, value_ts,
LS3_STATS_EMPTY_VALUE);
json_object_array_add(jobj_ranges, jobj_range);
json_object_new_string(title_text));
for (k = 0; k < report_ptr->count_ranges; k++) {
- struct json_object *jobj_range = json_object_new_object();
+ struct json_object *jobj_range =
+ json_object_new_object();
char buffer[20];
range_ptr = report_ptr->fs_ranges[k];
if (range_ptr == NULL)
continue;
- ls3_stats_get_time_str(buffer, range_ptr->last_time_access);
+ ls3_stats_get_time_str(buffer, sizeof(buffer),
+ range_ptr->last_time_access);
json_object_object_add(jobj_range,
"RangeDayStart",
- json_object_new_int64(range_ptr->range_start));
+ json_object_new_int64(
+ range_ptr->range_start));
json_object_object_add(jobj_range,
"RangeDayEnd",
- json_object_new_int64(range_ptr->range_end));
+ json_object_new_int64(
+ range_ptr->range_end));
json_object_object_add(jobj_range,
"CountFilesInRange",
- json_object_new_int64(range_ptr->count_in_range));
+ json_object_new_int64(
+ range_ptr->count_in_range));
json_object_object_add(jobj_range,
"MinSizeKB",
- json_object_new_int64(range_ptr->min));
+ json_object_new_int64(
+ range_ptr->rrt_min));
json_object_object_add(jobj_range,
"MaxSizeKB",
- json_object_new_int64(range_ptr->min));
+ json_object_new_int64(
+ range_ptr->rrt_max));
json_object_object_add(jobj_range,
"TotalSizeInRangeKB",
- json_object_new_int64(range_ptr->total_in_range));
+ json_object_new_int64(
+ range_ptr->total_in_range));
json_object_object_add(jobj_range,
"LastTimeAccess",
json_object_new_string(buffer));
"DevicePath: %s\n"
"DeviceName: %s\n"
"ClientMountPath: %s\n"
- "DeviceSizeInKB: %lu\n"
+ "Inodes count on device: %u\n"
+ "Free inodes count on device: %u\n"
"DeviceType: %s\n",
LS3_STATS_VERSION, f_time,
reports_with_stats->total_count_files, e_time,
reports_with_stats->device_path,
reports_with_stats->device_name,
reports_with_stats->client_mount_path,
- reports_with_stats->device_size >> 10,
+ reports_with_stats->inodes_count,
+ reports_with_stats->free_inodes_count,
reports_with_stats->device_is_mdt ? "MDT" : "OST");
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
char *title_text;
report_ptr = reports_with_stats->reports[i];
" Total: %lu %s\n"
" Ranges:\n",
title_text, report_ptr->files_count,
- report_ptr->min, value_ts,
- report_ptr->max, value_ts,
- report_ptr->avg, value_ts,
+ report_ptr->rt_min, value_ts,
+ report_ptr->rt_max, value_ts,
+ report_ptr->rt_avg, value_ts,
report_ptr->total_value,
(second_value_ts[0] != '\0') ?
second_value_ts : value_ts);
for (j = 0; j < report_ptr->count_ranges; j++) {
- char range_t[30];
+ char range_t[30]; /* size in 30 byte enough */
range_ptr = report_ptr->fs_ranges[j];
if (range_ptr == NULL)
continue; /* Nothing for print */
/* Different type of "range" field */
- ls3_stats_get_range_str(range_ptr, range_t, j, i, value_ts);
+ ls3_stats_get_range_str(range_ptr, range_t,
+ sizeof(range_t),
+ j, i, value_ts);
fprintf(yaml_fd,
" - RangeID: %i\n"
range_ptr->count_in_range, range_ptr->percentage,
range_ptr->cumulative_percentage,
range_ptr->total_in_range,
- (second_value_ts[0] != '\0') ? second_value_ts : value_ts,
+ (second_value_ts[0] != '\0') ?
+ second_value_ts : value_ts,
range_ptr->percent_in_range,
range_ptr->percent_cumulative_in_range,
- range_ptr->min, value_ts,
- range_ptr->max, value_ts);
+ range_ptr->rrt_min, value_ts,
+ range_ptr->rrt_max, value_ts);
}
}
if (range_ptr == NULL)
continue;
- ls3_stats_get_time_str(buffer,
+ ls3_stats_get_time_str(buffer, sizeof(buffer),
range_ptr->last_time_access);
fprintf(yaml_fd,
" RangeStart: %lu %s\n"
range_ptr->range_start, value_ts,
range_ptr->range_end, value_ts,
range_ptr->count_in_range,
- range_ptr->min, second_value_ts,
- range_ptr->max, second_value_ts,
+ range_ptr->rrt_min, second_value_ts,
+ range_ptr->rrt_max, second_value_ts,
range_ptr->total_in_range,
second_value_ts, buffer);
}
"Device path: %s\n"
"Device name: %s\n"
"Device type: %s\n"
- "Device size in KB: %lu\n"
- "Client mount path: %s\n"
- "RESULTS MAY BE INCOMPLETE\n\n",
+ "Inodes count on device: %u\n"
+ "Free inodes count on device: %u\n"
+ "Client mount path: %s\n\n",
LS3_STATS_VERSION, f_time,
reports_with_stats->total_count_files, e_time,
reports_with_stats->device_path,
reports_with_stats->device_name,
reports_with_stats->device_is_mdt ? "MDT" : "OST",
- reports_with_stats->device_size >> 10,
+ reports_with_stats->inodes_count,
+ reports_with_stats->free_inodes_count,
reports_with_stats->client_mount_path);
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
char *header_text;
report_ptr = reports_with_stats->reports[i];
LS3_FATAL("Unable to access the report data: %d\n", i);
if (report_ptr->files_count == 0)
- continue; /* Nothing for print */
+ continue; /* Nothing for print */
value_ts = ls3_stats_get_str_value_type(report_ptr->value_type);
second_value_ts =
fprintf(out_fd, "%s\nGeneral: Count: %lu | Min value in ranges:"
" %lu %s | Max value in ranges: %lu %s| Average value in ranges:"
" %lu %s | Total value: %lu %s\n\n",
- header_text, report_ptr->files_count, report_ptr->min,
- value_ts, report_ptr->max, value_ts, report_ptr->avg,
- value_ts, report_ptr->total_value,
+ header_text, report_ptr->files_count, report_ptr->rt_min,
+ value_ts, report_ptr->rt_max, value_ts,
+ report_ptr->rt_avg, value_ts, report_ptr->total_value,
(second_value_ts[0] != '\0') ? second_value_ts : value_ts);
- fprintf(out_fd, "[------------- %1d ------------] [---- %1d -----]"
- " [-- %1d --] [------- %1d --------] [-------- %1d --------]"
- " [-- %1d --] [------- %1d --------] [-------- %1d --------]"
- " [-------- %1d --------]\n", 0, 1, 2, 3, 4, 5, 6, 7, 8);
+ fprintf(out_fd, "[------------- 0 ------------] [---- 1 -----]"
+ " [-- 2 --] [------- 3 --------] [-------- 4 --------]"
+ " [-- 5 --] [------- 6 --------] [-------- 7 --------]"
+ " [-------- 8 --------]\n");
for (j = 0; j < report_ptr->count_ranges; j++) {
- char range_t[30];
+ char range_t[30]; /* size in 30 byte enough */
range_ptr = report_ptr->fs_ranges[j];
if (range_ptr == NULL)
continue; /* Nothing for print */
/* Different type of "range" field */
- ls3_stats_get_range_str(range_ptr, range_t, j, i, value_ts);
+ ls3_stats_get_range_str(range_ptr, range_t,
+ sizeof(range_t),
+ j, i, value_ts);
fprintf(out_fd, "[ %s] [ %11lu] [%6.2f%%]"
" [%6.2f%% cumulative] [%11lu %7s] [%6.2f%%]"
range_ptr->percentage,
range_ptr->cumulative_percentage,
range_ptr->total_in_range,
- (second_value_ts[0] != '\0') ? second_value_ts : value_ts,
+ (second_value_ts[0] != '\0') ?
+ second_value_ts : value_ts,
range_ptr->percent_in_range,
range_ptr->percent_cumulative_in_range,
- range_ptr->min, value_ts,
- range_ptr->max, value_ts);
+ range_ptr->rrt_min, value_ts,
+ range_ptr->rrt_max, value_ts);
}
fprintf(out_fd, "[----------------------------] [------------]"
if (range_ptr == NULL)
continue;
- ls3_stats_get_time_str(buffer,
+ ls3_stats_get_time_str(buffer, sizeof(buffer),
range_ptr->last_time_access);
fprintf(out_fd, "[ %8lu - %8lu %7s] [ %11lu ]"
range_ptr->range_start,
range_ptr->range_end, value_ts,
range_ptr->count_in_range,
- range_ptr->min, second_value_ts,
- range_ptr->max, second_value_ts,
+ range_ptr->rrt_min, second_value_ts,
+ range_ptr->rrt_max, second_value_ts,
range_ptr->total_in_range,
second_value_ts, buffer);
}
"Device path [%s]\n"
"Device name [%s]\n"
"Device type [%s]\n"
- "Device size in KB [%lu]\n"
+ "Inodes count on device [%u]\n"
+ "Free inodes count on device [%u]\n"
"Client mount path [%s]\n\n",
LS3_STATS_VERSION, f_time,
reports_with_stats->total_count_files, e_time,
reports_with_stats->device_path,
reports_with_stats->device_name,
reports_with_stats->device_is_mdt ? "MDT" : "OST",
- reports_with_stats->device_size >> 10,
+ reports_with_stats->inodes_count,
+ reports_with_stats->free_inodes_count,
reports_with_stats->client_mount_path);
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
char *value_ts;
char *title_text;
char *second_value_ts;
fprintf(csv_fd, "General,\nCount,%lu\nMinValueInRanges,%lu,%s\n"
"MaxValueInRanges,%lu,%s\nAverageValueInRanges,%lu,%s\n"
"TotalValue,%lu,%s\n\n",
- report_ptr->files_count, report_ptr->min,
- value_ts, report_ptr->max, value_ts, report_ptr->avg,
- value_ts, report_ptr->total_value,
- (second_value_ts[0] != '\0') ? second_value_ts : value_ts);
+ report_ptr->files_count, report_ptr->rt_min,
+ value_ts, report_ptr->rt_max, value_ts,
+ report_ptr->rt_avg, value_ts, report_ptr->total_value,
+ (second_value_ts[0] != '\0') ?
+ second_value_ts : value_ts);
fprintf(csv_fd, "Range,RangeCount,"
- "RangePercentage,RangeCumulativePercentage,TotalInRange,"
- "PercentInRange,PercentCumulativeInRange,RangeMin,RangeMax\n");
+ "RangePercentage,RangeCumulativePercentage,"
+ "TotalInRange,PercentInRange,PercentCumulativeInRange,"
+ "RangeMin,RangeMax\n");
for (j = 0; j < report_ptr->count_ranges; j++) {
- char range_t[30];
+ char range_t[30]; /* size in 30 byte enough */
range_ptr = report_ptr->fs_ranges[j];
if (range_ptr == NULL)
continue; /* Nothing for print */
/* Different type of "range" field */
- ls3_stats_get_range_str(range_ptr, range_t, j, i, value_ts);
- fprintf(csv_fd, "%s,%lu,%.2f,%.2f,%lu %s,%.2f,%.2f,%lu %s,%lu %s\n",
- range_t, range_ptr->count_in_range, range_ptr->percentage,
- range_ptr->cumulative_percentage, range_ptr->total_in_range,
- (second_value_ts[0] != '\0') ? second_value_ts : value_ts,
+ ls3_stats_get_range_str(range_ptr, range_t,
+ sizeof(range_t),
+ j, i, value_ts);
+ fprintf(csv_fd, "%s,%lu,%.2f,%.2f,%lu %s,%.2f,%.2f,"
+ "%lu %s,%lu %s\n",
+ range_t, range_ptr->count_in_range,
+ range_ptr->percentage,
+ range_ptr->cumulative_percentage,
+ range_ptr->total_in_range,
+ (second_value_ts[0] != '\0') ?
+ second_value_ts : value_ts,
range_ptr->percent_in_range,
range_ptr->percent_cumulative_in_range,
- range_ptr->min, value_ts, range_ptr->max, value_ts);
+ range_ptr->rrt_min, value_ts,
+ range_ptr->rrt_max, value_ts);
}
fprintf(csv_fd, "\n");
fprintf(csv_fd, "--------------------------------------------"
LS3_FATAL("Unable to access the user report data: %d\n", j);
fprintf(csv_fd, "\n%s\n", title );
- fprintf(csv_fd, "RangeDayStart,RangeDayEnd,CountFilesInRange,"
- "MinSizeKB,MaxSizeKB,TotalSizeInRangeKB,LastTimeAccess\n");
+ fprintf(csv_fd, "RangeDayStart,RangeDayEnd,"
+ "CountFilesInRange,MinSizeKB,MaxSizeKB,"
+ "TotalSizeInRangeKB,LastTimeAccess\n");
for (k = 0; k < report_ptr->count_ranges; k++) {
char buffer[20];
if (range_ptr == NULL)
continue;
- ls3_stats_get_time_str(buffer,
+ ls3_stats_get_time_str(buffer, sizeof(buffer),
range_ptr->last_time_access);
fprintf(csv_fd, "%lu,%lu,%lu,%lu,%lu,%lu,%s\n",
range_ptr->range_start,
range_ptr->range_end,
range_ptr->count_in_range,
- range_ptr->min, range_ptr->max,
+ range_ptr->rrt_min, range_ptr->rrt_max,
range_ptr->total_in_range, buffer);
}
}
struct report_template *report_ptr;
struct range_report_template *range_ptr;
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
double cumulative_percentage = 0;
double percent_cumulative_in_range = 0;
if (report_ptr->files_count == 0)
continue;
- if (i == LS3_STATS_FILES_SIZE)
+ if (i == LS3_STATS_TYPE_FILES_SIZE)
reports_with_stats->total_count_files =
report_ptr->files_count;
- report_ptr->avg =
+ report_ptr->rt_avg =
report_ptr->total_value / report_ptr->files_count;
for (j = 0; j < report_ptr->count_ranges; j++) {
range_ptr->percent_in_range;
}
}
-
- if (reports_with_stats->device_path)
- reports_with_stats->device_size =
- ls3_stats_get_dev_size(reports_with_stats->device_path);
}
static struct range_report_template *ls3_stats_get_new_range_ptr(uint64_t res)
struct range_report_template *range_ptr;
range_ptr = xcalloc(1, sizeof(struct range_report_template));
- range_ptr->min = UINT64_MAX;
+ range_ptr->rrt_min = UINT64_MAX;
if (res >= 2) {
range_ptr->range_start = (int)pow(2, floor(log2(res)));
range_ptr->range_end = range_ptr->range_start * 2;
xcalloc(1, sizeof(struct report_template));
report_ptr->count_ranges = LS3_STATS_COUNT_RANGE_BY_DEFAULT;
- report_ptr->min = UINT64_MAX;
+ report_ptr->rt_min = UINT64_MAX;
report_ptr->total_value = 0;
- report_ptr->curent_max_range = pow(2, report_ptr->count_ranges);
+ report_ptr->current_max_range = pow(2, report_ptr->count_ranges);
report_ptr->fs_ranges = (struct range_report_template**)xcalloc(
report_ptr->count_ranges,
sizeof(struct range_report_template*));
value_type = ls3_stats_get_value_type(report_type);
switch (value_type)
{
- case LS3_STATS_VALUE_TYPE_KB:
- result_range_value = range_value >> 10;
- break;
- case LS3_STATS_VALUE_TYPE_DAYS:
- result_range_value = ls3_stats_get_day_diff(range_value);
- result_second_value = second_value >> 10;
- report_ptr->second_value_type = LS3_STATS_VALUE_TYPE_KB;
- break;
- default:
- result_range_value = range_value;
- report_ptr->second_value_type =
- LS3_STATS_VALUE_TYPE_EMPTY;
- result_second_value = 0;
- break;
+ case LS3_STATS_VALUE_TYPE_KB:
+ result_range_value = range_value >> 10;
+ break;
+ case LS3_STATS_VALUE_TYPE_DAYS:
+ result_range_value = ls3_stats_get_day_diff(range_value);
+ result_second_value = second_value >> 10;
+ report_ptr->second_value_type = LS3_STATS_VALUE_TYPE_KB;
+ break;
+ default:
+ result_range_value = range_value;
+ report_ptr->second_value_type =
+ LS3_STATS_VALUE_TYPE_EMPTY;
+ result_second_value = 0;
+ break;
}
report_ptr->value_type = value_type;
index_range = ls3_stats_get_range_index(result_range_value);
pthread_mutex_lock(&report_ptr->report_template_mutex);
- if (result_range_value < report_ptr->min)
- report_ptr->min = result_range_value;
+ if (result_range_value < report_ptr->rt_min)
+ report_ptr->rt_min = result_range_value;
- if (result_range_value > report_ptr->max) {
- report_ptr->max = result_range_value;
- report_ptr->curent_max_range = pow(2, report_ptr->max);
+ if (result_range_value > report_ptr->rt_max) {
+ report_ptr->rt_max = result_range_value;
+ report_ptr->current_max_range = pow(2, report_ptr->rt_max);
if (index_range > report_ptr->count_ranges - 1)
ls3_stats_expand_num_of_ranges(report_ptr, index_range);
switch (report_type)
{
- case LS3_STATS_TIME_SINCE_LAST_MOD_RF:
- case LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF:
- case LS3_STATS_TIME_SINCE_LAST_ACCESS_RF:
- case LS3_STATS_TIME_SINCE_LAST_CREATION_RF:
- /* When the range is time and the value
- * is expressed in size */
- range_ptr->total_in_range += result_second_value;
- report_ptr->total_value += result_second_value;
- break;
- default:
- /* When range and value have same type for print */
- range_ptr->total_in_range += result_range_value;
- report_ptr->total_value += result_range_value;
- break;
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF:
+ case LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF:
+ /* When the range is time and the value
+ * is expressed in size */
+ range_ptr->total_in_range += result_second_value;
+ report_ptr->total_value += result_second_value;
+ break;
+ default:
+ /* When range and value have same type for print */
+ range_ptr->total_in_range += result_range_value;
+ report_ptr->total_value += result_range_value;
+ break;
}
range_ptr->count_in_range++;
report_ptr->files_count++;
- if (result_range_value < range_ptr->min)
- range_ptr->min = result_range_value;
+ if (result_range_value < range_ptr->rrt_min)
+ range_ptr->rrt_min = result_range_value;
- if (result_range_value > range_ptr->max)
- range_ptr->max = result_range_value;
+ if (result_range_value > range_ptr->rrt_max)
+ range_ptr->rrt_max = result_range_value;
pthread_mutex_unlock(&report_ptr->report_template_mutex);
if (!report_ptr)
LS3_FATAL("Unable to access the report data: %d\n", report_type);
- /* LS3_STATS_STRIPE_SIZE Will display in KB
+ /* LS3_STATS_TYPE_STRIPE_SIZE Will display in KB
* (+ exception redundant pointer allocations) */
- if (report_type == LS3_STATS_STRIPE_SIZE)
+ if (report_type == LS3_STATS_TYPE_STRIPE_SIZE)
local_id = local_id >> 10;
/* Get size in KB (here it's only for users & groups) */
report_ptr->value_type = LS3_STATS_VALUE_TYPE_KB;
pthread_mutex_lock(&report_ptr->report_template_mutex);
- if (result_second_value < report_ptr->min)
- report_ptr->min = result_second_value;
+ if (result_second_value < report_ptr->rt_min)
+ report_ptr->rt_min = result_second_value;
- if (result_second_value > report_ptr->max) {
- report_ptr->max = result_second_value;
- report_ptr->curent_max_range = local_id;
+ if (result_second_value > report_ptr->rt_max) {
+ report_ptr->rt_max = result_second_value;
+ report_ptr->current_max_range = local_id;
}
range_ptr = ls3_stats_find_id_in_ranges(local_id, report_ptr);
range_ptr = report_ptr->fs_ranges[current_index];
if (!range_ptr) {
- range_ptr =
- ls3_stats_get_new_range_ptr(LS3_STATS_EMPTY_VALUE);
+ range_ptr = ls3_stats_get_new_range_ptr(LS3_STATS_EMPTY_VALUE);
range_ptr->rrt_id = local_id;
report_ptr->fs_ranges[current_index] = range_ptr;
}
report_ptr->total_value += result_second_value;
report_ptr->files_count++;
- if (result_second_value < range_ptr->min)
- range_ptr->min = result_second_value;
+ if (result_second_value < range_ptr->rrt_min)
+ range_ptr->rrt_min = result_second_value;
- if (result_second_value > range_ptr->max)
- range_ptr->max = result_second_value;
+ if (result_second_value > range_ptr->rrt_max)
+ range_ptr->rrt_max = result_second_value;
pthread_mutex_unlock(&report_ptr->report_template_mutex);
}
index_range = ls3_stats_get_range_index(result_range_value);
pthread_mutex_lock(&report_ptr->report_template_mutex);
- if (result_range_value < report_ptr->min)
- report_ptr->min = result_range_value;
+ if (result_range_value < report_ptr->rt_min)
+ report_ptr->rt_min = result_range_value;
- if (result_range_value > report_ptr->max) {
- report_ptr->max = result_range_value;
- report_ptr->curent_max_range = pow(2, report_ptr->max);
+ if (result_range_value > report_ptr->rt_max) {
+ report_ptr->rt_max = result_range_value;
+ report_ptr->current_max_range = pow(2, report_ptr->rt_max);
if (index_range > report_ptr->count_ranges - 1)
ls3_stats_expand_num_of_ranges(report_ptr, index_range);
if (range > range_ptr->last_time_access)
range_ptr->last_time_access = range;
- if (result_second_value < range_ptr->min)
- range_ptr->min = result_second_value;
+ if (result_second_value < range_ptr->rrt_min)
+ range_ptr->rrt_min = result_second_value;
- if (result_second_value > range_ptr->max)
- range_ptr->max = result_second_value;
+ if (result_second_value > range_ptr->rrt_id)
+ range_ptr->rrt_max = result_second_value;
pthread_mutex_unlock(&report_ptr->report_template_mutex);
}
{
struct lipe_path_entry *lpe;
uint64_t allocate_file_size = 0;
- uint64_t alligned_size = 0; /* relative to block size */
- uint16_t block_size = 512;
const char *file_name;
- allocate_file_size = loa_all->loa_blocks * block_size;
- alligned_size = loa_all->loa_size + block_size - 1;
+ /* loa_all->loa_blocks is taken from the inode and reflects the .
+ * number of 512B blocks. Since in the blocks_from_inode()
+ * function we get the value from inode->i_blocks which is equal
+ * to the number of blocks with a size of 512B */
+ allocate_file_size = loa_all->loa_blocks * 512;
+ /* It is likely that loa_all->loa_size is also aligned to a
+ * block of 512 bytes somewhere in EXT2_I_SIZE(inode)...
+ * For this reason, we do not align the size. */
+
+ if (allocate_file_size == 0 && loa_all->loa_size == 0)
+ /* Skip this, TODO: reports_with_stats->error_counter++ */
+ return 0;
/* In most cases loa_all->loa_blocks is not available on MDT. */
if (!reports_with_stats->device_is_mdt) {
/* Get equal overhead (Files whose size is equal
* than capacity used. */
- if (allocate_file_size == alligned_size)
- ls3_stats_update_range(LS3_STATS_EQUAL_OVERHEAD,
+ if (allocate_file_size == loa_all->loa_size)
+ ls3_stats_update_range(LS3_STATS_TYPE_EQUAL_OVERHEAD,
loa_all->loa_size,
LS3_STATS_EMPTY_VALUE);
/* Get positive overhead (Files whose capacity used is
* larger than to its size. */
- else if (allocate_file_size - alligned_size > 0)
- ls3_stats_update_range(LS3_STATS_POSITIVE_OVERHEAD,
+ else if (allocate_file_size > loa_all->loa_size)
+ ls3_stats_update_range(LS3_STATS_TYPE_POSITIVE_OVERHEAD,
allocate_file_size -
loa_all->loa_size,
LS3_STATS_EMPTY_VALUE);
/* Get negative overhead (Files whose size is larger than
* capacity used. Includes directories, symlinks and
* regular files). */
- else if (alligned_size - allocate_file_size > 0)
- ls3_stats_update_range(LS3_STATS_NEGATIVE_OVERHEAD,
+ else
+ ls3_stats_update_range(LS3_STATS_TYPE_NEGATIVE_OVERHEAD,
loa_all->loa_size -
allocate_file_size,
LS3_STATS_EMPTY_VALUE);
* and special files) */
lipe_list_for_each_entry(lpe, &loa_all->loa_paths, lpe_linkage) {
file_name = ls3_stats_get_filename_from_path(lpe->lpe_path);
- ls3_stats_update_range(LS3_STATS_FILENAME_LENGTH,
+ ls3_stats_update_range(LS3_STATS_TYPE_FILENAME_LENGTH,
(int16_t)strlen(file_name),
LS3_STATS_EMPTY_VALUE);
}
if (!(loa_all->loa_mode & S_IFREG))
return 0;
- ls3_stats_update_range(LS3_STATS_FILES_SIZE, loa_all->loa_size,
+ ls3_stats_update_range(LS3_STATS_TYPE_FILES_SIZE, loa_all->loa_size,
LS3_STATS_EMPTY_VALUE);
- ls3_stats_update_range(LS3_STATS_TIME_SINCE_LAST_MOD_RF,
+ ls3_stats_update_range(LS3_STATS_TYPE_TIME_SINCE_LAST_MOD_RF,
loa_all->loa_mtime, loa_all->loa_size);
- ls3_stats_update_range(LS3_STATS_TIME_SINCE_LAST_MD_MOD_RF,
+ ls3_stats_update_range(LS3_STATS_TYPE_TIME_SINCE_LAST_MD_MOD_RF,
loa_all->loa_ctime, loa_all->loa_size);
- ls3_stats_update_range(LS3_STATS_TIME_SINCE_LAST_CREATION_RF,
+ ls3_stats_update_range(LS3_STATS_TYPE_TIME_SINCE_LAST_CREATION_RF,
loa_all->loa_crtime, loa_all->loa_size);
- ls3_stats_update_range(LS3_STATS_TIME_SINCE_LAST_ACCESS_RF,
+ ls3_stats_update_range(LS3_STATS_TYPE_TIME_SINCE_LAST_ACCESS_RF,
loa_all->loa_atime, loa_all->loa_size);
- ls3_stats_update_range_with_id(LS3_STATS_STORAGE_SET_SIZE_BY_USER,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_USER,
loa_all->loa_uid,
loa_all->loa_size);
- ls3_stats_update_range_with_id(LS3_STATS_STORAGE_SET_SIZE_BY_GROUP,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_GROUP,
loa_all->loa_gid,
loa_all->loa_size);
- ls3_stats_update_range_with_id(LS3_STATS_STORAGE_SET_SIZE_BY_PROJID,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_STORAGE_SET_SIZE_BY_PROJID,
loa_all->loa_projid,
loa_all->loa_size);
ls3_stats_update_user_report_range(LS3_STATS_USERS_REPORTS_MOD_RF,
if (rc < 0)
return -1;
- ls3_stats_update_range(LS3_STATS_STRIPE_COUNT, stripe_count,
+ ls3_stats_update_range(LS3_STATS_TYPE_STRIPE_COUNT, stripe_count,
LS3_STATS_EMPTY_VALUE);
- ls3_stats_update_range_with_id(LS3_STATS_MIRROR_COUNT,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_MIRROR_COUNT,
mirror_count, loa_all->loa_size);
- ls3_stats_update_range_with_id(LS3_STATS_STRIPE_SIZE,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_STRIPE_SIZE,
stripe_size, loa_all->loa_size);
/* TODO: Get info about compression (lvl/type/chunk_log_bits)
ptr_filter_fid = loa_all->loa_filter_fid;
ptr_ost_layout = ptr_filter_fid.ff_layout;
- ls3_stats_update_range(LS3_STATS_STRIPE_COUNT,
+ ls3_stats_update_range(LS3_STATS_TYPE_STRIPE_COUNT,
ptr_ost_layout.ol_stripe_count,
LS3_STATS_EMPTY_VALUE);
- ls3_stats_update_range_with_id(LS3_STATS_STRIPE_SIZE,
+ ls3_stats_update_range_with_id(LS3_STATS_TYPE_STRIPE_SIZE,
ptr_ost_layout.ol_stripe_size,
loa_all->loa_size);
- ls3_stats_update_range(LS3_STATS_CAPACITY_USED,
+ ls3_stats_update_range(LS3_STATS_TYPE_CAPACITY_USED,
allocate_file_size,
LS3_STATS_EMPTY_VALUE);
}
int i;
reports_with_stats = xcalloc(1, sizeof(struct fstats_report));
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
struct report_template *report_ptr =
ls3_stats_get_new_report_ptr();
(struct ls3_stats_user_report_template**)xcalloc(
reports_with_stats->max_count_users_in_report,
sizeof(struct ls3_stats_user_report_template*));
- reports_with_stats->last_user_idx_in_array = 0;
-
- reports_with_stats->device_size = 0;
+ reports_with_stats->last_user_idx_in_array = 0;
reports_with_stats->start_time = time(NULL);
pthread_mutex_init(&reports_with_stats->user_rt_mutex, NULL);
}
{
int i, j, k;
- for (i = 0; i < LS3_STATS_TOTAL_COUNT_REPORT; i++) {
+ for (i = 0; i < LS3_STATS_TYPE_TOTAL_COUNT_REPORT; i++) {
struct report_template *report_ptr =
reports_with_stats->reports[i];