]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Merge branch 'for-linus-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Sep 2016 19:52:31 +0000 (12:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Sep 2016 19:52:31 +0000 (12:52 -0700)
Pull btrfs fixes from Chris Mason:
 "I'm not proud of how long it took me to track down that one liner in
  btrfs_sync_log(), but the good news is the patches I was trying to
  blame for these problems were actually fine (sorry Filipe)"

* 'for-linus-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  btrfs: introduce tickets_id to determine whether asynchronous metadata reclaim work makes progress
  btrfs: remove root_log_ctx from ctx list before btrfs_sync_log returns
  btrfs: do not decrease bytes_may_use when replaying extents

1  2 
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c

diff --combined fs/btrfs/ctree.h
index eff3993c77b333f875ade96769e6f6dad5b47143,146d1c7078edca715fde727e7c106ef8ffc77b3f..33fe0355110552f93b1560476101de1fb4a86ae7
@@@ -427,6 -427,7 +427,7 @@@ struct btrfs_space_info 
        struct list_head ro_bgs;
        struct list_head priority_tickets;
        struct list_head tickets;
+       u64 tickets_id;
  
        struct rw_semaphore groups_sem;
        /* for block groups in our same type */
@@@ -3122,7 -3123,7 +3123,7 @@@ int btrfs_create_subvol_root(struct btr
                             struct btrfs_root *new_root,
                             struct btrfs_root *parent_root,
                             u64 new_dirid);
 -int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset,
 +int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
                         size_t size, struct bio *bio,
                         unsigned long bio_flags);
  int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
diff --combined fs/btrfs/extent-tree.c
index 8c8a4d1e02b9059a690fedf35ca0477bc8b75a54,d09cf7aa083b0244f6d04984448640b74655ab23..38c2df84cabd0cf2116239d1cf08d1d18709890f
@@@ -2044,7 -2044,7 +2044,7 @@@ int btrfs_discard_extent(struct btrfs_r
         */
        btrfs_bio_counter_inc_blocked(root->fs_info);
        /* Tell the block device(s) that the sectors can be discarded */
 -      ret = btrfs_map_block(root->fs_info, REQ_DISCARD,
 +      ret = btrfs_map_block(root->fs_info, REQ_OP_DISCARD,
                              bytenr, &num_bytes, &bbio, 0);
        /* Error condition is -ENOMEM */
        if (!ret) {
@@@ -4966,12 -4966,12 +4966,12 @@@ static void wake_all_tickets(struct lis
   */
  static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
  {
-       struct reserve_ticket *last_ticket = NULL;
        struct btrfs_fs_info *fs_info;
        struct btrfs_space_info *space_info;
        u64 to_reclaim;
        int flush_state;
        int commit_cycles = 0;
+       u64 last_tickets_id;
  
        fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work);
        space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
                spin_unlock(&space_info->lock);
                return;
        }
-       last_ticket = list_first_entry(&space_info->tickets,
-                                      struct reserve_ticket, list);
+       last_tickets_id = space_info->tickets_id;
        spin_unlock(&space_info->lock);
  
        flush_state = FLUSH_DELAYED_ITEMS_NR;
                                                              space_info);
                ticket = list_first_entry(&space_info->tickets,
                                          struct reserve_ticket, list);
-               if (last_ticket == ticket) {
+               if (last_tickets_id == space_info->tickets_id) {
                        flush_state++;
                } else {
-                       last_ticket = ticket;
+                       last_tickets_id = space_info->tickets_id;
                        flush_state = FLUSH_DELAYED_ITEMS_NR;
                        if (commit_cycles)
                                commit_cycles--;
@@@ -5384,6 -5383,7 +5383,7 @@@ again
                        list_del_init(&ticket->list);
                        num_bytes -= ticket->bytes;
                        ticket->bytes = 0;
+                       space_info->tickets_id++;
                        wake_up(&ticket->wait);
                } else {
                        ticket->bytes -= num_bytes;
@@@ -5426,6 -5426,7 +5426,7 @@@ again
                        num_bytes -= ticket->bytes;
                        space_info->bytes_may_use += ticket->bytes;
                        ticket->bytes = 0;
+                       space_info->tickets_id++;
                        wake_up(&ticket->wait);
                } else {
                        trace_btrfs_space_reservation(fs_info, "space_info",
@@@ -8216,6 -8217,7 +8217,7 @@@ int btrfs_alloc_logged_file_extent(stru
  {
        int ret;
        struct btrfs_block_group_cache *block_group;
+       struct btrfs_space_info *space_info;
  
        /*
         * Mixed block groups will exclude before processing the log so we only
        if (!block_group)
                return -EINVAL;
  
-       ret = btrfs_add_reserved_bytes(block_group, ins->offset,
-                                      ins->offset, 0);
-       BUG_ON(ret); /* logic error */
+       space_info = block_group->space_info;
+       spin_lock(&space_info->lock);
+       spin_lock(&block_group->lock);
+       space_info->bytes_reserved += ins->offset;
+       block_group->reserved += ins->offset;
+       spin_unlock(&block_group->lock);
+       spin_unlock(&space_info->lock);
        ret = alloc_reserved_file_extent(trans, root, 0, root_objectid,
                                         0, owner, offset, ins, 1);
        btrfs_put_block_group(block_group);