aboutsummaryrefslogtreecommitdiffstats
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)
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 0636f79672e9..8e606e6658aa 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)
678 balance_dirty_pages_ratelimited_nr( 678 balance_dirty_pages_ratelimited_nr(
679 root->fs_info->btree_inode->i_mapping, nr); 679 root->fs_info->btree_inode->i_mapping, nr);
680} 680}
681
682void btrfs_set_buffer_defrag(struct extent_buffer *buf)
683{
684 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
685 struct inode *btree_inode = root->fs_info->btree_inode;
686 set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start,
687 buf->start + buf->len - 1, EXTENT_DEFRAG, GFP_NOFS);
688}
689
690void btrfs_set_buffer_defrag_done(struct extent_buffer *buf)
691{
692 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
693 struct inode *btree_inode = root->fs_info->btree_inode;
694 set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start,
695 buf->start + buf->len - 1, EXTENT_DEFRAG_DONE,
696 GFP_NOFS);
697}
698
699int btrfs_buffer_defrag(struct extent_buffer *buf)
700{
701 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
702 struct inode *btree_inode = root->fs_info->btree_inode;
703 return test_range_bit(&BTRFS_I(btree_inode)->extent_tree,
704 buf->start, buf->start + buf->len - 1, EXTENT_DEFRAG, 0);
705}
706
707int btrfs_buffer_defrag_done(struct extent_buffer *buf)
708{
709 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
710 struct inode *btree_inode = root->fs_info->btree_inode;
711 return test_range_bit(&BTRFS_I(btree_inode)->extent_tree,
712 buf->start, buf->start + buf->len - 1,
713 EXTENT_DEFRAG_DONE, 0);
714}
715
716int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf)
717{
718 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
719 struct inode *btree_inode = root->fs_info->btree_inode;
720 return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree,
721 buf->start, buf->start + buf->len - 1,
722 EXTENT_DEFRAG_DONE, GFP_NOFS);
723}
724
725int btrfs_clear_buffer_defrag(struct extent_buffer *buf)
726{
727 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
728 struct inode *btree_inode = root->fs_info->btree_inode;
729 return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree,
730 buf->start, buf->start + buf->len - 1,
731 EXTENT_DEFRAG, GFP_NOFS);
732}
733
734int btrfs_read_buffer(struct extent_buffer *buf)
735{
736 struct btrfs_root *root = BTRFS_I(buf->pages[0]->mapping->host)->root;
737 struct inode *btree_inode = root->fs_info->btree_inode;
738 return read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree,
739 buf, 1);
740}