Btrfs: implement memory reclaim for leaf reference cache

The memory reclaiming issue happens when snapshot exists. In that
case, some cache entries may not be used during old snapshot dropping,
so they will remain in the cache until umount.

The patch adds a field to struct btrfs_leaf_ref to record create time. Besides,
the patch makes all dead roots of a given snapshot linked together in order of
create time. After a old snapshot was completely dropped, we check the dead
root list and remove all cache entries created before the oldest dead root in
the list.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Yan
2008-07-30 16:29:20 -04:00
committed by Chris Mason
parent 33958dc6d3
commit bcc63abbf3
15 changed files with 86 additions and 69 deletions

View File

@ -666,7 +666,8 @@ struct btrfs_root {
/* the dirty list is only used by non-reference counted roots */
struct list_head dirty_list;
spinlock_t orphan_lock;
spinlock_t list_lock;
struct list_head dead_list;
struct list_head orphan_list;
};