summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:17:34 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit6b80053d02be41886344b5007d04e345311ec0b5 (patch)
treec935b3f2f4a582697167c52f57b0985137a95206 /fs/btrfs/disk-io.c
parent09e71a326341f40111400c88aaf0498ef622824b (diff)
downloadop-kernel-dev-6b80053d02be41886344b5007d04e345311ec0b5.zip
op-kernel-dev-6b80053d02be41886344b5007d04e345311ec0b5.tar.gz
Btrfs: Add back the online defragging code
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0636f79..8e606e6 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -678,3 +678,63 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
balance_dirty_pages_ratelimited_nr(
root->fs_info->btree_inode->i_mapping, nr);
}
+
+void btrfs_set_buffer_defrag(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start,
+ buf->start + buf->len - 1, EXTENT_DEFRAG, GFP_NOFS);
+}
+
+void btrfs_set_buffer_defrag_done(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start,
+ buf->start + buf->len - 1, EXTENT_DEFRAG_DONE,
+ GFP_NOFS);
+}
+
+int btrfs_buffer_defrag(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ return test_range_bit(&BTRFS_I(btree_inode)->extent_tree,
+ buf->start, buf->start + buf->len - 1, EXTENT_DEFRAG, 0);
+}
+
+int btrfs_buffer_defrag_done(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ return test_range_bit(&BTRFS_I(btree_inode)->extent_tree,
+ buf->start, buf->start + buf->len - 1,
+ EXTENT_DEFRAG_DONE, 0);
+}
+
+int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree,
+ buf->start, buf->start + buf->len - 1,
+ EXTENT_DEFRAG_DONE, GFP_NOFS);
+}
+
+int btrfs_clear_buffer_defrag(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree,
+ buf->start, buf->start + buf->len - 1,
+ EXTENT_DEFRAG, GFP_NOFS);
+}
+
+int btrfs_read_buffer(struct extent_buffer *buf)
+{
+ struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+ return read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree,
+ buf, 1);
+}
OpenPOWER on IntegriCloud