diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-17 18:49:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-17 18:49:54 -0500 |
commit | f9156c7288e2d11501ded4d7fe6d9a3a41ee4057 (patch) | |
tree | 7bd26fc9a111c6af1601ecd2d1b0ab60da32f3f0 /fs/btrfs/inode.c | |
parent | 67175b855bfd6ed95ffeff95532173c07de6432d (diff) | |
parent | 96bdc7dc61fb1b1e8e858dafb13abee8482ba064 (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: (62 commits)
Btrfs: use larger system chunks
Btrfs: add a delalloc mutex to inodes for delalloc reservations
Btrfs: space leak tracepoints
Btrfs: protect orphan block rsv with spin_lock
Btrfs: add allocator tracepoints
Btrfs: don't call btrfs_throttle in file write
Btrfs: release space on error in page_mkwrite
Btrfs: fix btrfsck error 400 when truncating a compressed
Btrfs: do not use btrfs_end_transaction_throttle everywhere
Btrfs: add balance progress reporting
Btrfs: allow for resuming restriper after it was paused
Btrfs: allow for canceling restriper
Btrfs: allow for pausing restriper
Btrfs: add skip_balance mount option
Btrfs: recover balance on mount
Btrfs: save balance parameters to disk
Btrfs: soft profile changing mode (aka soft convert)
Btrfs: implement online profile changing
Btrfs: do not reduce profile in do_chunk_alloc()
Btrfs: virtual address space subset filter
...
Fix up trivial conflict in fs/btrfs/ioctl.c due to the use of the new
mnt_drop_write_file() helper.
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 81b235a61f8c..0da19a0ea00d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1951,12 +1951,28 @@ enum btrfs_orphan_cleanup_state { | |||
1951 | void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, | 1951 | void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, |
1952 | struct btrfs_root *root) | 1952 | struct btrfs_root *root) |
1953 | { | 1953 | { |
1954 | struct btrfs_block_rsv *block_rsv; | ||
1954 | int ret; | 1955 | int ret; |
1955 | 1956 | ||
1956 | if (!list_empty(&root->orphan_list) || | 1957 | if (!list_empty(&root->orphan_list) || |
1957 | root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE) | 1958 | root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE) |
1958 | return; | 1959 | return; |
1959 | 1960 | ||
1961 | spin_lock(&root->orphan_lock); | ||
1962 | if (!list_empty(&root->orphan_list)) { | ||
1963 | spin_unlock(&root->orphan_lock); | ||
1964 | return; | ||
1965 | } | ||
1966 | |||
1967 | if (root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE) { | ||
1968 | spin_unlock(&root->orphan_lock); | ||
1969 | return; | ||
1970 | } | ||
1971 | |||
1972 | block_rsv = root->orphan_block_rsv; | ||
1973 | root->orphan_block_rsv = NULL; | ||
1974 | spin_unlock(&root->orphan_lock); | ||
1975 | |||
1960 | if (root->orphan_item_inserted && | 1976 | if (root->orphan_item_inserted && |
1961 | btrfs_root_refs(&root->root_item) > 0) { | 1977 | btrfs_root_refs(&root->root_item) > 0) { |
1962 | ret = btrfs_del_orphan_item(trans, root->fs_info->tree_root, | 1978 | ret = btrfs_del_orphan_item(trans, root->fs_info->tree_root, |
@@ -1965,10 +1981,9 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, | |||
1965 | root->orphan_item_inserted = 0; | 1981 | root->orphan_item_inserted = 0; |
1966 | } | 1982 | } |
1967 | 1983 | ||
1968 | if (root->orphan_block_rsv) { | 1984 | if (block_rsv) { |
1969 | WARN_ON(root->orphan_block_rsv->size > 0); | 1985 | WARN_ON(block_rsv->size > 0); |
1970 | btrfs_free_block_rsv(root, root->orphan_block_rsv); | 1986 | btrfs_free_block_rsv(root, block_rsv); |
1971 | root->orphan_block_rsv = NULL; | ||
1972 | } | 1987 | } |
1973 | } | 1988 | } |
1974 | 1989 | ||
@@ -2224,14 +2239,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) | |||
2224 | continue; | 2239 | continue; |
2225 | } | 2240 | } |
2226 | nr_truncate++; | 2241 | nr_truncate++; |
2227 | /* | ||
2228 | * Need to hold the imutex for reservation purposes, not | ||
2229 | * a huge deal here but I have a WARN_ON in | ||
2230 | * btrfs_delalloc_reserve_space to catch offenders. | ||
2231 | */ | ||
2232 | mutex_lock(&inode->i_mutex); | ||
2233 | ret = btrfs_truncate(inode); | 2242 | ret = btrfs_truncate(inode); |
2234 | mutex_unlock(&inode->i_mutex); | ||
2235 | } else { | 2243 | } else { |
2236 | nr_unlink++; | 2244 | nr_unlink++; |
2237 | } | 2245 | } |
@@ -2845,7 +2853,7 @@ static void __unlink_end_trans(struct btrfs_trans_handle *trans, | |||
2845 | BUG_ON(!root->fs_info->enospc_unlink); | 2853 | BUG_ON(!root->fs_info->enospc_unlink); |
2846 | root->fs_info->enospc_unlink = 0; | 2854 | root->fs_info->enospc_unlink = 0; |
2847 | } | 2855 | } |
2848 | btrfs_end_transaction_throttle(trans, root); | 2856 | btrfs_end_transaction(trans, root); |
2849 | } | 2857 | } |
2850 | 2858 | ||
2851 | static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | 2859 | static int btrfs_unlink(struct inode *dir, struct dentry *dentry) |
@@ -3009,7 +3017,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
3009 | int pending_del_nr = 0; | 3017 | int pending_del_nr = 0; |
3010 | int pending_del_slot = 0; | 3018 | int pending_del_slot = 0; |
3011 | int extent_type = -1; | 3019 | int extent_type = -1; |
3012 | int encoding; | ||
3013 | int ret; | 3020 | int ret; |
3014 | int err = 0; | 3021 | int err = 0; |
3015 | u64 ino = btrfs_ino(inode); | 3022 | u64 ino = btrfs_ino(inode); |
@@ -3059,7 +3066,6 @@ search_again: | |||
3059 | leaf = path->nodes[0]; | 3066 | leaf = path->nodes[0]; |
3060 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | 3067 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); |
3061 | found_type = btrfs_key_type(&found_key); | 3068 | found_type = btrfs_key_type(&found_key); |
3062 | encoding = 0; | ||
3063 | 3069 | ||
3064 | if (found_key.objectid != ino) | 3070 | if (found_key.objectid != ino) |
3065 | break; | 3071 | break; |
@@ -3072,10 +3078,6 @@ search_again: | |||
3072 | fi = btrfs_item_ptr(leaf, path->slots[0], | 3078 | fi = btrfs_item_ptr(leaf, path->slots[0], |
3073 | struct btrfs_file_extent_item); | 3079 | struct btrfs_file_extent_item); |
3074 | extent_type = btrfs_file_extent_type(leaf, fi); | 3080 | extent_type = btrfs_file_extent_type(leaf, fi); |
3075 | encoding = btrfs_file_extent_compression(leaf, fi); | ||
3076 | encoding |= btrfs_file_extent_encryption(leaf, fi); | ||
3077 | encoding |= btrfs_file_extent_other_encoding(leaf, fi); | ||
3078 | |||
3079 | if (extent_type != BTRFS_FILE_EXTENT_INLINE) { | 3081 | if (extent_type != BTRFS_FILE_EXTENT_INLINE) { |
3080 | item_end += | 3082 | item_end += |
3081 | btrfs_file_extent_num_bytes(leaf, fi); | 3083 | btrfs_file_extent_num_bytes(leaf, fi); |
@@ -3103,7 +3105,7 @@ search_again: | |||
3103 | if (extent_type != BTRFS_FILE_EXTENT_INLINE) { | 3105 | if (extent_type != BTRFS_FILE_EXTENT_INLINE) { |
3104 | u64 num_dec; | 3106 | u64 num_dec; |
3105 | extent_start = btrfs_file_extent_disk_bytenr(leaf, fi); | 3107 | extent_start = btrfs_file_extent_disk_bytenr(leaf, fi); |
3106 | if (!del_item && !encoding) { | 3108 | if (!del_item) { |
3107 | u64 orig_num_bytes = | 3109 | u64 orig_num_bytes = |
3108 | btrfs_file_extent_num_bytes(leaf, fi); | 3110 | btrfs_file_extent_num_bytes(leaf, fi); |
3109 | extent_num_bytes = new_size - | 3111 | extent_num_bytes = new_size - |
@@ -3179,7 +3181,7 @@ delete: | |||
3179 | ret = btrfs_free_extent(trans, root, extent_start, | 3181 | ret = btrfs_free_extent(trans, root, extent_start, |
3180 | extent_num_bytes, 0, | 3182 | extent_num_bytes, 0, |
3181 | btrfs_header_owner(leaf), | 3183 | btrfs_header_owner(leaf), |
3182 | ino, extent_offset); | 3184 | ino, extent_offset, 0); |
3183 | BUG_ON(ret); | 3185 | BUG_ON(ret); |
3184 | } | 3186 | } |
3185 | 3187 | ||
@@ -3434,7 +3436,7 @@ static int btrfs_setsize(struct inode *inode, loff_t newsize) | |||
3434 | i_size_write(inode, newsize); | 3436 | i_size_write(inode, newsize); |
3435 | btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL); | 3437 | btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL); |
3436 | ret = btrfs_update_inode(trans, root, inode); | 3438 | ret = btrfs_update_inode(trans, root, inode); |
3437 | btrfs_end_transaction_throttle(trans, root); | 3439 | btrfs_end_transaction(trans, root); |
3438 | } else { | 3440 | } else { |
3439 | 3441 | ||
3440 | /* | 3442 | /* |
@@ -4655,7 +4657,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4655 | } | 4657 | } |
4656 | out_unlock: | 4658 | out_unlock: |
4657 | nr = trans->blocks_used; | 4659 | nr = trans->blocks_used; |
4658 | btrfs_end_transaction_throttle(trans, root); | 4660 | btrfs_end_transaction(trans, root); |
4659 | btrfs_btree_balance_dirty(root, nr); | 4661 | btrfs_btree_balance_dirty(root, nr); |
4660 | if (drop_inode) { | 4662 | if (drop_inode) { |
4661 | inode_dec_link_count(inode); | 4663 | inode_dec_link_count(inode); |
@@ -4723,7 +4725,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4723 | } | 4725 | } |
4724 | out_unlock: | 4726 | out_unlock: |
4725 | nr = trans->blocks_used; | 4727 | nr = trans->blocks_used; |
4726 | btrfs_end_transaction_throttle(trans, root); | 4728 | btrfs_end_transaction(trans, root); |
4727 | if (drop_inode) { | 4729 | if (drop_inode) { |
4728 | inode_dec_link_count(inode); | 4730 | inode_dec_link_count(inode); |
4729 | iput(inode); | 4731 | iput(inode); |
@@ -4782,7 +4784,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
4782 | } | 4784 | } |
4783 | 4785 | ||
4784 | nr = trans->blocks_used; | 4786 | nr = trans->blocks_used; |
4785 | btrfs_end_transaction_throttle(trans, root); | 4787 | btrfs_end_transaction(trans, root); |
4786 | fail: | 4788 | fail: |
4787 | if (drop_inode) { | 4789 | if (drop_inode) { |
4788 | inode_dec_link_count(inode); | 4790 | inode_dec_link_count(inode); |
@@ -4848,7 +4850,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
4848 | 4850 | ||
4849 | out_fail: | 4851 | out_fail: |
4850 | nr = trans->blocks_used; | 4852 | nr = trans->blocks_used; |
4851 | btrfs_end_transaction_throttle(trans, root); | 4853 | btrfs_end_transaction(trans, root); |
4852 | if (drop_on_err) | 4854 | if (drop_on_err) |
4853 | iput(inode); | 4855 | iput(inode); |
4854 | btrfs_btree_balance_dirty(root, nr); | 4856 | btrfs_btree_balance_dirty(root, nr); |
@@ -5121,7 +5123,7 @@ again: | |||
5121 | } | 5123 | } |
5122 | flush_dcache_page(page); | 5124 | flush_dcache_page(page); |
5123 | } else if (create && PageUptodate(page)) { | 5125 | } else if (create && PageUptodate(page)) { |
5124 | WARN_ON(1); | 5126 | BUG(); |
5125 | if (!trans) { | 5127 | if (!trans) { |
5126 | kunmap(page); | 5128 | kunmap(page); |
5127 | free_extent_map(em); | 5129 | free_extent_map(em); |
@@ -6402,10 +6404,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
6402 | u64 page_start; | 6404 | u64 page_start; |
6403 | u64 page_end; | 6405 | u64 page_end; |
6404 | 6406 | ||
6405 | /* Need this to keep space reservations serialized */ | ||
6406 | mutex_lock(&inode->i_mutex); | ||
6407 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); | 6407 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); |
6408 | mutex_unlock(&inode->i_mutex); | ||
6409 | if (!ret) | 6408 | if (!ret) |
6410 | ret = btrfs_update_time(vma->vm_file); | 6409 | ret = btrfs_update_time(vma->vm_file); |
6411 | if (ret) { | 6410 | if (ret) { |
@@ -6494,8 +6493,8 @@ out_unlock: | |||
6494 | if (!ret) | 6493 | if (!ret) |
6495 | return VM_FAULT_LOCKED; | 6494 | return VM_FAULT_LOCKED; |
6496 | unlock_page(page); | 6495 | unlock_page(page); |
6497 | btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); | ||
6498 | out: | 6496 | out: |
6497 | btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); | ||
6499 | return ret; | 6498 | return ret; |
6500 | } | 6499 | } |
6501 | 6500 | ||
@@ -6668,7 +6667,7 @@ end_trans: | |||
6668 | err = ret; | 6667 | err = ret; |
6669 | 6668 | ||
6670 | nr = trans->blocks_used; | 6669 | nr = trans->blocks_used; |
6671 | ret = btrfs_end_transaction_throttle(trans, root); | 6670 | ret = btrfs_end_transaction(trans, root); |
6672 | btrfs_btree_balance_dirty(root, nr); | 6671 | btrfs_btree_balance_dirty(root, nr); |
6673 | } | 6672 | } |
6674 | 6673 | ||
@@ -6749,6 +6748,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
6749 | extent_io_tree_init(&ei->io_tree, &inode->i_data); | 6748 | extent_io_tree_init(&ei->io_tree, &inode->i_data); |
6750 | extent_io_tree_init(&ei->io_failure_tree, &inode->i_data); | 6749 | extent_io_tree_init(&ei->io_failure_tree, &inode->i_data); |
6751 | mutex_init(&ei->log_mutex); | 6750 | mutex_init(&ei->log_mutex); |
6751 | mutex_init(&ei->delalloc_mutex); | ||
6752 | btrfs_ordered_inode_tree_init(&ei->ordered_tree); | 6752 | btrfs_ordered_inode_tree_init(&ei->ordered_tree); |
6753 | INIT_LIST_HEAD(&ei->i_orphan); | 6753 | INIT_LIST_HEAD(&ei->i_orphan); |
6754 | INIT_LIST_HEAD(&ei->delalloc_inodes); | 6754 | INIT_LIST_HEAD(&ei->delalloc_inodes); |
@@ -7074,7 +7074,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
7074 | btrfs_end_log_trans(root); | 7074 | btrfs_end_log_trans(root); |
7075 | } | 7075 | } |
7076 | out_fail: | 7076 | out_fail: |
7077 | btrfs_end_transaction_throttle(trans, root); | 7077 | btrfs_end_transaction(trans, root); |
7078 | out_notrans: | 7078 | out_notrans: |
7079 | if (old_ino == BTRFS_FIRST_FREE_OBJECTID) | 7079 | if (old_ino == BTRFS_FIRST_FREE_OBJECTID) |
7080 | up_read(&root->fs_info->subvol_sem); | 7080 | up_read(&root->fs_info->subvol_sem); |
@@ -7246,7 +7246,7 @@ out_unlock: | |||
7246 | if (!err) | 7246 | if (!err) |
7247 | d_instantiate(dentry, inode); | 7247 | d_instantiate(dentry, inode); |
7248 | nr = trans->blocks_used; | 7248 | nr = trans->blocks_used; |
7249 | btrfs_end_transaction_throttle(trans, root); | 7249 | btrfs_end_transaction(trans, root); |
7250 | if (drop_inode) { | 7250 | if (drop_inode) { |
7251 | inode_dec_link_count(inode); | 7251 | inode_dec_link_count(inode); |
7252 | iput(inode); | 7252 | iput(inode); |