]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Merge branch 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 27 Nov 2015 23:45:45 +0000 (15:45 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 27 Nov 2015 23:45:45 +0000 (15:45 -0800)
Pull btrfs fixes from Chris Mason:
 "This has Mark Fasheh's patches to fix quota accounting during subvol
  deletion, which we've been working on for a while now.  The patch is
  pretty small but it's a key fix.

  Otherwise it's a random assortment"

* 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  btrfs: fix balance range usage filters in 4.4-rc
  btrfs: qgroup: account shared subtree during snapshot delete
  Btrfs: use btrfs_get_fs_root in resolve_indirect_ref
  btrfs: qgroup: fix quota disable during rescan
  Btrfs: fix race between cleaner kthread and space cache writeout
  Btrfs: fix scrub preventing unused block groups from being deleted
  Btrfs: fix race between scrub and block group deletion
  btrfs: fix rcu warning during device replace
  btrfs: Continue replace when set_block_ro failed
  btrfs: fix clashing number of the enhanced balance usage filter
  Btrfs: fix the number of transaction units needed to remove a block group
  Btrfs: use global reserve when deleting unused block group after ENOSPC
  Btrfs: tests: checking for NULL instead of IS_ERR()
  btrfs: fix signed overflows in btrfs_sync_file

1  2 
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/volumes.c

diff --combined fs/btrfs/ctree.h
index 8c58191249cc14c33c376bb0c8c0a469cb95b894,a0165c6e6243768aff240add47dfe0ba52a589d2..35489e7129a7e8de9d0232279d41d3bbd19ae1df
@@@ -3367,7 -3367,7 +3367,7 @@@ static inline bool btrfs_mixed_space_in
  
  static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
  {
 -      return mapping_gfp_mask(mapping) & ~__GFP_FS;
 +      return mapping_gfp_constraint(mapping, ~__GFP_FS);
  }
  
  /* extent-tree.c */
@@@ -3416,6 -3416,7 +3416,7 @@@ int btrfs_cross_ref_exist(struct btrfs_
  struct btrfs_block_group_cache *btrfs_lookup_block_group(
                                                 struct btrfs_fs_info *info,
                                                 u64 bytenr);
+ void btrfs_get_block_group(struct btrfs_block_group_cache *cache);
  void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
  int get_block_group_index(struct btrfs_block_group_cache *cache);
  struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
@@@ -3479,6 -3480,9 +3480,9 @@@ int btrfs_make_block_group(struct btrfs
                           struct btrfs_root *root, u64 bytes_used,
                           u64 type, u64 chunk_objectid, u64 chunk_offset,
                           u64 size);
+ struct btrfs_trans_handle *btrfs_start_trans_remove_block_group(
+                               struct btrfs_fs_info *fs_info,
+                               const u64 chunk_offset);
  int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root, u64 group_start,
                             struct extent_map *em);
diff --combined fs/btrfs/file.c
index 977e715f0bf21a4ea8908700cfe4207dee1fe95d,8eb1f3c1b647da1f725906b0b0a19fceab4c4cbc..72e73461c0643bbf128504c93a9c47dd377784aa
@@@ -1882,8 -1882,13 +1882,13 @@@ int btrfs_sync_file(struct file *file, 
        struct btrfs_log_ctx ctx;
        int ret = 0;
        bool full_sync = 0;
-       const u64 len = end - start + 1;
+       u64 len;
  
+       /*
+        * The range length can be represented by u64, we have to do the typecasts
+        * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync()
+        */
+       len = (u64)end - (u64)start + 1;
        trace_btrfs_sync_file(file, datasync);
  
        /*
                        }
                }
                if (!full_sync) {
-                       ret = btrfs_wait_ordered_range(inode, start,
-                                                      end - start + 1);
+                       ret = btrfs_wait_ordered_range(inode, start, len);
                        if (ret) {
                                btrfs_end_transaction(trans, root);
                                goto out;
@@@ -2663,7 -2667,7 +2667,7 @@@ static long btrfs_fallocate(struct fil
                                        alloc_start);
                if (ret)
                        goto out;
 -      } else {
 +      } else if (offset + len > inode->i_size) {
                /*
                 * If we are fallocating from the end of the file onward we
                 * need to zero out the end of the page if i_size lands in the
diff --combined fs/btrfs/inode.c
index 994490d5fa6423dee4971e0ff013777d853fe6a6,f82d1f4460ddc0cc130e31ee59fc02cf72118518..a70c5790f8f5908f08f606d097fe33e6966af36b
@@@ -4046,9 -4046,7 +4046,7 @@@ int btrfs_unlink_inode(struct btrfs_tra
   */
  static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir)
  {
-       struct btrfs_trans_handle *trans;
        struct btrfs_root *root = BTRFS_I(dir)->root;
-       int ret;
  
        /*
         * 1 for the possible orphan item
         * 1 for the inode ref
         * 1 for the inode
         */
-       trans = btrfs_start_transaction(root, 5);
-       if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC)
-               return trans;
-       if (PTR_ERR(trans) == -ENOSPC) {
-               u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5);
-               trans = btrfs_start_transaction(root, 0);
-               if (IS_ERR(trans))
-                       return trans;
-               ret = btrfs_cond_migrate_bytes(root->fs_info,
-                                              &root->fs_info->trans_block_rsv,
-                                              num_bytes, 5);
-               if (ret) {
-                       btrfs_end_transaction(trans, root);
-                       return ERR_PTR(ret);
-               }
-               trans->block_rsv = &root->fs_info->trans_block_rsv;
-               trans->bytes_reserved = num_bytes;
-       }
-       return trans;
+       return btrfs_start_transaction_fallback_global_rsv(root, 5, 5);
  }
  
  static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
