diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index fab13456..896b7117 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -53,3 +53,13 @@ endif ifneq (,$(shell grep 'posix_acl_valid.*user_ns,' include/linux/posix_acl.h)) ccflags-y += -DKC_POSIX_ACL_VALID_USER_NS endif + +# +# v5.3-12296-g6d2052d188d9 +# +# The RBCOMPUTE function is now passed an extra flag, and should return a bool +# to indicate whether the propagated callback should stop or not. +# +ifneq (,$(shell grep 'static inline bool RBNAME.*_compute_max' include/linux/rbtree_augmented.h)) +ccflags-y += -DKC_RB_TREE_AUGMENTED_COMPUTE_MAX +endif diff --git a/kmod/src/tseq.c b/kmod/src/tseq.c index 781d00f3..b4b07f34 100644 --- a/kmod/src/tseq.c +++ b/kmod/src/tseq.c @@ -46,6 +46,23 @@ static struct scoutfs_tseq_entry *tseq_rb_next(struct scoutfs_tseq_entry *ent) return rb_entry(node, struct scoutfs_tseq_entry, node); } +#ifdef KC_RB_TREE_AUGMENTED_COMPUTE_MAX +static bool tseq_compute_total(struct scoutfs_tseq_entry *ent, bool exit) +{ + loff_t total = 1 + tseq_node_total(ent->node.rb_left) + + tseq_node_total(ent->node.rb_right); + + if (exit && ent->total == total) + return true; + + ent->total = total; + return false; +} + +RB_DECLARE_CALLBACKS(static, tseq_rb_callbacks, struct scoutfs_tseq_entry, + node, total, tseq_compute_total); +#else + static loff_t tseq_compute_total(struct scoutfs_tseq_entry *ent) { return 1 + tseq_node_total(ent->node.rb_left) + @@ -53,7 +70,8 @@ static loff_t tseq_compute_total(struct scoutfs_tseq_entry *ent) } RB_DECLARE_CALLBACKS(static, tseq_rb_callbacks, struct scoutfs_tseq_entry, - node, loff_t, total, tseq_compute_total) + node, loff_t, total, tseq_compute_total); +#endif void scoutfs_tseq_tree_init(struct scoutfs_tseq_tree *tree, scoutfs_tseq_show_t show)