2015-03-05 23:00:44 +03:00
#
# Copyright (C) 2014-2015 Red Hat, Inc.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License v.2.1.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2015-03-05 23:00:44 +03:00
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
2015-07-06 18:42:11 +03:00
SOURCES = lvmlockd-core.c
2023-02-17 01:40:25 +03:00
SOURCES2 = lvmlockctl.c
TARGETS = lvmlockd lvmlockctl
i n c l u d e $( top_builddir ) / m a k e . t m p l
2015-07-06 18:42:11 +03:00
i f e q ( "@BUILD_LOCKDSANLOCK@" , "yes" )
SOURCES += lvmlockd-sanlock.c
2023-02-17 01:28:08 +03:00
CFLAGS += $( LIBSANLOCKCLIENT_CFLAGS)
LOCK_LIBS += $( LIBSANLOCKCLIENT_LIBS)
2015-07-06 18:42:11 +03:00
e n d i f
i f e q ( "@BUILD_LOCKDDLM@" , "yes" )
SOURCES += lvmlockd-dlm.c
2023-02-17 01:28:08 +03:00
CFLAGS += $( LIBDLM) $( LIBDLMCONTROL_CFLAGS)
# LOCK_LIBS += $(LIBDLM_LIBS) $(LIBDLMCONTROL_LIBS)
LOCK_LIBS += -ldlm_lt $( LIBDLMCONTROL_LIBS)
2015-07-06 18:42:11 +03:00
e n d i f
2015-03-05 23:00:44 +03:00
lvmlockd: idm: Introduce new locking scheme
Alongside the existed locking schemes of DLM and sanlock, this patch is
to introduce new locking scheme: In-Drive-Mutex (IDM).
With the IDM support in the drive, the locks are resident in the drive,
thus, the locking lease is maintained in a central place: the drive
firmware. We can consider this is a typical client-server model,
every host (or node) in the server cluster launches the request for
leasing mutex to a drive firmware, the drive firmware works as an
arbitrator to grant the mutex to a requester and it can reject other
applicants if the mutex has been acquired. To satisfy the LVM
activation for different modes, IDM supports two locking modes:
exclusive and shareable.
Every IDM is identified with two IDs, one is the host ID and another is
the resource ID. The resource ID is a unique identifier for what the
resource it's protected, in the integration with lvmlockd, the resource
ID is combined with VG's UUID and LV's UUID; for the global locking,
the bytes in resource ID are all zeros, and for the VG locking, the
LV's UUID is set as zero. Every host can generate a random UUID and
use it as the host ID for the SCSI command, this ID is used to clarify
the ownership for mutex.
For easily invoking the IDM commands to drive, like other locking
scheme (e.g. sanlock), a daemon program named IDM lock manager is
created, so the detailed IDM SCSI commands are encapsulated in the
daemon, and lvmlockd uses the wrapper APIs to communicate with the
daemon program.
This patch introduces the IDM locking wrapper layer, it forwards the
locking requests from lvmlockd to the IDM lock manager, and returns the
result from drives' responding.
One thing should be mentioned is the IDM's LVB. IDM supports LVB to max
7 bytes when stores into the drive, the most significant byte of 8 bytes
is reserved for control bits. For this reason, the patch maps the
timestamp in macrosecond unit with its cached LVB, essentially, if any
timestamp was updated by other nodes, that means the local LVB is
invalidate. When the timestamp is stored into drive's LVB, it's
possbile to cause time-going-backwards issue, which is introduced by the
time precision or missing synchronization acrossing over multiple nodes.
So the IDM wrapper fixes up the timestamp by increment 1 to the latest
value and write back into drive.
Currently LVB is used to track VG changes and its purpose is to notify
lvmetad cache invalidation when detects any metadata has been altered;
but lvmetad is not used anymore for caching metadata, LVB doesn't
really work. It's possible that the LVB functionality could be useful
again in the future, so let's enable it for IDM in the first place.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
2021-05-07 05:25:12 +03:00
i f e q ( "@BUILD_LOCKDIDM@" , "yes" )
SOURCES += lvmlockd-idm.c
2023-02-17 01:28:08 +03:00
# LOCK_LIBS += $(LIBSEAGATEILM_LIBS) $(BLKID_LIBS)
LOCK_LIBS += -lseagate_ilm $( BLKID_LIBS)
lvmlockd: idm: Introduce new locking scheme
Alongside the existed locking schemes of DLM and sanlock, this patch is
to introduce new locking scheme: In-Drive-Mutex (IDM).
With the IDM support in the drive, the locks are resident in the drive,
thus, the locking lease is maintained in a central place: the drive
firmware. We can consider this is a typical client-server model,
every host (or node) in the server cluster launches the request for
leasing mutex to a drive firmware, the drive firmware works as an
arbitrator to grant the mutex to a requester and it can reject other
applicants if the mutex has been acquired. To satisfy the LVM
activation for different modes, IDM supports two locking modes:
exclusive and shareable.
Every IDM is identified with two IDs, one is the host ID and another is
the resource ID. The resource ID is a unique identifier for what the
resource it's protected, in the integration with lvmlockd, the resource
ID is combined with VG's UUID and LV's UUID; for the global locking,
the bytes in resource ID are all zeros, and for the VG locking, the
LV's UUID is set as zero. Every host can generate a random UUID and
use it as the host ID for the SCSI command, this ID is used to clarify
the ownership for mutex.
For easily invoking the IDM commands to drive, like other locking
scheme (e.g. sanlock), a daemon program named IDM lock manager is
created, so the detailed IDM SCSI commands are encapsulated in the
daemon, and lvmlockd uses the wrapper APIs to communicate with the
daemon program.
This patch introduces the IDM locking wrapper layer, it forwards the
locking requests from lvmlockd to the IDM lock manager, and returns the
result from drives' responding.
One thing should be mentioned is the IDM's LVB. IDM supports LVB to max
7 bytes when stores into the drive, the most significant byte of 8 bytes
is reserved for control bits. For this reason, the patch maps the
timestamp in macrosecond unit with its cached LVB, essentially, if any
timestamp was updated by other nodes, that means the local LVB is
invalidate. When the timestamp is stored into drive's LVB, it's
possbile to cause time-going-backwards issue, which is introduced by the
time precision or missing synchronization acrossing over multiple nodes.
So the IDM wrapper fixes up the timestamp by increment 1 to the latest
value and write back into drive.
Currently LVB is used to track VG changes and its purpose is to notify
lvmetad cache invalidation when detects any metadata has been altered;
but lvmetad is not used anymore for caching metadata, LVB doesn't
really work. It's possible that the LVB functionality could be useful
again in the future, so let's enable it for IDM in the first place.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
2021-05-07 05:25:12 +03:00
e n d i f
2021-03-20 01:10:55 +03:00
CFLOW_SOURCES = $( addprefix $( srcdir) /, $( SOURCES) )
CFLOW_TARGET = lvmlockd
2021-04-08 20:44:53 +03:00
.PHONY : install_lvmlockd install_lvmlockctl
2015-03-05 23:00:44 +03:00
2019-09-16 19:42:23 +03:00
CFLAGS += $( EXTRA_EXEC_CFLAGS)
2015-03-05 23:00:44 +03:00
INCLUDES += -I$( top_srcdir) /libdaemon/server
2019-09-16 19:42:23 +03:00
LDFLAGS += -L$( top_builddir) /libdaemon/server $( EXTRA_EXEC_LDFLAGS) $( ELDFLAGS)
2021-04-08 20:44:53 +03:00
LIBS += $( DAEMON_LIBS) $( PTHREAD_LIBS)
2019-09-16 19:42:23 +03:00
2023-02-17 01:34:25 +03:00
i f n e q ( , $( firstword $ ( LIBSYSTEMD_LIBS ) ) )
CFLAGS += $( LIBSYSTEMD_CFLAGS) -DUSE_SD_NOTIFY
LIBS += $( LIBSYSTEMD_LIBS)
2019-09-16 19:42:23 +03:00
e n d i f
2021-04-08 20:44:53 +03:00
lvmlockd : $( OBJECTS ) $( top_builddir ) /libdaemon /server /libdaemonserver .a $( INTERNAL_LIBS )
2018-11-29 19:09:27 +03:00
@echo " [CC] $@ "
2021-04-08 20:44:53 +03:00
$( Q) $( CC) $( CFLAGS) $( LDFLAGS) -o $@ $+ $( LOCK_LIBS) $( LIBS)
2015-03-05 23:00:44 +03:00
2021-04-08 20:44:53 +03:00
lvmlockctl : lvmlockctl .o $( INTERNAL_LIBS )
2018-11-29 19:09:27 +03:00
@echo " [CC] $@ "
2021-04-08 20:44:53 +03:00
$( Q) $( CC) $( CFLAGS) $( LDFLAGS) -o $@ $+ $( LIBS)
2015-03-05 23:00:44 +03:00
install_lvmlockd : lvmlockd
2018-11-29 19:09:27 +03:00
@echo " [INSTALL] $< "
$( Q) $( INSTALL_PROGRAM) -D $< $( sbindir) /$( <F)
2015-03-05 23:00:44 +03:00
install_lvmlockctl : lvmlockctl
2018-11-29 19:09:27 +03:00
@echo " [INSTALL] $< "
$( Q) $( INSTALL_PROGRAM) -D $< $( sbindir) /$( <F)
2015-03-05 23:00:44 +03:00
install_lvm2 : install_lvmlockd install_lvmlockctl
install : install_lvm 2