summaryrefslogtreecommitdiffstats
path: root/database/engine/datafile.h
diff options
context:
space:
mode:
Diffstat (limited to 'database/engine/datafile.h')
-rw-r--r--database/engine/datafile.h76
1 files changed, 49 insertions, 27 deletions
diff --git a/database/engine/datafile.h b/database/engine/datafile.h
index 1cf256aff..274add91e 100644
--- a/database/engine/datafile.h
+++ b/database/engine/datafile.h
@@ -13,27 +13,25 @@ struct rrdengine_instance;
#define DATAFILE_PREFIX "datafile-"
#define DATAFILE_EXTENSION ".ndf"
-#define MAX_DATAFILE_SIZE (1073741824LU)
-#define MIN_DATAFILE_SIZE (4194304LU)
+#ifndef MAX_DATAFILE_SIZE
+#define MAX_DATAFILE_SIZE (512LU * 1024LU * 1024LU)
+#endif
+#if MIN_DATAFILE_SIZE > MAX_DATAFILE_SIZE
+#error MIN_DATAFILE_SIZE > MAX_DATAFILE_SIZE
+#endif
+
+#define MIN_DATAFILE_SIZE (4LU * 1024LU * 1024LU)
#define MAX_DATAFILES (65536) /* Supports up to 64TiB for now */
-#define TARGET_DATAFILES (20)
+#define TARGET_DATAFILES (50)
-#define DATAFILE_IDEAL_IO_SIZE (1048576U)
+typedef enum __attribute__ ((__packed__)) {
+ DATAFILE_ACQUIRE_OPEN_CACHE = 0,
+ DATAFILE_ACQUIRE_PAGE_DETAILS,
+ DATAFILE_ACQUIRE_RETENTION,
-struct extent_info {
- uint64_t offset;
- uint32_t size;
- uint8_t number_of_pages;
- struct rrdengine_datafile *datafile;
- struct extent_info *next;
- struct rrdeng_page_descr *pages[];
-};
-
-struct rrdengine_df_extents {
- /* the extent list is sorted based on disk offset */
- struct extent_info *first;
- struct extent_info *last;
-};
+ // terminator
+ DATAFILE_ACQUIRE_MAX,
+} DATAFILE_ACQUIRE_REASONS;
/* only one event loop is supported for now */
struct rrdengine_datafile {
@@ -41,26 +39,50 @@ struct rrdengine_datafile {
unsigned fileno;
uv_file file;
uint64_t pos;
+ uv_rwlock_t extent_rwlock;
struct rrdengine_instance *ctx;
- struct rrdengine_df_extents extents;
struct rrdengine_journalfile *journalfile;
+ struct rrdengine_datafile *prev;
struct rrdengine_datafile *next;
-};
-struct rrdengine_datafile_list {
- struct rrdengine_datafile *first; /* oldest */
- struct rrdengine_datafile *last; /* newest */
+ struct {
+ SPINLOCK spinlock;
+ bool populated;
+ } populate_mrg;
+
+ struct {
+ SPINLOCK spinlock;
+ size_t running;
+ size_t flushed_to_open_running;
+ } writers;
+
+ struct {
+ SPINLOCK spinlock;
+ unsigned lockers;
+ unsigned lockers_by_reason[DATAFILE_ACQUIRE_MAX];
+ bool available;
+ time_t time_to_evict;
+ } users;
+
+ struct {
+ SPINLOCK spinlock;
+ Pvoid_t pending_epdl_by_extent_offset_judyL;
+ } extent_queries;
};
-void df_extent_insert(struct extent_info *extent);
+void datafile_acquire_dup(struct rrdengine_datafile *df);
+bool datafile_acquire(struct rrdengine_datafile *df, DATAFILE_ACQUIRE_REASONS reason);
+void datafile_release(struct rrdengine_datafile *df, DATAFILE_ACQUIRE_REASONS reason);
+bool datafile_acquire_for_deletion(struct rrdengine_datafile *df);
+
void datafile_list_insert(struct rrdengine_instance *ctx, struct rrdengine_datafile *datafile);
-void datafile_list_delete(struct rrdengine_instance *ctx, struct rrdengine_datafile *datafile);
+void datafile_list_delete_unsafe(struct rrdengine_instance *ctx, struct rrdengine_datafile *datafile);
void generate_datafilepath(struct rrdengine_datafile *datafile, char *str, size_t maxlen);
int close_data_file(struct rrdengine_datafile *datafile);
int unlink_data_file(struct rrdengine_datafile *datafile);
-int destroy_data_file(struct rrdengine_datafile *datafile);
+int destroy_data_file_unsafe(struct rrdengine_datafile *datafile);
int create_data_file(struct rrdengine_datafile *datafile);
-int create_new_datafile_pair(struct rrdengine_instance *ctx, unsigned tier, unsigned fileno);
+int create_new_datafile_pair(struct rrdengine_instance *ctx);
int init_data_files(struct rrdengine_instance *ctx);
void finalize_data_files(struct rrdengine_instance *ctx);