Skip to contentSkip to conversation

libmpathpersist: cleanup ABI and headers

PATCH In review [email protected] 2 participants 8 messages Dec 16, 2021 – Dec 17, 2021 Device mapper

lore
Share & tools
lore
#0 lore raw

cover libmpathpersist: cleanup ABI and headers

From: Martin Wilck <[email protected]>

Hi Christophe, hi Ben,

when reviewing Ben's last patch set, I noticed that the change of struct multipath would formally change the ABI of libmpathpersist, even though the public API as defined by mpath_persist.h doesn't reference this struct.

This set cleans this up by splitting the libmpathpersist code into a public part, a semi-private part (used by other multipath-tools components) and a private part (used by libmpathpersist alone). In the future, the abi check tools will detect an ABI change in cases like this, but it'll be easy to check whether the public or private part of the ABI is affected.

A minor version bump of the libmpathpersist version is required to reflect the fact that symbols have been removed from the LIBMPATHPERSIST versioned ABI.

The set also contains some other minor header file cleanups. No actual code flow is changed, only code shuffled around.

Regards
Martin

Martin Wilck (5):
libmpathpersist: split public and internal API
multipathd: remove duplicate definitions from main.h libmpathpersist/multipathd: remove duplicate definition
libmpathpersist: remove __STDC_FORMAT_MACROS
libmpathpersist: cleanup mpathpr.h

 libmpathpersist/Makefile                |   2 +-
 libmpathpersist/libmpathpersist.version |  27 +-
 libmpathpersist/mpath_persist.c         | 776 +----------------------
 libmpathpersist/mpath_persist_int.c     | 792 ++++++++++++++++++++++++
 libmpathpersist/mpath_persist_int.h     |  25 +
 libmpathpersist/mpath_pr_ioctl.c        |   3 +-
 libmpathpersist/mpathpr.h               |  49 +-
 mpathpersist/main.c                     |   1 +
 multipathd/main.c                       |   5 +-
 multipathd/main.h                       |  15 +-
 10 files changed, 848 insertions(+), 847 deletions(-)
 create mode 100644 libmpathpersist/mpath_persist_int.c
 create mode 100644 libmpathpersist/mpath_persist_int.h
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#1 lore raw

PATCH 1/5 libmpathpersist: split public and internal API

From: Martin Wilck <[email protected]>

The libmpathpersist library exports symbols that are not part of the public API. Move the respective code into a separate source file.

---
 libmpathpersist/Makefile                |   2 +-
 libmpathpersist/libmpathpersist.version |  27 +-
 libmpathpersist/mpath_persist.c         | 776 +----------------------
 libmpathpersist/mpath_persist_int.c     | 779 ++++++++++++++++++++++++
 libmpathpersist/mpath_persist_int.h     |  17 +
 libmpathpersist/mpathpr.h               |  12 -
 mpathpersist/main.c                     |   1 +
 multipathd/main.c                       |   1 +
 8 files changed, 818 insertions(+), 797 deletions(-)
 create mode 100644 libmpathpersist/mpath_persist_int.c
 create mode 100644 libmpathpersist/mpath_persist_int.h
libmpathpersist/Makefile +1 -1
index 1e6399d..fbc401e 100644
@@ -10,7 +10,7 @@ LDFLAGS += -L$(multipathdir) -L$(mpathcmddir)
 
 LIBDEPS += -lmultipath -lmpathcmd -ldevmapper -lpthread -ldl
 
-OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o
+OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o mpath_persist_int.o
 
 all: $(DEVLIB) man
 
libmpathpersist/libmpathpersist.version +14 -13
index fa312f6..a8c6aae 100644
@@ -10,27 +10,28 @@
  *
  * See libmultipath.version for general policy about version numbers.
  */
