#define MINCORE_VEC_SIZE (READAHEAD_FILE_SIZE_MAX/PAGE_SIZE)
+/* fixme:
+ *
+ * - detect ssd/lvm/... on btrfs
+ * - read ahead directories
+ */
+
static int btrfs_defrag(int fd) {
struct btrfs_ioctl_vol_args data;
ul = fd_first_block(m->fd);
if ((k = hashmap_put(files, p, ULONG_TO_PTR(ul))) < 0) {
-
- if (k != -EEXIST)
- log_warning("set_put() failed: %s", strerror(-k));
-
+ log_warning("set_put() failed: %s", strerror(-k));
free(p);
}
}
if (on_ssd || on_btrfs) {
/* On SSD or on btrfs, just write things out in the
- * order the files where accessed. */
+ * order the files were accessed. */
HASHMAP_FOREACH_KEY(q, p, files, i)
pack_file(pack, p, on_btrfs);
log_parse_environment();
log_open();
+ if (!enough_ram()) {
+ log_info("Disabling readahead collector due to low memory.");
+ return 0;
+ }
+
if (collect(argc >= 2 ? argv[1] : "/") < 0)
return 1;
#include <libudev.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/sysinfo.h>
#include "log.h"
#include "readahead-common.h"
return b;
}
+
+bool enough_ram(void) {
+ struct sysinfo si;
+
+ assert_se(sysinfo(&si) >= 0);
+
+ return si.totalram > 127 * 1024*1024; /* Enable readahead only
+ * with at least 128MB
+ * memory */
+}