]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Jan 2012 01:00:19 +0000 (17:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Jan 2012 01:00:19 +0000 (17:00 -0800)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix reservations in btrfs_page_mkwrite
  Btrfs: advance window_start if we're using a bitmap
  btrfs: mask out gfp flags in releasepage
  Btrfs: fix enospc error caused by wrong checks of the chunk
  Btrfs: do not defrag a file partially
  Btrfs: fix warning for 32-bit build of fs/btrfs/check-integrity.c
  Btrfs: use cluster->window_start when allocating from a cluster bitmap
  Btrfs: Check for NULL page in extent_range_uptodate
  btrfs: Fix busyloops in transaction waiting code
  Btrfs: make sure a bitmap has enough bytes
  Btrfs: fix uninit warning in backref.c

fs/btrfs/backref.c
fs/btrfs/check-integrity.c
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/free-space-cache.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/tree-log.c

index b9a843226de859c34c8e17f9172aeab0ff0f3be1..633c701a287d4be0242d5b1706515aad4845ecfb 100644 (file)
@@ -297,7 +297,7 @@ static int __add_delayed_refs(struct btrfs_delayed_ref_head *head, u64 seq,
        struct btrfs_delayed_extent_op *extent_op = head->extent_op;
        struct rb_node *n = &head->node.rb_node;
        int sgn;
-       int ret;
+       int ret = 0;
 
        if (extent_op && extent_op->update_key)
                btrfs_disk_key_to_cpu(info_key, &extent_op->key);
@@ -392,7 +392,7 @@ static int __add_inline_refs(struct btrfs_fs_info *fs_info,
                             struct btrfs_key *info_key, int *info_level,
                             struct list_head *prefs)
 {
-       int ret;
+       int ret = 0;
        int slot;
        struct extent_buffer *leaf;
        struct btrfs_key key;
index ad0b3ba735b77af069a19d3e1a37b2c8bece96fb..b669a7d8e499433c322d6ef49759f4f95e172743 100644 (file)
@@ -1662,7 +1662,7 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
        block = btrfsic_block_hashtable_lookup(bdev, dev_bytenr,
                                               &state->block_hashtable);
        if (NULL != block) {
-               u64 bytenr;
+               u64 bytenr = 0;
                struct list_head *elem_ref_to;
                struct list_head *tmp_ref_to;
 
@@ -2777,9 +2777,10 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
                        printk(KERN_INFO
                               "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu),"
                               " size=%lu, data=%p, bdev=%p)\n",
-                              rw, bh->b_blocknr,
-                              (unsigned long long)dev_bytenr, bh->b_size,
-                              bh->b_data, bh->b_bdev);
+                              rw, (unsigned long)bh->b_blocknr,
+                              (unsigned long long)dev_bytenr,
+                              (unsigned long)bh->b_size, bh->b_data,
+                              bh->b_bdev);
                btrfsic_process_written_block(dev_state, dev_bytenr,
                                              bh->b_data, bh->b_size, NULL,
                                              NULL, bh, rw);
@@ -2844,7 +2845,7 @@ void btrfsic_submit_bio(int rw, struct bio *bio)
                        printk(KERN_INFO
                               "submit_bio(rw=0x%x, bi_vcnt=%u,"
                               " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n",
-                              rw, bio->bi_vcnt, bio->bi_sector,
+                              rw, bio->bi_vcnt, (unsigned long)bio->bi_sector,
                               (unsigned long long)dev_bytenr,
                               bio->bi_bdev);
 
index 7aa9cd36bf1b496efd2a02e7cc86c1a08a29c663..811d9f918b1c2923c1b35a5ae966808b0e3c2fe6 100644 (file)
@@ -962,6 +962,13 @@ static int btree_releasepage(struct page *page, gfp_t gfp_flags)
        tree = &BTRFS_I(page->mapping->host)->io_tree;
        map = &BTRFS_I(page->mapping->host)->extent_tree;
 
+       /*
+        * We need to mask out eg. __GFP_HIGHMEM and __GFP_DMA32 as we're doing
+        * slab allocation from alloc_extent_state down the callchain where
+        * it'd hit a BUG_ON as those flags are not allowed.
+        */
+       gfp_flags &= ~GFP_SLAB_BUG_MASK;
+
        ret = try_release_extent_state(map, tree, page, gfp_flags);
        if (!ret)
                return 0;
index 700879ed64cfcc73f43f6e03819e579578db1e57..283af7a676a39b4c2f31d7d9b7caf81607eee4ea 100644 (file)
 #include "locking.h"
 #include "free-space-cache.h"
 
-/* control flags for do_chunk_alloc's force field
+/*
+ * control flags for do_chunk_alloc's force field
  * CHUNK_ALLOC_NO_FORCE means to only allocate a chunk
  * if we really need one.
  *
- * CHUNK_ALLOC_FORCE means it must try to allocate one
- *
  * CHUNK_ALLOC_LIMITED means to only try and allocate one
  * if we have very few chunks already allocated.  This is
  * used as part of the clustering code to help make sure
  * we have a good pool of storage to cluster in, without
  * filling the FS with empty chunks
  *
+ * CHUNK_ALLOC_FORCE means it must try to allocate one
+ *
  */
 enum {
        CHUNK_ALLOC_NO_FORCE = 0,
-       CHUNK_ALLOC_FORCE = 1,
-       CHUNK_ALLOC_LIMITED = 2,
+       CHUNK_ALLOC_LIMITED = 1,
+       CHUNK_ALLOC_FORCE = 2,
 };
 
 /*
@@ -3414,7 +3415,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
 
 again:
        spin_lock(&space_info->lock);
-       if (space_info->force_alloc)
+       if (force < space_info->force_alloc)
                force = space_info->force_alloc;
        if (space_info->full) {
                spin_unlock(&space_info->lock);
@@ -5794,6 +5795,7 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
                         u64 search_end, struct btrfs_key *ins,
                         u64 data)
 {
+       bool final_tried = false;
        int ret;
        u64 search_start = 0;
 
@@ -5813,22 +5815,25 @@ again:
                               search_start, search_end, hint_byte,
                               ins, data);
 
-       if (ret == -ENOSPC && num_bytes > min_alloc_size) {
-               num_bytes = num_bytes >> 1;
-               num_bytes = num_bytes & ~(root->sectorsize - 1);
-               num_bytes = max(num_bytes, min_alloc_size);
-               do_chunk_alloc(trans, root->fs_info->extent_root,
-                              num_bytes, data, CHUNK_ALLOC_FORCE);
-               goto again;
-       }
-       if (ret == -ENOSPC && btrfs_test_opt(root, ENOSPC_DEBUG)) {
-               struct btrfs_space_info *sinfo;
-
-               sinfo = __find_space_info(root->fs_info, data);
-               printk(KERN_ERR "btrfs allocation failed flags %llu, "
-                      "wanted %llu\n", (unsigned long long)data,
-                      (unsigned long long)num_bytes);
-               dump_space_info(sinfo, num_bytes, 1);
+       if (ret == -ENOSPC) {
+               if (!final_tried) {
+                       num_bytes = num_bytes >> 1;
+                       num_bytes = num_bytes & ~(root->sectorsize - 1);
+                       num_bytes = max(num_bytes, min_alloc_size);
+                       do_chunk_alloc(trans, root->fs_info->extent_root,
+                                      num_bytes, data, CHUNK_ALLOC_FORCE);
+                       if (num_bytes == min_alloc_size)
+                               final_tried = true;
+                       goto again;
+               } else if (btrfs_test_opt(root, ENOSPC_DEBUG)) {
+                       struct btrfs_space_info *sinfo;
+
+                       sinfo = __find_space_info(root->fs_info, data);
+                       printk(KERN_ERR "btrfs allocation failed flags %llu, "
+                              "wanted %llu\n", (unsigned long long)data,
+                              (unsigned long long)num_bytes);
+                       dump_space_info(sinfo, num_bytes, 1);
+               }
        }
 
        trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset);
index 9d09a4f81875817ebc45a7c5b80cbe6008061b22..fcf77e1ded40e8d47ed8f64742d8139a61295023 100644 (file)
@@ -3909,6 +3909,8 @@ int extent_range_uptodate(struct extent_io_tree *tree,
        while (start <= end) {
                index = start >> PAGE_CACHE_SHIFT;
                page = find_get_page(tree->mapping, index);
+               if (!page)
+                       return 1;
                uptodate = PageUptodate(page);
                page_cache_release(page);
                if (!uptodate) {
index d20ff87ca603bba8255b04a95f34d11bb385ab33..c2f20594c9f74fde7e97cbdf4dea728b9c5a4bd8 100644 (file)
@@ -2242,7 +2242,7 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
                if (entry->bitmap) {
                        ret = btrfs_alloc_from_bitmap(block_group,
                                                      cluster, entry, bytes,
-                                                     min_start);
+                                                     cluster->window_start);
                        if (ret == 0) {
                                node = rb_next(&entry->offset_index);
                                if (!node)
@@ -2251,6 +2251,7 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
                                                 offset_index);
                                continue;
                        }
+                       cluster->window_start += bytes;
                } else {
                        ret = entry->offset;
 
@@ -2475,7 +2476,7 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group,
        }
 
        list_for_each_entry(entry, bitmaps, list) {
-               if (entry->bytes < min_bytes)
+               if (entry->bytes < bytes)
                        continue;
                ret = btrfs_bitmap_cluster(block_group, entry, cluster, offset,
                                           bytes, cont1_bytes, min_bytes);
index 0da19a0ea00d5ac1e854cfe1a861ee828ccca15f..32214fe0f7e32eda73449b0063aecd3874ade562 100644 (file)
@@ -6401,18 +6401,23 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
        unsigned long zero_start;
        loff_t size;
        int ret;
+       int reserved = 0;
        u64 page_start;
        u64 page_end;
 
        ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
-       if (!ret)
+       if (!ret) {
                ret = btrfs_update_time(vma->vm_file);
+               reserved = 1;
+       }
        if (ret) {
                if (ret == -ENOMEM)
                        ret = VM_FAULT_OOM;
                else /* -ENOSPC, -EIO, etc */
                        ret = VM_FAULT_SIGBUS;
-               goto out;
+               if (reserved)
+                       goto out;
+               goto out_noreserve;
        }
 
        ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */
@@ -6495,6 +6500,7 @@ out_unlock:
        unlock_page(page);
 out:
        btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE);
+out_noreserve:
        return ret;
 }
 
