Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2350657pxb; Mon, 20 Sep 2021 19:45:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1D4BYvx1EdnlXxWs0m7U0Ed+DPdQ7w6R8HB4hnslJrMGjR3G+3pAHojzlVncHLpZr2kvC X-Received: by 2002:a17:906:7256:: with SMTP id n22mr32816404ejk.173.1632192357193; Mon, 20 Sep 2021 19:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192357; cv=none; d=google.com; s=arc-20160816; b=LXXdl2I57cznImZPeRqhyQOQPfnML0kF4A3UWeUOicrA+JI/pwxYbRqA0mMLa1kP0F Cyh6XOUyd+lYV/A/9MDyI02wOaKFMcBlUSjQoifRC/KqNnwzQjFovnwAikIPdn6dsDTB XMY0Miny4WaCObkYoUSrd5GwC3PfS0IjMn6vCgi8883pfYk14hFUq9sB4YIEl56Kob/N xV6h/itNc9r48BtmRVkPErcbEoRYLQmZUwvVk7vOcfMcMQnVI70O+UtR5f7Z1Y9V59UG Za1RXiNjEo3so2CTmJHLHPoXh8JT3aug+KzR22AQ/h1PJquakDkpGoonvgq6hH0g0sJq zOKQ== 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=ttJKhP1GjP4Y9KNPkS1Us1YnK92Od4BP0pb5NAeAQEE=; b=DcoIiY0fdxwrE4b0ALR7Y+i86/ZcsO1hbSz/asbBCmJ7nx0yhJ1jbxLOS7KWMwe141 R3SD9Ah6xhIHQEF2C+k08DVKJVnnUazb957LU0LRlInnlOlCjRPv+1Im8zKCE8LU/ZHW 5AfUkAQhwkKvtKcABX755W8SdWejbIOvi7jHc8X08EscEzWRWjy+onMqRDYKIIfslK2c IyXN8+g67+CD8D6wicjZFHaEic1ooLeVJ3Aa4dQ7PSBp83y6n+rP16Kvz1y9LVBehgz+ gDIYk1woCO/Cauuh9x4/8hdLQ9hEX/Gapezt1ahakGUT8YmtRLj7d/ENeQacAlBjKHy7 KqJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l0aYIYxm; 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 i8si16217964ejj.680.2021.09.20.19.45.32; Mon, 20 Sep 2021 19:45:57 -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=l0aYIYxm; 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 S1348312AbhITSZp (ORCPT + 99 others); Mon, 20 Sep 2021 14:25:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377442AbhITSS5 (ORCPT ); Mon, 20 Sep 2021 14:18:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23F2E6329D; Mon, 20 Sep 2021 17:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158586; bh=IqffpbbI8Z+v2EuYSGjTxctiRDY233GHDPPzVMP+09I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0aYIYxmg599Stbi/KzZVqRs+BQTtJCZsdjNWeCz2FpCDL3fFDzdZ/RWOzYfniSp4 rh/dnvdmKcUZfeEvy6D5RrUIDHcfBCq9DOOPgpZxfiiYRGf6Oy7hLOY3n2FKlaRR2A DkODtjlwC1JzJI/mBNfjbs4ETbUjqnOQIq8j8WPM= 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.4 192/260] btrfs: fix upper limit for max_inline for page size 64K Date: Mon, 20 Sep 2021 18:43:30 +0200 Message-Id: <20210920163937.639341599@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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: Anand Jain Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2894,6 +2894,29 @@ int open_ctree(struct super_block *sb, */ 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)); + + /* Cache block sizes */ + fs_info->nodesize = nodesize; + fs_info->sectorsize = sectorsize; + fs_info->stripesize = stripesize; + ret = btrfs_parse_options(fs_info, options, sb->s_flags); if (ret) { err = ret; @@ -2921,28 +2944,6 @@ int open_ctree(struct super_block *sb, 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->stripesize = stripesize; - - /* * mixed block groups end up with duplicate but slightly offset * extent buffers for the same range. It leads to corruptions */