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>
2011-04-20 09:06:11 +07:00
|
|
|
#ifndef __BTRFS_INODE_MAP
|
|
|
|
#define __BTRFS_INODE_MAP
|
|
|
|
|
|
|
|
void btrfs_init_free_ino_ctl(struct btrfs_root *root);
|
|
|
|
void btrfs_unpin_free_ino(struct btrfs_root *root);
|
|
|
|
void btrfs_return_ino(struct btrfs_root *root, u64 objectid);
|
|
|
|
int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid);
|
2011-04-20 09:33:24 +07:00
|
|
|
int btrfs_save_ino_cache(struct btrfs_root *root,
|
|
|
|
struct btrfs_trans_handle *trans);
|
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>
2011-04-20 09:06:11 +07:00
|
|
|
|
|
|
|
int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid);
|
|
|
|
|
|
|
|
#endif
|