From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 59A18158086 for ; Tue, 16 Nov 2021 19:45:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5FF82E07A5; Tue, 16 Nov 2021 19:45:40 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 39942E07A5 for ; Tue, 16 Nov 2021 19:45:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0252C342D05 for ; Tue, 16 Nov 2021 19:45:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3F7E2161 for ; Tue, 16 Nov 2021 19:45:34 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1637091880.8de265d8c68cf991be31317d45ea657275319868.gyakovlev@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/btrfs-progs/files/, sys-fs/btrfs-progs/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-fs/btrfs-progs/btrfs-progs-5.15-r1.ebuild sys-fs/btrfs-progs/btrfs-progs-5.15.ebuild sys-fs/btrfs-progs/files/5.15-filesystem-usage-chunks.patch sys-fs/btrfs-progs/files/5.15-filesystem-usage-data.patch X-VCS-Directories: sys-fs/btrfs-progs/files/ sys-fs/btrfs-progs/ X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: 8de265d8c68cf991be31317d45ea657275319868 X-VCS-Branch: master Date: Tue, 16 Nov 2021 19:45:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 90031b7d-1cf8-4774-9325-126db0467b5a X-Archives-Hash: 8553b3f85beb6efac7c83c5681603846 commit: 8de265d8c68cf991be31317d45ea657275319868 Author: Georgy Yakovlev gentoo org> AuthorDate: Tue Nov 16 19:43:07 2021 +0000 Commit: Georgy Yakovlev gentoo org> CommitDate: Tue Nov 16 19:44:40 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8de265d8 sys-fs/btrfs-progs: revbump 5.15, add (meta)data calculation patches Signed-off-by: Georgy Yakovlev gentoo.org> ...rogs-5.15.ebuild => btrfs-progs-5.15-r1.ebuild} | 6 ++ .../files/5.15-filesystem-usage-chunks.patch | 94 ++++++++++++++++++++++ .../files/5.15-filesystem-usage-data.patch | 37 +++++++++ 3 files changed, 137 insertions(+) diff --git a/sys-fs/btrfs-progs/btrfs-progs-5.15.ebuild b/sys-fs/btrfs-progs/btrfs-progs-5.15-r1.ebuild similarity index 94% rename from sys-fs/btrfs-progs/btrfs-progs-5.15.ebuild rename to sys-fs/btrfs-progs/btrfs-progs-5.15-r1.ebuild index 36548f98db8a..ec22d07e7854 100644 --- a/sys-fs/btrfs-progs/btrfs-progs-5.15.ebuild +++ b/sys-fs/btrfs-progs/btrfs-progs-5.15-r1.ebuild @@ -79,6 +79,12 @@ fi REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" +# https://github.com/kdave/btrfs-progs/issues/422 +PATCHES=( + "${FILESDIR}/${PV}-filesystem-usage-data.patch" + "${FILESDIR}/${PV}-filesystem-usage-chunks.patch" +) + pkg_setup() { use python && python-single-r1_pkg_setup } diff --git a/sys-fs/btrfs-progs/files/5.15-filesystem-usage-chunks.patch b/sys-fs/btrfs-progs/files/5.15-filesystem-usage-chunks.patch new file mode 100644 index 000000000000..be58afc8712c --- /dev/null +++ b/sys-fs/btrfs-progs/files/5.15-filesystem-usage-chunks.patch @@ -0,0 +1,94 @@ +From: Nikolay Borisov +To: linux-btrfs@vger.kernel.org +Cc: Nikolay Borisov +Subject: [PATCH] Fix calculation of chunk size for RAID1/DUP profiles +Date: Tue, 16 Nov 2021 16:02:06 +0200 +Message-Id: <20211116140206.291252-1-nborisov@suse.com> +List-ID: + +Current formula calculates the stripe size, however that's not what we want +in the case of RAID1/DUP profiles. In those cases since chunkc are mirrored +across devices we want the full size of the chunk. Without this patch the +'btrfs fi usage' output from an fs which is using RAID1 is: + + + + Data,RAID1: Size:2.00GiB, Used:1.00GiB (50.03%) + /dev/vdc 1.00GiB + /dev/vdf 1.00GiB + + Metadata,RAID1: Size:256.00MiB, Used:1.34MiB (0.52%) + /dev/vdc 128.00MiB + /dev/vdf 128.00MiB + + System,RAID1: Size:8.00MiB, Used:16.00KiB (0.20%) + /dev/vdc 4.00MiB + /dev/vdf 4.00MiB + + Unallocated: + /dev/vdc 8.87GiB + /dev/vdf 8.87GiB + + +So a 2 gigabyte RAID1 chunk actually will take up 4 gigabytes on the actual disks +2 each. In this case this is being miscalculated as taking up 1gb on each device. + +This also leads to erroneously calculated unallocated space. The correct output +in this case is: + + + + Data,RAID1: Size:2.00GiB, Used:1.00GiB (50.03%) + /dev/vdc 2.00GiB + /dev/vdf 2.00GiB + + Metadata,RAID1: Size:256.00MiB, Used:1.34MiB (0.52%) + /dev/vdc 256.00MiB + /dev/vdf 256.00MiB + + System,RAID1: Size:8.00MiB, Used:16.00KiB (0.20%) + /dev/vdc 8.00MiB + /dev/vdf 8.00MiB + + Unallocated: + /dev/vdc 7.74GiB + /dev/vdf 7.74GiB + + +Fix it by only utilising the chunk formula for profiles which are not RAID1/DUP. + +Signed-off-by: Nikolay Borisov +--- + cmds/filesystem-usage.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c +index 6195f633da44..5f2289a9b40d 100644 +--- a/cmds/filesystem-usage.c ++++ b/cmds/filesystem-usage.c +@@ -805,11 +805,17 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo, + */ + static u64 calc_chunk_size(struct chunk_info *ci) + { +- u32 div; ++ u32 div = 1; + +- /* No parity + sub_stripes, so order of "-" and "/" does not matter */ +- div = (ci->num_stripes - btrfs_bg_type_to_nparity(ci->type)) / +- btrfs_bg_type_to_sub_stripes(ci->type); ++ /* ++ * The formula doesn't work for RAID1/DUP types, we should just return the ++ * chunk size ++ */ ++ if (!(ci->type & (BTRFS_BLOCK_GROUP_RAID1_MASK|BTRFS_BLOCK_GROUP_DUP))) { ++ /* No parity + sub_stripes, so order of "-" and "/" does not matter */ ++ div = (ci->num_stripes - btrfs_bg_type_to_nparity(ci->type)) / ++ btrfs_bg_type_to_sub_stripes(ci->type); ++ } + + return ci->size / div; + } +-- +2.17.1 + + diff --git a/sys-fs/btrfs-progs/files/5.15-filesystem-usage-data.patch b/sys-fs/btrfs-progs/files/5.15-filesystem-usage-data.patch new file mode 100644 index 000000000000..f3b43d5c594d --- /dev/null +++ b/sys-fs/btrfs-progs/files/5.15-filesystem-usage-data.patch @@ -0,0 +1,37 @@ +From 2f3950c8304fec2aed9bf11b52d073683b137330 Mon Sep 17 00:00:00 2001 +From: Nikolay Borisov +Date: Mon, 15 Nov 2021 11:15:42 +0200 +Subject: [PATCH] btrfs-progs: fi usage: don't reset ratio to 1 if we don't + have RAID56 profile + +Commit 80714610f36e ("btrfs-progs: use raid table for ncopies") +slightly broke how raid ratio are being calculated since the resulting +code would always reset ratio to be 1 in case we didn't have RAID56 +profile. The correct behavior is to simply set it to 0 if we have RAID56 +as the calculation is different in this case and leave it intact +otherwise. + +This bug manifests by doing all size-related calculation for 'btrfs +filesystem usage' command as if all block groups are of type SINGLE. Fix +this by only resetting ratio 0 in case of RAID56. + +Issue: #422 +Signed-off-by: Nikolay Borisov +Signed-off-by: David Sterba +--- + cmds/filesystem-usage.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c +index e22efe3a4..bac0f0fd5 100644 +--- a/cmds/filesystem-usage.c ++++ b/cmds/filesystem-usage.c +@@ -508,8 +508,6 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo, + */ + if (flags & BTRFS_BLOCK_GROUP_RAID56_MASK) + ratio = 0; +- else +- ratio = 1; + + if (ratio > max_data_ratio) + max_data_ratio = ratio;