-LIBMPATHPERSIST_2.0.0 {
+LIBMPATHPERSIST_2.1.0 {
 global:
-
-	__mpath_persistent_reserve_in;
-	__mpath_persistent_reserve_out;
-	dumpHex;
-	mpath_alloc_prin_response;
+	/* public API as defined in mpath_persist.h */
+	libmpathpersist_exit;
+	libmpathpersist_init;
 	mpath_lib_exit;
 	mpath_lib_init;
 	mpath_mx_alloc_len;
+	mpath_persistent_reserve_free_vecs;
+	__mpath_persistent_reserve_in;
 	mpath_persistent_reserve_in;
 	mpath_persistent_reserve_init_vecs;
+	__mpath_persistent_reserve_out;
 	mpath_persistent_reserve_out;
-	mpath_persistent_reserve_free_vecs;
+local: *;
+};
+
+__LIBMPATHPERSIST_INT_1.0.0 {
+	/* Internal use by multipath-tools */
+	dumpHex;
+	mpath_alloc_prin_response;
 	prin_do_scsi_ioctl;
 	prout_do_scsi_ioctl;
 	update_map_pr;
-
-	/* added in 1.1.0 */
-	libmpathpersist_init;
-	libmpathpersist_exit;
-
-local: *;
 };
libmpathpersist/mpath_persist.c +5 -771

805 lines not on this page · raw message

libmpathpersist/mpath_persist_int.c new file +779 -0

779 lines not on this page · raw message

libmpathpersist/mpath_persist_int.h new file +17 -0
new file mode 100644
index 0000000..58d9c33
@@ -0,0 +1,17 @@
+#ifndef _MPATH_PERSIST_INT_H
+#define _MPATH_PERSIST_INT_H
+
+struct multipath;
+
+void * mpath_alloc_prin_response(int prin_sa);
+int do_mpath_persistent_reserve_in(vector curmp, vector pathvec,
+				   int fd, int rq_servact,
+				   struct prin_resp *resp, int noisy);
+void *mpath_alloc_prin_response(int prin_sa);
+int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd,
+				    int rq_servact, int rq_scope,
+				    unsigned int rq_type,
+				    struct prout_param_descriptor *paramp,
+				    int noisy);
+
+#endif /* _MPATH_PERSIST_INT_H */
libmpathpersist/mpathpr.h +0 -12
index 5ea8cd6..59411e6 100644
@@ -31,20 +31,8 @@ int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int
 int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope,
 		unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy);
 void * _mpath_pr_update (void *arg);
-int mpath_send_prin_activepath (char * dev, int rq_servact, struct prin_resp * resp, int noisy);
-int get_mpvec (vector curmp, vector pathvec, char * refwwid);
-void * mpath_prout_pthread_fn(void *p);
 void dumpHex(const char* , int len, int no_ascii);
 
-int mpath_prout_reg(struct multipath *mpp,int rq_servact, int rq_scope,
-	unsigned int rq_type,  struct prout_param_descriptor * paramp, int noisy);
-int mpath_prout_common(struct multipath *mpp,int rq_servact, int rq_scope,
-	unsigned int rq_type,  struct prout_param_descriptor * paramp, int noisy);
-int mpath_prout_rel(struct multipath *mpp,int rq_servact, int rq_scope,
-	unsigned int rq_type,  struct prout_param_descriptor * paramp, int noisy);
-int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
-	unsigned int rq_type,   struct prout_param_descriptor * paramp, int noisy);
-
 int update_prflag(char *mapname, int set);
 int update_prkey_flags(char *mapname, uint64_t prkey, uint8_t sa_flags);
 #define update_prkey(mapname, prkey) update_prkey_flags(mapname, prkey, 0)
mpathpersist/main.c +1 -0
index 14245cc..4bdd55c 100644
@@ -10,6 +10,7 @@
 #include <getopt.h>
 #include <libudev.h>
 #include "mpath_persist.h"
+#include "mpath_persist_int.h"
 #include "main.h"
 #include "debug.h"
 #include <pthread.h>
multipathd/main.c +1 -0
index 7a57a79..1db34ac 100644
@@ -66,6 +66,7 @@
 
 #include "mpath_cmd.h"
 #include "mpath_persist.h"
+#include "mpath_persist_int.h"
 
 #include "prioritizers/alua_rtpg.h"
 
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#2 lore raw

PATCH 2/5 multipathd: remove duplicate definitions from main.h

In reply to [email protected]

From: Martin Wilck <[email protected]>

We shouldn't define function prototypes in more than a single place.

---
 libmpathpersist/mpath_persist_int.h | 10 +++++++++-
 multipathd/main.c                   |  3 +++
 multipathd/main.h                   | 15 +--------------
 3 files changed, 13 insertions(+), 15 deletions(-)
libmpathpersist/mpath_persist_int.h +9 -1
index 58d9c33..3145753 100644
@@ -1,7 +1,10 @@
 #ifndef _MPATH_PERSIST_INT_H
 #define _MPATH_PERSIST_INT_H
 
-struct multipath;
+/*
+ * This header file contains symbols that are used by multipath-tools
+ * but aren't part of the public libmpathpersist API.
+ */
 
 void * mpath_alloc_prin_response(int prin_sa);
 int do_mpath_persistent_reserve_in(vector curmp, vector pathvec,
@@ -13,5 +16,10 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd,
 				    unsigned int rq_type,
 				    struct prout_param_descriptor *paramp,
 				    int noisy);
