Thread (16 messages) 16 messages, 3 authors, 2022-07-15

Re: [PATCH 4/9] md: factor out the rdev overlaps check from rdev_size_store

From: Guoqing Jiang <hidden>
Date: 2022-07-15 09:01:54
Also in: linux-block


On 7/13/22 7:31 PM, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
This splits the code into nicely readable chunks and also avoids
the refcount inc/dec manipulations.

Signed-off-by: Christoph Hellwig<hch@lst.de>
---
  drivers/md/md.c | 84 +++++++++++++++++++++++--------------------------
  1 file changed, 39 insertions(+), 45 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3127dcb8102ce..5346135ab51c8 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3344,14 +3344,33 @@ rdev_size_show(struct md_rdev *rdev, char *page)
  	return sprintf(page, "%llu\n", (unsigned long long)rdev->sectors / 2);
  }
  
-static int overlaps(sector_t s1, sector_t l1, sector_t s2, sector_t l2)
+static int md_rdevs_overlap(struct md_rdev *a, struct md_rdev *b)
  {
  	/* check if two start/length pairs overlap */
-	if (s1+l1 <= s2)
-		return 0;
-	if (s2+l2 <= s1)
-		return 0;
-	return 1;
+	if (a->data_offset + a->sectors <= b->data_offset)
+		return false;
+	if (b->data_offset + b->sectors <= a->data_offset)
+		return false;
+	return true;
+}
Given it returns true or false, better to change the return type to bool.
+
+static bool md_rdev_overlaps(struct md_rdev *rdev)
+{
The two names (md_rdevs_overlap/md_rdev_overlaps) are quite similar ...

Thanks,
Guoqing
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help