aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-28 20:00:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-28 20:00:19 -0500
commit67d2433ee7aa631bc3ab14c2af6bbc1d44d13a00 (patch)
treeeb29e1489f9f4a99308e08568328de73fb89fc2e /fs
parent1c36ab1a318ab5b3b502e7e4fff3628d1a97861f (diff)
parent9998eb703490589c3e8f1bf09b15203156776edb (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
* '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
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/backref.c4
-rw-r--r--fs/btrfs/check-integrity.c11
-rw-r--r--fs/btrfs/disk-io.c7
-rw-r--r--fs/btrfs/extent-tree.c49
-rw-r--r--fs/btrfs/extent_io.c2
-rw-r--r--fs/btrfs/free-space-cache.c5
-rw-r--r--fs/btrfs/inode.c10
-rw-r--r--fs/btrfs/ioctl.c2
-rw-r--r--fs/btrfs/tree-log.c6
9 files changed, 60 insertions, 36 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index b9a843226de8..633c701a287d 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -297,7 +297,7 @@ static int __add_delayed_refs(struct btrfs_delayed_ref_head *head, u64 seq,
297 struct btrfs_delayed_extent_op *extent_op = head->extent_op; 297 struct btrfs_delayed_extent_op *extent_op = head->extent_op;
298 struct rb_node *n = &head->node.rb_node; 298 struct rb_node *n = &head->node.rb_node;
299 int sgn; 299 int sgn;
300 int ret; 300 int ret = 0;
301 301
302 if (extent_op && extent_op->update_key) 302 if (extent_op && extent_op->update_key)
303 btrfs_disk_key_to_cpu(info_key, &extent_op->key); 303 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,
392 struct btrfs_key *info_key, int *info_level, 392 struct btrfs_key *info_key, int *info_level,
393 struct list_head *prefs) 393 struct list_head *prefs)
394{ 394{
395 int ret; 395 int ret = 0;
396 int slot; 396 int slot;
397 struct extent_buffer *leaf; 397 struct extent_buffer *leaf;
398 struct btrfs_key key; 398 struct btrfs_key key;
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index ad0b3ba735b7..b669a7d8e499 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1662,7 +1662,7 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
1662 block = btrfsic_block_hashtable_lookup(bdev, dev_bytenr, 1662 block = btrfsic_block_hashtable_lookup(bdev, dev_bytenr,
1663 &state->block_hashtable); 1663 &state->block_hashtable);
1664 if (NULL != block) { 1664 if (NULL != block) {
1665 u64 bytenr; 1665 u64 bytenr = 0;
1666 struct list_head *elem_ref_to; 1666 struct list_head *elem_ref_to;
1667 struct list_head *tmp_ref_to; 1667 struct list_head *tmp_ref_to;
1668 1668
@@ -2777,9 +2777,10 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
2777 printk(KERN_INFO 2777 printk(KERN_INFO
2778 "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu)," 2778 "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu),"
2779 " size=%lu, data=%p, bdev=%p)\n", 2779 " size=%lu, data=%p, bdev=%p)\n",
2780 rw, bh->b_blocknr, 2780 rw, (unsigned long)bh->b_blocknr,
2781 (unsigned long long)dev_bytenr, bh->b_size, 2781 (unsigned long long)dev_bytenr,
2782 bh->b_data, bh->b_bdev); 2782 (unsigned long)bh->b_size, bh->b_data,
2783 bh->b_bdev);
2783 btrfsic_process_written_block(dev_state, dev_bytenr, 2784 btrfsic_process_written_block(dev_state, dev_bytenr,
2784 bh->b_data, bh->b_size, NULL, 2785 bh->b_data, bh->b_size, NULL,
2785 NULL, bh, rw); 2786 NULL, bh, rw);
@@ -2844,7 +2845,7 @@ void btrfsic_submit_bio(int rw, struct bio *bio)
2844 printk(KERN_INFO 2845 printk(KERN_INFO
2845 "submit_bio(rw=0x%x, bi_vcnt=%u," 2846 "submit_bio(rw=0x%x, bi_vcnt=%u,"
2846 " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n", 2847 " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n",
2847 rw, bio->bi_vcnt, bio->bi_sector, 2848 rw, bio->bi_vcnt, (unsigned long)bio->bi_sector,
2848 (unsigned long long)dev_bytenr, 2849 (unsigned long long)dev_bytenr,
2849 bio->bi_bdev); 2850 bio->bi_bdev);
2850 2851
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 7aa9cd36bf1b..811d9f918b1c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -962,6 +962,13 @@ static int btree_releasepage(struct page *page, gfp_t gfp_flags)
962 tree = &BTRFS_I(page->mapping->host)->io_tree; 962 tree = &BTRFS_I(page->mapping->host)->io_tree;
963 map = &BTRFS_I(page->mapping->host)->extent_tree; 963 map = &BTRFS_I(page->mapping->host)->extent_tree;
964 964
965 /*
966 * We need to mask out eg. __GFP_HIGHMEM and __GFP_DMA32 as we're doing
967 * slab allocation from alloc_extent_state down the callchain where
968 * it'd hit a BUG_ON as those flags are not allowed.
969 */
970 gfp_flags &= ~GFP_SLAB_BUG_MASK;
971
965 ret = try_release_extent_state(map, tree, page, gfp_flags); 972 ret = try_release_extent_state(map, tree, page, gfp_flags);
966 if (!ret) 973 if (!ret)
967 return 0; 974 return 0;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 700879ed64cf..283af7a676a3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -34,23 +34,24 @@
34#include "locking.h" 34#include "locking.h"
35#include "free-space-cache.h" 35#include "free-space-cache.h"
36 36
37/* control flags for do_chunk_alloc's force field 37/*
38 * control flags for do_chunk_alloc's force field
38 * CHUNK_ALLOC_NO_FORCE means to only allocate a chunk 39 * CHUNK_ALLOC_NO_FORCE means to only allocate a chunk
39 * if we really need one. 40 * if we really need one.
40 * 41 *
41 * CHUNK_ALLOC_FORCE means it must try to allocate one
42 *
43 * CHUNK_ALLOC_LIMITED means to only try and allocate one 42 * CHUNK_ALLOC_LIMITED means to only try and allocate one
44 * if we have very few chunks already allocated. This is 43 * if we have very few chunks already allocated. This is
45 * used as part of the clustering code to help make sure 44 * used as part of the clustering code to help make sure
46 * we have a good pool of storage to cluster in, without 45 * we have a good pool of storage to cluster in, without
47 * filling the FS with empty chunks 46 * filling the FS with empty chunks
48 * 47 *
48 * CHUNK_ALLOC_FORCE means it must try to allocate one
49 *
49 */ 50 */
50enum { 51enum {
51 CHUNK_ALLOC_NO_FORCE = 0, 52 CHUNK_ALLOC_NO_FORCE = 0,
52 CHUNK_ALLOC_FORCE = 1, 53 CHUNK_ALLOC_LIMITED = 1,
53 CHUNK_ALLOC_LIMITED = 2, 54 CHUNK_ALLOC_FORCE = 2,
54}; 55};
55 56
56/* 57/*
@@ -3414,7 +3415,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
3414 3415
3415again: 3416again:
3416 spin_lock(&space_info->lock); 3417 spin_lock(&space_info->lock);
3417 if (space_info->force_alloc) 3418 if (force < space_info->force_alloc)
3418 force = space_info->force_alloc; 3419 force = space_info->force_alloc;
3419 if (space_info->full) { 3420 if (space_info->full) {
3420 spin_unlock(&space_info->lock); 3421 spin_unlock(&space_info->lock);
@@ -5794,6 +5795,7 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
5794 u64 search_end, struct btrfs_key *ins, 5795 u64 search_end, struct btrfs_key *ins,
5795 u64 data) 5796 u64 data)
5796{ 5797{
5798 bool final_tried = false;
5797 int ret; 5799 int ret;
5798 u64 search_start = 0; 5800 u64 search_start = 0;
5799 5801
@@ -5813,22 +5815,25 @@ again:
5813 search_start, search_end, hint_byte, 5815 search_start, search_end, hint_byte,
5814 ins, data); 5816 ins, data);
5815 5817
5816 if (ret == -ENOSPC && num_bytes > min_alloc_size) { 5818 if (ret == -ENOSPC) {
5817 num_bytes = num_bytes >> 1; 5819 if (!final_tried) {
5818 num_bytes = num_bytes & ~(root->sectorsize - 1); 5820 num_bytes = num_bytes >> 1;
5819 num_bytes = max(num_bytes, min_alloc_size); 5821 num_bytes = num_bytes & ~(root->sectorsize - 1);
5820 do_chunk_alloc(trans, root->fs_info->extent_root, 5822 num_bytes = max(num_bytes, min_alloc_size);
5821 num_bytes, data, CHUNK_ALLOC_FORCE); 5823 do_chunk_alloc(trans, root->fs_info->extent_root,
5822 goto again; 5824 num_bytes, data, CHUNK_ALLOC_FORCE);
5823 } 5825 if (num_bytes == min_alloc_size)
5824 if (ret == -ENOSPC && btrfs_test_opt(root, ENOSPC_DEBUG)) { 5826 final_tried = true;
5825 struct btrfs_space_info *sinfo; 5827 goto again;
5826 5828 } else if (btrfs_test_opt(root, ENOSPC_DEBUG)) {
5827 sinfo = __find_space_info(root->fs_info, data); 5829 struct btrfs_space_info *sinfo;
5828 printk(KERN_ERR "btrfs allocation failed flags %llu, " 5830
5829 "wanted %llu\n", (unsigned long long)data, 5831 sinfo = __find_space_info(root->fs_info, data);
5830 (unsigned long long)num_bytes); 5832 printk(KERN_ERR "btrfs allocation failed flags %llu, "
5831 dump_space_info(sinfo, num_bytes, 1); 5833 "wanted %llu\n", (unsigned long long)data,
5834 (unsigned long long)num_bytes);
5835 dump_space_info(sinfo, num_bytes, 1);
5836 }
5832 } 5837 }
5833 5838
5834 trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset); 5839 trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9d09a4f81875..fcf77e1ded40 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3909,6 +3909,8 @@ int extent_range_uptodate(struct extent_io_tree *tree,
3909 while (start <= end) { 3909 while (start <= end) {
3910 index = start >> PAGE_CACHE_SHIFT; 3910 index = start >> PAGE_CACHE_SHIFT;
3911 page = find_get_page(tree->mapping, index); 3911 page = find_get_page(tree->mapping, index);
3912 if (!page)
3913 return 1;
3912 uptodate = PageUptodate(page); 3914 uptodate = PageUptodate(page);
3913 page_cache_release(page); 3915 page_cache_release(page);
3914 if (!uptodate) { 3916 if (!uptodate) {
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index d20ff87ca603..c2f20594c9f7 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2242,7 +2242,7 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
2242 if (entry->bitmap) { 2242 if (entry->bitmap) {
2243 ret = btrfs_alloc_from_bitmap(block_group, 2243 ret = btrfs_alloc_from_bitmap(block_group,
2244 cluster, entry, bytes, 2244 cluster, entry, bytes,
2245 min_start); 2245 cluster->window_start);
2246 if (ret == 0) { 2246 if (ret == 0) {
2247 node = rb_next(&entry->offset_index); 2247 node = rb_next(&entry->offset_index);
2248 if (!node) 2248 if (!node)
@@ -2251,6 +2251,7 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
2251 offset_index); 2251 offset_index);
2252 continue; 2252 continue;
2253 } 2253 }
2254 cluster->window_start += bytes;
2254 } else { 2255 } else {
2255 ret = entry->offset; 2256 ret = entry->offset;
2256 2257
@@ -2475,7 +2476,7 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group,
2475 } 2476 }
2476 2477
2477 list_for_each_entry(entry, bitmaps, list) { 2478 list_for_each_entry(entry, bitmaps, list) {
2478 if (entry->bytes < min_bytes) 2479 if (entry->bytes < bytes)
2479 continue; 2480 continue;
2480 ret = btrfs_bitmap_cluster(block_group, entry, cluster, offset, 2481 ret = btrfs_bitmap_cluster(block_group, entry, cluster, offset,
2481 bytes, cont1_bytes, min_bytes); 2482 bytes, cont1_bytes, min_bytes);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0da19a0ea00d..32214fe0f7e3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6401,18 +6401,23 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
6401 unsigned long zero_start; 6401 unsigned long zero_start;
6402 loff_t size; 6402 loff_t size;
6403 int ret; 6403 int ret;
6404 int reserved = 0;
6404 u64 page_start; 6405 u64 page_start;
6405 u64 page_end; 6406 u64 page_end;
6406 6407
6407 ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); 6408 ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
6408 if (!ret) 6409 if (!ret) {
6409 ret = btrfs_update_time(vma->vm_file); 6410 ret = btrfs_update_time(vma->vm_file);
6411 reserved = 1;
6412 }
6410 if (ret) { 6413 if (ret) {
6411 if (ret == -ENOMEM) 6414 if (ret == -ENOMEM)
6412 ret = VM_FAULT_OOM; 6415 ret = VM_FAULT_OOM;
6413 else /* -ENOSPC, -EIO, etc */ 6416 else /* -ENOSPC, -EIO, etc */
6414 ret = VM_FAULT_SIGBUS; 6417 ret = VM_FAULT_SIGBUS;
6415 goto out; 6418 if (reserved)
6419 goto out;
6420 goto out_noreserve;
6416 } 6421 }
6417 6422
6418 ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */ 6423 ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */
@@ -6495,6 +6500,7 @@ out_unlock:
6495 unlock_page(page); 6500 unlock_page(page);
6496out: 6501out:
6497 btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); 6502 btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE);
6503out_noreserve:
6498 return ret; 6504 return ret;
6499} 6505}
6500 6506
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ab620014bcc3..03bb62a9ee24 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1065,7 +1065,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1065 i = range->start >> PAGE_CACHE_SHIFT; 1065 i = range->start >> PAGE_CACHE_SHIFT;
1066 } 1066 }
1067 if (!max_to_defrag) 1067 if (!max_to_defrag)
1068 max_to_defrag = last_index; 1068 max_to_defrag = last_index + 1;
1069 1069
1070 /* 1070 /*
1071 * make writeback starts from i, so the defrag range can be 1071 * make writeback starts from i, so the defrag range can be
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index cb877e0886a7..966cc74f5d6c 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1957,7 +1957,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans,
1957 1957
1958 finish_wait(&root->log_commit_wait[index], &wait); 1958 finish_wait(&root->log_commit_wait[index], &wait);
1959 mutex_lock(&root->log_mutex); 1959 mutex_lock(&root->log_mutex);
1960 } while (root->log_transid < transid + 2 && 1960 } while (root->fs_info->last_trans_log_full_commit !=
1961 trans->transid && root->log_transid < transid + 2 &&
1961 atomic_read(&root->log_commit[index])); 1962 atomic_read(&root->log_commit[index]));
1962 return 0; 1963 return 0;
1963} 1964}
@@ -1966,7 +1967,8 @@ static int wait_for_writer(struct btrfs_trans_handle *trans,
1966 struct btrfs_root *root) 1967 struct btrfs_root *root)
1967{ 1968{
1968 DEFINE_WAIT(wait); 1969 DEFINE_WAIT(wait);
1969 while (atomic_read(&root->log_writers)) { 1970 while (root->fs_info->last_trans_log_full_commit !=
1971 trans->transid && atomic_read(&root->log_writers)) {
1970 prepare_to_wait(&root->log_writer_wait, 1972 prepare_to_wait(&root->log_writer_wait,
1971 &wait, TASK_UNINTERRUPTIBLE); 1973 &wait, TASK_UNINTERRUPTIBLE);
1972 mutex_unlock(&root->log_mutex); 1974 mutex_unlock(&root->log_mutex);