diff options
author | Yan Zheng <zheng.yan@oracle.com> | 2008-10-09 11:46:29 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-10-09 11:46:29 -0400 |
commit | a76a3cd40c1127ca199d4f7f37bf0d541bf44eb2 (patch) | |
tree | a91e91d9f67ce8bd314cebdacc458315d3e54275 /fs/btrfs/inode.c | |
parent | a62b940160d8125016e85046e68ae621c99e751f (diff) |
Btrfs: Count space allocated to file in bytes
This patch makes btrfs count space allocated to file in bytes instead
of 512 byte sectors.
Everything else in btrfs uses a byte count instead of sector sizes or
blocks sizes, so this fits better.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ff0c35976657..f9df89c5fdfc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -652,7 +652,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
652 | BUG_ON(ret); | 652 | BUG_ON(ret); |
653 | btrfs_release_path(root, path); | 653 | btrfs_release_path(root, path); |
654 | 654 | ||
655 | inode->i_blocks += ordered_extent->len >> 9; | 655 | inode_add_bytes(inode, ordered_extent->len); |
656 | unlock_extent(io_tree, ordered_extent->file_offset, | 656 | unlock_extent(io_tree, ordered_extent->file_offset, |
657 | ordered_extent->file_offset + ordered_extent->len - 1, | 657 | ordered_extent->file_offset + ordered_extent->len - 1, |
658 | GFP_NOFS); | 658 | GFP_NOFS); |
@@ -1104,7 +1104,7 @@ void btrfs_read_locked_inode(struct inode *inode) | |||
1104 | inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, tspec); | 1104 | inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, tspec); |
1105 | inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, tspec); | 1105 | inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, tspec); |
1106 | 1106 | ||
1107 | inode->i_blocks = btrfs_inode_nblocks(leaf, inode_item); | 1107 | inode_set_bytes(inode, btrfs_inode_nbytes(leaf, inode_item)); |
1108 | BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item); | 1108 | BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item); |
1109 | inode->i_generation = BTRFS_I(inode)->generation; | 1109 | inode->i_generation = BTRFS_I(inode)->generation; |
1110 | inode->i_rdev = 0; | 1110 | inode->i_rdev = 0; |
@@ -1184,7 +1184,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, | |||
1184 | btrfs_set_timespec_nsec(leaf, btrfs_inode_ctime(item), | 1184 | btrfs_set_timespec_nsec(leaf, btrfs_inode_ctime(item), |
1185 | inode->i_ctime.tv_nsec); | 1185 | inode->i_ctime.tv_nsec); |
1186 | 1186 | ||
1187 | btrfs_set_inode_nblocks(leaf, item, inode->i_blocks); | 1187 | btrfs_set_inode_nbytes(leaf, item, inode_get_bytes(inode)); |
1188 | btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)->generation); | 1188 | btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)->generation); |
1189 | btrfs_set_inode_transid(leaf, item, trans->transid); | 1189 | btrfs_set_inode_transid(leaf, item, trans->transid); |
1190 | btrfs_set_inode_rdev(leaf, item, inode->i_rdev); | 1190 | btrfs_set_inode_rdev(leaf, item, inode->i_rdev); |
@@ -1679,7 +1679,7 @@ search_again: | |||
1679 | num_dec = (orig_num_bytes - | 1679 | num_dec = (orig_num_bytes - |
1680 | extent_num_bytes); | 1680 | extent_num_bytes); |
1681 | if (root->ref_cows && extent_start != 0) | 1681 | if (root->ref_cows && extent_start != 0) |
1682 | dec_i_blocks(inode, num_dec); | 1682 | inode_sub_bytes(inode, num_dec); |
1683 | btrfs_mark_buffer_dirty(leaf); | 1683 | btrfs_mark_buffer_dirty(leaf); |
1684 | } else { | 1684 | } else { |
1685 | extent_num_bytes = | 1685 | extent_num_bytes = |
@@ -1690,7 +1690,7 @@ search_again: | |||
1690 | if (extent_start != 0) { | 1690 | if (extent_start != 0) { |
1691 | found_extent = 1; | 1691 | found_extent = 1; |
1692 | if (root->ref_cows) | 1692 | if (root->ref_cows) |
1693 | dec_i_blocks(inode, num_dec); | 1693 | inode_sub_bytes(inode, num_dec); |
1694 | } | 1694 | } |
1695 | root_gen = btrfs_header_generation(leaf); | 1695 | root_gen = btrfs_header_generation(leaf); |
1696 | root_owner = btrfs_header_owner(leaf); | 1696 | root_owner = btrfs_header_owner(leaf); |
@@ -1700,8 +1700,8 @@ search_again: | |||
1700 | u32 size = new_size - found_key.offset; | 1700 | u32 size = new_size - found_key.offset; |
1701 | 1701 | ||
1702 | if (root->ref_cows) { | 1702 | if (root->ref_cows) { |
1703 | dec_i_blocks(inode, item_end + 1 - | 1703 | inode_sub_bytes(inode, item_end + 1 - |
1704 | found_key.offset - size); | 1704 | new_size); |
1705 | } | 1705 | } |
1706 | size = | 1706 | size = |
1707 | btrfs_file_extent_calc_inline_size(size); | 1707 | btrfs_file_extent_calc_inline_size(size); |
@@ -1709,8 +1709,8 @@ search_again: | |||
1709 | size, 1); | 1709 | size, 1); |
1710 | BUG_ON(ret); | 1710 | BUG_ON(ret); |
1711 | } else if (root->ref_cows) { | 1711 | } else if (root->ref_cows) { |
1712 | dec_i_blocks(inode, item_end + 1 - | 1712 | inode_sub_bytes(inode, item_end + 1 - |
1713 | found_key.offset); | 1713 | found_key.offset); |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | delete: | 1716 | delete: |
@@ -2514,7 +2514,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
2514 | inode->i_gid = current->fsgid; | 2514 | inode->i_gid = current->fsgid; |
2515 | inode->i_mode = mode; | 2515 | inode->i_mode = mode; |
2516 | inode->i_ino = objectid; | 2516 | inode->i_ino = objectid; |
2517 | inode->i_blocks = 0; | 2517 | inode_set_bytes(inode, 0); |
2518 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 2518 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
2519 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], | 2519 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], |
2520 | struct btrfs_inode_item); | 2520 | struct btrfs_inode_item); |
@@ -3557,7 +3557,8 @@ static int btrfs_getattr(struct vfsmount *mnt, | |||
3557 | struct inode *inode = dentry->d_inode; | 3557 | struct inode *inode = dentry->d_inode; |
3558 | generic_fillattr(inode, stat); | 3558 | generic_fillattr(inode, stat); |
3559 | stat->blksize = PAGE_CACHE_SIZE; | 3559 | stat->blksize = PAGE_CACHE_SIZE; |
3560 | stat->blocks = inode->i_blocks + (BTRFS_I(inode)->delalloc_bytes >> 9); | 3560 | stat->blocks = (inode_get_bytes(inode) + |
3561 | BTRFS_I(inode)->delalloc_bytes) >> 9; | ||
3561 | return 0; | 3562 | return 0; |
3562 | } | 3563 | } |
3563 | 3564 | ||