From 1eb2404c5988fde0336082f24de7eb075804be2f Mon Sep 17 00:00:00 2001 From: jinzhiguang Date: Thu, 6 Jun 2024 14:30:10 +0800 Subject: [PATCH] lvmlockd: use 4K sector size when any dev is 4K Signed-off-by: jinzhiguang --- ...se-4k-sector-size-when-any-dev-is-4k.patch | 49 +++++++++++++++++++ lvm2.spec | 6 ++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 0029-use-4k-sector-size-when-any-dev-is-4k.patch diff --git a/0029-use-4k-sector-size-when-any-dev-is-4k.patch b/0029-use-4k-sector-size-when-any-dev-is-4k.patch new file mode 100644 index 0000000..65e5782 --- /dev/null +++ b/0029-use-4k-sector-size-when-any-dev-is-4k.patch @@ -0,0 +1,49 @@ +From 2d1fe38d84d499011d13ae1ea11535398528fc87 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Mon, 11 May 2020 13:08:39 -0500 +Subject: [PATCH] lvmlockd: use 4K sector size when any dev is 4K + +When either logical block size or physical block size is 4K, +then lvmlockd creates sanlock leases based on 4K sectors, +but the lvm client side would create the internal lvmlock LV +based on the first logical block size it saw in the VG, +which could be 512. This could cause the lvmlock LV to be +too small to hold all the sanlock leases. Make the lvm client +side use the same sizing logic as lvmlockd. +--- + lib/locking/lvmlockd.c | 14 ++++---------- + 1 file changed, 4 insertions(+), 10 deletions(-) + +diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c +index e378fe6cba..dca7954abf 100644 +--- a/lib/locking/lvmlockd.c ++++ b/lib/locking/lvmlockd.c +@@ -635,7 +635,6 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in + const char *vg_lock_args = NULL; + const char *opts = NULL; + struct pv_list *pvl; +- struct device *sector_dev; + uint32_t sector_size = 0; + unsigned int physical_block_size, logical_block_size; + int num_mb = 0; +@@ -656,16 +655,11 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in + dm_list_iterate_items(pvl, &vg->pvs) { + if (!dev_get_direct_block_sizes(pvl->pv->dev, &physical_block_size, &logical_block_size)) + continue; +- +- if (!sector_size) { +- sector_size = logical_block_size; +- sector_dev = pvl->pv->dev; +- } else if (sector_size != logical_block_size) { +- log_error("Inconsistent logical block sizes for %s and %s.", +- dev_name(pvl->pv->dev), dev_name(sector_dev)); +- return 0; +- } ++ if ((physical_block_size == 4096) || (logical_block_size == 4096)) ++ sector_size = 4096; + } ++ if (!sector_size) ++ sector_size = 512; + + log_debug("Using sector size %u for sanlock LV", sector_size); + diff --git a/lvm2.spec b/lvm2.spec index ae2de20..af90e5a 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.09 -Release: 18 +Release: 19 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -77,6 +77,7 @@ patch25: 0025-toollib-fix-segfault-if-using-S-select-with-log-repo.patch Patch26: 0026-dm-event-release-buffer-on-dm_event_get_version.patch patch27: 0027-clean-up-group-struct-in-_stats_create_group-error-path.patch Patch28: 0028-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch +Patch29: 0029-use-4k-sector-size-when-any-dev-is-4k.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -502,6 +503,9 @@ fi %changelog +* Thu Jun 06 2024 jinzhiguang - 8:2.03.09-19 +- lvmlockd: use 4K sector size when any dev is 4K + * Thu Feb 22 2024 wangzhiqiang - 8:2.03.09-18 - vgchange: acquire an exclusive VG lock for refresh -- Gitee