diff options
author | Josef Bacik <jbacik@redhat.com> | 2009-02-20 11:00:09 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-02-20 11:00:09 -0500 |
commit | 6a63209fc02d5483371f07e4913ee8abad608051 (patch) | |
tree | 7595e0df452928b677b66a64baf0cb3b7ec53dfc /fs/btrfs/ctree.h | |
parent | 2cfbd50b536c878e58ab3681c4e944fa3d99b415 (diff) |
Btrfs: add better -ENOSPC handling
This is a step in the direction of better -ENOSPC handling. Instead of
checking the global bytes counter we check the space_info bytes counters to
make sure we have enough space.
If we don't we go ahead and try to allocate a new chunk, and then if that fails
we return -ENOSPC. This patch adds two counters to btrfs_space_info,
bytes_delalloc and bytes_may_use.
bytes_delalloc account for extents we've actually setup for delalloc and will
be allocated at some point down the line.
bytes_may_use is to keep track of how many bytes we may use for delalloc at
some point. When we actually set the extent_bit for the delalloc bytes we
subtract the reserved bytes from the bytes_may_use counter. This keeps us from
not actually being able to allocate space for any delalloc bytes.
Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 766b31ae3186..82491ba8fa40 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -596,13 +596,27 @@ struct btrfs_block_group_item { | |||
596 | 596 | ||
597 | struct btrfs_space_info { | 597 | struct btrfs_space_info { |
598 | u64 flags; | 598 | u64 flags; |
599 | u64 total_bytes; | 599 | |
600 | u64 bytes_used; | 600 | u64 total_bytes; /* total bytes in the space */ |
601 | u64 bytes_pinned; | 601 | u64 bytes_used; /* total bytes used on disk */ |
602 | u64 bytes_reserved; | 602 | u64 bytes_pinned; /* total bytes pinned, will be freed when the |
603 | u64 bytes_readonly; | 603 | transaction finishes */ |
604 | int full; | 604 | u64 bytes_reserved; /* total bytes the allocator has reserved for |
605 | int force_alloc; | 605 | current allocations */ |
606 | u64 bytes_readonly; /* total bytes that are read only */ | ||
607 | |||
608 | /* delalloc accounting */ | ||
609 | u64 bytes_delalloc; /* number of bytes reserved for allocation, | ||
610 | this space is not necessarily reserved yet | ||
611 | by the allocator */ | ||
612 | u64 bytes_may_use; /* number of bytes that may be used for | ||
613 | delalloc */ | ||
614 | |||
615 | int full; /* indicates that we cannot allocate any more | ||
616 | chunks for this space */ | ||
617 | int force_alloc; /* set if we need to force a chunk alloc for | ||
618 | this space */ | ||
619 | |||
606 | struct list_head list; | 620 | struct list_head list; |
607 | 621 | ||
608 | /* for block groups in our same type */ | 622 | /* for block groups in our same type */ |
@@ -1782,6 +1796,16 @@ int btrfs_add_dead_reloc_root(struct btrfs_root *root); | |||
1782 | int btrfs_cleanup_reloc_trees(struct btrfs_root *root); | 1796 | int btrfs_cleanup_reloc_trees(struct btrfs_root *root); |
1783 | int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len); | 1797 | int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len); |
1784 | u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); | 1798 | u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); |
1799 | void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *ionde); | ||
1800 | int btrfs_check_metadata_free_space(struct btrfs_root *root); | ||
1801 | int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode, | ||
1802 | u64 bytes); | ||
1803 | void btrfs_free_reserved_data_space(struct btrfs_root *root, | ||
1804 | struct inode *inode, u64 bytes); | ||
1805 | void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode, | ||
1806 | u64 bytes); | ||
1807 | void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode, | ||
1808 | u64 bytes); | ||
1785 | /* ctree.c */ | 1809 | /* ctree.c */ |
1786 | int btrfs_previous_item(struct btrfs_root *root, | 1810 | int btrfs_previous_item(struct btrfs_root *root, |
1787 | struct btrfs_path *path, u64 min_objectid, | 1811 | struct btrfs_path *path, u64 min_objectid, |
@@ -2027,8 +2051,6 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, | |||
2027 | unsigned long btrfs_force_ra(struct address_space *mapping, | 2051 | unsigned long btrfs_force_ra(struct address_space *mapping, |
2028 | struct file_ra_state *ra, struct file *file, | 2052 | struct file_ra_state *ra, struct file *file, |
2029 | pgoff_t offset, pgoff_t last_index); | 2053 | pgoff_t offset, pgoff_t last_index); |
2030 | int btrfs_check_free_space(struct btrfs_root *root, u64 num_required, | ||
2031 | int for_del); | ||
2032 | int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page); | 2054 | int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page); |
2033 | int btrfs_readpage(struct file *file, struct page *page); | 2055 | int btrfs_readpage(struct file *file, struct page *page); |
2034 | void btrfs_delete_inode(struct inode *inode); | 2056 | void btrfs_delete_inode(struct inode *inode); |