+int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int noisy);
+int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope,
+			 unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy);
+void dumpHex(const char* , int len, int no_ascii);
+int update_map_pr(struct multipath *mpp);
 
 #endif /* _MPATH_PERSIST_INT_H */
multipathd/main.c +3 -0
index 1db34ac..8926cbb 100644
@@ -89,6 +89,9 @@
 #define CMDSIZE 160
 #define MSG_SIZE 32
 
+int mpath_pr_event_handle(struct path *pp);
+void * mpath_pr_event_handler_fn (void * );
+
 #define LOG_MSG(lvl, pp)					\
 do {								\
 	if (pp->mpp && checker_selected(&pp->checker) &&	\
multipathd/main.h +1 -14
index 8356b25..459c734 100644
@@ -27,9 +27,6 @@ enum remove_path_result {
 				      * because the path was also removed */
 };
 
-struct prout_param_descriptor;
-struct prin_resp;
-
 extern pid_t daemon_pid;
 extern int uxsock_timeout;
 
@@ -44,17 +41,7 @@ int ev_remove_path (struct path *, struct vectors *, int);
 int ev_add_map (char *, const char *, struct vectors *);
 int ev_remove_map (char *, char *, int, struct vectors *);
 int flush_map(struct multipath *, struct vectors *, int);
-void * mpath_alloc_prin_response(int prin_sa);
-int prin_do_scsi_ioctl(char *, int rq_servact, struct prin_resp * resp,
-		       int noisy);
-void dumpHex(const char * , int len, int no_ascii);
-int prout_do_scsi_ioctl(char * , int rq_servact, int rq_scope,
-			unsigned int rq_type,
-			struct prout_param_descriptor *param, int noisy);
-int mpath_pr_event_handle(struct path *pp);
-void * mpath_pr_event_handler_fn (void * );
-int update_map_pr(struct multipath *mpp);
-void * mpath_pr_event_handler_fn (void * pathp );
+
 void handle_signals(bool);
 int __setup_multipath (struct vectors * vecs, struct multipath * mpp,
 		       int reset);
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#3 lore raw

PATCH 3/5 libmpathpersist/multipathd: remove duplicate definition

In reply to [email protected]

From: Martin Wilck <[email protected]>

... of FILE_NAME_SIZE.

---
 libmpathpersist/mpath_pr_ioctl.c | 3 +--
 multipathd/main.c                | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
libmpathpersist/mpath_pr_ioctl.c +1 -2
index 126601c..17c5284 100644
@@ -17,8 +17,7 @@
 #include "unaligned.h"
 
 #include "debug.h"
-
-#define FILE_NAME_SIZE          256
+#include "structs.h" /* FILE_NAME_SIZE */
 
 #define TIMEOUT 2000
 #define MAXRETRY 5
multipathd/main.c +0 -1
index 8926cbb..93851cd 100644
@@ -85,7 +85,6 @@
 #include "../third-party/valgrind/drd.h"
 #include "init_unwinder.h"
 
-#define FILE_NAME_SIZE 256
 #define CMDSIZE 160
 #define MSG_SIZE 32
 
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#4 lore raw

PATCH 4/5 libmpathpersist: remove __STDC_FORMAT_MACROS

In reply to [email protected]

From: Martin Wilck <[email protected]>

This has no effect. If at all, it should have been included before inttypes.h.

See https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format/8132440#8132440

---
 libmpathpersist/mpath_persist_int.c | 1 -
 1 file changed, 1 deletion(-)
libmpathpersist/mpath_persist_int.c +0 -1
index 7f6ac04..91bc35a 100644
@@ -34,7 +34,6 @@
 #include "mpath_pr_ioctl.h"
 
 
-#define __STDC_FORMAT_MACROS 1
 
 static int mpath_send_prin_activepath (char * dev, int rq_servact,
 				struct prin_resp * resp, int noisy)
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#5 lore raw

PATCH 5/5 libmpathpersist: cleanup mpathpr.h

In reply to [email protected]

From: Martin Wilck <[email protected]>

Quoted 1 line

From now on this header contains only symbols that need to be

accessed from multiple sources of libmpathpersist, but not from libmultipath or other source files (those go into libmpathpersist_int.h).

---
 libmpathpersist/mpath_persist_int.c | 14 +++++++++++
 libmpathpersist/mpathpr.h           | 37 ++++-------------------------
 2 files changed, 18 insertions(+), 33 deletions(-)
libmpathpersist/mpath_persist_int.c +14 -0
index 91bc35a..c6fc287 100644
@@ -33,7 +33,21 @@
 #include "mpathpr.h"
 #include "mpath_pr_ioctl.h"
 
+struct prout_param {
+	char dev[FILE_NAME_SIZE];
+	int rq_servact;
+	int rq_scope;
+	unsigned int rq_type;
+	struct prout_param_descriptor  *paramp;
+	int noisy;
+	int status;
+};
 
+struct threadinfo {
+	int status;
+	pthread_t id;
+	struct prout_param param;
+};
 
 static int mpath_send_prin_activepath (char * dev, int rq_servact,
 				struct prin_resp * resp, int noisy)
libmpathpersist/mpathpr.h +4 -33
index 59411e6..39a7d8e 100644
@@ -1,42 +1,13 @@
 #ifndef MPATHPR_H
 #define MPATHPR_H
 
-#include "structs.h" /* FILE_NAME_SIZE */
-
-struct prin_param {
-	char dev[FILE_NAME_SIZE];
-	int rq_servact;
-	struct prin_resp *resp;
-	int noisy;
-	int status;
-};
-
-struct prout_param {
-	char dev[FILE_NAME_SIZE];
-	int rq_servact;
-	int rq_scope;
-	unsigned int rq_type;
-	struct prout_param_descriptor  *paramp;
-	int noisy;
-	int status;
-};
-
-struct threadinfo {
-	int status;
-	pthread_t id;
-	struct prout_param param;
-};
-
-int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int noisy);
-int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope,
-		unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy);
-void * _mpath_pr_update (void *arg);
-void dumpHex(const char* , int len, int no_ascii);
+/*
+ * This header file contains symbols that are only used by
+ * libmpathpersist internally.
+ */
 
 int update_prflag(char *mapname, int set);
 int update_prkey_flags(char *mapname, uint64_t prkey, uint8_t sa_flags);
 #define update_prkey(mapname, prkey) update_prkey_flags(mapname, prkey, 0)
