+int cds_ja_range_validate(struct cds_ja *ja)
+{
+ uint64_t iter_key, start, end, last_end = UINT64_MAX;
+ struct cds_ja_node *ja_node, *last_node;
+ int ret = 0;
+
+ cds_lfht_rcu_flavor(ja->ht)->read_lock();
+ cds_ja_for_each_key_rcu(ja, iter_key, ja_node) {
+ struct cds_ja_range *range;
+ struct cds_ja_node *first_node;
+
+ first_node = ja_node;
+ cds_ja_for_each_duplicate_rcu(ja_node)
+ last_node = ja_node;
+ if (last_node != first_node) {
+ struct cds_ja_range *first_range = caa_container_of(first_node,
+ struct cds_ja_range, ja_node);
+ struct cds_ja_range *last_range = caa_container_of(last_node,
+ struct cds_ja_range, ja_node);
+ fprintf(stderr, "found duplicate node: first %" PRIu64 "-%" PRIu64 " last %" PRIu64 "-%" PRIu64 "\n",
+ first_range->start, first_range->end, last_range->start, last_range->end);
+ ret |= -1;
+ }
+ range = caa_container_of(last_node,
+ struct cds_ja_range, ja_node);
+ start = range->start;
+ end = range->end;
+ if (last_end != UINT64_MAX) {
+ if (start != last_end + 1) {
+ fprintf(stderr, "ja range discrepancy: last end: %" PRIu64 ", start: %" PRIu64 "\n",
+ last_end, start);
+ ret |= -1;
+ }
+ }
+ last_end = end;
+ }
+ if (last_end != UINT64_MAX - 1) {
+ fprintf(stderr, "ja range error: end of last range is: %" PRIu64 "\n",
+ last_end);
+ ret |= 1;
+ }
+ cds_lfht_rcu_flavor(ja->ht)->read_unlock();
+ return ret;
+}
+