static int _crypt_set_data_device(struct crypt_device *cd, const char *device)
{
	struct device *dev = NULL;
	int r;

	r = device_alloc(cd, &dev, device);
	if (r < 0)
		return r;

	if (!cd->metadata_device) {
		cd->metadata_device = cd->device;
	} else
		device_free(cd, cd->device);

	cd->device = dev;

	r = crypt_check_data_device_size(cd);
	if (!r && isLUKS2(cd->type))
		device_set_block_size(crypt_data_device(cd), LUKS2_get_sector_size(&cd->u.luks2.hdr));

	return r;
}
static int _crypt_set_data_device(struct crypt_device *cd, const char *device)
{
	struct device *dev = NULL;
	int r;

	r = device_alloc(cd, &dev, device);
	if (r < 0)
		return r;

	if (!cd->metadata_device) {
		cd->metadata_device = cd->device;
	} else
		device_free(cd, cd->device);

	cd->device = dev;

	r = crypt_check_data_device_size(cd);
	if (!r && isLUKS2(cd->type))
		device_set_block_size(crypt_data_device(cd), LUKS2_get_sector_size(&cd->u.luks2.hdr));

	return r;
}