Btrfs: Introduce global metadata reservation
PATCH 8/12 Btrfs: Introduce global metadata reservation
Reserve metadata space for extent tree, checksum tree and root tree
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/ctree.h +1 -7
@@ -682,21 +682,15 @@ struct btrfs_space_info {u64 bytes_reserved;/* total bytes the allocator has reserved for current allocations */ u64 bytes_readonly;/* total bytes that are read only */ -u64 bytes_super;/* total bytes reserved for the super blocks */ -u64 bytes_root;/* the number of bytes needed to commit a -transaction */ +u64 bytes_may_use;/* number of bytes that may be used for delalloc/allocations */ -u64 bytes_delalloc;/* number of bytes currently reserved for -delayed allocation */ u64 disk_used;/* total bytes used on disk */ int full;/* indicates that we cannot allocate any more chunks for this space */ int force_alloc;/* set if we need to force a chunk alloc for this space */ -int force_delalloc;/* make people start doing filemap_flush until -we're under a threshold */ struct list_head list;
fs/btrfs/disk-io.c +29 -31
128 lines not on this page · raw message
fs/btrfs/extent-tree.c +127 -19
203 lines not on this page · raw message
fs/btrfs/inode.c +11 -2
@@ -3885,7 +3885,7 @@ int btrfs_write_inode(struct inode *inodstruct btrfs_trans_handle *trans;int ret =0 ; -if (root->fs_info->btree_inode == inode) +if (BTRFS_I (inode)->dummy_inode)return 0 ;if (wait) {
@@ -3906,10 +3906,19 @@ void btrfs_dirty_inode(struct inode *ino {struct btrfs_root *root =BTRFS_I (inode)->root;struct btrfs_trans_handle *trans; +int ret; + +if (BTRFS_I (inode)->dummy_inode) +return ; trans =btrfs_join_transaction (root,1 );btrfs_set_trans_block_group (trans, inode); -btrfs_update_inode (trans, root, inode); + + ret =btrfs_update_inode (trans, root, inode); +if (ret) +printk (KERN_ERR "btrfs: fail to dirty inode %lu error %d\n" , + inode->i_ino, ret); +btrfs_end_transaction (trans, root); }
Only in 9/fs/btrfs: inode.c.rej
fs/btrfs/ioctl.c +7 -3
@@ -1334,8 +1334,10 @@ static int btrfs_ioctl_defrag(struct fil ret = -EPERM ; goto out; } -btrfs_defrag_root (root,0 ); -btrfs_defrag_root (root->fs_info->extent_root,0 ); + ret =btrfs_defrag_root (root,0 ); +if (ret) + goto out; + ret =btrfs_defrag_root (root->fs_info->extent_root,0 );break ;case S_IFREG :if (!(file->f_mode &FMODE_WRITE )) {
@@ -1365,9 +1367,11 @@ static int btrfs_ioctl_defrag(struct fil/* the rest are all set to zero by kzalloc */ range->len = (u64)-1 ; } -btrfs_defrag_file (file, range); + ret =btrfs_defrag_file (file, range);kfree (range);break ; +default : + ret = -EINVAL ; } out:mnt_drop_write (file->f_path.mnt);
fs/btrfs/transaction.c +58 -12
113 lines not on this page · raw message
Only in 9/fs/btrfs: transaction.c.orig
fs/btrfs/transaction.h +3 -0
@@ -106,6 +106,8 @@ int btrfs_commit_transaction(struct btrf struct btrfs_root *root);int btrfs_end_transaction_throttle (struct btrfs_trans_handle *trans,struct btrfs_root *root); +int btrfs_should_end_transaction (struct btrfs_trans_handle *trans, +struct btrfs_root *root);void btrfs_throttle (struct btrfs_root *root);int btrfs_record_root_in_trans (struct btrfs_trans_handle *trans,struct btrfs_root *root);
@@ -115,5 +117,6 @@ int btrfs_write_marked_extents(struct bt struct extent_io_tree *dirty_pages, int mark);int btrfs_wait_marked_extents (struct btrfs_root *root,struct extent_io_tree *dirty_pages,int mark); +int btrfs_transaction_blocked (struct btrfs_fs_info *info);int btrfs_transaction_in_commit (struct btrfs_fs_info *info);#endif
fs/btrfs/tree-defrag.c +4 -3
@@ -117,13 +117,14 @@ int btrfs_defrag_leaves(struct btrfs_tra path->nodes[1 ],0 , cache_only, &last_ret, &root->defrag_progress); -WARN_ON (ret && ret != -EAGAIN ); +if (ret) { +WARN_ON (ret == -EAGAIN ); + goto out; + }if (next_key_ret ==0 ) {memcpy (&root->defrag_progress, &key,sizeof (key)); ret = -EAGAIN ; } - -btrfs_release_path (root, path); out:if (path)btrfs_free_path (path);