Skip to contentSkip to conversation

Use udev flags in LVM

PATCH New Peter Rajnoha 1 participant 1 message Oct 19, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 Use udev flags in LVM

We don't want to create the symlinks in /dev/<vgname> and /dev/disk for invisible or non-top-level devices. However, we still need some of them to be initialised, so we need them to be visible for a while (for example the "_mlog"). But we can't distinguish this situation without any further information in udev rules (so we don't know when the symlinks should be and when it should not be created). Therefore, we use the udev flags encoded in the cookie value to pass this information into the udev rules.

Also, we need to increase the symlink priority for origin devices so they won't be overwritten by snapshots when the symlink has the same name (e.g. a symlink name based on FS UUID in /dev/disk/by-uuid directory).

I've added and exported a function called "dm_tree_add_new_dev_udev_flags" which is a wrapper around "dm_tree_add_new_dev". The flags are stored in tree node structure (for each device separately) so when the tree is traversed we can pass this information into dm_task_set_cookie then.

Peter

lib/activate/dev_manager.c +11 -2
index 13cec36..96928f6 100644
@@ -1003,6 +1003,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
 	uint32_t max_stripe_size = UINT32_C(0);
 	uint32_t read_ahead = lv->read_ahead;
 	uint32_t read_ahead_flags = UINT32_C(0);
+	uint16_t udev_flags = DM_UDEV_FLAG_NULL;
 
 	if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
 		return_0;
@@ -1022,18 +1023,26 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
 
 	lvlayer->lv = lv;
 
+	if (layer || !lv_is_visible(lv))
+		udev_flags |= DM_UDEV_FLAG_DISABLE_SUBSYSTEM_RULES |
+			      DM_UDEV_FLAG_DISABLE_DISK_RULES;
+
+	if (lv->origin_count)
+		udev_flags |= DM_UDEV_FLAG_HIGH_SYMLINK_PRIORITY;
+
 	/*
 	 * Add LV to dtree.
 	 * If we're working with precommitted metadata, clear any
 	 * existing inactive table left behind.
 	 * Major/minor settings only apply to the visible layer.
 	 */
-	if (!(dnode = dm_tree_add_new_dev(dtree, name, dlid,
+	if (!(dnode = dm_tree_add_new_dev_udev_flags(dtree, name, dlid,
 					     layer ? UINT32_C(0) : (uint32_t) lv->major,
 					     layer ? UINT32_C(0) : (uint32_t) lv->minor,
 					     _read_only_lv(lv),
 					     (lv->vg->status & PRECOMMITTED) ? 1 : 0,
-					     lvlayer)))
+					     lvlayer,
+					     udev_flags)))
 		return_0;
 
 	/* Store existing name so we can do rename later */
libdm/.exported_symbols +1 -0
index c357131..733804c 100644
@@ -50,6 +50,7 @@ dm_tree_create
 dm_tree_free
 dm_tree_add_dev
 dm_tree_add_new_dev
+dm_tree_add_new_dev_udev_flags
 dm_tree_node_get_name
 dm_tree_node_get_uuid
 dm_tree_node_get_info
libdm/libdevmapper.h +8 -0
index a40a843..6640268 100644
@@ -277,6 +277,14 @@ struct dm_tree_node *dm_tree_add_new_dev(struct dm_tree *tree,
 					 int read_only,
 					 int clear_inactive,
 					 void *context);
+struct dm_tree_node *dm_tree_add_new_dev_udev_flags(struct dm_tree *tree,
+						    const char *name,
+						    const char *uuid,
+						    uint32_t major, uint32_t minor,
+						    int read_only,
+						    int clear_inactive,
+						    void *context,
+						    uint16_t udev_flags);
 
 /*
  * Search for a node in the tree.
libdm/libdm-deptree.c +43 -15

158 lines not on this page · raw message