Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1348078ybp; Thu, 17 Oct 2019 11:24:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxH7sOpNLyStGe2+++cw1iAPxuVxQDLkH9iqrtvF3bJF0n9O4XtLQZmYlCCAmn10WaJKQD0 X-Received: by 2002:a17:906:2307:: with SMTP id l7mr4721801eja.320.1571336688440; Thu, 17 Oct 2019 11:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336688; cv=none; d=google.com; s=arc-20160816; b=AQH0Miv/S3M2QB0YVtdCv3ksfplIw/N6S58CbwFAJG3Z6qzHpQPE+BUjSo3ZQ7BMb4 IlAlO4aQcHboNbou256uLIH+EaBUeQ18mEProR3I4Nzh1UV4TgiLCH3tvumARE2qo/11 jv6NWjmPxZzxEdiagFRC0ayujbKcfsKMCtJbewSdBo52Z6GQwE2nzS29FN4PXj6tLzGb +M3za1QHg3Dq4yIap7+gWMqqwHG+WKu5h6uNP7uoRVcQH7P0FAhuY7zwhpRZpbQsN7Zx lY0DATmMHDD84Flwx67w26AcAhrBkqOPDHH8XC1RwrFyHotemY+PiktW2YSiohj/UxjP ZMpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T9jnNgGlGVDIeICbWTI7bWQDkYSrWALEouOXsXVupRI=; b=nMkv4l4vopLrEl5DooIS0uNyT9Y43bWfcYj+Ho2MnAaZ2F56yvj6bvKt441x0NVert 6JiHMo+As1j03mHb8BsME0f7oRyAyz/EKHDQaUv5ccCC3bgOj0ollf0Gkgqkx/IrGmgk 6eltguZgFAdKOmOI70lXSEGLCfwmn49usUSLnKsfUSziqsMKarXAsl6RahN/laEkxik8 sLA7LYcY32Ed3EXESvx8tBnnKhhv4NC0hOg+VXMfxBFC0a7IDhDgLqx2T4TYPribmwwF F83qfAldg+RHjtlkOqGvpVjQIfX60uqYtAG9ti7pKkgU+A3R/a7dd82jAzfJy8s6GsKS b/WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e7cSheKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23si2370659edh.248.2019.10.17.11.24.25; Thu, 17 Oct 2019 11:24:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e7cSheKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728240AbfJPWDw (ORCPT + 99 others); Wed, 16 Oct 2019 18:03:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:53894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438452AbfJPV7R (ORCPT ); Wed, 16 Oct 2019 17:59:17 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D707C20872; Wed, 16 Oct 2019 21:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263157; bh=Uh2jeS4GpW90snlql2r8augqkQlGIQcQl7PtYE5jiUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7cSheKyEQ9rpp25lZskA/CKiLupgKniChkogsgq9k8mrB77U9KkVpkz1dh3VrXp/ vEURQI19S1dqc2FcUI/NL+Ytvy1gjRPTE9z/DzWtUlNrw6tuIqXNjXu5NOAS9/9BnJ kSuQO8btQWff6gTqfO58gfMJkFNNuBPN/OV2rLps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zygo Blaxell , David Sterba Subject: [PATCH 5.3 085/112] btrfs: fix balance convert to single on 32-bit host CPUs Date: Wed, 16 Oct 2019 14:51:17 -0700 Message-Id: <20191016214904.960760213@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zygo Blaxell commit 7a54789074a54f64addf5b49bf1994f478337a83 upstream. Currently, the command: btrfs balance start -dconvert=single,soft . on a Raspberry Pi produces the following kernel message: BTRFS error (device mmcblk0p2): balance: invalid convert data profile single This fails because we use is_power_of_2(unsigned long) to validate the new data profile, the constant for 'single' profile uses bit 48, and there are only 32 bits in a long on ARM. Fix by open-coding the check using u64 variables. Tested by completing the original balance command on several Raspberry Pis. Fixes: 818255feece6 ("btrfs: use common helper instead of open coding a bit test") CC: stable@vger.kernel.org # 4.20+ Signed-off-by: Zygo Blaxell Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3854,7 +3854,11 @@ static int alloc_profile_is_valid(u64 fl return !extended; /* "0" is valid for usual profiles */ /* true if exactly one bit set */ - return is_power_of_2(flags); + /* + * Don't use is_power_of_2(unsigned long) because it won't work + * for the single profile (1ULL << 48) on 32-bit CPUs. + */ + return flags != 0 && (flags & (flags - 1)) == 0; } static inline int balance_need_close(struct btrfs_fs_info *fs_info)