return 1;
}
+static bool sample_repeated_patterns(struct heuristic_ws *ws)
+{
+ const u32 half_of_sample = ws->sample_size / 2;
+ const u8 *data = ws->sample;
+
+ return memcmp(&data[0], &data[half_of_sample], half_of_sample) == 0;
+}
+
static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
struct heuristic_ws *ws)
{
heuristic_collect_sample(inode, start, end, ws);
+ if (sample_repeated_patterns(ws)) {
+ ret = 1;
+ goto out;
+ }
+
memset(ws->bucket, 0, sizeof(*ws->bucket)*BUCKET_SIZE);
for (i = 0; i < ws->sample_size; i++) {
ws->bucket[byte].count++;
}
+out:
__free_workspace(0, ws_list, true);
-
return ret;
}