[Cluster-devel] [PATCH] gfs2-utils: build: Avoid using the kernel versions of kernel headers

2012-11-02 Thread Andrew Price
Currently the configure script checks for kernel headers at
/lib/modules/`uname -r`/source/include/linux/* which means we're using
kernel headers not meant to be used in userspace code. Thus we see a lot
of Attempt to use kernel headers from user space warnings when
building with a kernel-devel package installed.

Instead we should be using the userspace versions of the headers in
/usr/include/linux/. This patch removes the config options and checks
which pull in the kernel includes and lets the configure script find the
linux headers in the default include path.

Also removes an unnecessary include of kdev_t.h and updates the linux
header checks in configure.ac to only check for the ones we use.

Signed-off-by: Andrew Price anpr...@redhat.com
---
 configure.ac| 40 
 gfs2/libgfs2/misc.c |  1 -
 2 files changed, 4 insertions(+), 37 deletions(-)

diff --git a/configure.ac b/configure.ac
index ef09569..07c6673 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,16 +82,6 @@ check_lib_no_libs() {
LIBS=$ac_check_lib_save_LIBS
 }
 
-# check kernel headers path
-uname=$(uname -r)
-if test -d /lib/modules/$uname/source -o -L /lib/modules/$uname/source; 
then
-   DEFAULT_KERNEL_DIR=/lib/modules/$uname/source
-elif test -d /lib/modules/$uname/build -o -L /lib/modules/$uname -r/build; 
then
-   DEFAULT_KERNEL_DIR=/lib/modules/$uname/build
-else
-   DEFAULT_KERNEL_DIR=/usr/src/linux
-fi
-
 # local options
 AC_ARG_ENABLE([debug],
[  --enable-debug  enable debug build. ],
@@ -113,13 +103,6 @@ AC_ARG_WITH([sysloglevel],
[ SYSLOGLEVEL=$withval ],
[ SYSLOGLEVEL=LOG_INFO ])
 
-AC_ARG_WITH([kernel],
-   [  --with-kernel=path  path to kernel source. ],
-   [ KERNEL_DIR=$withval ],
-   [ KERNEL_DIR=$DEFAULT_KERNEL_DIR ])
-
-KERNEL_CPPFLAGS=-I$KERNEL_DIR/include
-
 # gfs_controld isn't required in the latest versions of cluster
 AM_CONDITIONAL([BUILD_GFS_CONTROLD], [test x$enable_gfs_controld = xyes])
 AS_IF([test x$enable_gfs_controld = xyes], [
@@ -151,27 +134,15 @@ check_lib_no_libs pthread pthread_mutex_lock
 
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h 
mntent.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h 
sys/ioctl.h sys/mount.h sys/param.h sys/socket.h sys/time.h sys/vfs.h syslog.h 
termios.h unistd.h])
 
-BACKUP_CPPFLAGS=$CPPFLAGS
-CPPFLAGS=$KERNEL_CPPFLAGS
-
-# check kernel headers
-# 2.6.26 adds dlm_plock.h that's our checking barrier, instead
-# of implementing some insane kernel version checks
-AC_CHECK_HEADERS([linux/dlmconstants.h linux/dlm_plock.h linux/kdev_t.h 
linux/limits.h linux/types.h],,
-[AC_MSG_ERROR([Unable to find required kernel headers.
-Make sure to install kernel headers 2.6.26 (or higher) or use 
--with-kernel=path
-configure option to point to the kernel source.])])
+AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h 
linux/netlink.h linux/fs.h],,
+[AC_MSG_ERROR([Unable to find all required kernel headers.])])
 
 AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
 [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
[AC_MSG_ERROR([Unable to find gfs2 uuid support in your 
headers.
 Please update your kernel headers to a more recent version])],
[#include linux/gfs2_ondisk.h])],
-[AC_MSG_ERROR([Unable to find required kernel headers.
-Make sure to install kernel headers 2.6.26 (or higher) or use 
--with-kernel=path
-configure option to point to the kernel source.])])
-
-CPPFLAGS=$BACKUP_CPPFLAGS
+[AC_MSG_ERROR([Unable to find required kernel headers.])])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
@@ -200,7 +171,6 @@ AC_CHECK_FUNCS([ftruncate gettimeofday memset realpath 
rmdir select setlocale so
 
 LOGDIR=${localstatedir}/log/cluster
 CLUSTERVARRUN=${localstatedir}/run/cluster
-CLUSTERVARLIB=${localstatedir}/lib/cluster
 
 ## do subst
 
@@ -212,8 +182,6 @@ AC_SUBST([CLUSTERVARRUN])
 AC_DEFINE_UNQUOTED([CLUSTERVARRUN], $(eval echo ${CLUSTERVARRUN}),
   [Default cluster var/run directory])
 
-AC_SUBST([CLUSTERVARLIB])
-
 AC_DEFINE_UNQUOTED([SYSLOGFACILITY], $(eval echo ${SYSLOGFACILITY}),
   [Default syslog facility])
 
@@ -273,7 +241,7 @@ done
 
 CFLAGS=$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS \
$EXTRA_WARNINGS $WERROR_CFLAGS
-CPPFLAGS=$KERNEL_CPPFLAGS -I\$(top_builddir)/make -I\$(top_srcdir)/make \
+CPPFLAGS=-I\$(top_builddir)/make -I\$(top_srcdir)/make \
  -I. $ENV_CPPFLAGS
 LDFLAGS=$ENV_LDFLAGS
 
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index c2eb245..9efddcd 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -15,7 +15,6 @@
 #include linux/types.h
 #include sys/file.h
 #include dirent.h
-#include linux/kdev_t.h
 #include sys/sysmacros.h
 #include mntent.h
 #include sys/time.h
-- 
1.7.11.7



Re: [Cluster-devel] [PATCH] gfs2-utils: build: Avoid using the kernel versions of kernel headers

2012-11-02 Thread Steven Whitehouse
Hi,

Looks good to me,

Steve.

On Fri, 2012-11-02 at 13:57 +, Andrew Price wrote:
 Currently the configure script checks for kernel headers at
 /lib/modules/`uname -r`/source/include/linux/* which means we're using
 kernel headers not meant to be used in userspace code. Thus we see a lot
 of Attempt to use kernel headers from user space warnings when
 building with a kernel-devel package installed.
 
 Instead we should be using the userspace versions of the headers in
 /usr/include/linux/. This patch removes the config options and checks
 which pull in the kernel includes and lets the configure script find the
 linux headers in the default include path.
 
 Also removes an unnecessary include of kdev_t.h and updates the linux
 header checks in configure.ac to only check for the ones we use.
 
 Signed-off-by: Andrew Price anpr...@redhat.com
 ---
  configure.ac| 40 
  gfs2/libgfs2/misc.c |  1 -
  2 files changed, 4 insertions(+), 37 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
 index ef09569..07c6673 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -82,16 +82,6 @@ check_lib_no_libs() {
   LIBS=$ac_check_lib_save_LIBS
  }
  
 -# check kernel headers path
 -uname=$(uname -r)
 -if test -d /lib/modules/$uname/source -o -L /lib/modules/$uname/source; 
 then
 - DEFAULT_KERNEL_DIR=/lib/modules/$uname/source
 -elif test -d /lib/modules/$uname/build -o -L /lib/modules/$uname 
 -r/build; then
 - DEFAULT_KERNEL_DIR=/lib/modules/$uname/build
 -else
 - DEFAULT_KERNEL_DIR=/usr/src/linux
 -fi
 -
  # local options
  AC_ARG_ENABLE([debug],
   [  --enable-debug  enable debug build. ],
 @@ -113,13 +103,6 @@ AC_ARG_WITH([sysloglevel],
   [ SYSLOGLEVEL=$withval ],
   [ SYSLOGLEVEL=LOG_INFO ])
  
 -AC_ARG_WITH([kernel],
 - [  --with-kernel=path  path to kernel source. ],
 - [ KERNEL_DIR=$withval ],
 - [ KERNEL_DIR=$DEFAULT_KERNEL_DIR ])
 -
 -KERNEL_CPPFLAGS=-I$KERNEL_DIR/include
 -
  # gfs_controld isn't required in the latest versions of cluster
  AM_CONDITIONAL([BUILD_GFS_CONTROLD], [test x$enable_gfs_controld = xyes])
  AS_IF([test x$enable_gfs_controld = xyes], [
 @@ -151,27 +134,15 @@ check_lib_no_libs pthread pthread_mutex_lock
  
  AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h 
 mntent.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h 
 sys/ioctl.h sys/mount.h sys/param.h sys/socket.h sys/time.h sys/vfs.h 
 syslog.h termios.h unistd.h])
  
 -BACKUP_CPPFLAGS=$CPPFLAGS
 -CPPFLAGS=$KERNEL_CPPFLAGS
 -
 -# check kernel headers
 -# 2.6.26 adds dlm_plock.h that's our checking barrier, instead
 -# of implementing some insane kernel version checks
 -AC_CHECK_HEADERS([linux/dlmconstants.h linux/dlm_plock.h linux/kdev_t.h 
 linux/limits.h linux/types.h],,
 -  [AC_MSG_ERROR([Unable to find required kernel headers.
 -Make sure to install kernel headers 2.6.26 (or higher) or use 
 --with-kernel=path
 -configure option to point to the kernel source.])])
 +AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h 
 linux/netlink.h linux/fs.h],,
 +  [AC_MSG_ERROR([Unable to find all required kernel headers.])])
  
  AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
[AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
   [AC_MSG_ERROR([Unable to find gfs2 uuid support in your 
 headers.
  Please update your kernel headers to a more recent version])],
   [#include linux/gfs2_ondisk.h])],
 -  [AC_MSG_ERROR([Unable to find required kernel headers.
 -Make sure to install kernel headers 2.6.26 (or higher) or use 
 --with-kernel=path
 -configure option to point to the kernel source.])])
 -
 -CPPFLAGS=$BACKUP_CPPFLAGS
 +  [AC_MSG_ERROR([Unable to find required kernel headers.])])
  
  # Checks for typedefs, structures, and compiler characteristics.
  AC_C_INLINE
 @@ -200,7 +171,6 @@ AC_CHECK_FUNCS([ftruncate gettimeofday memset realpath 
 rmdir select setlocale so
  
  LOGDIR=${localstatedir}/log/cluster
  CLUSTERVARRUN=${localstatedir}/run/cluster
 -CLUSTERVARLIB=${localstatedir}/lib/cluster
  
  ## do subst
  
 @@ -212,8 +182,6 @@ AC_SUBST([CLUSTERVARRUN])
  AC_DEFINE_UNQUOTED([CLUSTERVARRUN], $(eval echo ${CLUSTERVARRUN}),
  [Default cluster var/run directory])
  
 -AC_SUBST([CLUSTERVARLIB])
 -
  AC_DEFINE_UNQUOTED([SYSLOGFACILITY], $(eval echo ${SYSLOGFACILITY}),
  [Default syslog facility])
  
 @@ -273,7 +241,7 @@ done
  
  CFLAGS=$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS \
   $EXTRA_WARNINGS $WERROR_CFLAGS
 -CPPFLAGS=$KERNEL_CPPFLAGS -I\$(top_builddir)/make -I\$(top_srcdir)/make \
 +CPPFLAGS=-I\$(top_builddir)/make -I\$(top_srcdir)/make \
 -I. $ENV_CPPFLAGS
  LDFLAGS=$ENV_LDFLAGS
  
 diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
 index c2eb245..9efddcd 100644
 --- a/gfs2/libgfs2/misc.c
 +++ b/gfs2/libgfs2/misc.c
 @@ -15,7 +15,6 @@
  

[Cluster-devel] DLM patches from PLD Linux

2012-11-02 Thread Jacek Konieczny
Hello,

These are three of the patches I have applied to dlm when packaging
it for PLD Linux. I think they could be applied upstream.

Greets,
Jacek



[Cluster-devel] [PATCH 2/3] Run dlm.service after sys-kernel-config.mount

2012-11-02 Thread Jacek Konieczny
dlm_controld requires configfs mounted. systemd can take care for that,
but it does it better if the order is set in the unit file.

Signed-off-by: Jacek Konieczny jaj...@jajcus.net
---
 init/dlm.service | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/dlm.service b/init/dlm.service
index d7cf9c7..3c4e53e 100644
--- a/init/dlm.service
+++ b/init/dlm.service
@@ -1,6 +1,6 @@
 [Unit]
 Description=dlm control daemon
-After=syslog.target network.target corosync.service
+After=syslog.target network.target corosync.service sys-kernel-config.mount
 
 [Service]
 Type=forking
-- 
1.7.12.4



[Cluster-devel] [PATCH 3/3] Do not crash uncleanly on SIGINT and SIGHUP

2012-11-02 Thread Jacek Konieczny
Unclean shut-down of dlm_controld may trigger a node fencing,
this should not be triggered by mistake.

SIGINT is the natural way to stop dlm_controld started on a terminal
with '-D' for debugging – let this work like SIGTERM.

SIGHUP is often used for config reload. dlm_controld doesn't support
that, but when someone tries this by mistake, this is not a reason to
crash.

Signed-off-by: Jacek Konieczny jaj...@jajcus.net
---
 dlm_controld/main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 6eafa49..fd469f9 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1582,6 +1582,15 @@ int main(int argc, char **argv)
rv = sigaction(SIGTERM, act, NULL);
if (rv  0)
return -rv;
+   rv = sigaction(SIGINT, act, NULL);
+   if (rv  0)
+   return -rv;
+
+   memset(act, 0, sizeof(act));
+   act.sa_handler = SIG_IGN;
+   rv = sigaction(SIGHUP, act, NULL);
+   if (rv  0)
+   return -rv;
 
memset(act, 0, sizeof(act));
act.sa_handler = sigchld_handler;
-- 
1.7.12.4



[Cluster-devel] [PATCH 1/3] Fix linking order

2012-11-02 Thread Jacek Konieczny
Objects should generally be listed before the libraries they require.
DLM building fails for me without these changes.

Signed-off-by: Jacek Konieczny jaj...@jajcus.net
---
 dlm_controld/Makefile | 4 ++--
 dlm_tool/Makefile | 2 +-
 fence/Makefile| 2 +-
 libdlm/Makefile   | 8 
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index d279b0d..f42a913 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -62,10 +62,10 @@ LIB_LDFLAGS += -Wl,-z,relro -pie
 all: $(LIB_TARGET) $(BIN_TARGET)
 
 $(BIN_TARGET): $(BIN_SOURCE)
-   $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ -L.
+   $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
 
 $(LIB_TARGET): $(LIB_SOURCE)
-   $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ 
-Wl,-soname=$(LIB_SMAJOR) $^
+   $(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ 
-Wl,-soname=$(LIB_SMAJOR)
ln -sf $(LIB_TARGET) $(LIB_SO)
ln -sf $(LIB_TARGET) $(LIB_SMAJOR)
 
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index fe43677..c16d8f5 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -39,7 +39,7 @@ BIN_LDFLAGS += -lpthread -ldlm -ldlmcontrol
 all: $(BIN_TARGET)
 
 $(BIN_TARGET): $(BIN_SOURCE)
-   $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@
+   $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@
 
 clean:
rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/fence/Makefile b/fence/Makefile
index 0f1a29c..b4c59dd 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -40,7 +40,7 @@ BIN_LDFLAGS += -ldl
 all: $(BIN_TARGET)
 
 $(BIN_TARGET): $(BIN_SOURCE)
-   $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ -L.
+   $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
 
 clean:
rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 565a600..76d3504 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -86,18 +86,18 @@ LLT_LDFLAGS += $(LDFLAGS)
 all: $(LIB_TARGET) $(LLT_TARGET) $(LIB_PC) $(LLT_PC)
 
 $(LIB_O): $(SOURCE) 
-   $(CC) $(LIB_CFLAGS) -c -o $@ $
+   $(CC) $ $(LIB_CFLAGS) -c -o $@
 
 $(LLT_O): $(SOURCE) 
-   $(CC) $(LLT_CFLAGS) -c -o $@ $
+   $(CC) $ $(LLT_CFLAGS) -c -o $@
 
 $(LIB_TARGET): $(LIB_O)
-   $(CC) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR) $^
+   $(CC) $^ $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR)
ln -sf $(LIB_TARGET) $(LIB_SO)
ln -sf $(LIB_TARGET) $(LIB_SMAJOR)
 
 $(LLT_TARGET): $(LLT_O)
-   $(CC) $(LLT_LDFLAGS) -shared -o $@ -Wl,-soname=$(LLT_SMAJOR) $^
+   $(CC) $^ $(LLT_LDFLAGS) -shared -o $@ -Wl,-soname=$(LLT_SMAJOR)
ln -sf $(LLT_TARGET) $(LLT_SO)
ln -sf $(LLT_TARGET) $(LLT_SMAJOR)
 
-- 
1.7.12.4