Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1734030pxb; Thu, 16 Sep 2021 14:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm4vIDvx1lMbl0oPHbjXE1ELqyKMqM8yzvWNyOAgS7MQ37ubr/Wj33RdAg2ELRw0KxpUaF X-Received: by 2002:a05:6e02:144f:: with SMTP id p15mr2016569ilo.287.1631827082011; Thu, 16 Sep 2021 14:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631827082; cv=none; d=google.com; s=arc-20160816; b=HzCrmn262JC/+Zogoww4Zayqpw1eMvizkSrAuN/D+lYbSwEgKSyP1vbHRgY5RpCHIo 0z4P9/o6H9NQKmTuwcJT860dClkQy3bcUycuOyR7NbZ8ApIAaiLfMU8aFWWcnTFEEd8H TdOuRi6+fYswfKTxfvh9zwtHslrs0hJL30liZAzvoIZM80avLbrXL+7ke8G4I/bbCyJ6 7dy+vVMwo17B993kWXL8Y4Sp9Wt6oclPF+XL9VAx5LlqDeILjOiI6Iw2tKBJJ8tBd8bv 7r4Ixg8gVhB8UstUsSV4Djo7Nat4ZyJPt/89kJFD8xRhj8QaayKpnoWsRa4K0oKQAwL0 Y1+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P5VU9ccadnaw+kL5mY+FE354CS8NZ32Xbg0MKaKMN1k=; b=TWzarah05sGv6IgtSODy/px5NsoFsPnSxZNcaVfOk2529H8cEhyiY2MyX2cC9U1Jkw LE8Ksvp+MRmInwzU3gTvrXzF59nUMKGaOdVP321EJbmZFkVvwlFsvcY/JElZRPXHZOgM q2SlVcm+kVXm74AdKAZnIL+lvXQ1JmPeUh4D/XoK6CUZEsjhrYYkrkaB1K/srIyYUcQV LNy4/9zk1MNRtNhRWcIbOS5TfWFYHdbsbFkNa6Q3z/ntGa5iKJ8bIY/VAvxIdf6Wq4o/ Mpfb1YL255/Q6AjLqSGvmTi5ORGXsS2nCtDQSRF/Ef+sHSezciBSa2K7wYF8hkG31X8l 3GoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aDCjnyc+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si3968853jad.86.2021.09.16.14.17.50; Thu, 16 Sep 2021 14:18:02 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=aDCjnyc+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244484AbhIPQhL (ORCPT + 99 others); Thu, 16 Sep 2021 12:37:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242872AbhIPQ3o (ORCPT ); Thu, 16 Sep 2021 12:29:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4E93261130; Thu, 16 Sep 2021 16:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809124; bh=EX9RbR/g7CdtthmohUNp1pQW/MaDhhIkIsTCRNQMkB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aDCjnyc+H6ygtaNpEUKs7/u7WwOLecEvVbw818/Bwum7juhohVKhcWKbBzHZwgNFi lwa+NLNFflYpBvtl8DB4MqbxpA9ZR5/PNo8L7W5Vmvd+ASPWwwqOlJuqU094LKf5su X0GKpR7P+9JW9d6u4hlbjCv0jnRhSu6Oqw7erxXo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Tsvetkov , Anand Jain , David Sterba Subject: [PATCH 5.13 007/380] btrfs: fix upper limit for max_inline for page size 64K Date: Thu, 16 Sep 2021 17:56:04 +0200 Message-Id: <20210916155804.220225336@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anand Jain commit 6f93e834fa7c5faa0372e46828b4b2a966ac61d7 upstream. The mount option max_inline ranges from 0 to the sectorsize (which is now equal to page size). But we parse the mount options too early and before the actual sectorsize is read from the superblock. So the upper limit of max_inline is unaware of the actual sectorsize and is limited by the temporary sectorsize 4096, even on a system where the default sectorsize is 64K. Fix this by reading the superblock sectorsize before the mount option parse. Reported-by: Alexander Tsvetkov CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3329,6 +3329,30 @@ int __cold open_ctree(struct super_block */ fs_info->compress_type = BTRFS_COMPRESS_ZLIB; + /* + * Flag our filesystem as having big metadata blocks if they are bigger + * than the page size. + */ + if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { + if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) + btrfs_info(fs_info, + "flagging fs with big metadata feature"); + features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; + } + + /* Set up fs_info before parsing mount options */ + nodesize = btrfs_super_nodesize(disk_super); + sectorsize = btrfs_super_sectorsize(disk_super); + stripesize = sectorsize; + fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); + fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); + + fs_info->nodesize = nodesize; + fs_info->sectorsize = sectorsize; + fs_info->sectorsize_bits = ilog2(sectorsize); + fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size; + fs_info->stripesize = stripesize; + ret = btrfs_parse_options(fs_info, options, sb->s_flags); if (ret) { err = ret; @@ -3356,30 +3380,6 @@ int __cold open_ctree(struct super_block btrfs_info(fs_info, "has skinny extents"); /* - * flag our filesystem as having big metadata blocks if - * they are bigger than the page size - */ - if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { - if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) - btrfs_info(fs_info, - "flagging fs with big metadata feature"); - features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; - } - - nodesize = btrfs_super_nodesize(disk_super); - sectorsize = btrfs_super_sectorsize(disk_super); - stripesize = sectorsize; - fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); - fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); - - /* Cache block sizes */ - fs_info->nodesize = nodesize; - fs_info->sectorsize = sectorsize; - fs_info->sectorsize_bits = ilog2(sectorsize); - fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size; - fs_info->stripesize = stripesize; - - /* * mixed block groups end up with duplicate but slightly offset * extent buffers for the same range. It leads to corruptions */