[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210212182641.GB20817@wotan.suse.de>
Date: Fri, 12 Feb 2021 18:26:41 +0000
From: Michal Rostecki <mrostecki@...e.de>
To: Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>,
"open list:BTRFS FILE SYSTEM" <linux-btrfs@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
Michal Rostecki <mrostecki@...e.com>
Subject: Re: [PATCH RFC 4/6] btrfs: Check if the filesystem is has mixed type
of devices
On Wed, Feb 10, 2021 at 05:08:05AM +0100, Michał Mirosław wrote:
> On Tue, Feb 09, 2021 at 09:30:38PM +0100, Michal Rostecki wrote:
> > From: Michal Rostecki <mrostecki@...e.com>
> >
> > Add the btrfs_check_mixed() function which checks if the filesystem has
> > the mixed type of devices (non-rotational and rotational). This
> > information is going to be used in roundrobin raid1 read policy.a
> [...]
> > @@ -669,8 +699,12 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
> > }
> >
> > q = bdev_get_queue(bdev);
> > - if (!blk_queue_nonrot(q))
> > + rotating = !blk_queue_nonrot(q);
> > + device->rotating = rotating;
> > + if (rotating)
> > fs_devices->rotating = true;
> > + if (!fs_devices->mixed)
> > + fs_devices->mixed = btrfs_check_mixed(fs_devices, rotating);
> [...]
>
> Since this is adding to a set, a faster way is:
>
> if (fs_devices->rotating != rotating)
> fs_devices->mixed = true;
>
> The scan might be necessary on device removal, though.
>
Actually, that's not going to work in case of appenging a rotational
device when all previous devices are non-rotational.
if (rotating)
fs_devices->rotating = true;
if (fs_devices->rotating != rotating)
fs_devices->mixed = true;
If all devices are non-rotational, we start with the following
attributes:
fs_devices->rotating: false
fs_devices->mixed: false
Then, while appending a rotational disk, we have:
rotating = true;
if (rotating) // if (true)
fs_devices->rotating = true; // overriding with `true`
if (fs_devices->rotating != rotating) // if (true != true), which is false
fs_devices->mixed = true; // NOT EXECUTED
So we end up fs_devices->mixed being `false`, despite having a mixed
array.
Inverting the order of those `if` checks would break the other
permuitations which start with rotational disks.
Therefore, to cover all cases, I think we need a full check, always.
Regards,
Michal
Powered by blists - more mailing lists