Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3323341pxb; Fri, 12 Feb 2021 15:40:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUFmAYxsmVJVL8hONMjgGLfGP367WYy5vXIzzGlrRNAW9gvIpvE3P6rdHlWQCG0CpixIZH X-Received: by 2002:a17:906:4a81:: with SMTP id x1mr3854893eju.80.1613173208867; Fri, 12 Feb 2021 15:40:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613173208; cv=none; d=google.com; s=arc-20160816; b=MnVZdV2asUL3fAASV8jjvq4mxfp3ObZBI3l4psd8iwU0OsOUmiDR31XStfMDUZmZFj 0zExw9+UL4Ge9VcdzrOxhR1tdEi1EUu3DZ86fAaZM5ILDJQ9jj95LDc46Wu21572nImw 2w+5ijnTsvU+yLxQQr8yhJ8kLaPsUwmxwSqnM5NMhj3tH+Uyp3oaonNVAzkTdJdFHscw pebIACETTu3KVKuWoaI/2/lksYKlhXfYvxOXoGRFVpHpvIAVB+NBoUBl/cMxmzJnNOYb VqK7pl/R7CK4nowsLL/cLxNHCE63gOmgRO4K71tq79y2naTSLc3lf/rXx3erSIjKBlYl qdkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xMcwZlaKxG7y/7L9yIukMwL8wDupAFROVF0HEwjsSbU=; b=urT1Y0gRenrdnekdEz5BlRze5GTAU97wXpY2rDLd5wzB8n5Vaffn3Ie28yONKIef+s Z+BTOawvrgutAQ9V0heR54QgWsGMhc0BcHdRESo51WeoonkJaZOKHawONLy11noaAg6U sfhLAUwINDACiyaVh3A2iFPM/kZ2NVN6SRQiwQNR6bcz7JzNruE+ynOw1OJ8Tgo8MlhV W+Klir6b7WZVHa2o6DSOfPGMQ3dCruHh+PG4Ewlwv1P+xPiXCDHsz4P3E06Y4ueYgVQm oZM1h05X1HDQLH7a7JurmD2bQ3rSTCN5epMroMhkWE5kCpY9PmDZxTdsJq3qEcR4jDJQ Qobw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=dqWjAImN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb25si1776633ejb.244.2021.02.12.15.39.43; Fri, 12 Feb 2021 15:40:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=dqWjAImN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhBLXhM (ORCPT + 99 others); Fri, 12 Feb 2021 18:37:12 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:18838 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLXhL (ORCPT ); Fri, 12 Feb 2021 18:37:11 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4DcqdS2Jp2z2d; Sat, 13 Feb 2021 00:36:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1613172988; bh=1LIPV2cA41mWUhh9p8sX1mkd4boZDMkZYUfcvKjKciA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dqWjAImNL+CwZRFOURoGv1b76qCHUxxwGVLBEtzkHKNvzVDjcldzajoLDOSofVGtr q9xMG7KBw5zL3eerdDnvmcbahqcqeAeeDzinN0Xsmq13nwHoFou4xxSSWkGWppkrQ4 iPF6ypjXlV02pEY1yzrjGa0FzAgUA6syuACcE35KRIIaaj8sZgwBZgtt6O2XIwtXmf mZur81wnmmBfKrLMEyuF1UAUhm59rUhEZsV2bwdVot64WY6DR7VCZs2Jzqq03OB0Ju vMjkxgfKSLTeq3AZS1iPVDSKFkbj1qCosCUwPM9YbD22NjmB8aAmdOCPGehU0yEoDT ptqx+p6svNk2Q== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Sat, 13 Feb 2021 00:36:02 +0100 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Michal Rostecki Cc: Chris Mason , Josef Bacik , David Sterba , "open list:BTRFS FILE SYSTEM" , open list , Michal Rostecki Subject: Re: [PATCH RFC 4/6] btrfs: Check if the filesystem is has mixed type of devices Message-ID: <20210212233602.GA30441@qmqm.qmqm.pl> References: <20210209203041.21493-1-mrostecki@suse.de> <20210209203041.21493-5-mrostecki@suse.de> <20210210040805.GB12086@qmqm.qmqm.pl> <20210212182641.GB20817@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210212182641.GB20817@wotan.suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 06:26:41PM +0000, Michal Rostecki wrote: > 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 > > > > > > 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. [...] > Inverting the order of those `if` checks would break the other > permuitations which start with rotational disks. But not if you would add: if (adding first device) fs_devices->rotating = rotating; before the checks. But them, there is a simpler way: count how many rotating vs non-rotating devices there are while adding them. Like: rotating ? ++n_rotating : ++n_fixed; And then on remove you'd have it covered. Best Regards Micha? Miros?aw