mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-11-30 04:40:06 +00:00
Code to support CXL Dynamic Capacity devices will have extent ranges which need to be compared for intersection not a subset as is being checked in range_contains(). range_overlaps() is defined in btrfs with a different meaning from what is required in the standard range code. Dan Williams pointed this out in [1]. Adjust the btrfs call according to his suggestion there. Then add a generic range_overlaps(). Cc: Dan Williams <dan.j.williams@intel.com> Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <josef@toxicpanda.com> Cc: David Sterba <dsterba@suse.com> Cc: linux-btrfs@vger.kernel.org Link: https://lore.kernel.org/all/65949f79ef908_8dc68294f2@dwillia2-xfh.jf.intel.com.notmuch/ [1] Acked-by: David Sterba <dsterba@suse.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Link: https://patch.msgid.link/20241107-dcd-type2-upstream-v7-1-56a84e66bc36@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
43 lines
971 B
C
43 lines
971 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_RANGE_H
|
|
#define _LINUX_RANGE_H
|
|
#include <linux/types.h>
|
|
|
|
struct range {
|
|
u64 start;
|
|
u64 end;
|
|
};
|
|
|
|
static inline u64 range_len(const struct range *range)
|
|
{
|
|
return range->end - range->start + 1;
|
|
}
|
|
|
|
/* True if r1 completely contains r2 */
|
|
static inline bool range_contains(struct range *r1, struct range *r2)
|
|
{
|
|
return r1->start <= r2->start && r1->end >= r2->end;
|
|
}
|
|
|
|
/* True if any part of r1 overlaps r2 */
|
|
static inline bool range_overlaps(const struct range *r1,
|
|
const struct range *r2)
|
|
{
|
|
return r1->start <= r2->end && r1->end >= r2->start;
|
|
}
|
|
|
|
int add_range(struct range *range, int az, int nr_range,
|
|
u64 start, u64 end);
|
|
|
|
|
|
int add_range_with_merge(struct range *range, int az, int nr_range,
|
|
u64 start, u64 end);
|
|
|
|
void subtract_range(struct range *range, int az, u64 start, u64 end);
|
|
|
|
int clean_sort_range(struct range *range, int az);
|
|
|
|
void sort_range(struct range *range, int nr_range);
|
|
|
|
#endif
|