index ab620014bcc3a5bd4782f948251bb25a166b6a78..03bb62a9ee24d3e84cef380cda53af10ff673590 100644 (file)
@@ -1065,7 +1065,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
                i = range->start >> PAGE_CACHE_SHIFT;
        }
        if (!max_to_defrag)
-               max_to_defrag = last_index;
+               max_to_defrag = last_index + 1;
 
        /*
         * make writeback starts from i, so the defrag range can be
index cb877e0886a71b80e0f44f60e0d884f57203a597..966cc74f5d6c7303b06bb8bd067826f07510ffc8 100644 (file)
@@ -1957,7 +1957,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans,
 
                finish_wait(&root->log_commit_wait[index], &wait);
                mutex_lock(&root->log_mutex);
-       } while (root->log_transid < transid + 2 &&
+       } while (root->fs_info->last_trans_log_full_commit !=
+                trans->transid && root->log_transid < transid + 2 &&
                 atomic_read(&root->log_commit[index]));
        return 0;
 }
@@ -1966,7 +1967,8 @@ static int wait_for_writer(struct btrfs_trans_handle *trans,
                           struct btrfs_root *root)
 {
        DEFINE_WAIT(wait);
-       while (atomic_read(&root->log_writers)) {
+       while (root->fs_info->last_trans_log_full_commit !=
+              trans->transid && atomic_read(&root->log_writers)) {
                prepare_to_wait(&root->log_writer_wait,
                                &wait, TASK_UNINTERRUPTIBLE);
                mutex_unlock(&root->log_mutex);