[0/3] readmirror feature
mbox series

Message ID 20190425115946.2550-1-anand.jain@oracle.com
Headers show
Series
  • readmirror feature
Related show

Message

Anand Jain April 25, 2019, 11:59 a.m. UTC
These patches are tested to be working fine.

Function call chain  __btrfs_map_block()->find_live_mirror() uses
thread pid to determine the %mirror_num when the mirror_num=0.

This patch introduces a framework so that we can add policies to determine
the %mirror_num. And adds the devid as the readmirror policy.

The property is stored as an extented attributes of root inode
(BTRFS_FS_TREE_OBJECTID).
User provided devid list is validated against the fs_devices::dev_list.

 For example:
   Usage:
     btrfs property set <mnt> readmirror devid<n>[,<m>...]
     btrfs property set <mnt> readmirror ""

   mkfs.btrfs -fq -draid1 -mraid1 /dev/sd[b-d] && mount /dev/sdb /btrfs
   btrfs prop set /btrfs readmirror devid1,2
   btrfs prop get /btrfs readmirror
    readmirror=devid1,2
   getfattr -n btrfs.readmirror --absolute-names /btrfs
    btrfs.readmirror="devid1,2"
   btrfs prop set /btrfs readmirror ""
   getfattr -n btrfs.readmirror --absolute-names /btrfs
    /btrfs: btrfs.readmirror: No such attribute
   btrfs prop get /btrfs readmirror

RFC->v1:
  Drops pid as one of the readmirror policy choices and as usual remains
  as default. And when the devid is reset the readmirror policy falls back
  to pid.
  Drops the mount -o readmirror idea, it can be added at a later point of
  time.
  Property now accepts more than 1 devid as readmirror device. As shown
  in the example above.

Anand Jain (3):
  btrfs: add inode pointer to prop_handler::validate()
  btrfs: add readmirror property framework
  btrfs: add readmirror devid property

 fs/btrfs/props.c   | 120 +++++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/props.h   |   4 +-
 fs/btrfs/volumes.c |  25 +++++++++-
 fs/btrfs/volumes.h |   8 +++
 fs/btrfs/xattr.c   |   2 +-
 5 files changed, 150 insertions(+), 9 deletions(-)

Anand Jain (2):
  btrfs-progs: add helper to create xattr name
  btrfs-progs: add readmirror policy

 props.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 68 insertions(+), 7 deletions(-)

Comments

Steven Davies May 11, 2019, 3:24 p.m. UTC | #1
Tested-by: Steven Davies <btrfs-list@steev.me.uk>

Series (inc. btrfs-progs changes) tested working as expected against 
current btrfs-devel and btrfs-progs/devel.

Am I correct in thinking that if more than one devid is assigned as a 
readmirror, the lowest available devid will be preferred?

Also I think it would be nice to be able to set this property at mkfs time.

I'd love to see this feature make it upstream.
Anand Jain May 28, 2019, 1:56 p.m. UTC | #2
> On 11 May 2019, at 11:24 PM, Steven Davies <btrfs-list@steev.me.uk> wrote:
> 
> Tested-by: Steven Davies <btrfs-list@steev.me.uk>
> 
> Series (inc. btrfs-progs changes) tested working as expected against current btrfs-devel and btrfs-progs/devel.
> 
> Am I correct in thinking that if more than one devid is assigned as a readmirror, the lowest available devid will be preferred?
> 

As of now, it's just don’t do that kind of approach and it picks stripe 0 as read mirror device. And a disk is stripe 0 if it has largest disk free space as the time of chunk allocation. So it's kind of hard to predict which disk gets picked.

I have plans to write a patch to maintain the consistent allocation order.

> Also I think it would be nice to be able to set this property at mkfs time.
> 

Yeah. It certainly makes sense in case of mixed device types such as ssd and hdd or hdd/ssd and iscsi.

Thanks, Anand

> I'd love to see this feature make it upstream.
> 
> -- 
> Steven Davies
> 
> On 25/04/2019 12:59, Anand Jain wrote:
>> These patches are tested to be working fine.
>> Function call chain  __btrfs_map_block()->find_live_mirror() uses
>> thread pid to determine the %mirror_num when the mirror_num=0.
>> This patch introduces a framework so that we can add policies to determine
>> the %mirror_num. And adds the devid as the readmirror policy.
>> The property is stored as an extented attributes of root inode
>> (BTRFS_FS_TREE_OBJECTID).
>> User provided devid list is validated against the fs_devices::dev_list.
>> For example:
>>   Usage:
>>     btrfs property set <mnt> readmirror devid<n>[,<m>...]
>>     btrfs property set <mnt> readmirror ""
>>   mkfs.btrfs -fq -draid1 -mraid1 /dev/sd[b-d] && mount /dev/sdb /btrfs
>>   btrfs prop set /btrfs readmirror devid1,2
>>   btrfs prop get /btrfs readmirror
>>    readmirror=devid1,2
>>   getfattr -n btrfs.readmirror --absolute-names /btrfs
>>    btrfs.readmirror="devid1,2"
>>   btrfs prop set /btrfs readmirror ""
>>   getfattr -n btrfs.readmirror --absolute-names /btrfs
>>    /btrfs: btrfs.readmirror: No such attribute
>>   btrfs prop get /btrfs readmirror
>> RFC->v1:
>>  Drops pid as one of the readmirror policy choices and as usual remains
>>  as default. And when the devid is reset the readmirror policy falls back
>>  to pid.
>>  Drops the mount -o readmirror idea, it can be added at a later point of
>>  time.
>>  Property now accepts more than 1 devid as readmirror device. As shown
>>  in the example above.
>> Anand Jain (3):
>>  btrfs: add inode pointer to prop_handler::validate()
>>  btrfs: add readmirror property framework
>>  btrfs: add readmirror devid property
>> fs/btrfs/props.c   | 120 +++++++++++++++++++++++++++++++++++++++++++--
>> fs/btrfs/props.h   |   4 +-
>> fs/btrfs/volumes.c |  25 +++++++++-
>> fs/btrfs/volumes.h |   8 +++
>> fs/btrfs/xattr.c   |   2 +-
>> 5 files changed, 150 insertions(+), 9 deletions(-)
>> Anand Jain (2):
>>  btrfs-progs: add helper to create xattr name
>>  btrfs-progs: add readmirror policy
>> props.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
>> 1 file changed, 68 insertions(+), 7 deletions(-)