#define LS3_PRINT_ABSOLUTE_PATH "print-absolute-path"
#define LS3_PRINT_RELATIVE_PATH "print-relative-path"
#define LS3_COLLECT_STATS "collect-fsize-stats"
+#define LS3_SHOW_COUNTERS "show-counters"
#define LS3_GETOPT_DEVICE_PATH "lipe-getopt-device-path"
#define LS3_GETOPT_CLIENT_MOUNT_PATH "lipe-getopt-client-mount-path"
bool ls3_debug;
bool save_fsize_stats;
+bool show_counters;
bool ls3_warn_get_attr;
const char *ls3_progname_;
__thread int ls3_tid; /* gettid() thread id for debug messages. */
return SCM_UNSPECIFIED;
}
+static void ls3_counters_print(void)
+{
+ printf("scanned: %ju\n", ls3_scanned_inodes_counter);
+ printf("matched: %ju\n", ls3_matched_inodes_counter);
+}
+
+SCM_DEFINE(ls3_scm_show_counters, LS3_SHOW_COUNTERS, 0, 0, 0,
+ (), "increase match counter")
+{
+ if (!show_counters)
+ show_counters = true;
+
+ return SCM_UNSPECIFIED;
+}
+
SCM_DEFINE(ls3_scm_collect_fsize_stats, LS3_COLLECT_STATS, 0, 1, 0,
(SCM string), "collect file size info of current file")
{
LS3_OPT_PRINT_RELATIVE_PATH,
LS3_OPT_REQUIRED_ATTRS,
LS3_OPT_THREAD_COUNT,
+ LS3_OPT_SHOW_COUNTERS,
LS3_OPT_COLLECT_STATS,
LS3_OPT_HELP = 'h',
{ LS3_PRINT_FILE_FID, no_argument, NULL, LS3_OPT_PRINT_FILE_FID },
{ LS3_PRINT_SELF_FID, no_argument, NULL, LS3_OPT_PRINT_SELF_FID },
{ "print-json", optional_argument, NULL, LS3_OPT_PRINT_JSON },
+ { LS3_SHOW_COUNTERS, no_argument, NULL, LS3_OPT_SHOW_COUNTERS},
{ LS3_COLLECT_STATS, optional_argument, NULL, LS3_OPT_COLLECT_STATS},
{ "print-absolute-path", no_argument, NULL, LS3_OPT_PRINT_ABSOLUTE_PATH },
{ "print-relative-path", no_argument, NULL, LS3_OPT_PRINT_RELATIVE_PATH },
"print-self-fid",
"print-absolute-path",
"print-relative-path",
+ "show-counters",
"collect-fsize-stats",
NULL);
}
if (save_fsize_stats)
ls3_stats_printf();
+ if (show_counters)
+ ls3_counters_print();
+
ls3_stats_destroy();
LS3_DEBUG_D(exit_status);
exit(exit_status);
uintmax_t sc_read_attr_error_count[LS3_OBJECT_ATTR_BIT_MAX];
uintmax_t sc_read_attr_error_count_total;
uintmax_t sc_other_error_count;
+ uintmax_t sc_scanned_inodes_counter;
+ uintmax_t sc_matched_inodes_counter;
};
struct ls3_thread_info {
uintmax_t ti_other_error_count;
int ti_started;
int ti_should_stop; /* Use __ATOMIC_RELAXED. */
+ uintmax_t ti_scanned_inodes_counter;
+ uintmax_t ti_matched_inodes_counter;
};
const char LS3_CSTR_AUTO[] = "AUTO";
const char LS3_CSTR_NONE[] = "NONE";
+uintmax_t ls3_scanned_inodes_counter = 0;
+uintmax_t ls3_matched_inodes_counter = 0;
#ifndef EXT4_SNAPFILE_FL
# define EXT4_SNAPFILE_FL 0x01000000 /* Inode is a snapshot */
static void ls3_scan_inode(struct ls3_instance *li,
ext2_filsys fs,
ext2_ino_t ino,
- struct ext2_inode_large *inode)
+ struct ext2_inode_large *inode,
+ struct ls3_thread_info *ti)
{
struct lipe_object lo = {
.u.lo_ldiskfs.lol_fs = fs,
};
struct ls3_object_attrs loa;
int rc;
+ SCM matched;
lipe_object_attrs_init(&loa);
ls3_copy_inode_attrs(&loa, fs, ino, inode);
LS3_CURRENT.lc_object = &lo;
LS3_CURRENT.lc_attrs = &loa;
- scm_catch(SCM_BOOL_T, li->li_scm_policy_thunk, ls3_scm_policy_exception_handler);
+ matched = scm_catch(SCM_BOOL_T, li->li_scm_policy_thunk,
+ ls3_scm_policy_exception_handler);
+ if (!scm_is_bool(matched))
+ /* If we don't have a match we get false,
+ * but if we do have a match we don't get a bool */
+ ti->ti_matched_inodes_counter++;
LS3_CURRENT.lc_object = NULL;
LS3_CURRENT.lc_attrs = NULL;
continue;
}
- ls3_scan_inode(li, fs, ino, inode);
+ ls3_scan_inode(li, fs, ino, inode, ti);
+ ti->ti_scanned_inodes_counter++;
}
rc = 0;
ti->ti_instance = li;
ti->ti_scan_control = sc;
ti->ti_thread_index = i;
+ ti->ti_scanned_inodes_counter = 0;
+ ti->ti_matched_inodes_counter = 0;
rc = pthread_create(&ti->ti_thread_id, pattr, &ls3_scan_thread_start, ti);
if (rc != 0) {
sc->sc_read_attr_error_count_total +=
ti->ti_read_attr_error_count[j];
}
-
+ sc->sc_scanned_inodes_counter += ti->ti_scanned_inodes_counter;
+ sc->sc_matched_inodes_counter += ti->ti_matched_inodes_counter;
sc->sc_other_error_count += ti->ti_other_error_count;
}
unsigned long group_desc_per_batch;
struct ls3_scan_control sc = {
.sc_thread_count = 0,
+ .sc_scanned_inodes_counter = 0,
+ .sc_matched_inodes_counter = 0,
.sc_break_rc = INTMAX_MIN,
.sc_group_desc_count = fs->group_desc_count,
};
LS3_WARNING("device '%s': other error count %"PRIuMAX"\n",
li->li_device_path, sc.sc_other_error_count);
+ ls3_scanned_inodes_counter = sc.sc_scanned_inodes_counter;
+ ls3_matched_inodes_counter = sc.sc_matched_inodes_counter;
+
/* If (lipe-scan-break rc) was called then return rc
* regardless of other errors. */
if (sc.sc_break_rc != INTMAX_MIN)