Skip to contentSkip to conversation

master - libdm: new dm_task_get_info with internal_suspend

PATCH Zdenek Kabelac 1 participant 1 message May 15, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=797c18d543947f4c2777b4dcf3ceff57cb55352b
Commit:        797c18d543947f4c2777b4dcf3ceff57cb55352b
Parent:        3f10dfd6c79e05de89a9ef09bd92239ec1681b13
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri May 15 15:29:46 2015 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri May 15 16:48:22 2015 +0200

libdm: new dm_task_get_info with internal_suspend

Introduce new implmentation of dm_task_get_info() function with support for reading internal_suspend.
.
This time it is done in a 'versioned' way.

We keep the old fashion dm_task_get_info(Base) to implement the old behavior of 1.02.95 libdm code.

libdm version 1.02.96 introduced 'macro' wrapper dm_task_get_info_with_deferred_remove with new implementation of dm_task_get_info() - we cannot do anything else then to provide compatible version of this symbol.

Now in version 1.02.97 we add new versioned implementation of dm_task_get_info(DM_1_02_97) symbol.

This has the effect that i.e. rpm build will finaly resolve proper dependency on a new symbol - so it will be no longer possible, to build a new binary and use old library
(rpm -q --provides will show libdevmapper.so.1.02(DM_1_02_97)(64bit))

Also the history is now tracked. If a new function is added (or reimplemented), it needs to be placed in proper file, so it could be exported with right versioning symbol. File .exported_symbols.Base should and any existing older DM should be treated as read-only after a release.

Also - only libdm has been currently enhanced with versioned .Base file, as soon as other libs (liblvm, libdevmapper-event) needs changes they should also get their exported symbol files - meanwhile make.tmpl handles both cases.

---
 WHATS_NEW_DM                       |    2 +
 lib/misc/lib.h                     |   11 ++
 libdm/.exported_symbols            |    2 +-
 libdm/.exported_symbols.Base       |  287 ++++++++++++++++++++++++++++++++++++
 libdm/.exported_symbols.DM_1_02_97 |    1 +
 libdm/ioctl/libdm-iface.c          |   36 ++++-
 libdm/libdevmapper.h               |    3 +-
 make.tmpl.in                       |   21 +++-
 8 files changed, 354 insertions(+), 9 deletions(-)
WHATS_NEW_DM +2 -0
index 4288899..cdea8c2 100644
@@ -1,5 +1,7 @@
 Version 1.02.97 - 
 ==============================
+  New dm_task_get_info(DM_1_02_97) supports internal_suspend state.
+  New symbols are versioned and comes with versioned symbol name (DM_1_02_97).
 
 Version 1.02.96 - 2nd May 2015
 ==============================
lib/misc/lib.h +11 -0
index 3a35c22..63e58d0 100644
@@ -30,6 +30,17 @@
 #define PRIptrdiff_t "td"
 #define PRIpid_t PRId32
 
