On 01/31/2018 04:06 PM, Nikolay Borisov wrote:

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1a462ab85c49..4759e988b0df 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1100,6 +1100,8 @@ struct btrfs_fs_info {
        spinlock_t ref_verify_lock;
        struct rb_root block_tree;
  #endif
+       /* Policy to balance read across mirrored devices */
+       int read_mirror_policy;

make that member enum btrfs_read_mirror_type

 yep. Will do.

::

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index a61715677b67..39ba59832f38 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5269,7 +5269,13 @@ static int find_live_mirror(struct btrfs_fs_info 
*fs_info,
        else
                num = map->num_stripes;
- optimal = first + current->pid % num;
+       switch(fs_info->read_mirror_policy) {
+       case BTRFS_READ_MIRROR_DEFAULT:
+       case BTRFS_READ_MIRROR_BY_PID:
+       default:
+               optimal = first + current->pid % num;
+               break;
+       }

Why not factor out this code in a separate function with descriptive
name and some documentation. It seems you have plans how to extend this
mechanism further so let's try and make it maintainable from the get-go.

  This is in fact restoring the original design, will add comments.
  In the long term we may have up couple of more choices (like LBA),
  will move it to a function.

Thanks, Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to