aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-09 16:07:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-09 16:07:40 -0400
commit983a5f84a4a11c8706ca70615125db711336b684 (patch)
treebbf16b836903aaf523e7c637a0d7191ba8fa172d /fs/btrfs/file.c
parent8769e078a9a2bce13d39c08e0e5a513f5320e1de (diff)
parent667e7d94a1683661cff5fe9a0fa0d7f8fdd2c007 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs update from Chris Mason: "These are mostly fixes. The biggest exceptions are Josef's skinny extents and Jan Schmidt's code to rebuild our quota indexes if they get out of sync (or you enable quotas on an existing filesystem). The skinny extents are off by default because they are a new variation on the extent allocation tree format. btrfstune -x enables them, and the new format makes the extent allocation tree about 30% smaller. I rebased this a few days ago to rework Dave Sterba's crc checks on the super block, but almost all of these go back to rc6, since I though 3.9 was due any minute. The biggest missing fix is the tracepoint bug that was hit late in 3.9. I ran into problems with that in overnight testing and I'm still tracking it down. I'll definitely have that fixed for rc2." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (101 commits) Btrfs: allow superblock mismatch from older mkfs btrfs: enhance superblock checks btrfs: fix misleading variable name for flags btrfs: use unsigned long type for extent state bits Btrfs: improve the loop of scrub_stripe btrfs: read entire device info under lock btrfs: remove unused gfp mask parameter from release_extent_buffer callchain btrfs: handle errors returned from get_tree_block_key btrfs: make static code static & remove dead code Btrfs: deal with errors in write_dev_supers Btrfs: remove almost all of the BUG()'s from tree-log.c Btrfs: deal with free space cache errors while replaying log Btrfs: automatic rescan after "quota enable" command Btrfs: rescan for qgroups Btrfs: split btrfs_qgroup_account_ref into four functions Btrfs: allocate new chunks if the space is not enough for global rsv Btrfs: separate sequence numbers for delayed ref tracking and tree mod log btrfs: move leak debug code to functions Btrfs: return free space in cow error path Btrfs: set UUID in root_item for created trees ...
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index bc4d54c465a0..4205ba752d40 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -193,8 +193,8 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
193 * the same inode in the tree, we will merge them together (by 193 * the same inode in the tree, we will merge them together (by
194 * __btrfs_add_inode_defrag()) and free the one that we want to requeue. 194 * __btrfs_add_inode_defrag()) and free the one that we want to requeue.
195 */ 195 */
196void btrfs_requeue_inode_defrag(struct inode *inode, 196static void btrfs_requeue_inode_defrag(struct inode *inode,
197 struct inode_defrag *defrag) 197 struct inode_defrag *defrag)
198{ 198{
199 struct btrfs_root *root = BTRFS_I(inode)->root; 199 struct btrfs_root *root = BTRFS_I(inode)->root;
200 int ret; 200 int ret;
@@ -474,7 +474,7 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
474/* 474/*
475 * unlocks pages after btrfs_file_write is done with them 475 * unlocks pages after btrfs_file_write is done with them
476 */ 476 */
477void btrfs_drop_pages(struct page **pages, size_t num_pages) 477static void btrfs_drop_pages(struct page **pages, size_t num_pages)
478{ 478{
479 size_t i; 479 size_t i;
480 for (i = 0; i < num_pages; i++) { 480 for (i = 0; i < num_pages; i++) {
@@ -498,9 +498,9 @@ void btrfs_drop_pages(struct page **pages, size_t num_pages)
498 * doing real data extents, marking pages dirty and delalloc as required. 498 * doing real data extents, marking pages dirty and delalloc as required.
499 */ 499 */
500int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode, 500int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode,
501 struct page **pages, size_t num_pages, 501 struct page **pages, size_t num_pages,
502 loff_t pos, size_t write_bytes, 502 loff_t pos, size_t write_bytes,
503 struct extent_state **cached) 503 struct extent_state **cached)
504{ 504{
505 int err = 0; 505 int err = 0;
506 int i; 506 int i;
@@ -553,6 +553,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
553 int testend = 1; 553 int testend = 1;
554 unsigned long flags; 554 unsigned long flags;
555 int compressed = 0; 555 int compressed = 0;
556 bool modified;
556 557
557 WARN_ON(end < start); 558 WARN_ON(end < start);
558 if (end == (u64)-1) { 559 if (end == (u64)-1) {
@@ -562,6 +563,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
562 while (1) { 563 while (1) {
563 int no_splits = 0; 564 int no_splits = 0;
564 565
566 modified = false;
565 if (!split) 567 if (!split)
566 split = alloc_extent_map(); 568 split = alloc_extent_map();
567 if (!split2) 569 if (!split2)
@@ -593,6 +595,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
593 compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags); 595 compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags);
594 clear_bit(EXTENT_FLAG_PINNED, &em->flags); 596 clear_bit(EXTENT_FLAG_PINNED, &em->flags);
595 clear_bit(EXTENT_FLAG_LOGGING, &flags); 597 clear_bit(EXTENT_FLAG_LOGGING, &flags);
598 modified = !list_empty(&em->list);
596 remove_extent_mapping(em_tree, em); 599 remove_extent_mapping(em_tree, em);
597 if (no_splits) 600 if (no_splits)
598 goto next; 601 goto next;
@@ -608,15 +611,15 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
608 split->block_len = em->block_len; 611 split->block_len = em->block_len;
609 else 612 else
610 split->block_len = split->len; 613 split->block_len = split->len;
614 split->ram_bytes = em->ram_bytes;
611 split->orig_block_len = max(split->block_len, 615 split->orig_block_len = max(split->block_len,
612 em->orig_block_len); 616 em->orig_block_len);
613 split->generation = gen; 617 split->generation = gen;
614 split->bdev = em->bdev; 618 split->bdev = em->bdev;
615 split->flags = flags; 619 split->flags = flags;
616 split->compress_type = em->compress_type; 620 split->compress_type = em->compress_type;
617 ret = add_extent_mapping(em_tree, split); 621 ret = add_extent_mapping(em_tree, split, modified);
618 BUG_ON(ret); /* Logic error */ 622 BUG_ON(ret); /* Logic error */
619 list_move(&split->list, &em_tree->modified_extents);
620 free_extent_map(split); 623 free_extent_map(split);
621 split = split2; 624 split = split2;
622 split2 = NULL; 625 split2 = NULL;
@@ -633,6 +636,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
633 split->generation = gen; 636 split->generation = gen;
634 split->orig_block_len = max(em->block_len, 637 split->orig_block_len = max(em->block_len,
635 em->orig_block_len); 638 em->orig_block_len);
639 split->ram_bytes = em->ram_bytes;
636 640
637 if (compressed) { 641 if (compressed) {
638 split->block_len = em->block_len; 642 split->block_len = em->block_len;
@@ -644,9 +648,8 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
644 split->orig_start = em->orig_start; 648 split->orig_start = em->orig_start;
645 } 649 }
646 650
647 ret = add_extent_mapping(em_tree, split); 651 ret = add_extent_mapping(em_tree, split, modified);
648 BUG_ON(ret); /* Logic error */ 652 BUG_ON(ret); /* Logic error */
649 list_move(&split->list, &em_tree->modified_extents);
650 free_extent_map(split); 653 free_extent_map(split);
651 split = NULL; 654 split = NULL;
652 } 655 }
@@ -822,7 +825,7 @@ next_slot:
822 825
823 memcpy(&new_key, &key, sizeof(new_key)); 826 memcpy(&new_key, &key, sizeof(new_key));
824 new_key.offset = end; 827 new_key.offset = end;
825 btrfs_set_item_key_safe(trans, root, path, &new_key); 828 btrfs_set_item_key_safe(root, path, &new_key);
826 829
827 extent_offset += end - key.offset; 830 extent_offset += end - key.offset;
828 btrfs_set_file_extent_offset(leaf, fi, extent_offset); 831 btrfs_set_file_extent_offset(leaf, fi, extent_offset);
@@ -1038,7 +1041,7 @@ again:
1038 ino, bytenr, orig_offset, 1041 ino, bytenr, orig_offset,
1039 &other_start, &other_end)) { 1042 &other_start, &other_end)) {
1040 new_key.offset = end; 1043 new_key.offset = end;
1041 btrfs_set_item_key_safe(trans, root, path, &new_key); 1044 btrfs_set_item_key_safe(root, path, &new_key);
1042 fi = btrfs_item_ptr(leaf, path->slots[0], 1045 fi = btrfs_item_ptr(leaf, path->slots[0],
1043 struct btrfs_file_extent_item); 1046 struct btrfs_file_extent_item);
1044 btrfs_set_file_extent_generation(leaf, fi, 1047 btrfs_set_file_extent_generation(leaf, fi,
@@ -1072,7 +1075,7 @@ again:
1072 trans->transid); 1075 trans->transid);
1073 path->slots[0]++; 1076 path->slots[0]++;
1074 new_key.offset = start; 1077 new_key.offset = start;
1075 btrfs_set_item_key_safe(trans, root, path, &new_key); 1078 btrfs_set_item_key_safe(root, path, &new_key);
1076 1079
1077 fi = btrfs_item_ptr(leaf, path->slots[0], 1080 fi = btrfs_item_ptr(leaf, path->slots[0],
1078 struct btrfs_file_extent_item); 1081 struct btrfs_file_extent_item);
@@ -1883,7 +1886,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
1883 1886
1884 path->slots[0]++; 1887 path->slots[0]++;
1885 key.offset = offset; 1888 key.offset = offset;
1886 btrfs_set_item_key_safe(trans, root, path, &key); 1889 btrfs_set_item_key_safe(root, path, &key);
1887 fi = btrfs_item_ptr(leaf, path->slots[0], 1890 fi = btrfs_item_ptr(leaf, path->slots[0],
1888 struct btrfs_file_extent_item); 1891 struct btrfs_file_extent_item);
1889 num_bytes = btrfs_file_extent_num_bytes(leaf, fi) + end - 1892 num_bytes = btrfs_file_extent_num_bytes(leaf, fi) + end -
@@ -1913,6 +1916,7 @@ out:
1913 } else { 1916 } else {
1914 hole_em->start = offset; 1917 hole_em->start = offset;
1915 hole_em->len = end - offset; 1918 hole_em->len = end - offset;
1919 hole_em->ram_bytes = hole_em->len;
1916 hole_em->orig_start = offset; 1920 hole_em->orig_start = offset;
1917 1921
1918 hole_em->block_start = EXTENT_MAP_HOLE; 1922 hole_em->block_start = EXTENT_MAP_HOLE;
@@ -1925,10 +1929,7 @@ out:
1925 do { 1929 do {
1926 btrfs_drop_extent_cache(inode, offset, end - 1, 0); 1930 btrfs_drop_extent_cache(inode, offset, end - 1, 0);
1927 write_lock(&em_tree->lock); 1931 write_lock(&em_tree->lock);
1928 ret = add_extent_mapping(em_tree, hole_em); 1932 ret = add_extent_mapping(em_tree, hole_em, 1);
1929 if (!ret)
1930 list_move(&hole_em->list,
1931 &em_tree->modified_extents);
1932 write_unlock(&em_tree->lock); 1933 write_unlock(&em_tree->lock);
1933 } while (ret == -EEXIST); 1934 } while (ret == -EEXIST);
1934 free_extent_map(hole_em); 1935 free_extent_map(hole_em);