From: Ira Weiny <ira.weiny@intel.com>
To: Dave Jiang <dave.jiang@intel.com>, Fan Ni <fan.ni@samsung.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Navneet Singh <navneet.singh@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org,
nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org,
Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH v7 01/27] range: Add range_overlaps()
Date: Thu, 07 Nov 2024 14:58:19 -0600 [thread overview]
Message-ID: <20241107-dcd-type2-upstream-v7-1-56a84e66bc36@intel.com> (raw)
In-Reply-To: <20241107-dcd-type2-upstream-v7-0-56a84e66bc36@intel.com>
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>
---
fs/btrfs/ordered-data.c | 10 +++++-----
include/linux/range.h | 8 ++++++++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 2104d60c216166d577ef81750c63167248f33b6a..744c3375ee6a88e0fc01ef7664e923a48cbe6dca 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -111,8 +111,8 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
return NULL;
}
-static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
- u64 len)
+static int btrfs_range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
+ u64 len)
{
if (file_offset + len <= entry->file_offset ||
entry->file_offset + entry->num_bytes <= file_offset)
@@ -985,7 +985,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
while (1) {
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
- if (range_overlaps(entry, file_offset, len))
+ if (btrfs_range_overlaps(entry, file_offset, len))
break;
if (entry->file_offset >= file_offset + len) {
@@ -1114,12 +1114,12 @@ struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range(
}
if (prev) {
entry = rb_entry(prev, struct btrfs_ordered_extent, rb_node);
- if (range_overlaps(entry, file_offset, len))
+ if (btrfs_range_overlaps(entry, file_offset, len))
goto out;
}
if (next) {
entry = rb_entry(next, struct btrfs_ordered_extent, rb_node);
- if (range_overlaps(entry, file_offset, len))
+ if (btrfs_range_overlaps(entry, file_offset, len))
goto out;
}
/* No ordered extent in the range */
diff --git a/include/linux/range.h b/include/linux/range.h
index 6ad0b73cb7adc0ee53451b8fed0a70772adc98fa..876cd5355158eff267a42991ba17fa35a1d31600 100644
--- a/include/linux/range.h
+++ b/include/linux/range.h
@@ -13,11 +13,19 @@ 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);
--
2.47.0
next prev parent reply other threads:[~2024-11-07 20:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 20:58 [PATCH v7 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Ira Weiny
2024-11-07 20:58 ` Ira Weiny [this message]
2024-11-07 20:58 ` [PATCH v7 02/27] ACPI/CDAT: Add CDAT/DSMAS shared and read only flag values Ira Weiny
2024-11-07 20:58 ` [PATCH v7 03/27] dax: Document struct dev_dax_range Ira Weiny
2024-11-07 20:58 ` [PATCH v7 04/27] cxl/pci: Delay event buffer allocation Ira Weiny
2024-11-07 20:58 ` [PATCH v7 05/27] cxl/hdm: Use guard() in cxl_dpa_set_mode() Ira Weiny
2024-11-07 20:58 ` [PATCH v7 06/27] cxl/region: Refactor common create region code Ira Weiny
2024-11-07 20:58 ` [PATCH v7 07/27] cxl/mbox: Flag support for Dynamic Capacity Devices (DCD) ira.weiny
2024-11-07 20:58 ` [PATCH v7 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
2024-11-07 20:58 ` [PATCH v7 09/27] cxl/core: Separate region mode from decoder mode ira.weiny
2024-11-07 20:58 ` [PATCH v7 10/27] cxl/region: Add dynamic capacity decoder and region modes ira.weiny
2024-11-07 20:58 ` [PATCH v7 11/27] cxl/hdm: Add dynamic capacity size support to endpoint decoders ira.weiny
2024-11-07 20:58 ` [PATCH v7 12/27] cxl/cdat: Gather DSMAS data for DCD regions Ira Weiny
2024-11-07 20:58 ` [PATCH v7 13/27] cxl/mem: Expose DCD partition capabilities in sysfs ira.weiny
2024-11-07 20:58 ` [PATCH v7 14/27] cxl/port: Add endpoint decoder DC mode support to sysfs ira.weiny
2024-11-07 20:58 ` [PATCH v7 15/27] cxl/region: Add sparse DAX region support ira.weiny
2024-11-07 20:58 ` [PATCH v7 16/27] cxl/events: Split event msgnum configuration from irq setup Ira Weiny
2024-11-07 20:58 ` [PATCH v7 17/27] cxl/pci: Factor out interrupt policy check Ira Weiny
2024-11-07 20:58 ` [PATCH v7 18/27] cxl/mem: Configure dynamic capacity interrupts ira.weiny
2024-11-07 20:58 ` [PATCH v7 19/27] cxl/core: Return endpoint decoder information from region search Ira Weiny
2024-11-07 20:58 ` [PATCH v7 20/27] cxl/extent: Process DCD events and realize region extents ira.weiny
2024-11-07 20:58 ` [PATCH v7 21/27] cxl/region/extent: Expose region extent information in sysfs ira.weiny
2024-11-07 20:58 ` [PATCH v7 22/27] dax/bus: Factor out dev dax resize logic Ira Weiny
2024-11-07 20:58 ` [PATCH v7 23/27] dax/region: Create resources on sparse DAX regions ira.weiny
2024-11-07 20:58 ` [PATCH v7 24/27] cxl/region: Read existing extents on region creation ira.weiny
2024-11-07 20:58 ` [PATCH v7 25/27] cxl/mem: Trace Dynamic capacity Event Record ira.weiny
2024-11-07 20:58 ` [PATCH v7 26/27] tools/testing/cxl: Make event logs dynamic Ira Weiny
2024-11-07 20:58 ` [PATCH v7 27/27] tools/testing/cxl: Add DC Regions to mock mem data Ira Weiny
2024-11-08 17:27 ` [PATCH v7 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241107-dcd-type2-upstream-v7-1-56a84e66bc36@intel.com \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=clm@fb.com \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=dsterba@suse.com \
--cc=fan.ni@samsung.com \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=navneet.singh@intel.com \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox