file = av[optind++];
ssd = is_ssd(file);
+ if (is_vol_small(file)) {
+ printf("SMALL VOLUME: forcing mixed metadata/data groups\n");
+ mixed = 1;
+ if (metadata_profile != data_profile) {
+ if (metadata_profile_opt || data_profile_opt) {
+ fprintf(stderr,
+ "With mixed block groups data and metadata profiles must be the same\n");
+ exit(1);
+ }
+ }
+ }
/*
* Set default profiles according to number of added devices.
* For mixed groups defaults are single/single.
BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */
}
} else {
- /* this is not needed but just for completeness */
metadata_profile = 0;
data_profile = 0;
}
}
- if (mixed) {
- if (metadata_profile != data_profile) {
- fprintf(stderr, "With mixed block groups data and metadata "
- "profiles must be the same\n");
- exit(1);
- }
- }
-
blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) {
blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
}
return ret;
}
+
+int is_vol_small(char *file)
+{
+ int fd = -1;
+ int e;
+ struct stat st;
+ u64 size;
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ return -errno;
+ if (fstat(fd, &st) < 0) {
+ e = -errno;
+ close(fd);
+ return e;
+ }
+ size = btrfs_device_size(fd, &st);
+ if (size == 0) {
+ close(fd);
+ return -1;
+ }
+ if (size < 1024 * 1024 * 1024) {
+ close(fd);
+ return 1;
+ } else {
+ close(fd);
+ return 0;
+ }
+}
int get_label_mounted(const char *mount_path, char *labelp);
int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
u64 dev_cnt, int mixed, char *estr);
+int is_vol_small(char *file);
#endif