aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2012-09-05 21:10:51 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-01 15:19:15 -0400
commit9e8a4a8b0b9484e8d14674fc62c9ad8ac9dbce5b (patch)
treed1c2cc07c1d016b6d9e8352a41247e1da2778f28 /fs/btrfs/inode.c
parent3d6b5c3b5c0b970ce8a9d3bac6854f5c0ce0295a (diff)
Btrfs: use flag EXTENT_DEFRAG for snapshot-aware defrag
We're going to use this flag EXTENT_DEFRAG to indicate which range belongs to defragment so that we can implement snapshow-aware defrag: We set the EXTENT_DEFRAG flag when dirtying the extents that need defragmented, so later on writeback thread can differentiate between normal writeback and writeback started by defragmentation. Original-Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d34eb329720d..9b21cf97cdd5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3549,7 +3549,8 @@ again:
3549 } 3549 }
3550 3550
3551 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, 3551 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end,
3552 EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, 3552 EXTENT_DIRTY | EXTENT_DELALLOC |
3553 EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
3553 0, 0, &cached_state, GFP_NOFS); 3554 0, 0, &cached_state, GFP_NOFS);
3554 3555
3555 ret = btrfs_set_extent_delalloc(inode, page_start, page_end, 3556 ret = btrfs_set_extent_delalloc(inode, page_start, page_end,
@@ -6061,7 +6062,8 @@ unlock:
6061 if (lockstart < lockend) { 6062 if (lockstart < lockend) {
6062 if (create && len < lockend - lockstart) { 6063 if (create && len < lockend - lockstart) {
6063 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, 6064 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
6064 lockstart + len - 1, unlock_bits, 1, 0, 6065 lockstart + len - 1,
6066 unlock_bits | EXTENT_DEFRAG, 1, 0,
6065 &cached_state, GFP_NOFS); 6067 &cached_state, GFP_NOFS);
6066 /* 6068 /*
6067 * Beside unlock, we also need to cleanup reserved space 6069 * Beside unlock, we also need to cleanup reserved space
@@ -6069,8 +6071,8 @@ unlock:
6069 */ 6071 */
6070 clear_extent_bit(&BTRFS_I(inode)->io_tree, 6072 clear_extent_bit(&BTRFS_I(inode)->io_tree,
6071 lockstart + len, lockend, 6073 lockstart + len, lockend,
6072 unlock_bits | EXTENT_DO_ACCOUNTING, 6074 unlock_bits | EXTENT_DO_ACCOUNTING |
6073 1, 0, NULL, GFP_NOFS); 6075 EXTENT_DEFRAG, 1, 0, NULL, GFP_NOFS);
6074 } else { 6076 } else {
6075 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, 6077 clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
6076 lockend, unlock_bits, 1, 0, 6078 lockend, unlock_bits, 1, 0,
@@ -6635,8 +6637,8 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset)
6635 */ 6637 */
6636 clear_extent_bit(tree, page_start, page_end, 6638 clear_extent_bit(tree, page_start, page_end,
6637 EXTENT_DIRTY | EXTENT_DELALLOC | 6639 EXTENT_DIRTY | EXTENT_DELALLOC |
6638 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING, 1, 0, 6640 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
6639 &cached_state, GFP_NOFS); 6641 EXTENT_DEFRAG, 1, 0, &cached_state, GFP_NOFS);
6640 /* 6642 /*
6641 * whoever cleared the private bit is responsible 6643 * whoever cleared the private bit is responsible
6642 * for the finish_ordered_io 6644 * for the finish_ordered_io
@@ -6652,7 +6654,8 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset)
6652 } 6654 }
6653 clear_extent_bit(tree, page_start, page_end, 6655 clear_extent_bit(tree, page_start, page_end,
6654 EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | 6656 EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC |
6655 EXTENT_DO_ACCOUNTING, 1, 1, &cached_state, GFP_NOFS); 6657 EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
6658 &cached_state, GFP_NOFS);
6656 __btrfs_releasepage(page, GFP_NOFS); 6659 __btrfs_releasepage(page, GFP_NOFS);
6657 6660
6658 ClearPageChecked(page); 6661 ClearPageChecked(page);
@@ -6749,7 +6752,8 @@ again:
6749 * prepare_pages in the normal write path. 6752 * prepare_pages in the normal write path.
6750 */ 6753 */
6751 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, 6754 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end,
6752 EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, 6755 EXTENT_DIRTY | EXTENT_DELALLOC |
6756 EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
6753 0, 0, &cached_state, GFP_NOFS); 6757 0, 0, &cached_state, GFP_NOFS);
6754 6758
6755 ret = btrfs_set_extent_delalloc(inode, page_start, page_end, 6759 ret = btrfs_set_extent_delalloc(inode, page_start, page_end,