1. 26 9月, 2022 3 次提交
  2. 06 9月, 2022 1 次提交
    • Q
      btrfs: fix the max chunk size and stripe length calculation · 5da431b7
      Qu Wenruo 提交于
      [BEHAVIOR CHANGE]
      Since commit f6fca391 ("btrfs: store chunk size in space-info
      struct"), btrfs no longer can create larger data chunks than 1G:
      
        mkfs.btrfs -f -m raid1 -d raid0 $dev1 $dev2 $dev3 $dev4
        mount $dev1 $mnt
      
        btrfs balance start --full $mnt
        btrfs balance start --full $mnt
        umount $mnt
      
        btrfs ins dump-tree -t chunk $dev1 | grep "DATA|RAID0" -C 2
      
      Before that offending commit, what we got is a 4G data chunk:
      
      	item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 9492758528) itemoff 15491 itemsize 176
      		length 4294967296 owner 2 stripe_len 65536 type DATA|RAID0
      		io_align 65536 io_width 65536 sector_size 4096
      		num_stripes 4 sub_stripes 1
      
      Now what we got is only 1G data chunk:
      
      	item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 6271533056) itemoff 15491 itemsize 176
      		length 1073741824 owner 2 stripe_len 65536 type DATA|RAID0
      		io_align 65536 io_width 65536 sector_size 4096
      		num_stripes 4 sub_stripes 1
      
      This will increase the number of data chunks by the number of devices,
      not only increase system chunk usage, but also greatly increase mount
      time.
      
      Without a proper reason, we should not change the max chunk size.
      
      [CAUSE]
      Previously, we set max data chunk size to 10G, while max data stripe
      length to 1G.
      
      Commit f6fca391 ("btrfs: store chunk size in space-info struct")
      completely ignored the 10G limit, but use 1G max stripe limit instead,
      causing above shrink in max data chunk size.
      
      [FIX]
      Fix the max data chunk size to 10G, and in decide_stripe_size_regular()
      we limit stripe_size to 1G manually.
      
      This should only affect data chunks, as for metadata chunks we always
      set the max stripe size the same as max chunk size (256M or 1G
      depending on fs size).
      
      Now the same script result the same old result:
      
      	item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 9492758528) itemoff 15491 itemsize 176
      		length 4294967296 owner 2 stripe_len 65536 type DATA|RAID0
      		io_align 65536 io_width 65536 sector_size 4096
      		num_stripes 4 sub_stripes 1
      Reported-by: NWang Yugui <wangyugui@e16-tech.com>
      Fixes: f6fca391 ("btrfs: store chunk size in space-info struct")
      Signed-off-by: NQu Wenruo <wqu@suse.com>
      Reviewed-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      5da431b7
  3. 23 8月, 2022 1 次提交
  4. 25 7月, 2022 21 次提交
  5. 16 5月, 2022 10 次提交
  6. 18 4月, 2022 2 次提交
  7. 06 4月, 2022 1 次提交
  8. 25 3月, 2022 1 次提交
    • Q
      btrfs: remove device item and update super block in the same transaction · bbac5869
      Qu Wenruo 提交于
      [BUG]
      There is a report that a btrfs has a bad super block num devices.
      
      This makes btrfs to reject the fs completely.
      
        BTRFS error (device sdd3): super_num_devices 3 mismatch with num_devices 2 found here
        BTRFS error (device sdd3): failed to read chunk tree: -22
        BTRFS error (device sdd3): open_ctree failed
      
      [CAUSE]
      During btrfs device removal, chunk tree and super block num devs are
      updated in two different transactions:
      
        btrfs_rm_device()
        |- btrfs_rm_dev_item(device)
        |  |- trans = btrfs_start_transaction()
        |  |  Now we got transaction X
        |  |
        |  |- btrfs_del_item()
        |  |  Now device item is removed from chunk tree
        |  |
        |  |- btrfs_commit_transaction()
        |     Transaction X got committed, super num devs untouched,
        |     but device item removed from chunk tree.
        |     (AKA, super num devs is already incorrect)
        |
        |- cur_devices->num_devices--;
        |- cur_devices->total_devices--;
        |- btrfs_set_super_num_devices()
           All those operations are not in transaction X, thus it will
           only be written back to disk in next transaction.
      
      So after the transaction X in btrfs_rm_dev_item() committed, but before
      transaction X+1 (which can be minutes away), a power loss happen, then
      we got the super num mismatch.
      
      [FIX]
      Instead of starting and committing a transaction inside
      btrfs_rm_dev_item(), start a transaction in side btrfs_rm_device() and
      pass it to btrfs_rm_dev_item().
      
      And only commit the transaction after everything is done.
      Reported-by: NLuca Béla Palkovics <luca.bela.palkovics@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CA+8xDSpvdm_U0QLBAnrH=zqDq_cWCOH5TiV46CKmp3igr44okQ@mail.gmail.com/
      CC: stable@vger.kernel.org # 4.14+
      Reviewed-by: NAnand Jain <anand.jain@oracle.com>
      Signed-off-by: NQu Wenruo <wqu@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      bbac5869