master - device: add infrastructure to support external device info
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbfde21e7cdc770f0a1189d40f983aa046d605bb Commit: fbfde21e7cdc770f0a1189d40f983aa046d605bb Parent: 578b236a19fab565a4416b17cbc26d53a72b66db Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Dec 12 12:55:41 2014 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Jan 30 13:01:12 2015 +0100
device: add infrastructure to support external device info
--- lib/Makefile.in | 1 + lib/device/dev-cache.c | 3 + lib/device/dev-ext.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 27 ++++++++ 4 files changed, 195 insertions(+), 0 deletions(-)
lib/Makefile.in +1 -0
@@ -56,6 +56,7 @@ SOURCES =\ datastruct/btree.c \ datastruct/str_list.c \ device/dev-cache.c \ + device/dev-ext.c \ device/dev-io.c \ device/dev-md.c \ device/dev-swap.c \
lib/device/dev-cache.c +3 -0
@@ -64,6 +64,9 @@ static void _dev_init(struct device *dev, int max_error_count) dev->read_ahead =-1 ; dev->max_error_count = max_error_count; + dev->ext.enabled =0 ; + dev->ext.src =DEV_EXT_NONE ; +dm_list_init (&dev->aliases);dm_list_init (&dev->open_list); }
lib/device/dev-ext.c new file +164 -0
164 lines not on this page · raw message
lib/device/device.h +27 -0
@@ -29,6 +29,23 @@#define DEV_O_DIRECT_TESTED 0x00000040/* DEV_O_DIRECT is reliable */ /* +* Support for external device info. +* Any new external device info source needs to be +* registered using EXT_REGISTER macro in dev-ext.c. +*/ +typedef enum { +DEV_EXT_NONE , +DEV_EXT_UDEV , +DEV_EXT_NUM +}dev_ext_t ; + +struct dev_ext { +int enabled; +dev_ext_t src; +void *handle; +}; + +/* * All devices in LVM will be represented by one of these. * pointer comparisons are valid. */
@@ -47,6 +64,7 @@ struct device {uint32_t flags;uint64_t end;struct dm_list open_list; +struct dev_ext ext;char pvid[ID_LEN +1 ];char _padding[7 ];
@@ -64,6 +82,15 @@ struct device_area { };/* +* Support for external device info. +*/ +const char *dev_ext_name (struct device *dev); +int dev_ext_enable (struct device *dev,dev_ext_t src); +int dev_ext_disable (struct device *dev); +struct dev_ext *dev_ext_get (struct device *dev); +int dev_ext_release (struct device *dev); + +/* * All io should use these routines. */ int dev_get_block_size (struct device *dev,unsigned int *phys_block_size,unsigned int *block_size);