diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-02-17 18:11:24 +0100 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-10-14 16:47:37 +0200 |
commit | d0e22a260c5142171c730436664febb045b9f0f0 (patch) | |
tree | aa8180451e2d741aad17760542fb6866e2c00e95 /drivers/block/drbd/drbd_interval.c | |
parent | fcefa62e4c26e70c70b9e8252a4bc9b9031a4182 (diff) | |
download | linux-d0e22a260c5142171c730436664febb045b9f0f0.tar.gz linux-d0e22a260c5142171c730436664febb045b9f0f0.tar.xz |
drbd: Iterate over all overlapping intervals in a tree
Add a macro and helper function for doing that.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_interval.c')
-rw-r--r-- | drivers/block/drbd/drbd_interval.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c index 14dbe2dd2d33..0e53f102e68a 100644 --- a/drivers/block/drbd/drbd_interval.c +++ b/drivers/block/drbd/drbd_interval.c @@ -157,3 +157,21 @@ drbd_find_overlap(struct rb_root *root, sector_t sector, unsigned int size) } return overlap; } + +struct drbd_interval * +drbd_next_overlap(struct drbd_interval *i, sector_t sector, unsigned int size) +{ + sector_t end = sector + (size >> 9); + struct rb_node *node; + + for (;;) { + node = rb_next(&i->rb); + if (!node) + return NULL; + i = rb_entry(node, struct drbd_interval, rb); + if (i->sector >= end) + return NULL; + if (sector < i->sector + (i->size >> 9)) + return i; + } +} |