Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3154324pxb; Fri, 12 Feb 2021 10:29:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCSEf5vvWaJETK/7/etMqJiXz/eoJCdxWEVdJBVnB1SMA+CCCN/DcIQW8Q4vVol7llUidq X-Received: by 2002:a17:906:a898:: with SMTP id ha24mr4455182ejb.413.1613154554746; Fri, 12 Feb 2021 10:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613154554; cv=none; d=google.com; s=arc-20160816; b=aCu75uG+2NJvF4FfpGCJLFMXMLAogwiGYCimmI9BDZvBqnh7jBUdXy7xMOJT83KFSv 4eRd86f23WWk+0xe6aLMpA+yD7GQ/Fc5KmbjeINnpj/ivBD/Cfu1/rmsujjSFGer3dKl zDJGZ1Mp3r9pd1OSnDNIlc3xuByeE2eMVZPn3hkf+I36LVE2PlC4iyD/w0kTZL6Kfg+f ck95JjQ3RmP+SbNyIvTP3wYQPd6PUDGVcQcDVMd41GePJdbAkUROX+HWfG8tJA73m5Jo c9D0ssx2EMk2dfeJO+920+rx3LZI5XC2Q0bQ3kElDjgCf6KxtyDZmveIoAFiQ+tofOPQ 0LuA== 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; bh=1o+YyzSAOkFFw0dtm6KOd38Yne9oOxbF7HqiqV7hNPM=; b=sJi6b0lMmUwqDOJSk3D2+asjHZB+5ozd5tRb/kAJ8dhDlx4KXBaWHOiznG4xW4BPrL Z5Le44LY8b5nhrIL2+SiImwELIUGi3CJ1b7gkCSfywl6qX5X6ryqebQYWcXEpD6JME27 ZoxDeyT7LAbI8mYfW7yX29gjDgOB3GPWS7A1s7CLQcyzHp6l8cY4rt6IeJ35ERLllJZX 5mqi2WK3YiyrB+O0V4tG1s5+DS7GiQ593kegHCDS+VdlxT8c/AESZXlWaqs5zXJOX9NZ v9or1yYPvpscEPfwpov5EDmpmsmyWaCettDn1q3jXakKrZqpcymqgicVp0xm1siOYS7p DPuA== ARC-Authentication-Results: i=1; mx.google.com; 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 jw10si3788760ejc.357.2021.02.12.10.28.49; Fri, 12 Feb 2021 10:29:14 -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; 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 S231294AbhBLS1Z (ORCPT + 99 others); Fri, 12 Feb 2021 13:27:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:34408 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbhBLS1X (ORCPT ); Fri, 12 Feb 2021 13:27:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B7592AF6F; Fri, 12 Feb 2021 18:26:42 +0000 (UTC) Date: Fri, 12 Feb 2021 18:26:41 +0000 From: Michal Rostecki To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= 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: <20210212182641.GB20817@wotan.suse.de> References: <20210209203041.21493-1-mrostecki@suse.de> <20210209203041.21493-5-mrostecki@suse.de> <20210210040805.GB12086@qmqm.qmqm.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210210040805.GB12086@qmqm.qmqm.pl> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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