-void * mpath_alloc_prin_response(int prin_sa);
-int update_map_pr(struct multipath *mpp);
 
 #endif
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#6 lore raw

Re: [dm-devel] [PATCH 5/5] libmpathpersist: cleanup mpathpr.h

Quoted 8 lines · On Thu, 2021-12-16 at 13:55 +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

From now on this header contains only symbols that need to be accessed from multiple sources of libmpathpersist, but not from libmultipath or other source files (those go into libmpathpersist_int.h).

This patch causes a build-time error under Alpine (uclibc), which is trivially fixed by adding an "#include <string.h>" in mpath_updatepr.c. Unless you insist that I resubmit, I'll just fix it up locally once it's reviewed.

Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

maintainer Reviewed-by on the v1 series
#7 lore raw
In reply to [email protected]
Quoted 19 lines · On Thu, Dec 16, 2021 at 01:54:57PM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

Hi Christophe, hi Ben,

when reviewing Ben's last patch set, I noticed that the change of struct multipath would formally change the ABI of libmpathpersist, even though the public API as defined by mpath_persist.h doesn't reference this struct.

This set cleans this up by splitting the libmpathpersist code into a public part, a semi-private part (used by other multipath-tools components) and a private part (used by libmpathpersist alone). In the future, the abi check tools will detect an ABI change in cases like this, but it'll be easy to check whether the public or private part of the ABI is affected.

A minor version bump of the libmpathpersist version is required to reflect the fact that symbols have been removed from the LIBMPATHPERSIST versioned ABI.

Quoted 5 lines

The set also contains some other minor header file cleanups. No actual code flow is changed, only code shuffled around.

Regards
Martin

For the set

Quoted 8 lines

Martin Wilck (5):
libmpathpersist: split public and internal API
multipathd: remove duplicate definitions from main.h libmpathpersist/multipathd: remove duplicate definition
libmpathpersist: remove __STDC_FORMAT_MACROS
libmpathpersist: cleanup mpathpr.h

Quoted 16 lines
 libmpathpersist/Makefile                |   2 +-
 libmpathpersist/libmpathpersist.version |  27 +-
 libmpathpersist/mpath_persist.c         | 776 +----------------------
 libmpathpersist/mpath_persist_int.c     | 792 ++++++++++++++++++++++++
 libmpathpersist/mpath_persist_int.h     |  25 +
 libmpathpersist/mpath_pr_ioctl.c        |   3 +-
 libmpathpersist/mpathpr.h               |  49 +-
 mpathpersist/main.c                     |   1 +
 multipathd/main.c                       |   5 +-
 multipathd/main.h                       |  15 +-
 10 files changed, 848 insertions(+), 847 deletions(-)
 create mode 100644 libmpathpersist/mpath_persist_int.c
 create mode 100644 libmpathpersist/mpath_persist_int.h
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel