[PATCH 25/52] Introduce interval tree basic data structures

Vivek Goyal
2018-12-10T17:12:51Z

We want to use interval tree to keep track of per inode dax mappings.
Introduce basic data structures.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/fuse/fuse_i.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index fb49ca9d05ac..a24f31156b47 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -97,11 +97,22 @@ struct fuse_forget_link {
struct fuse_forget_link *next;
};

+#define START(node) ((node)->start)
+#define LAST(node) ((node)->end)
+
/** Translation information for file offsets to DAX window offsets */
struct fuse_dax_mapping {
/* Will connect in fc->free_ranges to keep track of free memory */
struct list_head list;

+ /* For interval tree in file/inode */
+ struct rb_node rb;
+ /** Start Position in file */
+ __u64 start;
+ /** End Position in file */
+ __u64 end;
+ __u64 __subtree_last;
+
/** Position in DAX window */
u64 window_offset;

@@ -191,6 +202,10 @@ struct fuse_inode {

/** Lock for serializing lookup and readdir for back compatibility*/
struct mutex mutex;
+
+ /** Sorted rb tree of struct fuse_dax_mapping elements */
+ struct rb_root_cached dmap_tree;
+ unsigned long nr_dmaps;
};

/** FUSE inode state bits */
--
2.13.6