diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-19 22:06:11 -0400 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-25 04:46:04 -0400 |
commit | 581bb050941b4f220f84d3e5ed6dace3d42dd382 (patch) | |
tree | 5ebd56af5eb3612f508419b188dfc18e959e7c94 /fs/btrfs/ctree.h | |
parent | 34d52cb6c50b5a43901709998f59fb1c5a43dc4a (diff) |
Btrfs: Cache free inode numbers in memory
Currently btrfs stores the highest objectid of the fs tree, and it always
returns (highest+1) inode number when we create a file, so inode numbers
won't be reclaimed when we delete files, so we'll run out of inode numbers
as we keep create/delete files in 32bits machines.
This fixes it, and it works similarly to how we cache free space in block
cgroups.
We start a kernel thread to read the file tree. By scanning inode items,
we know which chunks of inode numbers are free, and we cache them in
an rb-tree.
Because we are searching the commit root, we have to carefully handle the
cross-transaction case.
The rb-tree is a hybrid extent+bitmap tree, so if we have too many small
chunks of inode numbers, we'll use bitmaps. Initially we allow 16K ram
of extents, and a bitmap will be used if we exceed this threshold. The
extents threshold is adjusted in runtime.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d17e4a3b8bf7..c96a4e4c5566 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1102,6 +1102,15 @@ struct btrfs_root { | |||
1102 | spinlock_t accounting_lock; | 1102 | spinlock_t accounting_lock; |
1103 | struct btrfs_block_rsv *block_rsv; | 1103 | struct btrfs_block_rsv *block_rsv; |
1104 | 1104 | ||
1105 | /* free ino cache stuff */ | ||
1106 | struct mutex fs_commit_mutex; | ||
1107 | struct btrfs_free_space_ctl *free_ino_ctl; | ||
1108 | enum btrfs_caching_type cached; | ||
1109 | spinlock_t cache_lock; | ||
1110 | wait_queue_head_t cache_wait; | ||
1111 | struct btrfs_free_space_ctl *free_ino_pinned; | ||
1112 | u64 cache_progress; | ||
1113 | |||
1105 | struct mutex log_mutex; | 1114 | struct mutex log_mutex; |
1106 | wait_queue_head_t log_writer_wait; | 1115 | wait_queue_head_t log_writer_wait; |
1107 | wait_queue_head_t log_commit_wait[2]; | 1116 | wait_queue_head_t log_commit_wait[2]; |
@@ -2408,12 +2417,6 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, | |||
2408 | struct btrfs_root *root, u64 offset); | 2417 | struct btrfs_root *root, u64 offset); |
2409 | int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); | 2418 | int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); |
2410 | 2419 | ||
2411 | /* inode-map.c */ | ||
2412 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | ||
2413 | struct btrfs_root *fs_root, | ||
2414 | u64 dirid, u64 *objectid); | ||
2415 | int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid); | ||
2416 | |||
2417 | /* inode-item.c */ | 2420 | /* inode-item.c */ |
2418 | int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, | 2421 | int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, |
2419 | struct btrfs_root *root, | 2422 | struct btrfs_root *root, |