+#if defined(__GNUC__)
+#define DM_EXPORTED_SYMBOL(func, ver) \
+	__asm__(".symver " #func "_v" #ver ", " #func "@@DM_" #ver )
+#define DM_EXPORTED_SYMBOL_BASE(func) \
+	__asm__(".symver " #func "_base, " #func "@Base" )
+#else
+#define DM_EXPORTED_SYMBOL(func, ver)
+#define DM_EXPORTED_SYMBOL_BASE(func)
+#endif
+
+
 #include "intl.h"
 #include "libdevmapper.h"
 #include "util.h"
libdm/.exported_symbols +1 -1
index 5bacc26..2b85343 100644
@@ -1,3 +1,3 @@
 dm_log
 dm_log_with_errno
-dm_task_get_info
+dm_task_get_info_with_deferred_remove
libdm/.exported_symbols.Base new file +287 -0

287 lines not on this page · raw message

libdm/.exported_symbols.DM_1_02_97 new file +1 -0
new file mode 100644
index 0000000..dcc513a
@@ -0,0 +1 @@
+dm_task_get_info
libdm/ioctl/libdm-iface.c +32 -4
index 298723e..face593 100644
@@ -666,7 +666,13 @@ int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
 	return 1;
 }
 
+#if defined(__GNUC__)
+int dm_task_get_info_v1_02_97(struct dm_task *dmt, struct dm_info *info);
+DM_EXPORTED_SYMBOL(dm_task_get_info, 1_02_97);
+int dm_task_get_info_v1_02_97(struct dm_task *dmt, struct dm_info *info)
+#else
 int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
+#endif
 {
 	if (!dmt->dmi.v4)
 		return 0;
@@ -683,6 +689,7 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
 	info->inactive_table = dmt->dmi.v4->flags & DM_INACTIVE_PRESENT_FLAG ?
 	    1 : 0;
 	info->deferred_remove = dmt->dmi.v4->flags & DM_DEFERRED_REMOVE;
+	info->internal_suspend = (dmt->dmi.v4->flags & DM_INTERNAL_SUSPEND_FLAG) ? 1 : 0;
 	info->target_count = dmt->dmi.v4->target_count;
 	info->open_count = dmt->dmi.v4->open_count;
 	info->event_nr = dmt->dmi.v4->event_nr;
@@ -2061,6 +2068,12 @@ void dm_lib_exit(void)
 	_version_checked = 0;
 }
 
+#if defined(__GNUC__)
+/*
+ * Maintain binary backward compatibility.
+ * Version script mechanism works with 'gcc' compatible compilers only.
+ */
+
 /*
  * This following code is here to retain ABI compatibility after adding
  * the field deferred_remove to struct dm_info in version 1.02.89.
@@ -2076,16 +2089,31 @@ void dm_lib_exit(void)
  * N.B. Keep this function at the end of the file to make sure that
  * no code in this file accidentally calls it.
  */
-#undef dm_task_get_info
-int dm_task_get_info(struct dm_task *dmt, struct dm_info *info);
-int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
+
+int dm_task_get_info_base(struct dm_task *dmt, struct dm_info *info);
+DM_EXPORTED_SYMBOL_BASE(dm_task_get_info);
+int dm_task_get_info_base(struct dm_task *dmt, struct dm_info *info)
 {
 	struct dm_info new_info;
 
-	if (!dm_task_get_info_with_deferred_remove(dmt, &new_info))
+	if (!dm_task_get_info_v1_02_97(dmt, &new_info))
 		return 0;
 
 	memcpy(info, &new_info, offsetof(struct dm_info, deferred_remove));
 
 	return 1;
 }
+
+int dm_task_get_info_with_deferred_remove(struct dm_task *dmt, struct dm_info *info);
+int dm_task_get_info_with_deferred_remove(struct dm_task *dmt, struct dm_info *info)
+{
+	struct dm_info new_info;
+
+	if (!dm_task_get_info_v1_02_97(dmt, &new_info))
+		return 0;
+
+	memcpy(info, &new_info, offsetof(struct dm_info, internal_suspend));
+
+	return 1;
+}
+#endif
libdm/libdevmapper.h +1 -2
index 309e63f..8295e3c 100644
@@ -151,6 +151,7 @@ struct dm_info {
 	int32_t target_count;
 
 	int deferred_remove;
+	int internal_suspend;
 };
 
 struct dm_deps {
@@ -174,8 +175,6 @@ struct dm_versions {
 
 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);
-
-#define dm_task_get_info dm_task_get_info_with_deferred_remove
 int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
 
 /*
make.tmpl.in +19 -2
index 4311490..33d79c2 100644
@@ -485,7 +485,7 @@ distclean: cleandir $(SUBDIRS.distclean)
 	test -z "$(DISTCLEAN_DIRS)" || $(RM) -r $(DISTCLEAN_DIRS)
 	$(RM) $(DISTCLEAN_TARGETS) Makefile
 
-.exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols
+.exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols $(DEPS)
 	set -e; \
 	( cat $(srcdir)/.exported_symbols; \
 	  if test x$(EXPORTED_HEADER) != x; then \
@@ -494,11 +494,28 @@ distclean: cleandir $(SUBDIRS.distclean)
 	  fi \
 	) > $@
 
+EXPORTED_UC := $(shell echo $(EXPORTED_FN_PREFIX) | tr '[a-z]' '[A-Z]')
+EXPORTED_FILES := $(wildcard $(srcdir)/.exported_symbols.Base $(srcdir)/.exported_symbols.$(EXPORTED_UC)_[0-9_]*[0-9])
+
+ifeq (0,$(words $(EXPORTED_FILES)))
 .export.sym: .exported_symbols_generated
 	set -e; (echo "Base {"; echo "	global:"; \
-		 sed "s/^/		/;s/$$/;/" < $<; \
+		 $(SED) "s/^/		/;s/$$/;/" < $<; \
 		 echo "	local:"; echo "		*;"; echo "};") > $@
 
+else
+.export.sym: .exported_symbols_generated $(EXPORTED_FILES)
+	set -e; \
+	R=$(shell sort $^ | uniq -u);\
+	test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
+	(for i in $(EXPORTED_FILES) ; do\
+		echo "$${i##*.} {"; echo "	global:";\
+		$(SED) "s/^/		/;s/$$/;/" < $$i;\
+		test "$$i" = Base && { echo "	local:"; echo "		*;"; };\
+		echo "};";\
+	done ) > $@
+endif
+
 ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov \
  help check check_local check_cluster check_lvmetad check_lvmpolld))
     ifdef SOURCES