From patchwork Sat Apr 4 10:32:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 11474193 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6ECAC1744 for ; Sat, 4 Apr 2020 10:32:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D89720719 for ; Sat, 4 Apr 2020 10:32:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=libero.it header.i=@libero.it header.b="TcX90m2b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbgDDKcX (ORCPT ); Sat, 4 Apr 2020 06:32:23 -0400 Received: from smtp-16.italiaonline.it ([213.209.10.16]:58897 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726084AbgDDKcT (ORCPT ); Sat, 4 Apr 2020 06:32:19 -0400 Received: from venice.bhome ([94.37.173.46]) by smtp-16.iol.local with ESMTPA id Kg63jDxJE6Q7RKg64jI6Vl; Sat, 04 Apr 2020 12:32:16 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1585996337; bh=X9BqhunZ47MjClTm0UgGSPVbGskvlnmCKfCU9w/DWss=; h=From; b=TcX90m2b/ryIf+BzY3c/IST0KtA1L6sIig2ucB669AJTk3M7rhm4oFSyKMuQiBMlx +meceqGV3KkYKb/l9AA3RgTOoQK23BS0DG80ELzx7YIQt3dwwX1vAz4Ab+Cx4vnqeS VHYb0oJ1jTSbNOzX6VihmszraVcWrwRdfjJqLqR4jNbqhQxVP3bFoaSpeow1TjraoH bES8WgKqeH/1R3IU7v5uMKTovUbm1oPW1Fl9GSENEYW2cKmEWYEjvfPTJeKAty8Zsz skl/KPZogx5KMaC3mnBUQeAVbx+pyh6JBlF5xd+4L/PTehN5DIDlfXalGmeqdyJeCb TaO/uexz5zhgg== X-CNFS-Analysis: v=2.3 cv=LelCFQXi c=1 sm=1 tr=0 a=TpQr5eyM7/bznjVQAbUtjA==:117 a=TpQr5eyM7/bznjVQAbUtjA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=QjIyc2Qvnuyww2qCVJEA:9 From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Zygo Blaxell , Qu Wenruo , David Sterba , Graham Cobb , Goffredo Baroncelli Subject: [PATCH 1/5] btrfs-progs: Add code for checking mixed profile function Date: Sat, 4 Apr 2020 12:32:08 +0200 Message-Id: <20200404103212.40986-2-kreijack@libero.it> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200404103212.40986-1-kreijack@libero.it> References: <20200404103212.40986-1-kreijack@libero.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKdd+esTeTN1C6k7X/myqPWbWe6+kX1Hj+B7yA5/cGAS/y098Pi5sAxP2Ivr+Mw8PWGotyjzcFi18TquKi0VV1LGpgwLI3p7KRWWBldwOSeChSby4yvj rs9lg2SBauptvJwvxaNBSJH6p1ZQqPdfoBycG5pG+LJBctlNXaTj0SLp5JJH2TPp55NKuMnFpN5CM/ktX88YiNjkSG7Sf9wpkUr+SUH47bRLQUeed7DLZ1EM A6ur/S/C7uAAz1PJm66H3J9JehzM7LaxHxCOV0tqb5U+G5TkUol4zKdz7+RHiCAYsECykkMhLbjcuGbypK1EdkRBvzDGsIQFaKP94DKbOjs= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goffredo Baroncelli Add code to show a warning if a mixed profiles filesystem is detected. Signed-off-by: Goffredo Baroncelli --- common/utils.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++ common/utils.h | 11 +++ 2 files changed, 199 insertions(+) diff --git a/common/utils.c b/common/utils.c index a7761683..5c9ff562 100644 --- a/common/utils.c +++ b/common/utils.c @@ -1710,3 +1710,191 @@ void print_all_devices(struct list_head *devices) print_device_info(dev, "\t"); printf("\n"); } + +static int bit_count(u64 x) +{ + int ret = 0; + + while (x) { + if (x & 1) + ret++; + x >>= 1; + } + return ret; +} + +static void sprint_profiles(char **ptr, u64 profiles) +{ + int i; + int first = true; + int l = 1; + + *ptr = NULL; + + for (i = 0 ; i < BTRFS_NR_RAID_TYPES ; i++) + l += strlen(btrfs_raid_array[i].raid_name) + 2; + + *ptr = malloc(l); + if (!*ptr) + return; + **ptr = 0; + + for (i = 0 ; i < BTRFS_NR_RAID_TYPES ; i++) { + if (!(btrfs_raid_array[i].bg_flag & profiles)) + continue; + + if (!first) + strcat(*ptr, ", "); + strcat(*ptr, btrfs_raid_array[i].raid_name); + first = false; + } + if (profiles & BTRFS_AVAIL_ALLOC_BIT_SINGLE) { + if (!first) + strcat(*ptr, ", "); + strcat(*ptr, btrfs_raid_array[BTRFS_RAID_SINGLE].raid_name); + } +} + +int btrfs_string_check_for_mixed_profiles_by_fd(int fd, char **data_ret, + char **metadata_ret, + char **mixed_ret, + char **system_ret) +{ + int ret; + int i; + struct btrfs_ioctl_space_args *sargs; + u64 data_profiles = 0; + u64 metadata_profiles = 0; + u64 system_profiles = 0; + u64 mixed_profiles = 0; + static const u64 mixed_profile_fl = BTRFS_BLOCK_GROUP_METADATA | + BTRFS_BLOCK_GROUP_DATA; + + ret = get_df(fd, &sargs); + if (ret < 0) + return -1; + + for (i = 0 ; i < sargs->total_spaces ; i++) { + u64 flags = sargs->spaces[i].flags; + + if (!(flags & BTRFS_BLOCK_GROUP_PROFILE_MASK)) + flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; + + if ((flags & mixed_profile_fl) == mixed_profile_fl) + mixed_profiles |= flags; + else if (flags & BTRFS_BLOCK_GROUP_DATA) + data_profiles |= flags; + else if (flags & BTRFS_BLOCK_GROUP_METADATA) + metadata_profiles |= flags; + else if (flags & BTRFS_BLOCK_GROUP_SYSTEM) + system_profiles |= flags; + } + free(sargs); + + data_profiles &= BTRFS_EXTENDED_PROFILE_MASK; + system_profiles &= BTRFS_EXTENDED_PROFILE_MASK; + mixed_profiles &= BTRFS_EXTENDED_PROFILE_MASK; + metadata_profiles &= BTRFS_EXTENDED_PROFILE_MASK; + + if ((bit_count(data_profiles) <= 1) && + (bit_count(metadata_profiles) <= 1) && + (bit_count(system_profiles) <= 1) && + (bit_count(mixed_profiles) <= 1)) + return 0; + + if (data_ret) { + if (bit_count(data_profiles) > 1) + sprint_profiles(data_ret, data_profiles); + else + *data_ret = NULL; + } + if (metadata_ret) { + if (bit_count(metadata_profiles) > 1) + sprint_profiles(metadata_ret, metadata_profiles); + else + *metadata_ret = NULL; + } + if (mixed_ret) { + if (bit_count(mixed_profiles) > 1) + sprint_profiles(mixed_ret, mixed_profiles); + else + *mixed_ret = NULL; + } + if (system_ret) { + if (bit_count(system_profiles) > 1) + sprint_profiles(system_ret, system_profiles); + else + *system_ret = NULL; + } + + return 1; +} + +int btrfs_check_for_mixed_profiles_by_path(char *path) +{ + int fd; + int ret; + DIR *dirstream; + + fd = btrfs_open_dir(path, &dirstream, 0); + if (fd < 0) + return -1; + closedir(dirstream); + + ret = btrfs_check_for_mixed_profiles_by_fd(fd); + close(fd); + + return ret; +} + +int btrfs_check_for_mixed_profiles_by_fd(int fd) +{ + int ret; + int first = true; + char *data_prof, *mixed_prof, *metadata_prof, *system_prof; + + ret = btrfs_string_check_for_mixed_profiles_by_fd(fd, &data_prof, + &metadata_prof, &mixed_prof, &system_prof); + + if (ret != 1) + return ret; + + fprintf(stderr, + "WARNING: Multiple profiles detected. See 'man btrfs(5)'.\n"); + fprintf(stderr, "WARNING: "); + if (data_prof) { + fprintf(stderr, "data -> [%s]", data_prof); + first = false; + } + if (metadata_prof) { + if (!first) + fprintf(stderr, ", "); + fprintf(stderr, "metadata -> [%s]", metadata_prof); + first = false; + } + if (mixed_prof) { + if (!first) + fprintf(stderr, ", "); + fprintf(stderr, "data+metadata -> [%s]", mixed_prof); + first = false; + } + if (system_prof) { + if (!first) + fprintf(stderr, ", "); + fprintf(stderr, "system -> [%s]", system_prof); + first = false; + } + + fprintf(stderr, "\n"); + + if (data_prof) + free(data_prof); + if (metadata_prof) + free(metadata_prof); + if (mixed_prof) + free(mixed_prof); + if (system_prof) + free(system_prof); + + return 1; +} diff --git a/common/utils.h b/common/utils.h index 5c1afda9..c4e6e935 100644 --- a/common/utils.h +++ b/common/utils.h @@ -137,4 +137,15 @@ u64 rand_u64(void); unsigned int rand_range(unsigned int upper); void init_rand_seed(u64 seed); +int btrfs_string_check_for_mixed_profiles_by_fd(int fd, char **data_ret, + char **metadata_ret, + char **mixed_ret, + char **system_ret); +static inline int btrfs_test_for_mixed_profiles_by_fd(int fd) +{ + return btrfs_string_check_for_mixed_profiles_by_fd(fd, 0L, 0L, 0L, 0L); +} +int btrfs_check_for_mixed_profiles_by_path(char *path); +int btrfs_check_for_mixed_profiles_by_fd(int fd); + #endif From patchwork Sat Apr 4 10:32:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 11474185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B41B815AB for ; Sat, 4 Apr 2020 10:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A8A220719 for ; Sat, 4 Apr 2020 10:32:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=libero.it header.i=@libero.it header.b="TBZ+KxJV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbgDDKcU (ORCPT ); Sat, 4 Apr 2020 06:32:20 -0400 Received: from smtp-16.italiaonline.it ([213.209.10.16]:40101 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726077AbgDDKcT (ORCPT ); Sat, 4 Apr 2020 06:32:19 -0400 Received: from venice.bhome ([94.37.173.46]) by smtp-16.iol.local with ESMTPA id Kg63jDxJE6Q7RKg65jI6W0; Sat, 04 Apr 2020 12:32:17 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1585996337; bh=59BuvjRcLOL1x6GYkCxK9VYmBAAs5KwXXoMRs59x1do=; h=From; b=TBZ+KxJV1zcXrqCe6rn8oM5MFo2seTwf9vlNQmXpWERcxStWC3EflJsT1goKAJq+H 7pdX0UuirCr5O9dqAnZiaNZ3fEHEINh459Ab+7GtyFIhXdmwBUMthJQECmTtXUryWL yfyzstjqbEF76Le2BNw4qnkITalzytPX3KENt82uEnJtkqseXyb3IHAJqGuqUyoEZz ykL5tr5ni/oZA4COmcXyPcJFNxuY3Hz1XfKIJtl79hFkBfNrVuC2uCBRzwybAoCX7C /oL6lF1KBYK+3giTDQw/HLVGjKmiObPKuojYLpz5bdPKbOF5ecOdX3+2oasgYFyIq4 vOs6YDgvt97aw== X-CNFS-Analysis: v=2.3 cv=LelCFQXi c=1 sm=1 tr=0 a=TpQr5eyM7/bznjVQAbUtjA==:117 a=TpQr5eyM7/bznjVQAbUtjA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=VPATK8qPJ3NAqgEWvUUA:9 From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Zygo Blaxell , Qu Wenruo , David Sterba , Graham Cobb , Goffredo Baroncelli Subject: [PATCH 2/5] btrfs-progs: Add mixed profiles check to some btrfs sub-commands. Date: Sat, 4 Apr 2020 12:32:09 +0200 Message-Id: <20200404103212.40986-3-kreijack@libero.it> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200404103212.40986-1-kreijack@libero.it> References: <20200404103212.40986-1-kreijack@libero.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKdd+esTeTN1C6k7X/myqPWbWe6+kX1Hj+B7yA5/cGAS/y098Pi5sAxP2Ivr+Mw8PWGotyjzcFi18TquKi0VV1LGpgwLI3p7KRWWBldwOSeChSby4yvj rs9lg2SBauptvJwvxaNBSJH6p1ZQqPdfoBycG5pG+LJBctlNXaTj0SLp5JJH2TPp55NKuMnFpN5CM/ktX88YiNjkSG7Sf9wpkUr+SUH47bRLQUeed7DLZ1EM A6ur/S/C7uAAz1PJm66H3J9JehzM7LaxHxCOV0tqb5U+G5TkUol4zKdz7+RHiCAYsECykkMhLbjcuGbypK1EdkRBvzDGsIQFaKP94DKbOjs= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goffredo Baroncelli Add a check in some btrfs subcommands to detect if a filesystem has mixed profiles for data/metadata/system. In this case a warning is showed. Signed-off-by: Goffredo Baroncelli --- cmds/balance.c | 2 ++ cmds/device.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cmds/balance.c b/cmds/balance.c index 5392a604..20d0ebc1 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -716,6 +716,7 @@ static int cmd_balance_pause(const struct cmd_struct *cmd, ret = 1; } + btrfs_check_for_mixed_profiles_by_fd(fd); close_file_or_dir(fd, dirstream); return ret; } @@ -756,6 +757,7 @@ static int cmd_balance_cancel(const struct cmd_struct *cmd, ret = 1; } + btrfs_check_for_mixed_profiles_by_fd(fd); close_file_or_dir(fd, dirstream); return ret; } diff --git a/cmds/device.c b/cmds/device.c index 24158308..401b32b9 100644 --- a/cmds/device.c +++ b/cmds/device.c @@ -143,6 +143,7 @@ static int cmd_device_add(const struct cmd_struct *cmd, } error_out: + btrfs_check_for_mixed_profiles_by_fd(fdmnt); close_file_or_dir(fdmnt, dirstream); return !!ret; } @@ -225,6 +226,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd, } } + btrfs_check_for_mixed_profiles_by_fd(fdmnt); close_file_or_dir(fdmnt, dirstream); return !!ret; } From patchwork Sat Apr 4 10:32:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 11474189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5C4715AB for ; Sat, 4 Apr 2020 10:32:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA239206C3 for ; Sat, 4 Apr 2020 10:32:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=libero.it header.i=@libero.it header.b="TWIF6FhV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbgDDKcT (ORCPT ); Sat, 4 Apr 2020 06:32:19 -0400 Received: from smtp-16.italiaonline.it ([213.209.10.16]:48447 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726112AbgDDKcT (ORCPT ); Sat, 4 Apr 2020 06:32:19 -0400 Received: from venice.bhome ([94.37.173.46]) by smtp-16.iol.local with ESMTPA id Kg63jDxJE6Q7RKg65jI6WI; Sat, 04 Apr 2020 12:32:17 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1585996337; bh=v5GXkAYXlRDB+G3QchwUz/DqODtZF0Pxm8NMl7Q+/uU=; h=From; b=TWIF6FhVGMQXgzXf2UgSBlkoEliTTdRcKoz6OL8mjmtn+J1Vey3LhScYgeRGZWqKo spyqndp1/hL3lfw95zhmyeg3xHL2CiJ2QHPv6gbc66ftsgnSosaIoljjmHzBu52K9b XDGEB6zrny10z9Fta5u1vJYPN3qFCAU6HI+lb2pgzwgRFhQ6wjRHih3PhEO9xxLVtD WsdlInyiUVwpWNCFBjNRSqfMPqhTCBotCZ1jLbX4EnsaR+rEuY2RuxeIismzQIhPtH GymsauiJDY5EMvnpe/Z0UQVRWiPe0IoNek8GXK6iao4tMlsUjcenXmH4Wwvcj4gyBF rUnqSlKWSrBmA== X-CNFS-Analysis: v=2.3 cv=LelCFQXi c=1 sm=1 tr=0 a=TpQr5eyM7/bznjVQAbUtjA==:117 a=TpQr5eyM7/bznjVQAbUtjA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=k2A2CUVQ5W2PnF00lrAA:9 From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Zygo Blaxell , Qu Wenruo , David Sterba , Graham Cobb , Goffredo Baroncelli Subject: [PATCH 3/5] Add check for multiple profile in btrfs fi us Date: Sat, 4 Apr 2020 12:32:10 +0200 Message-Id: <20200404103212.40986-4-kreijack@libero.it> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200404103212.40986-1-kreijack@libero.it> References: <20200404103212.40986-1-kreijack@libero.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKdd+esTeTN1C6k7X/myqPWbWe6+kX1Hj+B7yA5/cGAS/y098Pi5sAxP2Ivr+Mw8PWGotyjzcFi18TquKi0VV1LGpgwLI3p7KRWWBldwOSeChSby4yvj rs9lg2SBauptvJwvxaNBSJH6p1ZQqPdfoBycG5pG+LJBctlNXaTj0SLp5JJH2TPp55NKuMnFpN5CM/ktX88YiNjkSG7Sf9wpkUr+SUH47bRLQUeed7DLZ1EM A6ur/S/C7uAAz1PJm66H3J9JehzM7LaxHxCOV0tqb5U+G5TkUol4zKdz7+RHiCAYsECykkMhLbjcuGbypK1EdkRBvzDGsIQFaKP94DKbOjs= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goffredo Baroncelli A new line in the "Overall" section is added to inform that a 'Multiple profile' is present. Signed-off-by: Goffredo Baroncelli --- cmds/filesystem-usage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index aa7065d5..742b4ea4 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -492,6 +492,11 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo, printf(" Global reserve:\t\t%*s\t(used: %s)\n", width, pretty_size_mode(l_global_reserve, unit_mode), pretty_size_mode(l_global_reserve_used, unit_mode)); + if (btrfs_test_for_mixed_profiles_by_fd(fd) > 0) + printf(" Multiple profile:\t\t%*s\n", width, "YES"); + else + printf(" Multiple profile:\t\t%*s\n", width, "no"); + exit: From patchwork Sat Apr 4 10:32:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 11474191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F635912 for ; Sat, 4 Apr 2020 10:32:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0536920719 for ; Sat, 4 Apr 2020 10:32:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=libero.it header.i=@libero.it header.b="V0bRITJp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726278AbgDDKcX (ORCPT ); Sat, 4 Apr 2020 06:32:23 -0400 Received: from smtp-16.italiaonline.it ([213.209.10.16]:37549 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDDKcT (ORCPT ); Sat, 4 Apr 2020 06:32:19 -0400 Received: from venice.bhome ([94.37.173.46]) by smtp-16.iol.local with ESMTPA id Kg63jDxJE6Q7RKg65jI6WS; Sat, 04 Apr 2020 12:32:17 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1585996338; bh=lMqD33KxfDP7FXbolls4YrJLt3TmQ4a8GsYEsin2uGY=; h=From; b=V0bRITJpe+0P9BHQ4uJc0re7sjNYEKIMshqGjaJkoO1oqtx0Q92j7IL7z+clHj6pt 6wj+dM3Bu5weu7k8zXdSIBoo4sGcbAtjJ3wk1SHqLV5E9zrC5SscR/5H8kYwqAwIrV E1G/CcZEka+P16nLjBzDbL2cZsYejEXY0xAn7H9HKWgDVA6IUz2G7kw1gtb3Pv33Rt 5KYg/r7VXYQa+TsyP4nAR8zkdTliYh87LLeHTKdv1dAt1k+KjkOYuWkLVUqrpjIJ9p QS0/WBdKDuew172Q0UhIhQwHZ6//oP0goXzkcdOqK9rGuDnyIiKXtmmp/dMv7MFemo 0TS+DomnuQ0fA== X-CNFS-Analysis: v=2.3 cv=LelCFQXi c=1 sm=1 tr=0 a=TpQr5eyM7/bznjVQAbUtjA==:117 a=TpQr5eyM7/bznjVQAbUtjA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=RUdbwsFTIHsY3NEGO5kA:9 From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Zygo Blaxell , Qu Wenruo , David Sterba , Graham Cobb , Goffredo Baroncelli Subject: [PATCH 4/5] Add further check in btrfs subcommand Date: Sat, 4 Apr 2020 12:32:11 +0200 Message-Id: <20200404103212.40986-5-kreijack@libero.it> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200404103212.40986-1-kreijack@libero.it> References: <20200404103212.40986-1-kreijack@libero.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKAGwLMXXr86U8TsKLPeJGlM+Q5SkBcu5LXuqJE0AUZ3SD8jePIyqFazIUOPNZKtP7UTnBT/YGIHndjwJAVetsrOQ8Cp2j97j7vaQVrpe/4YoqPkcRQc JtFUMFANXp6j0977pueoUYGdoc/cmd53kdzMaqQ3SyLf3tfq+qoPAO51P47QDAOJyabDXcrWovCwKw6/Dod3kPZZCCG2DDvjtaGVETf2mDylX7Y1/cki8mot 71x3cl/Me0b3BfG7wM3s/nCekk9Mniw2FD26Wn7P8+bCkb7FpiaZLhhKFoCPNei2cbHrOX0732vS+D5dMzY7CcLpa59jxw2DgeA5Gn39sgI= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goffredo Baroncelli Signed-off-by: Goffredo Baroncelli --- cmds/device.c | 1 + cmds/filesystem.c | 1 + 2 files changed, 2 insertions(+) diff --git a/cmds/device.c b/cmds/device.c index 401b32b9..d83f92a7 100644 --- a/cmds/device.c +++ b/cmds/device.c @@ -661,6 +661,7 @@ static int cmd_device_usage(const struct cmd_struct *cmd, int argc, char **argv) } ret = _cmd_device_usage(fd, argv[i], unit_mode); + btrfs_check_for_mixed_profiles_by_fd(fd); close_file_or_dir(fd, dirstream); if (ret) diff --git a/cmds/filesystem.c b/cmds/filesystem.c index 4f22089a..c4bb13dd 100644 --- a/cmds/filesystem.c +++ b/cmds/filesystem.c @@ -111,6 +111,7 @@ static int cmd_filesystem_df(const struct cmd_struct *cmd, error("get_df failed: %m"); } + btrfs_check_for_mixed_profiles_by_fd(fd); close_file_or_dir(fd, dirstream); return !!ret; } From patchwork Sat Apr 4 10:32:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 11474187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06ED4912 for ; Sat, 4 Apr 2020 10:32:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9BCE2072B for ; Sat, 4 Apr 2020 10:32:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=libero.it header.i=@libero.it header.b="AoTqIbq+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbgDDKcV (ORCPT ); Sat, 4 Apr 2020 06:32:21 -0400 Received: from smtp-16-i2.italiaonline.it ([213.209.12.16]:53448 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726157AbgDDKcU (ORCPT ); Sat, 4 Apr 2020 06:32:20 -0400 Received: from venice.bhome ([94.37.173.46]) by smtp-16.iol.local with ESMTPA id Kg63jDxJE6Q7RKg66jI6Wo; Sat, 04 Apr 2020 12:32:18 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2014; t=1585996338; bh=NvzAaTARaLJ96vxBk5dd3zVfmf+EeFgB/b1nhVCFYZU=; h=From; b=AoTqIbq+7jt+9U1Oe3dqFFZmHE/LS9OCmnlK62yGBEGQaSTVUvPsWh1G0iIHWxJxo EQr2X9Kes/lLG2vf2Fcxa6N+Akqd9rs7h4FRo3l2DWsRNMzzkz12zUn0kDwF88awAP eo47prsCKe4u2cJ+6N4UV9CTg0bZz0/B8i4G2878DlbkK3dos2A0wBIgd4gLmlnNKB SfC+2sOA2WPwAfviBc3634X6wmHXhqidkwTk3XIizCGs1jppL1d+GfPkd7bI8eWcf9 8esk+HG5l4+c84r7ZtDvEbMyIXHvEhEm/FcvKUwsLinEk589gizkcJXuEYSlBKMG0m 6g7wPWi6ynX6A== X-CNFS-Analysis: v=2.3 cv=LelCFQXi c=1 sm=1 tr=0 a=TpQr5eyM7/bznjVQAbUtjA==:117 a=TpQr5eyM7/bznjVQAbUtjA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=T92Z9xJX5iHLdJxoEloA:9 From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Zygo Blaxell , Qu Wenruo , David Sterba , Graham Cobb , Goffredo Baroncelli Subject: [PATCH 5/5] Update the man page in order to give a guideline about mixed profiles. Date: Sat, 4 Apr 2020 12:32:12 +0200 Message-Id: <20200404103212.40986-6-kreijack@libero.it> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200404103212.40986-1-kreijack@libero.it> References: <20200404103212.40986-1-kreijack@libero.it> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKAGwLMXXr86U8TsKLPeJGlM+Q5SkBcu5LXuqJE0AUZ3SD8jePIyqFazIUOPNZKtP7UTnBT/YGIHndjwJAVetsrOQ8Cp2j97j7vaQVrpe/4YoqPkcRQc JtFUMFANXp6j0977pueoUYGdoc/cmd53kdzMaqQ3SyLf3tfq+qoPAO51P47QDAOJyabDXcrWovCwKw6/Dod3kPZZCCG2DDvjtaGVETf2mDylX7Y1/cki8mot 71x3cl/Me0b3BfG7wM3s/nCekk9Mniw2FD26Wn7P8+bCkb7FpiaZLhhKFoCPNei2cbHrOX0732vS+D5dMzY7CcLpa59jxw2DgeA5Gn39sgI= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goffredo Baroncelli Signed-off-by: Goffredo Baroncelli --- Documentation/btrfs-man5.asciidoc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/btrfs-man5.asciidoc b/Documentation/btrfs-man5.asciidoc index 56b1ed58..88f1c5ed 100644 --- a/Documentation/btrfs-man5.asciidoc +++ b/Documentation/btrfs-man5.asciidoc @@ -846,6 +846,37 @@ work and a workaround would need to be used to mount a multi-device filesystem. The mount option 'device' can trigger the device scanning during mount. +FILESYSTEM WITH MULTIPLE PROFILES +--------------------------------- + +It is possible that a btrfs filesystem features block group of the same +type (e.g. data) with different profiles. +This could happen when a profile conversion is interrupted (see +`btrfs-balance(8)`). +Some 'btrfs' commands perform a test to detect this kind of condition. In such +case a warning like this is showed: + +-------------------- +WARNING: Multiple profiles detected. See 'man btrfs(5)'. +WARNING: data -> [raid1, single], metadata -> [raid1, single] +-------------------- + +In a case like this, it is suggested to complete the conversion running +`btrfs balance`. This because the next block group allocation +is performed on the basis of the set of the profiles present on the disks, +according to the following priorities: + +* RAID6 +* RAID5 +* RAID10 +* RAID1 +* RAID0 + +For example if both the profile RAID6 and RAID1 are present on the disks, +the next block group allocation will be RAID6, regardeless of the last +`btrfs balance`. + + SEE ALSO -------- `acl`(5),