aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2009-07-27 13:57:01 -0400
committerChris Mason <chris.mason@oracle.com>2009-07-27 13:57:01 -0400
commit68b38550ddbea13d296184bf69edff387618b1d3 (patch)
treec0c3901b77f273ac08c39c641586884f41a90b84 /fs/btrfs/ctree.h
parent631c07c8d12bcc6ce4a0fbfbd64ea843d78e2b10 (diff)
Btrfs: change how we unpin extents
We are racy with async block caching and unpinning extents. This patch makes things much less complicated by only unpinning the extent if the block group is cached. We check the block_group->cached var under the block_group->lock spin lock. If it is set to BTRFS_CACHE_FINISHED then we update the pinned counters, and unpin the extent and add the free space back. If it is not set to this, we start the caching of the block group so the next time we unpin extents we can unpin the extent. This keeps us from racing with the async caching threads, lets us kill the fs wide async thread counter, and keeps us from having to set DELALLOC bits for every extent we hit if there are caching kthreads going. One thing that needed to be changed was btrfs_free_super_mirror_extents. Now instead of just looking for LOCKED extents, we also look for DIRTY extents, since we could have left some extents pinned in the previous transaction that will never get freed now that we are unmounting, which would cause us to leak memory. So btrfs_free_super_mirror_extents has been changed to btrfs_free_pinned_extents, and it will clear the extents locked for the super mirror, and any remaining pinned extents that may be present. Thank you, Signed-off-by: Josef Bacik <jbacik@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 42b03c4ee494..17ad92c29cfd 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -845,7 +845,6 @@ struct btrfs_fs_info {
845 atomic_t async_submit_draining; 845 atomic_t async_submit_draining;
846 atomic_t nr_async_bios; 846 atomic_t nr_async_bios;
847 atomic_t async_delalloc_pages; 847 atomic_t async_delalloc_pages;
848 atomic_t async_caching_threads;
849 848
850 /* 849 /*
851 * this is used by the balancing code to wait for all the pending 850 * this is used by the balancing code to wait for all the pending
@@ -1926,7 +1925,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
1926 struct btrfs_root *root, unsigned long count); 1925 struct btrfs_root *root, unsigned long count);
1927int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 1926int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
1928int btrfs_update_pinned_extents(struct btrfs_root *root, 1927int btrfs_update_pinned_extents(struct btrfs_root *root,
1929 u64 bytenr, u64 num, int pin, int mark_free); 1928 u64 bytenr, u64 num, int pin);
1930int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, 1929int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
1931 struct btrfs_root *root, struct extent_buffer *leaf); 1930 struct btrfs_root *root, struct extent_buffer *leaf);
1932int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, 1931int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans,
@@ -2011,7 +2010,7 @@ void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode,
2011 u64 bytes); 2010 u64 bytes);
2012void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode, 2011void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,
2013 u64 bytes); 2012 u64 bytes);
2014void btrfs_free_super_mirror_extents(struct btrfs_fs_info *info); 2013void btrfs_free_pinned_extents(struct btrfs_fs_info *info);
2015/* ctree.c */ 2014/* ctree.c */
2016int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, 2015int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
2017 int level, int *slot); 2016 int level, int *slot);