mkfs: change default metadata blocksize to 16KB

16KB is faster and leads to less metadata fragmentation in almost all
workloads.  It does slightly increase lock contention on the root nodes
in some workloads, but that is best dealt with by adding more subvolumes
(for now).

This uses 16KB or the page size, whichever is bigger.  If you're doing a
mixed block group mkfs, it uses the sectorsize instead.

Since the kernel refuses to mount a mixed block group FS where the
metadata leaf size doesn't match the data sectorsize, this also adds a
similar check during mkfs.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
Chris Mason 2013-11-08 13:51:52 -05:00
parent 06ceeb209e
commit c652e4efb8
1 changed files with 18 additions and 1 deletions

19
mkfs.c
View File

@ -46,6 +46,8 @@
static u64 index_cnt = 2; static u64 index_cnt = 2;
#define DEFAULT_MKFS_LEAF_SIZE 16384
struct directory_name_entry { struct directory_name_entry {
char *dir_name; char *dir_name;
char *path; char *path;
@ -1222,7 +1224,7 @@ int main(int ac, char **av)
u64 alloc_start = 0; u64 alloc_start = 0;
u64 metadata_profile = 0; u64 metadata_profile = 0;
u64 data_profile = 0; u64 data_profile = 0;
u32 leafsize = sysconf(_SC_PAGESIZE); u32 leafsize = max_t(u32, sysconf(_SC_PAGESIZE), DEFAULT_MKFS_LEAF_SIZE);
u32 sectorsize = 4096; u32 sectorsize = 4096;
u32 nodesize = leafsize; u32 nodesize = leafsize;
u32 stripesize = 4096; u32 stripesize = 4096;
@ -1232,6 +1234,7 @@ int main(int ac, char **av)
int ret; int ret;
int i; int i;
int mixed = 0; int mixed = 0;
int leaf_forced = 0;
int data_profile_opt = 0; int data_profile_opt = 0;
int metadata_profile_opt = 0; int metadata_profile_opt = 0;
int discard = 1; int discard = 1;
@ -1269,6 +1272,7 @@ int main(int ac, char **av)
case 'n': case 'n':
nodesize = parse_size(optarg); nodesize = parse_size(optarg);
leafsize = parse_size(optarg); leafsize = parse_size(optarg);
leaf_forced = 1;
break; break;
case 'L': case 'L':
label = parse_label(optarg); label = parse_label(optarg);
@ -1386,8 +1390,21 @@ int main(int ac, char **av)
BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */ BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */
} }
} else { } else {
u32 best_leafsize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize);
metadata_profile = 0; metadata_profile = 0;
data_profile = 0; data_profile = 0;
if (!leaf_forced) {
leafsize = best_leafsize;
nodesize = best_leafsize;
if (check_leaf_or_node_size(leafsize, sectorsize))
exit(1);
}
if (leafsize != sectorsize) {
fprintf(stderr, "Error: mixed metadata/data block groups "
"require metadata blocksizes equal to the sectorsize\n");
exit(1);
}
} }
ret = test_num_disk_vs_raid(metadata_profile, data_profile, ret = test_num_disk_vs_raid(metadata_profile, data_profile,