lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  9 Feb 2021 21:30:37 +0100
From:   Michal Rostecki <mrostecki@...e.de>
To:     Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
        David Sterba <dsterba@...e.com>,
        linux-btrfs@...r.kernel.org (open list:BTRFS FILE SYSTEM),
        linux-kernel@...r.kernel.org (open list)
Cc:     Michal Rostecki <mrostecki@...e.com>
Subject: [PATCH RFC 3/6] btrfs: Add stripe_physical function

From: Michal Rostecki <mrostecki@...e.com>

Move the calculation of the physical address for a stripe to the new
function - stripe_physical(). It can be used by raid1 read policies to
calculate the offset and select mirrors based on I/O locality.

Signed-off-by: Michal Rostecki <mrostecki@...e.com>
---
 fs/btrfs/volumes.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 292175206873..1ac364a2f105 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5498,6 +5498,23 @@ int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
 	return ret;
 }
 
+/*
+ * Calculates the physical location for the given stripe and I/O geometry.
+ *
+ * @map:           mapping containing the logical extent
+ * @stripe_index:  index of the stripe to make a calculation for
+ * @stripe_offset: offset of the block in its stripe
+ * @stripe_nr:     index of the stripe whete the block falls in
+ *
+ * Returns the physical location.
+ */
+static u64 stripe_physical(struct map_lookup *map, u32 stripe_index,
+			   u64 stripe_offset, u64 stripe_nr)
+{
+	return map->stripes[stripe_index].physical + stripe_offset +
+		stripe_nr * map->stripe_len;
+}
+
 static int find_live_mirror(struct btrfs_fs_info *fs_info,
 			    struct map_lookup *map, int first,
 			    int dev_replace_is_ongoing)
@@ -6216,8 +6233,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
 	}
 
 	for (i = 0; i < num_stripes; i++) {
-		bbio->stripes[i].physical = map->stripes[stripe_index].physical +
-			stripe_offset + stripe_nr * map->stripe_len;
+		bbio->stripes[i].physical = stripe_physical(map, stripe_index,
+							    stripe_offset,
+							    stripe_nr);
 		bbio->stripes[i].dev = map->stripes[stripe_index].dev;
 		stripe_index++;
 	}
-- 
2.30.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