linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: rotate mirror selection
@ 2011-10-05 10:17 David Sterba
  0 siblings, 0 replies; only message in thread
From: David Sterba @ 2011-10-05 10:17 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Single process will always select the same mirror (raid1 and raid10),
selection si based on PID. Use a simple incremental counter on every
attempt. This is just a heuristic, we do not know which mirror device is
least loaded, but there is a good chance the distribution over mirrors
will improve.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/volumes.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e138af7..3f0cc12 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2893,6 +2893,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
 	int num_stripes;
 	int max_errors = 0;
 	struct btrfs_multi_bio *multi = NULL;
+	static unsigned int mirror_rotor = 0;
 
 	if (multi_ret && !(rw & (REQ_WRITE | REQ_DISCARD)))
 		stripes_allocated = 1;
@@ -3000,7 +3001,7 @@ again:
 		else {
 			stripe_index = find_live_mirror(map, 0,
 					    map->num_stripes,
-					    current->pid % map->num_stripes);
+					    mirror_rotor++ % map->num_stripes);
 		}
 
 	} else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
@@ -3026,7 +3027,7 @@ again:
 		else {
 			stripe_index = find_live_mirror(map, stripe_index,
 					      map->sub_stripes, stripe_index +
-					      current->pid % map->sub_stripes);
+					      mirror_rotor++ % map->sub_stripes);
 		}
 	} else {
 		/*
-- 
1.7.6


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-05 10:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 10:17 [PATCH] btrfs: rotate mirror selection David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).