linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@libero.it>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [BUG][PATCH] btrfs: a mixed profile DUP and RAID1C3/RAID1C4 prevent to alloc a new chunk
Date: Sat, 30 May 2020 20:53:20 +0200	[thread overview]
Message-ID: <20200530185321.8373-1-kreijack@libero.it> (raw)


Hi All,

after the thread "Question: how understand the raid profile of a btrfs
filesystem" [*] I was working to cleanup the function
btrfs_reduce_alloc_profile(), when I figured that it was incompatible with
a mixed profile of DUP and RAID1C3/RAID1C4.

This is a very uncommon situation; to be honest it very unlikely that it will
happen at all.

However if the filesystem has a mixed profiles of DUP and RAID1C3/RAID1C4 (of
the same type of chunk of course, i.e. if you have metadata RAID1C3 and data
DUP there is no problem because the type of chunks are different), the function
btrfs_reduce_alloc_profile() returns both the profiles and subsequent calls
to alloc_profile_is_valid() return invalid.

The problem is how the function btrfs_reduce_alloc_profile "reduces" the
profiles.

[...]
static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags)
[...]
        allowed &= flags;

        if (allowed & BTRFS_BLOCK_GROUP_RAID6)
                allowed = BTRFS_BLOCK_GROUP_RAID6;
        else if (allowed & BTRFS_BLOCK_GROUP_RAID5)
                allowed = BTRFS_BLOCK_GROUP_RAID5;
        else if (allowed & BTRFS_BLOCK_GROUP_RAID10)
                allowed = BTRFS_BLOCK_GROUP_RAID10;
        else if (allowed & BTRFS_BLOCK_GROUP_RAID1)
                allowed = BTRFS_BLOCK_GROUP_RAID1;
        else if (allowed & BTRFS_BLOCK_GROUP_RAID0)
                allowed = BTRFS_BLOCK_GROUP_RAID0;

	flags &= ~BTRFS_BLOCK_GROUP_PROFILE_MASK;

[...]

"allowed" are all the possibles profiles allowed by the disks. 
"flags" contains the existing profiles.

If "flags" contains both DUP, RAID1C3 no reduction is performed and both
the profiles are returned.

If full conversion from DUP to RAID1C3 is performed, there is no problem.
But a partial conversion from DUP to RAID1C3 is performed, then there is no
possibility to allocate a new chunk.

On my tests the filesystem was never corrupted, but only force to RO.
However I was unable to exit from this state without my patch.

[*] https://lore.kernel.org/linux-btrfs/517dac49-5f57-2754-2134-92d716e50064@alice.it/

-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5


             reply	other threads:[~2020-05-30 18:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-30 18:53 Goffredo Baroncelli [this message]
2020-05-30 18:53 ` [PATCH] btrfs: btrfs_reduce_alloc_profile(): add support for raid1c3/raid1c4 Goffredo Baroncelli
2020-05-31  0:51 ` [BUG][PATCH] btrfs: a mixed profile DUP and RAID1C3/RAID1C4 prevent to alloc a new chunk Qu Wenruo
2020-05-31  5:58   ` Goffredo Baroncelli
2020-06-01  6:04   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200530185321.8373-1-kreijack@libero.it \
    --to=kreijack@libero.it \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).