2013-04-04 13:57:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 Oracle. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License v2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 021110-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2015-01-21 16:49:26 +00:00
|
|
|
#ifndef __BTRFS_FREE_SPACE_CACHE_H__
|
|
|
|
#define __BTRFS_FREE_SPACE_CACHE_H__
|
2013-04-04 13:57:50 +00:00
|
|
|
|
2015-06-10 00:21:42 +00:00
|
|
|
#include "kerncompat.h"
|
|
|
|
#include "ctree.h"
|
2019-06-20 13:30:57 +00:00
|
|
|
#include "kernel-lib/rbtree.h"
|
2015-06-10 00:21:42 +00:00
|
|
|
|
2013-04-04 13:57:50 +00:00
|
|
|
struct btrfs_free_space {
|
|
|
|
struct rb_node offset_index;
|
|
|
|
u64 offset;
|
|
|
|
u64 bytes;
|
|
|
|
unsigned long *bitmap;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btrfs_free_space_ctl {
|
|
|
|
struct rb_root free_space_offset;
|
|
|
|
u64 free_space;
|
|
|
|
int extents_thresh;
|
|
|
|
int free_extents;
|
|
|
|
int total_bitmaps;
|
|
|
|
int unit;
|
|
|
|
u64 start;
|
|
|
|
void *private;
|
2014-05-28 09:25:24 +00:00
|
|
|
u32 sectorsize;
|
2013-04-04 13:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int load_free_space_cache(struct btrfs_fs_info *fs_info,
|
2020-05-01 06:52:19 +00:00
|
|
|
struct btrfs_block_group *block_group);
|
2013-04-04 13:57:50 +00:00
|
|
|
|
|
|
|
void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl);
|
2020-05-01 06:52:19 +00:00
|
|
|
void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group);
|
|
|
|
void btrfs_dump_free_space(struct btrfs_block_group *block_group, u64 bytes);
|
2013-04-04 13:57:50 +00:00
|
|
|
struct btrfs_free_space *
|
|
|
|
btrfs_find_free_space(struct btrfs_free_space_ctl *ctl, u64 offset, u64 bytes);
|
2020-05-01 06:52:19 +00:00
|
|
|
int btrfs_init_free_space_ctl(struct btrfs_block_group *block_group,
|
2013-04-04 13:57:50 +00:00
|
|
|
int sectorsize);
|
|
|
|
void unlink_free_space(struct btrfs_free_space_ctl *ctl,
|
|
|
|
struct btrfs_free_space *info);
|
2015-09-30 03:51:45 +00:00
|
|
|
int btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, u64 offset,
|
|
|
|
u64 bytes);
|
2016-10-13 09:22:26 +00:00
|
|
|
int btrfs_clear_free_space_cache(struct btrfs_fs_info *fs_info,
|
2020-05-01 06:52:19 +00:00
|
|
|
struct btrfs_block_group *bg);
|
2013-04-04 13:57:50 +00:00
|
|
|
#endif
|