Udev integration: add LVM fields support for dmsetup
PATCH 1/4 Udev integration: add LVM fields support for dmsetup
Hi,
this is the first patch of the whole udev integration patchset. Udev integration patchset relies on "uevent cookie env var support" DM patch, see dm-devel list.
This patch adds support for splitting given UUID and LVM name into its subsystem (the UUID prefix), VG/LV/LV layer constituents. This way we can import these values in udev rules and use its primary use is to create the directories with symlinks under /dev dir.
Peter
libdm/.exported_symbols +1 -0
@@ -116,6 +116,7 @@ dm_hash_get_first dm_hash_get_next dm_set_selinux_context dm_task_set_geometry +dm_split_lvm_name_mem dm_split_lvm_name dm_split_words dm_snprintf
libdm/libdevmapper.h +9 -0
@@ -131,6 +131,13 @@ struct dm_versions {char name[0 ]; }; +struct dm_split_name { +char *subsystem; +char *vg; +char *lv; +char *lv_layer; +}; +int dm_get_library_version (char *version,size_t size);int dm_task_get_driver_version (struct dm_task *dmt,char *version,size_t size);int dm_task_get_info (struct dm_task *dmt,struct dm_info *dmi);
@@ -819,6 +826,8 @@ int dm_set_selinux_context(const char *path, mode_t mode);* Break up the name of a mapped device into its constituent * Volume Group, Logical Volume and Layer (if present). */ +void dm_split_lvm_name_mem (char *mem,char **vgname,char **lvname,char **layer); +int dm_split_lvm_name (struct dm_pool *mem,const char *dmname,char **vgname,char **lvname,char **layer);
libdm/libdm-string.c +7 -1
@@ -90,13 +90,19 @@ static char *_unquote(char *component)return r; } +void dm_split_lvm_name_mem (char *mem,char **vgname,char **lvname,char **layer) +{ + *vgname = mem; +_unquote (*layer =_unquote (*lvname =_unquote (*vgname))); +} +int dm_split_lvm_name (struct dm_pool *mem,const char *dmname,char **vgname,char **lvname,char **layer) {if (!(*vgname =dm_pool_strdup (mem, dmname)))return 0 ; -_unquote (*layer =_unquote (*lvname =_unquote (*vgname))); +dm_split_lvm_name_mem (*vgname, vgname, lvname, layer);return 1 ; }
tools/dmsetup.c +105 -1
165 lines not on this page · raw message
PATCH 1/4 Udev integration: add LVM fields support for dmsetup
Quoted 2 lines · Peter Rajnoha
+dm_split_lvm_name_mem
dm_split_lvm_name
Do we really need both?
(What if mem was NULL in the existing fn?)
tools/dmsetup.c typedef enum { · line 145
Quoted 3 lines
tools/dmsetup.c +2
-1-DR_TREE =8 /* Complete dependency tree required */ +DR_TREE =8 ,/* Complete dependency tree required */ +DR_NAME =16
So presumably we use a similar trick to what we did in lvm recently for the PV label fields, where if the user supplies the name (rather than the major/minor method) and only asks for DM_NAME fields, we skip the ioctls.
If they ask for the prefix though, still use the ioctl - though if it;s already set in an environment variable and only one device is being requested, that could take precedence.
Anyway, it's a very minor cleanup, so leave it for now.
Quoted 1 line
+static char *_get_uuid_prefix(const char *uuid)
Maybe _extract_uuid_prefix ?
Does it return a const?
tools/dmsetup.c static struct dm_task *_get_deps_task(int major, int minor) · line 302
Quoted 1 line
tools/dmsetup.c +1
-0+int len;
size_t ?
tools/dmsetup.c static struct dm_task *_get_deps_task(int major, int minor) · line 329
Quoted 1 line
tools/dmsetup.c +1
-0+if (!strcmp (split_name->subsystem,"LVM" ))
Is this code no longer supporting on-the-fly updating from a system running a version of lvm that did not add the prefixes?
If it's too hard to make this code work without them, then we must document the requirement to reboot immediately after updating and without manipulating any devices.
It may be better to recommend that people upgrade to an intermediate version first, then reboot, then upgrade to this version.
tools/dmsetup.c FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers · line 2065
Quoted 4 lines
tools/dmsetup.c +4
-0+FIELD_O(NAME, dm_split_name, STR, "Subsystem", subsystem, 10, dm_subsystem, "subsystem", "DM subsystem.") +FIELD_O(NAME, dm_split_name, STR, "VGName", vg, 10, dm_vg_name, "vg_name", "LVM volume group name.") +FIELD_O(NAME, dm_split_name, STR, "LVName", lv, 10, dm_lv_name, "lv_name", "LVM logical volume name.") +FIELD_O (NAME , dm_split_name,STR ,"LVLayer" , lv_layer,10 , dm_lv_layer_name,"lv_layer" ,"LVM layer." )
4 lots of 10 ?
Normally it's related to the size of the column heading used.
Alasdair
Signature · 1 line
agk at redhat.com
PATCH 1/4 Udev integration: add LVM fields support for dmsetup
Quoted 5 lines · Alasdair G Kergon
Quoted 2 lines · Peter Rajnoha
+dm_split_lvm_name_mem
dm_split_lvm_nameDo we really need both?
I think, I added this, because I could not access usable dm_pool memory here so it could be used with dm_split_lvm_name directly. I created more general dm_split_lvm_name_mem which is not bound to dm_pool but can use any block of memory instead. Yes, it's a little bit strange, I admit. But is there a way I can use a dm_pool in this context ("_display_info_cols" function)?
Quoted 12 lines
(What if mem was NULL in the existing fn?)
tools/dmsetup.c typedef enum { · line 145
Quoted 3 lines
tools/dmsetup.c +2
-1-DR_TREE =8 /* Complete dependency tree required */ +DR_TREE =8 ,/* Complete dependency tree required */ +DR_NAME =16 So presumably we use a similar trick to what we did in lvm recently for the PV label fields, where if the user supplies the name (rather than the major/minor method) and only asks for
DM_NAMEfields, we skip the ioctls.
If they ask for the prefix though, still use the ioctl - though if it;s already set in an environment variable and only one device is being requested, that could take precedence.
Yes, I'll add this. But we don't have to use ioctl with the UUID prefix either. It could be read from /sys dir and given as input to dmsetup directly, too. So we can make a "split-this-uuid" just like we want to do for the DM name. So I think we can avoid ioctls altogether in here.
Quoted 9 lines
tools/dmsetup.c static struct dm_task *_get_deps_task(int major, int minor) · line 329
Quoted 1 line
tools/dmsetup.c +1
-0+if (!strcmp (split_name->subsystem,"LVM" ))Is this code no longer supporting on-the-fly updating from a system running a version of lvm that did not add the prefixes?
If it's too hard to make this code work without them, then we must document the requirement to reboot immediately after updating and without manipulating any devices.
It may be better to recommend that people upgrade to an intermediate version first, then reboot, then upgrade to this version.
hmmm...
Quoted 7 lines
tools/dmsetup.c FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers · line 2065
Quoted 4 lines
tools/dmsetup.c +4
-0+FIELD_O(NAME, dm_split_name, STR, "Subsystem", subsystem, 10, dm_subsystem, "subsystem", "DM subsystem.") +FIELD_O(NAME, dm_split_name, STR, "VGName", vg, 10, dm_vg_name, "vg_name", "LVM volume group name.") +FIELD_O(NAME, dm_split_name, STR, "LVName", lv, 10, dm_lv_name, "lv_name", "LVM logical volume name.") +FIELD_O (NAME , dm_split_name,STR ,"LVLayer" , lv_layer,10 , dm_lv_layer_name,"lv_layer" ,"LVM layer." )4 lots of 10 ?
Normally it's related to the size of the column heading used.
Yes :) I just didn't know the relation here, the exact size, so I did not bother much. I left it as the last thing to do. Apparently, I forgot to look at it once again.
Peter
PATCH 1/4 Udev integration: add LVM fields support for dmsetup
In reply to Peter RajnohaA couple minor cleanup comments for this patch set:
1. Warnings when compiling these patches.ioctl/libdm-iface.c:867: warning: no previous prototype for ?dm_cookie_supported? dmsetup.c:332: warning: assignment discards qualifiers from pointer target type
2. whitespace / tabs - set to 8 spaces / tab?
Areas I noticed were dm_cookie_supported() definitions and other indents.
PATCH 1/4 Udev integration: add LVM fields support for dmsetup
Quoted 4 lines · Dave Wysochanski
A couple minor cleanup comments for this patch set:
1. Warnings when compiling these patches.ioctl/libdm-iface.c:867: warning: no previous prototype for ?dm_cookie_supported? dmsetup.c:332: warning: assignment discards qualifiers from pointer target type
Yes, I've noticed, too :) I've added proper casting here, so it's OK now...
Quoted 3 lines
2. whitespace / tabs - set to 8 spaces / tab?
Areas I noticed weredm_cookie_supported()definitions and other indents.
...ok, I'll have a look
Thanks
Peter