struct extent_io_tree io_tree;
struct extent_io_tree io_failure_tree;
struct inode vfs_inode;
+ atomic_t ordered_writeback;
u64 ordered_trans;
/*
(start_pos + num_written - 1) >> PAGE_CACHE_SHIFT);
}
current->backing_dev_info = NULL;
+ btrfs_ordered_throttle(root, inode);
return num_written ? num_written : err;
}
inode->i_mapping, GFP_NOFS);
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
return 0;
}
inode->i_mapping, GFP_NOFS);
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->delalloc_bytes = 0;
BTRFS_I(inode)->root = root;
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
BTRFS_I(inode)->delalloc_bytes = 0;
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
}
dir->i_sb->s_dirt = 1;
extent_io_tree_init(&BTRFS_I(inode)->io_failure_tree,
inode->i_mapping, GFP_NOFS);
BTRFS_I(inode)->delalloc_bytes = 0;
+ atomic_set(&BTRFS_I(inode)->ordered_writeback, 0);
BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
}
dir->i_sb->s_dirt = 1;
return ret;
}
+int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode)
+{
+ struct btrfs_transaction *cur = root->fs_info->running_transaction;
+ while(cur == root->fs_info->running_transaction &&
+ atomic_read(&BTRFS_I(inode)->ordered_writeback)) {
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
+ congestion_wait(WRITE, HZ/20);
+#else
+ blk_congestion_wait(WRITE, HZ/20);
+#endif
+ }
+ return 0;
+}
u64 *root_objectid, u64 *objectid,
struct inode **inode);
int btrfs_del_ordered_inode(struct inode *inode);
+int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode);
#endif
mutex_unlock(&root->fs_info->trans_mutex);
mutex_unlock(&root->fs_info->fs_mutex);
- if (S_ISREG(inode->i_mode))
+ if (S_ISREG(inode->i_mode)) {
+ atomic_inc(&BTRFS_I(inode)->ordered_writeback);
filemap_fdatawrite(inode->i_mapping);
+ atomic_dec(&BTRFS_I(inode)->ordered_writeback);
+ }
iput(inode);
mutex_lock(&root->fs_info->fs_mutex);
mutex_unlock(&root->fs_info->trans_mutex);
mutex_unlock(&root->fs_info->fs_mutex);
- if (S_ISREG(inode->i_mode))
+ if (S_ISREG(inode->i_mode)) {
+ atomic_inc(&BTRFS_I(inode)->ordered_writeback);
filemap_write_and_wait(inode->i_mapping);
+ atomic_dec(&BTRFS_I(inode)->ordered_writeback);
+ }
atomic_dec(&inode->i_count);
iput(inode);