Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 115875 | Differences between
and this patch

Collapse All | Expand All

(-)evms-2.5.4/doc/evms.conf (+19 lines)
Lines 251-253 lvm2 { Link Here
251
	device_size_prompt = yes
251
	device_size_prompt = yes
252
}
252
}
253
253
254
# User devmapper section
255
# This allows us to use a device-mapper device directly as a disk
256
# without the need for loopback
257
# Be careful not to specify any targets that are created by evms
258
# This can be useful for any devices created via dmraid or other means
259
260
# In order for this to work "dm*" has to be in the list of includes
261
262
devmapper {
263
	# This needs to be set to yes to enable
264
	#dm_user = yes
265
	
266
	# List of targets to discover as disks
267
	# These are the target names as seen with "dmsetup ls"
268
	# only specific targets can be used
269
	# we need to avoid evms created targets
270
	#dm_user_targets = [ raid1_device raid0_device ]
271
}
272
(-)evms-2.5.4/engine/dm-targets.c (-8 / +39 lines)
Lines 800-827 static int mirror_build_params(dm_target Link Here
800
 * Fill in a mirror target structure based on an ASCII table string of the form:
800
 * Fill in a mirror target structure based on an ASCII table string of the form:
801
 *   <log_type> <num_log_params> [<log_params>]* <num_mirrors> [<major>:<minor> <start_lba>]{2,}
801
 *   <log_type> <num_log_params> [<log_params>]* <num_mirrors> [<major>:<minor> <start_lba>]{2,}
802
 *
802
 *
803
 * Currently, log_type will always be "core", num_log_params is 1, and
803
 * Currently, log_type will always be "core", num_log_params is 1 or 2, and
804
 * log_params is chunk-size (in sectors).
804
 * log_params is chunk-size (in sectors).
805
 **/
805
 **/
806
static int mirror_translate_params(dm_target_t *target)
806
static int mirror_translate_params(dm_target_t *target)
807
{
807
{
808
	dm_target_mirror_t *mirror = target->data.mirror;
808
	dm_target_mirror_t *mirror = target->data.mirror;
809
	char *params = target->params;
809
	char *params = target->params;
810
	int i, rc;
810
	int i, rc, num_opts;
811
811
812
	LOG_PROC_ENTRY();
812
	LOG_PROC_ENTRY();
813
813
814
	/* Skip "core 1" at the start of the string. */
814
	/* Skip "core" at the start of the string. */
815
	params = next_token(params);
816
	params = next_token(params);
815
	params = next_token(params);
817
816
818
	rc = sscanf(params, "%u %u", &mirror->chunk_size, &mirror->num_mirrors);
817
	/* get the number of options for core and the chunk size */
818
	rc = sscanf(params, "%u %u", &num_opts, &mirror->chunk_size);
819
	if (rc != 2) {
819
	if (rc != 2) {
820
		rc = EINVAL;
820
		rc = EINVAL;
821
		goto out;
821
		goto out;
822
	}
822
	}
823
824
	params = next_token(params);
823
	params = next_token(params);
824
825
	/* skip the options for core based on num_opts */
826
	for (i = 0; i < num_opts; i++) {
827
		params = next_token(params);
828
	}
829
830
	/* get the number of mirrors */
831
	rc = sscanf(params, "%u", &mirror->num_mirrors);
832
	if (rc != 1) {
833
		rc = EINVAL;
834
		goto out;
835
	}
825
	params = next_token(params);
836
	params = next_token(params);
826
837
827
	for (i = 0; i < mirror->num_mirrors; i++) {
838
	for (i = 0; i < mirror->num_mirrors; i++) {
Lines 855-867 out: Link Here
855
static int mirror_pretranslate_params(char *params, u_int32_t *num_devs,
866
static int mirror_pretranslate_params(char *params, u_int32_t *num_devs,
856
				      u_int32_t *num_groups)
867
				      u_int32_t *num_groups)
857
{
868
{
858
	int rc;
869
	int rc, i, num_opts = 0;
870
	char *num_devs_point;
859
871
860
	LOG_PROC_ENTRY();
872
	LOG_PROC_ENTRY();
861
873
862
	rc = sscanf(params, "%*s %*d %*u %u", num_devs);
874
	/* The mirror target can have more than 1 option
875
	this affects the location of the number of member disks */
876
877
	rc = sscanf(params, "%*s %u", &num_opts);
878
	if (rc != 1) {
879
		rc = EINVAL;
880
		goto out;
881
	}
882
883
	/* skip "core <num_opts>" */
884
	num_devs_point = next_token(params);
885
	num_devs_point = next_token(params);
886
887
	/* skip the options for core based on num_opts */
888
	for (i = 0; i < num_opts; i++) {
889
		num_devs_point = next_token(params);
890
	}
891
892
	rc = sscanf(num_devs_point, "%u", num_devs);
863
	rc = (rc != 1) ? EINVAL : 0;
893
	rc = (rc != 1) ? EINVAL : 0;
864
894
895
out:
865
	LOG_PROC_EXIT_INT(rc);
896
	LOG_PROC_EXIT_INT(rc);
866
	return rc;
897
	return rc;
867
}
898
}
(-)evms-2.5.4/plugins/disk/localdskmgr.c (-1 / +102 lines)
Lines 1329-1341 static int check_multipath(storage_objec Link Here
1329
	rc = EngFncs->dm_get_targets(disk, &targets);
1329
	rc = EngFncs->dm_get_targets(disk, &targets);
1330
	if (rc) {
1330
	if (rc) {
1331
		LOG_ERROR("Error getting DM mapping for disk %s.\n", disk->name);
1331
		LOG_ERROR("Error getting DM mapping for disk %s.\n", disk->name);
1332
		rc=0;
1332
		goto out;
1333
		goto out;
1333
	}
1334
	}
1334
1335
1335
	/* Reject all non-multipath devices. */
1336
	/* Reject all non-multipath devices. */
1336
	if (targets->type != DM_TARGET_MULTIPATH) {
1337
	if (targets->type != DM_TARGET_MULTIPATH) {
1337
		LOG_DEBUG("Disk %s is not a multipath device.\n", disk->name);
1338
		LOG_DEBUG("Disk %s is not a multipath device.\n", disk->name);
1338
		rc = EINVAL;
1339
		//rc = EINVAL;
1339
		goto out;
1340
		goto out;
1340
	}
1341
	}
1341
1342
Lines 1396-1401 static void remove_multipath_children(li Link Here
1396
}
1397
}
1397
1398
1398
/**
1399
/**
1400
 * check_user_devicemapper
1401
 *
1402
 * Check if this disk is a User created DM device.
1403
 **/
1404
static int check_user_devicemapper(storage_object_t * disk)
1405
{
1406
	dm_device_list_t * dm_list, * dm_entry;
1407
	dm_target_t * targets = NULL;
1408
	local_disk_t * ld = disk->private_data;
1409
	int rc = 0, dm_user_targets_count = 0, i, dmup_len;
1410
	boolean user_dm_enable;
1411
	const char * const * dm_user_targets;
1412
	char * dm_user_prefix = "dm/";
1413
1414
	LOG_ENTRY();
1415
1416
	/* Get the list of active DM devices. */
1417
	dm_list = get_dm_device_list();
1418
	if (!dm_list) {
1419
		LOG_WARNING("Cannot get list of DM devices.\n");
1420
		goto out;
1421
	}
1422
1423
	/* Search the DM list for an entry that matches this disk. */
1424
	dm_entry = find_disk_in_dm_devices(disk, dm_list);
1425
	if (!dm_entry) {
1426
		LOG_DEBUG("Disk %s is not a DM device.\n", disk->name);
1427
		goto out;
1428
	}
1429
1430
	user_dm_enable = FALSE;
1431
	EngFncs->get_config_bool("devmapper.dm_user", &user_dm_enable);
1432
1433
	EngFncs->get_config_string_array("devmapper.dm_user_targets",
1434
					 &dm_user_targets_count, &dm_user_targets);
1435
1436
	if (user_dm_enable == FALSE) {
1437
		LOG_DEBUG("devmapper.dm_user not enabled.\n");
1438
		rc = EINVAL;
1439
		goto out;
1440
	}
1441
1442
	/* search the named targets in the config for the DM name*/
1443
	user_dm_enable = FALSE;
1444
	for (i = 0; i < dm_user_targets_count; i++) {		
1445
		if (strncmp(dm_user_targets[i], dm_entry->name, EVMS_NAME_SIZE) == 0) {
1446
			user_dm_enable = TRUE;
1447
		}
1448
	}
1449
1450
	if (user_dm_enable == FALSE) {
1451
		LOG_DEBUG("%s not found in devmapper.dm_user_targets.\n", dm_entry->name);
1452
		rc = EINVAL;
1453
		goto out;
1454
	}
1455
1456
	/* Get the DM mapping for this disk. */
1457
	/* we can use this in the future if we need to, and it's good to check */
1458
	strncpy(disk->name, dm_entry->name, EVMS_NAME_SIZE);
1459
	rc = EngFncs->dm_get_targets(disk, &targets);
1460
	if (rc) {
1461
		LOG_ERROR("Error getting DM mapping for disk %s.\n", disk->name);
1462
		goto out;
1463
	}
1464
1465
	/* Copy the DM name to this disk. */
1466
	dmup_len = strlen(dm_user_prefix);
1467
	LOG_DEBUG("Changing disk name from %s to %s%s.\n",
1468
		  disk->name, dm_user_prefix ,dm_entry->name);
1469
1470
	strncpy(disk->name, dm_user_prefix, dmup_len);
1471
	strncpy((disk->name)+dmup_len, dm_entry->name, EVMS_NAME_SIZE-dmup_len);
1472
1473
	/* Reject all multipath devices that
1474
	 * were created by other EVMS plugins.
1475
	 */
1476
	rc = check_multipath_name(disk);
1477
	if (rc) {
1478
		LOG_DEBUG("Multipath disk %s belongs to another EVMS plugin.\n",
1479
			  disk->name);
1480
		goto out;
1481
	}
1482
1483
	ld->flags |= LD_FLAG_USERDM;
1484
1485
out:
1486
	/*EngFncs->dm_deallocate_targets(targets); */
1487
	LOG_EXIT_INT(rc);
1488
	return rc;
1489
}
1490
1491
/**
1399
 * get_geometry
1492
 * get_geometry
1400
 *
1493
 *
1401
 * Use the HDIO_GETGEO_BIG or HDIO_GETGEO ioctl to get the disk's geometry.
1494
 * Use the HDIO_GETGEO_BIG or HDIO_GETGEO ioctl to get the disk's geometry.
Lines 1478-1483 static int get_fake_geometry(storage_obj Link Here
1478
	if (disk->dev_major == LOOP_MAJOR ||
1571
	if (disk->dev_major == LOOP_MAJOR ||
1479
	    disk->dev_major == NBD_MAJOR ||
1572
	    disk->dev_major == NBD_MAJOR ||
1480
	    disk->dev_major == DRBD_MAJOR ||
1573
	    disk->dev_major == DRBD_MAJOR ||
1574
		ld->flags & LD_FLAG_USERDM ||
1481
	    ld->flags & LD_FLAG_MULTIPATH) {
1575
	    ld->flags & LD_FLAG_MULTIPATH) {
1482
		LOG_DEBUG("Creating fake geometry for disk %s.\n", disk->name);
1576
		LOG_DEBUG("Creating fake geometry for disk %s.\n", disk->name);
1483
		disk->geometry.heads = 255;
1577
		disk->geometry.heads = 255;
Lines 1745-1750 static int LD_discover(list_anchor_t inp Link Here
1745
		/* Get the disk's hard-sector-size. */
1839
		/* Get the disk's hard-sector-size. */
1746
		get_hardsector_size(&working_disk);
1840
		get_hardsector_size(&working_disk);
1747
1841
1842
		/* Check for User created DM devices. */
1843
		rc = check_user_devicemapper(&working_disk);
1844
		if (rc) {
1845
			close_dev(&working_disk);
1846
			continue;
1847
		}
1848
1748
		/* Get the disk's geometry. */
1849
		/* Get the disk's geometry. */
1749
		rc = get_geometry(&working_disk);
1850
		rc = get_geometry(&working_disk);
1750
		if (rc) {
1851
		if (rc) {
(-)evms-2.5.4/plugins/disk/localdskmgr.h (+1 lines)
Lines 80-85 typedef struct local_disk { Link Here
80
#define LD_FLAG_MULTIPATH	(1 << 0)
80
#define LD_FLAG_MULTIPATH	(1 << 0)
81
#define LD_FLAG_IDE		(1 << 1)
81
#define LD_FLAG_IDE		(1 << 1)
82
#define LD_FLAG_SCSI		(1 << 2)
82
#define LD_FLAG_SCSI		(1 << 2)
83
#define LD_FLAG_USERDM		(1 << 3)
83
84
84
extern engine_functions_t *EngFncs;
85
extern engine_functions_t *EngFncs;
85
extern plugin_record_t    *my_plugin_record;
86
extern plugin_record_t    *my_plugin_record;

Return to bug 115875