From 008b3683bff0edf46b5693bde401942de5f1497e Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Fri, 22 Mar 2019 21:25:28 +0100 Subject: [PATCH] - updated to 2.03.02 --- bashizm.patch | 12 +- device-mapper-dmsetup-deps-export.patch | 10 +- device-mapper-dmsetup-export.patch | 20 +- link.patch | 12 + lvm2-no-systemd.patch | 8 +- lvm2-run-dir.patch | 8 +- lvm2-selinux.patch | 12 +- lvm2-thin.patch | 18 +- lvm2-tld_init.patch | 24 +- lvm2.spec | 19 +- sanlock-fix.patch | 642 ++++++++++++++++++++++++ 11 files changed, 721 insertions(+), 64 deletions(-) create mode 100644 link.patch create mode 100644 sanlock-fix.patch diff --git a/bashizm.patch b/bashizm.patch index 51870d6..5bcdad3 100644 --- a/bashizm.patch +++ b/bashizm.patch @@ -1,6 +1,6 @@ -diff -ur LVM2.2.03.01.orig/configure LVM2.2.03.01/configure ---- LVM2.2.03.01.orig/configure 2018-10-31 14:54:24.000000000 +0000 -+++ LVM2.2.03.01/configure 2018-12-04 08:44:19.090403000 +0000 +diff -ur LVM2.2.03.02.orig/configure LVM2.2.03.02/configure +--- LVM2.2.03.02.orig/configure 2019-03-22 17:12:48.137000000 +0100 ++++ LVM2.2.03.02/configure 2019-03-22 17:13:03.980000000 +0100 @@ -3067,7 +3067,7 @@ fi case "$host_os" in @@ -29,9 +29,9 @@ diff -ur LVM2.2.03.01.orig/configure LVM2.2.03.01/configure esac ################################################################################ -diff -ur LVM2.2.03.01.orig/configure.ac LVM2.2.03.01/configure.ac ---- LVM2.2.03.01.orig/configure.ac 2018-10-31 14:54:24.000000000 +0000 -+++ LVM2.2.03.01/configure.ac 2018-12-04 08:44:19.091403000 +0000 +diff -ur LVM2.2.03.02.orig/configure.ac LVM2.2.03.02/configure.ac +--- LVM2.2.03.02.orig/configure.ac 2019-03-22 17:12:48.155000000 +0100 ++++ LVM2.2.03.02/configure.ac 2019-03-22 17:13:03.980000000 +0100 @@ -30,7 +30,7 @@ AS_IF([test -z "$CFLAGS"], [COPTIMISE_FLAG="-O2"]) case "$host_os" in diff --git a/device-mapper-dmsetup-deps-export.patch b/device-mapper-dmsetup-deps-export.patch index 1144b26..bace4d3 100644 --- a/device-mapper-dmsetup-deps-export.patch +++ b/device-mapper-dmsetup-deps-export.patch @@ -1,7 +1,7 @@ -diff -urp LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.00/libdm/dm-tools/dmsetup.c ---- LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c 2018-10-21 14:36:09.255416609 +0000 -+++ LVM2.2.03.00/libdm/dm-tools/dmsetup.c 2018-10-21 14:37:55.506416609 +0000 -@@ -2568,6 +2568,7 @@ static int _export(CMD_ARGS) +diff -ur LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.02/libdm/dm-tools/dmsetup.c +--- LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c 2019-03-22 17:08:18.345000000 +0100 ++++ LVM2.2.03.02/libdm/dm-tools/dmsetup.c 2019-03-22 17:09:27.125000000 +0100 +@@ -2562,6 +2562,7 @@ const char *name = NULL; const char *uuid = NULL; struct dm_info info; @@ -9,7 +9,7 @@ diff -urp LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.00/libdm/dm-tools if (names) name = names->name; -@@ -2637,6 +2638,28 @@ static int _export(CMD_ARGS) +@@ -2631,6 +2632,28 @@ printf("\n"); } diff --git a/device-mapper-dmsetup-export.patch b/device-mapper-dmsetup-export.patch index a197bdf..ef21a68 100644 --- a/device-mapper-dmsetup-export.patch +++ b/device-mapper-dmsetup-export.patch @@ -1,7 +1,7 @@ -diff -urp LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.00/libdm/dm-tools/dmsetup.c ---- LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c 2018-10-21 13:36:20.379416609 +0000 -+++ LVM2.2.03.00/libdm/dm-tools/dmsetup.c 2018-10-21 14:20:38.626416609 +0000 -@@ -2557,6 +2557,93 @@ out: +diff -ur LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.02/libdm/dm-tools/dmsetup.c +--- LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c 2019-03-22 16:55:55.393000000 +0100 ++++ LVM2.2.03.02/libdm/dm-tools/dmsetup.c 2019-03-22 17:00:55.046000000 +0100 +@@ -2551,6 +2551,93 @@ return r; } @@ -95,7 +95,7 @@ diff -urp LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.00/libdm/dm-tools /* Show target names and their version numbers */ static int _targets(CMD_ARGS) { -@@ -6232,6 +6319,7 @@ static struct command _dmsetup_commands[ +@@ -6230,6 +6317,7 @@ {"stats", " [] [...]", 1, -1, 1, 1, _stats}, {"status", "[...] [--noflush] [--target ]", 0, -1, 2, 0, _status}, {"table", "[...] [--concise] [--target ] [--showkeys]", 0, -1, 2, 0, _status}, @@ -103,10 +103,10 @@ diff -urp LVM2.2.03.00.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.00/libdm/dm-tools {"wait", " [] [--noflush]", 0, 2, 0, 0, _wait}, {"mknodes", "[...]", 0, -1, 1, 0, _mknodes}, {"mangle", "[...]", 0, -1, 1, 0, _mangle}, -diff -urp LVM2.2.03.00.orig/man/dmsetup.8_main LVM2.2.03.00/man/dmsetup.8_main ---- LVM2.2.03.00.orig/man/dmsetup.8_main 2018-10-21 13:36:20.380416609 +0000 -+++ LVM2.2.03.00/man/dmsetup.8_main 2018-10-21 14:20:38.625416609 +0000 -@@ -59,6 +59,14 @@ dmsetup \(em low level logical volume ma +diff -ur LVM2.2.03.02.orig/man/dmsetup.8_main LVM2.2.03.02/man/dmsetup.8_main +--- LVM2.2.03.02.orig/man/dmsetup.8_main 2019-03-22 16:55:55.394000000 +0100 ++++ LVM2.2.03.02/man/dmsetup.8_main 2019-03-22 17:00:55.047000000 +0100 +@@ -59,6 +59,14 @@ . .HP .B dmsetup @@ -121,7 +121,7 @@ diff -urp LVM2.2.03.00.orig/man/dmsetup.8_main LVM2.2.03.00/man/dmsetup.8_main .de CMD_HELP . BR help . RB [ -c | -C | --columns ] -@@ -651,6 +659,9 @@ device. Device names on output can be cu +@@ -651,6 +659,9 @@ \fBdevname\fP (map name for device-mapper devices, equal to blkdevname otherwise). . .HP diff --git a/link.patch b/link.patch new file mode 100644 index 0000000..e89d3ae --- /dev/null +++ b/link.patch @@ -0,0 +1,12 @@ +diff -ur LVM2.2.03.02.orig/tools/Makefile.in LVM2.2.03.02/tools/Makefile.in +--- LVM2.2.03.02.orig/tools/Makefile.in 2018-12-18 15:22:34.000000000 +0100 ++++ LVM2.2.03.02/tools/Makefile.in 2019-03-22 21:16:03.771000000 +0100 +@@ -154,7 +154,7 @@ + $(Q) $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \ + $(CFLAGS) $(CLDFLAGS) -o $@ \ + @CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@ \ +- $(LVMINTERNAL_LIBS) $(LVMLIBS) ++ $(LVMINTERNAL_LIBS) $(LVMLIBS) -ldevmapper-event + + liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX) + @echo " [LN] $@" diff --git a/lvm2-no-systemd.patch b/lvm2-no-systemd.patch index 514551a..9aee4e1 100644 --- a/lvm2-no-systemd.patch +++ b/lvm2-no-systemd.patch @@ -1,7 +1,7 @@ -diff -urp LVM2.2.03.00.orig/daemons/lvmlockd/Makefile.in LVM2.2.03.00/daemons/lvmlockd/Makefile.in ---- LVM2.2.03.00.orig/daemons/lvmlockd/Makefile.in 2018-10-21 15:23:18.299416609 +0000 -+++ LVM2.2.03.00/daemons/lvmlockd/Makefile.in 2018-10-21 15:23:35.952416609 +0000 -@@ -15,7 +15,7 @@ srcdir = @srcdir@ +diff -ur LVM2.2.03.02.orig/daemons/lvmlockd/Makefile.in LVM2.2.03.02/daemons/lvmlockd/Makefile.in +--- LVM2.2.03.02.orig/daemons/lvmlockd/Makefile.in 2019-03-22 17:12:10.302000000 +0100 ++++ LVM2.2.03.02/daemons/lvmlockd/Makefile.in 2019-03-22 17:12:30.044000000 +0100 +@@ -15,7 +15,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ diff --git a/lvm2-run-dir.patch b/lvm2-run-dir.patch index d0435ae..bade245 100644 --- a/lvm2-run-dir.patch +++ b/lvm2-run-dir.patch @@ -1,7 +1,7 @@ -diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac ---- LVM2.2.03.00.orig/configure.ac 2018-10-21 14:35:34.502416609 +0000 -+++ LVM2.2.03.00/configure.ac 2018-10-21 14:35:49.006416609 +0000 -@@ -681,8 +681,7 @@ pkg_config_init() { +diff -ur LVM2.2.03.02.orig/configure.ac LVM2.2.03.02/configure.ac +--- LVM2.2.03.02.orig/configure.ac 2019-03-22 17:02:35.939000000 +0100 ++++ LVM2.2.03.02/configure.ac 2019-03-22 17:06:34.965000000 +0100 +@@ -689,8 +689,7 @@ ################################################################################ AC_MSG_CHECKING(for default run directory) diff --git a/lvm2-selinux.patch b/lvm2-selinux.patch index 34c316a..9f87a47 100644 --- a/lvm2-selinux.patch +++ b/lvm2-selinux.patch @@ -1,10 +1,10 @@ -diff -urp LVM2.2.03.00.orig/tools/Makefile.in LVM2.2.03.00/tools/Makefile.in ---- LVM2.2.03.00.orig/tools/Makefile.in 2018-10-10 10:11:03.000000000 +0000 -+++ LVM2.2.03.00/tools/Makefile.in 2018-10-21 13:35:25.885416609 +0000 -@@ -91,6 +91,9 @@ endif - - LVMLIBS = $(LVMINTERNAL_LIBS) -laio +diff -ur LVM2.2.03.02.orig/tools/Makefile.in LVM2.2.03.02/tools/Makefile.in +--- LVM2.2.03.02.orig/tools/Makefile.in 2018-12-18 15:22:34.000000000 +0100 ++++ LVM2.2.03.02/tools/Makefile.in 2019-03-22 16:54:15.870000000 +0100 +@@ -92,6 +92,9 @@ + LVMLIBS = $(SYSTEMD_LIBS) -L$(top_builddir)/libdm -ldevmapper $(LIBS) -laio LIB_VERSION = $(LIB_VERSION_LVM) + INCLUDES = -I$(top_builddir)/tools +ifneq ("@STATIC_LINK@", "yes") + LVMLIBS += -lselinux -lsepol +endif diff --git a/lvm2-thin.patch b/lvm2-thin.patch index 90078e8..f1a74c3 100644 --- a/lvm2-thin.patch +++ b/lvm2-thin.patch @@ -1,7 +1,7 @@ -diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac ---- LVM2.2.03.00.orig/configure.ac 2018-10-21 14:38:26.196416609 +0000 -+++ LVM2.2.03.00/configure.ac 2018-10-21 14:38:47.235416609 +0000 -@@ -388,7 +388,7 @@ dnl -- thin_check needs-check flag +diff -ur LVM2.2.03.02.orig/configure.ac LVM2.2.03.02/configure.ac +--- LVM2.2.03.02.orig/configure.ac 2019-03-22 17:10:13.162000000 +0100 ++++ LVM2.2.03.02/configure.ac 2019-03-22 17:10:38.684000000 +0100 +@@ -396,7 +396,7 @@ AC_ARG_ENABLE(thin_check_needs_check, AC_HELP_STRING([--disable-thin_check_needs_check], [required if thin_check version is < 0.3.0]), @@ -10,7 +10,7 @@ diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac # Test if necessary thin tools are available # if not - use plain defaults and warn user -@@ -403,7 +403,7 @@ case "$THIN" in +@@ -411,7 +411,7 @@ THIN_CONFIGURE_WARN=y fi fi @@ -19,7 +19,7 @@ diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac THIN_CHECK_VSN=`"$THIN_CHECK_CMD" -V 2>/dev/null` THIN_CHECK_VSN_MAJOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $1}'` THIN_CHECK_VSN_MINOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $2}'` -@@ -416,6 +416,8 @@ case "$THIN" in +@@ -424,6 +424,8 @@ AC_MSG_WARN([$THIN_CHECK_CMD: Old version "$THIN_CHECK_VSN" found]) THIN_CHECK_VERSION_WARN=y THIN_CHECK_NEEDS_CHECK=no @@ -28,7 +28,7 @@ diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac fi fi # Empty means a config way to ignore thin dumping -@@ -502,7 +504,7 @@ dnl -- cache_check needs-check flag +@@ -510,7 +512,7 @@ AC_ARG_ENABLE(cache_check_needs_check, AC_HELP_STRING([--disable-cache_check_needs_check], [required if cache_check version is < 0.5]), @@ -37,7 +37,7 @@ diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac # Test if necessary cache tools are available # if not - use plain defaults and warn user -@@ -517,7 +519,7 @@ case "$CACHE" in +@@ -525,7 +527,7 @@ CACHE_CONFIGURE_WARN=y fi fi @@ -46,7 +46,7 @@ diff -urp LVM2.2.03.00.orig/configure.ac LVM2.2.03.00/configure.ac $CACHE_CHECK_CMD -V 2>/dev/null >conftest.tmp read -r CACHE_CHECK_VSN < conftest.tmp IFS=.- read -r CACHE_CHECK_VSN_MAJOR CACHE_CHECK_VSN_MINOR CACHE_CHECK_VSN_PATCH LEFTOVER < conftest.tmp -@@ -541,6 +543,8 @@ case "$CACHE" in +@@ -549,6 +551,8 @@ AC_MSG_WARN([$CACHE_CHECK_CMD: Old version "$CACHE_CHECK_VSN" does not support new cache format V2]) CACHE_CHECK_VERSION_WARN=y fi diff --git a/lvm2-tld_init.patch b/lvm2-tld_init.patch index ecc58b2..83b42eb 100644 --- a/lvm2-tld_init.patch +++ b/lvm2-tld_init.patch @@ -1,6 +1,6 @@ -diff -urp LVM2.2.03.00.orig/scripts/blk_availability_init_red_hat.in LVM2.2.03.00/scripts/blk_availability_init_red_hat.in ---- LVM2.2.03.00.orig/scripts/blk_availability_init_red_hat.in 2018-10-21 14:21:38.112416609 +0000 -+++ LVM2.2.03.00/scripts/blk_availability_init_red_hat.in 2018-10-21 14:21:53.152416609 +0000 +diff -ur LVM2.2.03.02.orig/scripts/blk_availability_init_red_hat.in LVM2.2.03.02/scripts/blk_availability_init_red_hat.in +--- LVM2.2.03.02.orig/scripts/blk_availability_init_red_hat.in 2019-03-22 17:01:45.758000000 +0100 ++++ LVM2.2.03.02/scripts/blk_availability_init_red_hat.in 2019-03-22 17:01:58.006000000 +0100 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh @@ -44,9 +44,9 @@ diff -urp LVM2.2.03.00.orig/scripts/blk_availability_init_red_hat.in LVM2.2.03.0 + exit 3 ;; esac -diff -urp LVM2.2.03.00.orig/scripts/cmirrord_init_red_hat.in LVM2.2.03.00/scripts/cmirrord_init_red_hat.in ---- LVM2.2.03.00.orig/scripts/cmirrord_init_red_hat.in 2018-10-21 14:21:38.112416609 +0000 -+++ LVM2.2.03.00/scripts/cmirrord_init_red_hat.in 2018-10-21 14:25:55.744416609 +0000 +diff -ur LVM2.2.03.02.orig/scripts/cmirrord_init_red_hat.in LVM2.2.03.02/scripts/cmirrord_init_red_hat.in +--- LVM2.2.03.02.orig/scripts/cmirrord_init_red_hat.in 2019-03-22 17:01:45.758000000 +0100 ++++ LVM2.2.03.02/scripts/cmirrord_init_red_hat.in 2019-03-22 17:01:58.006000000 +0100 @@ -2,7 +2,7 @@ # # chkconfig: - 22 78 @@ -175,9 +175,9 @@ diff -urp LVM2.2.03.00.orig/scripts/cmirrord_init_red_hat.in LVM2.2.03.00/script -exit $rtrn +exit $RETVAL -diff -urp LVM2.2.03.00.orig/scripts/lvm2_lvmpolld_init_red_hat.in LVM2.2.03.00/scripts/lvm2_lvmpolld_init_red_hat.in ---- LVM2.2.03.00.orig/scripts/lvm2_lvmpolld_init_red_hat.in 2018-10-21 14:21:38.112416609 +0000 -+++ LVM2.2.03.00/scripts/lvm2_lvmpolld_init_red_hat.in 2018-10-21 14:25:59.004416609 +0000 +diff -ur LVM2.2.03.02.orig/scripts/lvm2_lvmpolld_init_red_hat.in LVM2.2.03.02/scripts/lvm2_lvmpolld_init_red_hat.in +--- LVM2.2.03.02.orig/scripts/lvm2_lvmpolld_init_red_hat.in 2019-03-22 17:01:45.758000000 +0100 ++++ LVM2.2.03.02/scripts/lvm2_lvmpolld_init_red_hat.in 2019-03-22 17:01:58.006000000 +0100 @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh @@ -324,9 +324,9 @@ diff -urp LVM2.2.03.00.orig/scripts/lvm2_lvmpolld_init_red_hat.in LVM2.2.03.00/s -exit $rtrn +exit $RETVAL -diff -urp LVM2.2.03.00.orig/scripts/lvm2_monitoring_init_red_hat.in LVM2.2.03.00/scripts/lvm2_monitoring_init_red_hat.in ---- LVM2.2.03.00.orig/scripts/lvm2_monitoring_init_red_hat.in 2018-10-21 14:21:38.112416609 +0000 -+++ LVM2.2.03.00/scripts/lvm2_monitoring_init_red_hat.in 2018-10-21 14:25:59.004416609 +0000 +diff -ur LVM2.2.03.02.orig/scripts/lvm2_monitoring_init_red_hat.in LVM2.2.03.02/scripts/lvm2_monitoring_init_red_hat.in +--- LVM2.2.03.02.orig/scripts/lvm2_monitoring_init_red_hat.in 2019-03-22 17:01:45.758000000 +0100 ++++ LVM2.2.03.02/scripts/lvm2_monitoring_init_red_hat.in 2019-03-22 17:01:58.006000000 +0100 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh diff --git a/lvm2.spec b/lvm2.spec index 7e4ef85..d82faa3 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -31,21 +31,22 @@ Summary: The new version of Logical Volume Manager for Linux Summary(pl.UTF-8): Nowa wersja Logical Volume Managera dla Linuksa Name: lvm2 -Version: 2.03.01 +Version: 2.03.02 Release: 1 License: GPL v2 and LGPL v2.1 Group: Applications/System Source0: ftp://sources.redhat.com/pub/lvm2/LVM2.%{version}.tgz -# Source0-md5: 800287d3521388dcc4a601d099b47bcd +# Source0-md5: 5fc07da5461a3794a751dcfc355827d5 Patch0: %{name}-selinux.patch Patch1: device-mapper-dmsetup-export.patch Patch2: %{name}-tld_init.patch -Patch3: dl-dlsym.patch -Patch4: %{name}-run-dir.patch -Patch5: device-mapper-dmsetup-deps-export.patch -Patch6: %{name}-thin.patch -Patch7: %{name}-no-systemd.patch -Patch8: bashizm.patch +Patch3: %{name}-run-dir.patch +Patch4: device-mapper-dmsetup-deps-export.patch +Patch5: %{name}-thin.patch +Patch6: %{name}-no-systemd.patch +Patch7: bashizm.patch +Patch8: sanlock-fix.patch +Patch9: link.patch URL: http://www.sourceware.org/lvm2/ BuildRequires: autoconf >= 2.69 BuildRequires: automake @@ -288,6 +289,7 @@ Statyczna biblioteka devmapper zbudowana z dietlibc. %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 # do not force --export-symbol linker option for e.g. statically linked executables # -rdynamic compiler option drives linker in the right way. @@ -584,6 +586,7 @@ fi /lib/udev/rules.d/10-dm.rules /lib/udev/rules.d/11-dm-lvm.rules /lib/udev/rules.d/13-dm-disk.rules +/lib/udev/rules.d/69-dm-lvm-metad.rules /lib/udev/rules.d/95-dm-notify.rules %attr(755,root,root) %{_sbindir}/dmeventd %attr(755,root,root) %{_sbindir}/dmsetup diff --git a/sanlock-fix.patch b/sanlock-fix.patch new file mode 100644 index 0000000..c6ca012 --- /dev/null +++ b/sanlock-fix.patch @@ -0,0 +1,642 @@ +From 0b01e3f5d7ce1c954aa9f3707aa645508664f7f1 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Mon, 22 Oct 2018 15:45:23 -0500 +Subject: [PATCH] lvmlockd: use new sanlock sector/align interface + +The choice about sector size and lease align size is +now made by the sanlock user, in this case lvmlockd. +This will allow lvmlockd to use other lease sizes in +the future. This also prevents breakage if hosts +report different sector sizes, or the sector size +reported by a device changes. +--- + daemons/lvmlockd/lvmlockd-core.c | 21 ++- + daemons/lvmlockd/lvmlockd-internal.h | 8 +- + daemons/lvmlockd/lvmlockd-sanlock.c | 311 +++++++++++++++++++++++++++++++---- + 3 files changed, 301 insertions(+), 39 deletions(-) + +diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c +index 6490b40..5bdbefe 100644 +--- a/daemons/lvmlockd/lvmlockd-core.c ++++ b/daemons/lvmlockd/lvmlockd-core.c +@@ -929,12 +929,12 @@ static void lm_rem_resource(struct lockspace *ls, struct resource *r) + lm_rem_resource_sanlock(ls, r); + } + +-static int lm_find_free_lock(struct lockspace *ls, uint64_t *free_offset) ++static int lm_find_free_lock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size) + { + if (ls->lm_type == LD_LM_DLM) + return 0; + else if (ls->lm_type == LD_LM_SANLOCK) +- return lm_find_free_lock_sanlock(ls, free_offset); ++ return lm_find_free_lock_sanlock(ls, free_offset, sector_size, align_size); + return -1; + } + +@@ -2427,11 +2427,16 @@ static void *lockspace_thread_main(void *arg_in) + + if (act->op == LD_OP_FIND_FREE_LOCK && act->rt == LD_RT_VG) { + uint64_t free_offset = 0; ++ int sector_size = 0; ++ int align_size = 0; ++ + log_debug("S %s find free lock", ls->name); +- rv = lm_find_free_lock(ls, &free_offset); +- log_debug("S %s find free lock %d offset %llu", +- ls->name, rv, (unsigned long long)free_offset); ++ rv = lm_find_free_lock(ls, &free_offset, §or_size, &align_size); ++ log_debug("S %s find free lock %d offset %llu sector_size %d align_size %d", ++ ls->name, rv, (unsigned long long)free_offset, sector_size, align_size); + ls->free_lock_offset = free_offset; ++ ls->free_lock_sector_size = sector_size; ++ ls->free_lock_align_size = align_size; + list_del(&act->list); + act->result = rv; + add_client_result(act); +@@ -3237,6 +3242,8 @@ static int work_init_lv(struct action *act) + char vg_args[MAX_ARGS+1]; + char lv_args[MAX_ARGS+1]; + uint64_t free_offset = 0; ++ int sector_size = 0; ++ int align_size = 0; + int lm_type = 0; + int rv = 0; + +@@ -3252,6 +3259,8 @@ static int work_init_lv(struct action *act) + lm_type = ls->lm_type; + memcpy(vg_args, ls->vg_args, MAX_ARGS); + free_offset = ls->free_lock_offset; ++ sector_size = ls->free_lock_sector_size; ++ align_size = ls->free_lock_align_size; + } + pthread_mutex_unlock(&lockspaces_mutex); + +@@ -3268,7 +3277,7 @@ static int work_init_lv(struct action *act) + + if (lm_type == LD_LM_SANLOCK) { + rv = lm_init_lv_sanlock(ls_name, act->vg_name, act->lv_uuid, +- vg_args, lv_args, free_offset); ++ vg_args, lv_args, sector_size, align_size, free_offset); + + memcpy(act->lv_args, lv_args, MAX_ARGS); + return rv; +diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h +index a2280b8..ead3098 100644 +--- a/daemons/lvmlockd/lvmlockd-internal.h ++++ b/daemons/lvmlockd/lvmlockd-internal.h +@@ -174,7 +174,9 @@ struct lockspace { + int8_t lm_type; /* lock manager: LM_DLM, LM_SANLOCK */ + void *lm_data; + uint64_t host_id; +- uint64_t free_lock_offset; /* start search for free lock here */ ++ uint64_t free_lock_offset; /* for sanlock, start search for free lock here */ ++ int free_lock_sector_size; /* for sanlock */ ++ int free_lock_align_size; /* for sanlock */ + + uint32_t start_client_id; /* client_id that started the lockspace */ + pthread_t thread; /* makes synchronous lock requests */ +@@ -468,7 +470,7 @@ static inline int lm_hosts_dlm(struct lockspace *ls, int notify) + #ifdef LOCKDSANLOCK_SUPPORT + + int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args); +-int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, char *vg_args, char *lv_args, uint64_t free_offset); ++int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, char *vg_args, char *lv_args, int sector_size, int align_size, uint64_t free_offset); + int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r); + int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args); + int lm_prepare_lockspace_sanlock(struct lockspace *ls); +@@ -488,7 +490,7 @@ int lm_gl_is_enabled(struct lockspace *ls); + int lm_get_lockspaces_sanlock(struct list_head *ls_rejoin); + int lm_data_size_sanlock(void); + int lm_is_running_sanlock(void); +-int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset); ++int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size); + + static inline int lm_support_sanlock(void) + { +diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c +index d5d6864..892b446 100644 +--- a/daemons/lvmlockd/lvmlockd-sanlock.c ++++ b/daemons/lvmlockd/lvmlockd-sanlock.c +@@ -24,10 +24,29 @@ + #include "sanlock_admin.h" + #include "sanlock_resource.h" + ++/* FIXME: these are copied from sanlock.h only until ++ an updated version of sanlock is available with them. */ ++#define SANLK_RES_ALIGN1M 0x00000010 ++#define SANLK_RES_ALIGN2M 0x00000020 ++#define SANLK_RES_ALIGN4M 0x00000040 ++#define SANLK_RES_ALIGN8M 0x00000080 ++#define SANLK_RES_SECTOR512 0x00000100 ++#define SANLK_RES_SECTOR4K 0x00000200 ++#define SANLK_LSF_ALIGN1M 0x00000010 ++#define SANLK_LSF_ALIGN2M 0x00000020 ++#define SANLK_LSF_ALIGN4M 0x00000040 ++#define SANLK_LSF_ALIGN8M 0x00000080 ++#define SANLK_LSF_SECTOR512 0x00000100 ++#define SANLK_LSF_SECTOR4K 0x00000200 ++ + #include + #include + #include + #include ++#include ++#include ++ ++#define ONE_MB 1048576 + + /* + ------------------------------------------------------------------------------- +@@ -139,6 +158,7 @@ release all the leases for the VG. + + struct lm_sanlock { + struct sanlk_lockspace ss; ++ int sector_size; + int align_size; + int sock; /* sanlock daemon connection */ + }; +@@ -201,7 +221,6 @@ int lm_data_size_sanlock(void) + * ... + */ + +-#define LS_BEGIN 0 + #define GL_LOCK_BEGIN UINT64_C(65) + #define VG_LOCK_BEGIN UINT64_C(66) + #define LV_LOCK_BEGIN UINT64_C(67) +@@ -324,6 +343,152 @@ fail: + return rv; + } + ++static void _read_sysfs_size(dev_t devno, const char *name, unsigned int *val) ++{ ++ char path[PATH_MAX]; ++ char buf[32]; ++ FILE *fp; ++ size_t len; ++ ++ snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/queue/%s", ++ (int)MAJOR(devno), (int)MINOR(devno), name); ++ ++ if (!(fp = fopen(path, "r"))) ++ return; ++ ++ if (!fgets(buf, sizeof(buf), fp)) ++ goto out; ++ ++ if ((len = strlen(buf)) && buf[len - 1] == '\n') ++ buf[--len] = '\0'; ++ ++ if (strlen(buf)) ++ *val = atoi(buf); ++out: ++ fclose(fp); ++} ++ ++/* Select sector/align size for a new VG based on what the device reports for ++ sector size of the lvmlock LV. */ ++ ++static int get_sizes_device(char *path, int *sector_size, int *align_size) ++{ ++ unsigned int physical_block_size = 0; ++ unsigned int logical_block_size = 0; ++ struct stat st; ++ int rv; ++ ++ rv = stat(path, &st); ++ if (rv < 0) { ++ log_error("Failed to stat device to get block size %s %d", path, errno); ++ return -1; ++ } ++ ++ _read_sysfs_size(st.st_rdev, "physical_block_size", &physical_block_size); ++ _read_sysfs_size(st.st_rdev, "logical_block_size", &logical_block_size); ++ ++ if ((physical_block_size == 512) && (logical_block_size == 512)) { ++ *sector_size = 512; ++ *align_size = ONE_MB; ++ return 0; ++ } ++ ++ if ((physical_block_size == 4096) && (logical_block_size == 4096)) { ++ *sector_size = 4096; ++ *align_size = 8 * ONE_MB; ++ return 0; ++ } ++ ++ if (physical_block_size && (physical_block_size != 512) && (physical_block_size != 4096)) { ++ log_warn("WARNING: invalid block sizes physical %u logical %u for %s", ++ physical_block_size, logical_block_size, path); ++ physical_block_size = 0; ++ } ++ ++ if (logical_block_size && (logical_block_size != 512) && (logical_block_size != 4096)) { ++ log_warn("WARNING: invalid block sizes physical %u logical %u for %s", ++ physical_block_size, logical_block_size, path); ++ logical_block_size = 0; ++ } ++ ++ if (!physical_block_size && !logical_block_size) { ++ log_error("Failed to get a block size for %s", path); ++ return -1; ++ } ++ ++ if (!physical_block_size || !logical_block_size) { ++ log_warn("WARNING: incomplete block size information physical %u logical %u for %s", ++ physical_block_size, logical_block_size, path); ++ if (!physical_block_size) ++ physical_block_size = logical_block_size; ++ if (!logical_block_size) ++ logical_block_size = physical_block_size; ++ } ++ ++ if ((logical_block_size == 4096) && (physical_block_size == 512)) { ++ log_warn("WARNING: mixed block sizes physical %u logical %u (using 4096) for %s", ++ physical_block_size, logical_block_size, path); ++ *sector_size = 4096; ++ *align_size = 8 * ONE_MB; ++ return 0; ++ } ++ ++ if ((physical_block_size == 4096) && (logical_block_size == 512)) { ++ log_warn("WARNING: mixed block sizes physical %u logical %u (using 4096) for %s", ++ physical_block_size, logical_block_size, path); ++ *sector_size = 4096; ++ *align_size = 8 * ONE_MB; ++ return 0; ++ } ++ ++ if (physical_block_size == 512) { ++ *sector_size = 512; ++ *align_size = ONE_MB; ++ return 0; ++ } ++ ++ if (physical_block_size == 4096) { ++ *sector_size = 4096; ++ *align_size = 8 * ONE_MB; ++ return 0; ++ } ++ ++ log_error("Failed to get a block size for %s", path); ++ return -1; ++} ++ ++ ++/* Get the sector/align sizes that were used to create an existing VG. ++ sanlock encoded this in the lockspace/resource structs on disk. */ ++ ++static int get_sizes_lockspace(char *path, int *sector_size, int *align_size) ++{ ++ struct sanlk_lockspace ss; ++ uint32_t io_timeout = 0; ++ int rv; ++ ++ memset(&ss, 0, sizeof(ss)); ++ memcpy(ss.host_id_disk.path, path, SANLK_PATH_LEN); ++ ss.host_id_disk.offset = 0; ++ ++ rv = sanlock_read_lockspace(&ss, 0, &io_timeout); ++ if (rv < 0) { ++ log_error("get_sizes_lockspace %s error %d", path, rv); ++ return rv; ++ } ++ ++ if ((ss.flags & SANLK_LSF_SECTOR4K) && (ss.flags & SANLK_LSF_ALIGN8M)) { ++ *sector_size = 4096; ++ *align_size = 8 * ONE_MB; ++ } else if ((ss.flags & SANLK_LSF_SECTOR512) && (ss.flags & SANLK_LSF_ALIGN1M)) { ++ *sector_size = 512; ++ *align_size = ONE_MB; ++ } ++ ++ log_debug("get_sizes_lockspace found %d %d", *sector_size, *align_size); ++ return 0; ++} ++ + /* + * vgcreate + * +@@ -343,7 +508,8 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + uint32_t daemon_version; + uint32_t daemon_proto; + uint64_t offset; +- int align_size; ++ int sector_size = 0; ++ int align_size = 0; + int i, rv; + + memset(&ss, 0, sizeof(ss)); +@@ -387,23 +553,25 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + log_debug("sanlock daemon version %08x proto %08x", + daemon_version, daemon_proto); + +- rv = sanlock_align(&disk); +- if (rv <= 0) { ++ /* Nothing formatted on disk yet, use what the device reports. */ ++ rv = get_sizes_device(disk.path, §or_size, &align_size); ++ if (rv < 0) { + if (rv == -EACCES) { + log_error("S %s init_vg_san sanlock error -EACCES: no permission to access %s", + ls_name, disk.path); + return -EDEVOPEN; + } else { +- log_error("S %s init_vg_san sanlock error %d trying to get align size of %s", ++ log_error("S %s init_vg_san sanlock error %d trying to get sector/align size of %s", + ls_name, rv, disk.path); + return -EARGS; + } +- } else +- align_size = rv; ++ } + + strncpy(ss.name, ls_name, SANLK_NAME_LEN); + memcpy(ss.host_id_disk.path, disk.path, SANLK_PATH_LEN); +- ss.host_id_disk.offset = LS_BEGIN * align_size; ++ ss.host_id_disk.offset = 0; ++ ss.flags = (sector_size == 4096) ? (SANLK_LSF_SECTOR4K | SANLK_LSF_ALIGN8M) : ++ (SANLK_LSF_SECTOR512 | SANLK_LSF_ALIGN1M); + + rv = sanlock_write_lockspace(&ss, 0, 0, sanlock_io_timeout); + if (rv < 0) { +@@ -436,6 +604,8 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN); + rd.rs.disks[0].offset = align_size * GL_LOCK_BEGIN; + rd.rs.num_disks = 1; ++ rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + rv = sanlock_write_resource(&rd.rs, 0, 0, 0); + if (rv < 0) { +@@ -449,6 +619,8 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN); + rd.rs.disks[0].offset = align_size * VG_LOCK_BEGIN; + rd.rs.num_disks = 1; ++ rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + rv = sanlock_write_resource(&rd.rs, 0, 0, 0); + if (rv < 0) { +@@ -472,6 +644,8 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + + memset(&rd, 0, sizeof(rd)); + rd.rs.num_disks = 1; ++ rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + memcpy(rd.rs.disks[0].path, disk.path, SANLK_PATH_LEN); + strncpy(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN); + strcpy(rd.rs.name, "#unused"); +@@ -510,13 +684,13 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar + */ + + int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, +- char *vg_args, char *lv_args, uint64_t free_offset) ++ char *vg_args, char *lv_args, ++ int sector_size, int align_size, uint64_t free_offset) + { + struct sanlk_resourced rd; + char lock_lv_name[MAX_ARGS+1]; + char lock_args_version[MAX_ARGS+1]; + uint64_t offset; +- int align_size; + int rv; + + memset(&rd, 0, sizeof(rd)); +@@ -534,7 +708,7 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, + LV_LOCK_ARGS_MAJOR, LV_LOCK_ARGS_MINOR, LV_LOCK_ARGS_PATCH); + + if (daemon_test) { +- align_size = 1048576; ++ align_size = ONE_MB; + snprintf(lv_args, MAX_ARGS, "%s:%llu", + lock_args_version, + (unsigned long long)((align_size * LV_LOCK_BEGIN) + (align_size * daemon_test_lv_count))); +@@ -547,12 +721,35 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, + if ((rv = build_dm_path(rd.rs.disks[0].path, SANLK_PATH_LEN, vg_name, lock_lv_name))) + return rv; + +- align_size = sanlock_align(&rd.rs.disks[0]); +- if (align_size <= 0) { +- log_error("S %s init_lv_san align error %d", ls_name, align_size); +- return -EINVAL; ++ /* ++ * These should not usually be zero, maybe only the first time this function is called? ++ * We need to use the same sector/align sizes that are already being used. ++ */ ++ if (!sector_size || !align_size) { ++ rv = get_sizes_lockspace(rd.rs.disks[0].path, §or_size, &align_size); ++ if (rv < 0) { ++ log_error("S %s init_lv_san read_lockspace error %d %s", ++ ls_name, rv, rd.rs.disks[0].path); ++ return rv; ++ } ++ ++ if (sector_size) ++ log_debug("S %s init_lv_san found ls sector_size %d align_size %d", ls_name, sector_size, align_size); ++ else { ++ /* use the old method */ ++ align_size = sanlock_align(&rd.rs.disks[0]); ++ if (align_size <= 0) { ++ log_error("S %s init_lv_san align error %d", ls_name, align_size); ++ return -EINVAL; ++ } ++ sector_size = (align_size == ONE_MB) ? 512 : 4096; ++ log_debug("S %s init_lv_san found old sector_size %d align_size %d", ls_name, sector_size, align_size); ++ } + } + ++ rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); ++ + if (free_offset) + offset = free_offset; + else +@@ -595,6 +792,8 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, + ls_name, lv_name, (unsigned long long)offset); + + strncpy(rd.rs.name, lv_name, SANLK_NAME_LEN); ++ rd.rs.flags = (sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + rv = sanlock_write_resource(&rd.rs, 0, 0, 0); + if (!rv) { +@@ -626,7 +825,8 @@ int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ + char lock_lv_name[MAX_ARGS+1]; + uint64_t offset; + uint32_t io_timeout; +- int align_size; ++ int sector_size = 0; ++ int align_size = 0; + int i, rv; + + memset(&disk, 0, sizeof(disk)); +@@ -655,20 +855,13 @@ int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ + /* FIXME: device is not always ready for us here */ + sleep(1); + +- align_size = sanlock_align(&disk); +- if (align_size <= 0) { +- log_error("S %s rename_vg_san bad align size %d %s", +- ls_name, align_size, disk.path); +- return -EINVAL; +- } +- + /* + * Lockspace + */ + + memset(&ss, 0, sizeof(ss)); + memcpy(ss.host_id_disk.path, disk.path, SANLK_PATH_LEN); +- ss.host_id_disk.offset = LS_BEGIN * align_size; ++ ss.host_id_disk.offset = 0; + + rv = sanlock_read_lockspace(&ss, 0, &io_timeout); + if (rv < 0) { +@@ -677,6 +870,26 @@ int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ + return rv; + } + ++ if ((ss.flags & SANLK_LSF_SECTOR4K) && (ss.flags & SANLK_LSF_ALIGN8M)) { ++ sector_size = 4096; ++ align_size = 8 * ONE_MB; ++ } else if ((ss.flags & SANLK_LSF_SECTOR512) && (ss.flags & SANLK_LSF_ALIGN1M)) { ++ sector_size = 512; ++ align_size = ONE_MB; ++ } else { ++ /* use the old method */ ++ align_size = sanlock_align(&ss.host_id_disk); ++ if (align_size <= 0) { ++ log_error("S %s rename_vg_san unknown sector/align size for %s", ++ ls_name, ss.host_id_disk.path); ++ return -1; ++ } ++ sector_size = (align_size == ONE_MB) ? 512 : 4096; ++ } ++ ++ if (!sector_size || !align_size) ++ return -1; ++ + strncpy(ss.name, ls_name, SANLK_NAME_LEN); + + rv = sanlock_write_lockspace(&ss, 0, 0, sanlock_io_timeout); +@@ -830,6 +1043,11 @@ int lm_ex_disable_gl_sanlock(struct lockspace *ls) + rd1.rs.num_disks = 1; + strncpy(rd1.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1); + rd1.rs.disks[0].offset = lms->align_size * GL_LOCK_BEGIN; ++ ++ rd1.rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); ++ rd2.rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + rv = sanlock_acquire(lms->sock, -1, 0, 1, &rs1, NULL); + if (rv < 0) { +@@ -891,6 +1109,8 @@ int lm_able_gl_sanlock(struct lockspace *ls, int enable) + rd.rs.num_disks = 1; + strncpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1); + rd.rs.disks[0].offset = lms->align_size * GL_LOCK_BEGIN; ++ rd.rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + rv = sanlock_write_resource(&rd.rs, 0, 0, 0); + if (rv < 0) { +@@ -936,7 +1156,8 @@ static int gl_is_enabled(struct lockspace *ls, struct lm_sanlock *lms) + + rv = sanlock_read_resource(&rd.rs, 0); + if (rv < 0) { +- log_error("gl_is_enabled read_resource error %d", rv); ++ log_error("gl_is_enabled read_resource align_size %d offset %llu error %d", ++ lms->align_size, (unsigned long long)offset, rv); + return rv; + } + +@@ -973,7 +1194,7 @@ int lm_gl_is_enabled(struct lockspace *ls) + * been disabled.) + */ + +-int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset) ++int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size) + { + struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data; + struct sanlk_resourced rd; +@@ -983,15 +1204,22 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset) + int round = 0; + + if (daemon_test) { +- *free_offset = (1048576 * LV_LOCK_BEGIN) + (1048576 * (daemon_test_lv_count + 1)); ++ *free_offset = (ONE_MB * LV_LOCK_BEGIN) + (ONE_MB * (daemon_test_lv_count + 1)); ++ *sector_size = 512; ++ *align_size = ONE_MB; + return 0; + } + ++ *sector_size = lms->sector_size; ++ *align_size = lms->align_size; ++ + memset(&rd, 0, sizeof(rd)); + + strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN); + rd.rs.num_disks = 1; + strncpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1); ++ rd.rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : ++ (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + if (ls->free_lock_offset) + offset = ls->free_lock_offset; +@@ -1091,6 +1319,8 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls) + char disk_path[SANLK_PATH_LEN]; + char killpath[SANLK_PATH_LEN]; + char killargs[SANLK_PATH_LEN]; ++ int sector_size = 0; ++ int align_size = 0; + int gl_found; + int ret, rv; + +@@ -1207,13 +1437,33 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls) + goto fail; + } + +- lms->align_size = sanlock_align(&lms->ss.host_id_disk); +- if (lms->align_size <= 0) { +- log_error("S %s prepare_lockspace_san align error %d", lsname, lms->align_size); ++ rv = get_sizes_lockspace(disk_path, §or_size, &align_size); ++ if (rv < 0) { ++ log_error("S %s prepare_lockspace_san cannot get sector/align sizes %d", lsname, rv); + ret = -EMANAGER; + goto fail; + } + ++ if (!sector_size) { ++ log_debug("S %s prepare_lockspace_san using old size method", lsname); ++ /* use the old method */ ++ align_size = sanlock_align(&lms->ss.host_id_disk); ++ if (align_size <= 0) { ++ log_error("S %s prepare_lockspace_san align error %d", lsname, align_size); ++ return -EINVAL; ++ } ++ sector_size = (align_size == ONE_MB) ? 512 : 4096; ++ log_debug("S %s prepare_lockspace_san found old sector_size %d align_size %d", lsname, sector_size, align_size); ++ } ++ ++ log_debug("S %s prepare_lockspace_san sizes %d %d", lsname, sector_size, align_size); ++ ++ lms->align_size = align_size; ++ lms->sector_size = sector_size; ++ ++ lms->ss.flags = (sector_size == 4096) ? (SANLK_LSF_SECTOR4K | SANLK_LSF_ALIGN8M) : ++ (SANLK_LSF_SECTOR512 | SANLK_LSF_ALIGN1M); ++ + gl_found = gl_is_enabled(ls, lms); + if (gl_found < 0) { + log_error("S %s prepare_lockspace_san gl_enabled error %d", lsname, gl_found); +@@ -1351,6 +1601,7 @@ static int lm_add_resource_sanlock(struct lockspace *ls, struct resource *r) + strncpy(rds->rs.name, r->name, SANLK_NAME_LEN); + rds->rs.num_disks = 1; + memcpy(rds->rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN); ++ rds->rs.flags = (lms->sector_size == 4096) ? (SANLK_RES_SECTOR4K | SANLK_RES_ALIGN8M) : (SANLK_RES_SECTOR512 | SANLK_RES_ALIGN1M); + + if (r->type == LD_RT_GL) + rds->rs.disks[0].offset = GL_LOCK_BEGIN * lms->align_size; +-- +2.9.3 + -- 2.37.3