]> git.karo-electronics.de Git - karo-tx-linux.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, 18 Dec 2015 23:35:08 +0000 (15:35 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 18 Dec 2015 23:35:08 +0000 (15:35 -0800)
Pull btrfs fixes from Chris Mason:
 "A couple of small fixes"

* 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: check prepare_uptodate_page() error code earlier
  Btrfs: check for empty bitmap list in setup_cluster_bitmaps
  btrfs: fix misleading warning when space cache failed to load
  Btrfs: fix transaction handle leak in balance
  Btrfs: fix unprotected list move from unused_bgs to deleted_bgs list

1  2 
fs/btrfs/file.c
fs/btrfs/free-space-cache.c
fs/btrfs/volumes.c

diff --combined fs/btrfs/file.c
index 72e73461c0643bbf128504c93a9c47dd377784aa,870150547f5c5968efb1b1532cca8f87310af99a..0f09526aa7d9d2017bb229eb4310f777c4b3b578
@@@ -1291,7 -1291,8 +1291,8 @@@ out
   * on error we return an unlocked page and the error value
   * on success we return a locked page and 0
   */
- static int prepare_uptodate_page(struct page *page, u64 pos,
+ static int prepare_uptodate_page(struct inode *inode,
+                                struct page *page, u64 pos,
                                 bool force_uptodate)
  {
        int ret = 0;
                        unlock_page(page);
                        return -EIO;
                }
+               if (page->mapping != inode->i_mapping) {
+                       unlock_page(page);
+                       return -EAGAIN;
+               }
        }
        return 0;
  }
@@@ -1324,6 -1329,7 +1329,7 @@@ static noinline int prepare_pages(struc
        int faili;
  
        for (i = 0; i < num_pages; i++) {
+ again:
                pages[i] = find_or_create_page(inode->i_mapping, index + i,
                                               mask | __GFP_WRITE);
                if (!pages[i]) {
                }
  
                if (i == 0)
-                       err = prepare_uptodate_page(pages[i], pos,
+                       err = prepare_uptodate_page(inode, pages[i], pos,
                                                    force_uptodate);
-               if (i == num_pages - 1)
-                       err = prepare_uptodate_page(pages[i],
+               if (!err && i == num_pages - 1)
+                       err = prepare_uptodate_page(inode, pages[i],
                                                    pos + write_bytes, false);
                if (err) {
                        page_cache_release(pages[i]);
+                       if (err == -EAGAIN) {
+                               err = 0;
+                               goto again;
+                       }
                        faili = i - 1;
                        goto fail;
                }
@@@ -2667,7 -2677,7 +2677,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
index 85a1f8621b51f09f0893abae9ffab90382efdcfc,f331ef7d573a3c46a86c7cf66068313470eb4a2e..cfe99bec49dedd723e2a7fff04ace299be37ef87
@@@ -85,8 -85,8 +85,8 @@@ static struct inode *__lookup_free_spac
        }
  
        mapping_set_gfp_mask(inode->i_mapping,
 -                      mapping_gfp_mask(inode->i_mapping) &
 -                      ~(__GFP_FS | __GFP_HIGHMEM));
 +                      mapping_gfp_constraint(inode->i_mapping,
 +                      ~(__GFP_FS | __GFP_HIGHMEM)));
  
        return inode;
  }
@@@ -891,7 -891,7 +891,7 @@@ out
                spin_unlock(&block_group->lock);
                ret = 0;
  
-               btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuild it now",
+               btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuilding it now",
                        block_group->key.objectid);
        }
  
@@@ -2972,7 -2972,7 +2972,7 @@@ setup_cluster_bitmap(struct btrfs_block
                     u64 cont1_bytes, u64 min_bytes)
  {
        struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
-       struct btrfs_free_space *entry;
+       struct btrfs_free_space *entry = NULL;
        int ret = -ENOSPC;
        u64 bitmap_offset = offset_to_bitmap(ctl, offset);
  
         * The bitmap that covers offset won't be in the list unless offset
         * is just its start offset.
         */
-       entry = list_first_entry(bitmaps, struct btrfs_free_space, list);
-       if (entry->offset != bitmap_offset) {
+       if (!list_empty(bitmaps))
+               entry = list_first_entry(bitmaps, struct btrfs_free_space, list);
+       if (!entry || entry->offset != bitmap_offset) {
                entry = tree_search_offset(ctl, bitmap_offset, 1, 0);
                if (entry && list_empty(&entry->list))
                        list_add(&entry->list, bitmaps);
diff --combined fs/btrfs/volumes.c
index 45645220660996773b1f76cd1d526d4aeae33dac,86124cde907a8cc695230376e7e50b0bf0f6be1d..a23399e8e3aba2f63d4c0cee90932d073d3bd113
@@@ -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;
  }
@@@ -3548,12 -3548,11 +3548,11 @@@ again
  
                        ret = btrfs_force_chunk_alloc(trans, chunk_root,
                                                      BTRFS_BLOCK_GROUP_DATA);
+                       btrfs_end_transaction(trans, chunk_root);
                        if (ret < 0) {
                                mutex_unlock(&fs_info->delete_unused_bgs_mutex);
                                goto error;
                        }
-                       btrfs_end_transaction(trans, chunk_root);
                        chunk_reserved = 1;
                }