@@@ -6366,6 -6344,9 +6344,6 @@@ static int btrfs_mknod(struct inode *di
        u64 objectid;
        u64 index = 0;
  
 -      if (!new_valid_dev(rdev))
 -              return -EINVAL;
 -
        /*
         * 2 for inode item and ref
         * 2 for dir items
diff --combined fs/btrfs/volumes.c
index a6df8fdc1312ce78e97f9f90037ff5b236a58a92,750285e4f274503ad0e34451c90b1b6c5a484fe5..45645220660996773b1f76cd1d526d4aeae33dac
@@@ -232,8 -232,8 +232,8 @@@ static struct btrfs_device *__alloc_dev
        spin_lock_init(&dev->reada_lock);
        atomic_set(&dev->reada_in_flight, 0);
        atomic_set(&dev->dev_stats_ccnt, 0);
 -      INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_WAIT);
 -      INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_WAIT);
 +      INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
 +      INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
  
        return dev;
  }
@@@ -1973,8 -1973,7 +1973,7 @@@ void btrfs_rm_dev_replace_remove_srcdev
        if (srcdev->writeable) {
                fs_devices->rw_devices--;
                /* zero out the old super if it is writable */
-               btrfs_scratch_superblocks(srcdev->bdev,
-                                       rcu_str_deref(srcdev->name));
+               btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str);
        }
  
        if (srcdev->bdev)
@@@ -2024,8 -2023,7 +2023,7 @@@ void btrfs_destroy_dev_replace_tgtdev(s
        btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);
  
        if (tgtdev->bdev) {
-               btrfs_scratch_superblocks(tgtdev->bdev,
-                                       rcu_str_deref(tgtdev->name));
+               btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);
                fs_info->fs_devices->open_devices--;
        }
        fs_info->fs_devices->num_devices--;
@@@ -2853,7 -2851,8 +2851,8 @@@ static int btrfs_relocate_chunk(struct 
        if (ret)
                return ret;
  
-       trans = btrfs_start_transaction(root, 0);
+       trans = btrfs_start_trans_remove_block_group(root->fs_info,
+                                                    chunk_offset);
        if (IS_ERR(trans)) {
                ret = PTR_ERR(trans);
                btrfs_std_error(root->fs_info, ret, NULL);
@@@ -3123,7 -3122,7 +3122,7 @@@ static int chunk_profiles_filter(u64 ch
        return 1;
  }
  
- static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
+ static int chunk_usage_range_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
                              struct btrfs_balance_args *bargs)
  {
        struct btrfs_block_group_cache *cache;
        return ret;
  }
  
- static int chunk_usage_range_filter(struct btrfs_fs_info *fs_info,
+ static int chunk_usage_filter(struct btrfs_fs_info *fs_info,
                u64 chunk_offset, struct btrfs_balance_args *bargs)
  {
        struct btrfs_block_group_cache *cache;