2017-10-19 05:41:37 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2021-09-06 14:23:14 +00:00
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 021110-1307, USA.
|
2017-10-19 05:41:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Defines and functions declarations for mkfs --rootdir
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BTRFS_MKFS_ROOTDIR_H__
|
|
|
|
#define __BTRFS_MKFS_ROOTDIR_H__
|
|
|
|
|
2022-09-15 11:59:39 +00:00
|
|
|
#include "kerncompat.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
2017-10-19 05:41:37 +00:00
|
|
|
|
2022-09-15 11:59:39 +00:00
|
|
|
struct btrfs_fs_info;
|
|
|
|
struct btrfs_root;
|
|
|
|
|
2024-08-07 14:55:52 +00:00
|
|
|
struct rootdir_subvol {
|
|
|
|
struct list_head list;
|
|
|
|
char *dir;
|
|
|
|
char *full_path;
|
2024-08-15 14:27:01 +00:00
|
|
|
bool is_default;
|
2024-08-27 10:49:45 +00:00
|
|
|
bool readonly;
|
2024-08-07 14:55:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int btrfs_mkfs_fill_dir(struct btrfs_trans_handle *trans, const char *source_dir,
|
|
|
|
struct btrfs_root *root, struct list_head *subvols);
|
btrfs-progs: mkfs/rootdir: Use over-reserve method to make size estimate easier
Use an easier method to calculate the estimate device size for
mkfs.btrfs --rootdir.
The new method will over-estimate, but should ensure we won't encounter
ENOSPC.
It relies on the following data:
1) number of inodes -- for metadata chunk size
2) rounded up data size of each regular inode -- for data chunk size
Total meta chunk size = round_up(nr_inode * (PATH_MAX * 3 + sectorsize),
min_chunk_size) * profile_multiplier
PATH_MAX is the maximum size possible for INODE_REF/DIR_INDEX/DIR_ITEM.
Sectorsize is the maximum size possible for inline extent.
min_chunk_size is 8M for SINGLE, and 32M for DUP, get from
btrfs_alloc_chunk().
profile_multiplier is 1 for Single, 2 for DUP.
Total data chunk size is much easier.
Total data chunk size = round_up(total_data_usage, min_chunk_size) *
profile_multiplier
Total_data_usage is the sum of *rounded up* size of each regular inode
use.
min_chunk_size is 8M for SINGLE, 64M for DUP, get from btrfS_alloc_chunk().
Same profile_multiplier for meta.
This over-estimate calculate is, of course inacurrate, but since we will
later shrink the fs to its real usage, it doesn't matter much now.
Signed-off-by: Qu Wenruo <wqu@suse.com>
[ update comments ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-19 02:11:07 +00:00
|
|
|
u64 btrfs_mkfs_size_dir(const char *dir_name, u32 sectorsize, u64 min_dev_size,
|
|
|
|
u64 meta_profile, u64 data_profile);
|
2017-10-19 09:13:55 +00:00
|
|
|
int btrfs_mkfs_shrink_fs(struct btrfs_fs_info *fs_info, u64 *new_size_ret,
|
|
|
|
bool shrink_file_size);
|
2017-10-19 05:41:37 +00:00
|
|
|
|
|
|
|
#endif
|