Merge branch 'for-chris-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/fdmana...
authorChris Mason <clm@fb.com>
Tue, 13 Dec 2016 17:14:42 +0000 (09:14 -0800)
committerChris Mason <clm@fb.com>
Tue, 13 Dec 2016 17:14:42 +0000 (09:14 -0800)
Patches queued up by Filipe:

The most important change is still the fix for the extent tree
corruption that happens due to balance when qgroups are enabled (a
regression introduced in 4.7 by a fix for a regression from the last
qgroups rework). This has been hitting SLE and openSUSE users and QA
very badly, where transactions keep getting aborted when running
delayed references leaving the root filesystem in RO mode and nearly
unusable.  There are fixes here that allow us to run xfstests again
with the integrity checker enabled, which has been impossible since 4.8
(apparently I'm the only one running xfstests with the integrity
checker enabled, which is useful to validate dirtied leafs, like
checking if there are keys out of order, etc).  The rest are just some
trivial fixes, most of them tagged for stable, and two cleanups.

Signed-off-by: Chris Mason <clm@fb.com>
1  2 
fs/btrfs/delayed-ref.h
fs/btrfs/disk-io.c
fs/btrfs/file.c
fs/btrfs/qgroup.c
fs/btrfs/relocation.c
fs/btrfs/tree-log.c

   * ref_head. Must clean this mess up later.
   */
  struct btrfs_delayed_ref_node {
-       /*
-        * ref_head use rb tree, stored in ref_root->href.
-        * indexed by bytenr
-        */
-       struct rb_node rb_node;
        /*data/tree ref use list, stored in ref_head->ref_list. */
        struct list_head list;
 +      /*
 +       * If action is BTRFS_ADD_DELAYED_REF, also link this node to
 +       * ref_head->ref_add_list, then we do not need to iterate the
 +       * whole ref_head->ref_list to find BTRFS_ADD_DELAYED_REF nodes.
 +       */
 +      struct list_head add_list;
  
        /* the starting bytenr of the extent */
        u64 bytenr;
@@@ -584,9 -595,12 +596,12 @@@ static noinline int check_leaf(struct b
                return 0;
        }
  
+       if (nritems == 0)
+               return 0;
        /* Check the 0 item */
        if (btrfs_item_offset_nr(leaf, 0) + btrfs_item_size_nr(leaf, 0) !=
 -          BTRFS_LEAF_DATA_SIZE(root)) {
 +          BTRFS_LEAF_DATA_SIZE(fs_info)) {
                CORRUPT("invalid item offset size pair", leaf, root, 0);
                return -EIO;
        }
diff --cc fs/btrfs/file.c
@@@ -2372,7 -2347,7 +2372,7 @@@ static int btrfs_punch_hole(struct inod
        u64 tail_len;
        u64 orig_start = offset;
        u64 cur_offset;
-       u64 min_size = btrfs_calc_trunc_metadata_size(fs_info, 1);
 -      u64 min_size = btrfs_calc_trans_metadata_size(root, 1);
++      u64 min_size = btrfs_calc_trans_metadata_size(fs_info, 1);
        u64 drop_end;
        int ret = 0;
        int err = 0;
                ret = -ENOMEM;
                goto out_free;
        }
-       rsv->size = btrfs_calc_trunc_metadata_size(fs_info, 1);
 -      rsv->size = btrfs_calc_trans_metadata_size(root, 1);
++      rsv->size = btrfs_calc_trans_metadata_size(fs_info, 1);
        rsv->failfast = 1;
  
        /*
Simple merge
@@@ -2403,12 -2370,8 +2404,9 @@@ void free_reloc_roots(struct list_head 
  static noinline_for_stack
  void merge_reloc_roots(struct reloc_control *rc)
  {
 +      struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
        struct btrfs_root *root;
        struct btrfs_root *reloc_root;
-       u64 last_snap;
-       u64 otransid;
-       u64 objectid;
        LIST_HEAD(reloc_roots);
        int found = 0;
        int ret = 0;
@@@ -5224,7 -5204,9 +5223,8 @@@ process_leaf
                        if (di_key.type == BTRFS_ROOT_ITEM_KEY)
                                continue;
  
 -                      di_inode = btrfs_iget(root->fs_info->sb, &di_key,
 -                                            root, NULL);
+                       btrfs_release_path(path);
 +                      di_inode = btrfs_iget(fs_info->sb, &di_key, root, NULL);
                        if (IS_ERR(di_inode)) {
                                ret = PTR_ERR(di_inode);
                                goto next_dir_inode;