This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new b3d680e sanlock: delta_read_lockspace_sizes with specific host_id
b3d680e is described below
commit b3d680e13f0fc0481534016f2ce84203decbcaa1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 18 13:15:35 2025 -0500
sanlock: delta_read_lockspace_sizes with specific host_id
If delta_read_lockspace_sizes() is given a specific host_id,
then only read the delta lease from that host_id sector.
This isolates the effects of a different host_id lease that
is corrupted.
In delta_read_lockspace(), require a specific sector size.
---
src/cmd.c | 6 ++----
src/delta_lease.c | 52 +++++++++++++++++++++++++++++++++++-----------------
src/delta_lease.h | 4 ++--
src/lockspace.c | 8 +++++---
src/lockspace.h | 2 +-
5 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/src/cmd.c b/src/cmd.c
index ef794c2..d0648bb 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1627,8 +1627,7 @@ static void cmd_read_lockspace(struct task *task, struct cmd_args *ca, uint32_t
align_size = sanlk_lsf_align_flag_to_size(lockspace.flags);
if (!sector_size) {
- /* reads the first leader record to get sector size */
- result = delta_read_lockspace_sizes(task, &sd, com.io_timeout, §or_size, &align_size);
+ result = delta_read_lockspace_sizes(task, &sd, host_id, com.io_timeout, §or_size, &align_size);
if (result < 0)
goto out_close;
if ((sector_size != 512) && (sector_size != 4096)) {
@@ -1637,8 +1636,7 @@ static void cmd_read_lockspace(struct task *task, struct cmd_args *ca, uint32_t
}
}
- result = delta_read_lockspace(task, &sd, sector_size, align_size, host_id, &lockspace,
- com.io_timeout, &host);
+ result = delta_read_lockspace(task, &sd, sector_size, host_id, &lockspace, com.io_timeout, &host);
if (result == SANLK_OK)
result = 0;
diff --git a/src/delta_lease.c b/src/delta_lease.c
index cc93f27..9e98d3b 100644
--- a/src/delta_lease.c
+++ b/src/delta_lease.c
@@ -144,13 +144,9 @@ static int verify_leader(struct sync_disk *disk,
return result;
}
-
-/* read the lockspace name and io_timeout given the disk location */
-
int delta_read_lockspace(struct task *task,
struct sync_disk *disk,
- int sector_size_hint,
- int align_size_hint,
+ int sector_size,
uint64_t host_id,
struct sanlk_lockspace *ls,
int io_timeout,
@@ -167,12 +163,7 @@ int delta_read_lockspace(struct task *task,
memset(&leader_end, 0, sizeof(struct leader_record));
- /*
- * All we need to read is the leader_record which is returned whether
- * or not the sector_size_hint is wrong or not.
- */
-
- rv = read_sectors(disk, sector_size_hint, host_id - 1, 1, (char *)&leader_end, sizeof(struct leader_record),
+ rv = read_sectors(disk, sector_size, host_id - 1, 1, (char *)&leader_end, sizeof(struct leader_record),
task, io_timeout, "read_lockspace");
if (rv < 0)
return rv;
@@ -217,6 +208,7 @@ int delta_read_lockspace(struct task *task,
int delta_read_lockspace_sizes(struct task *task,
struct sync_disk *disk,
+ uint64_t host_id,
int io_timeout,
int *sector_size,
int *align_size)
@@ -227,13 +219,36 @@ int delta_read_lockspace_sizes(struct task *task,
memset(&leader_end, 0, sizeof(struct leader_record));
- /*
- * read the first 4k, which either includes one 4k delta lease or 8 512b
- * delta leases. In either case, we only look at the initial leader
- * record to get to the sector size.
- */
+ /* With no host_id, get sizes from any leader record. */
+ if (!host_id)
+ host_id = 1;
+
+ rv = read_sectors(disk, 512, host_id - 1, 1, (char *)&leader_end, sizeof(struct leader_record),
+ task, io_timeout, "read_lockspace_sector_size");
+ if (rv < 0)
+ goto next;
+
+ leader_record_in(&leader_end, &leader);
- rv = read_sectors(disk, 4096, 0, 1, (char *)&leader_end, sizeof(struct leader_record),
+ if (leader.magic != DELTA_DISK_MAGIC)
+ goto next;
+
+ if ((leader.version & 0xFFFF0000) != DELTA_DISK_VERSION_MAJOR)
+ goto next;
+
+ if (leader.sector_size != 512)
+ goto next;
+
+ *sector_size = leader.sector_size;
+
+ *align_size = leader_align_size_from_flag(leader.flags);
+ if (!*align_size)
+ *align_size = sector_size_to_align_size_old(leader.sector_size);
+
+ return SANLK_OK;
+
+ next:
+ rv = read_sectors(disk, 4096, host_id - 1, 1, (char *)&leader_end, sizeof(struct leader_record),
task, io_timeout, "read_lockspace_sector_size");
if (rv < 0)
return rv;
@@ -246,6 +261,9 @@ int delta_read_lockspace_sizes(struct task *task,
if ((leader.version & 0xFFFF0000) != DELTA_DISK_VERSION_MAJOR)
return SANLK_LEADER_VERSION;
+ if (leader.sector_size != 4096)
+ return SANLK_LEADER_SECTORSIZE;
+
*sector_size = leader.sector_size;
*align_size = leader_align_size_from_flag(leader.flags);
diff --git a/src/delta_lease.h b/src/delta_lease.h
index c3030a4..dca228c 100644
--- a/src/delta_lease.h
+++ b/src/delta_lease.h
@@ -62,8 +62,7 @@ int delta_lease_init_host(struct task *task,
int delta_read_lockspace(struct task *task,
struct sync_disk *disk,
- int sector_size_hint,
- int align_size_hint,
+ int sector_size,
uint64_t host_id,
struct sanlk_lockspace *ls,
int io_timeout,
@@ -71,6 +70,7 @@ int delta_read_lockspace(struct task *task,
int delta_read_lockspace_sizes(struct task *task,
struct sync_disk *disk,
+ uint64_t host_id,
int io_timeout,
int *sector_size,
int *align_size);
diff --git a/src/lockspace.c b/src/lockspace.c
index 04043c6..9f37e73 100644
--- a/src/lockspace.c
+++ b/src/lockspace.c
@@ -897,16 +897,18 @@ static void *lockspace_thread(void *arg_in)
}
opened = 1;
- rv = delta_read_lockspace_sizes(&task, &sp->host_id_disk, sp->io_timeout, §or_size, &align_size);
+ rv = delta_read_lockspace_sizes(&task, &sp->host_id_disk, sp->host_id, sp->io_timeout, §or_size, &align_size);
if (rv < 0) {
- log_erros(sp, "failed to read device to find sector size error %d %s", rv, sp->host_id_disk.path);
+ log_erros(sp, "failed to read device to find sector size for host_id %llu error %d %s",
+ (unsigned long long)sp->host_id, rv, sp->host_id_disk.path);
acquire_result = rv;
delta_result = -1;
goto set_status;
}
if ((sector_size != 512) && (sector_size != 4096)) {
- log_erros(sp, "failed to get valid sector size %d %s", sector_size, sp->host_id_disk.path);
+ log_erros(sp, "failed to get valid sector size %d for host_id %llu %s",
+ sector_size, (unsigned long long)sp->host_id, sp->host_id_disk.path);
acquire_result = SANLK_LEADER_SECTORSIZE;
delta_result = -1;
goto set_status;
diff --git a/src/lockspace.h b/src/lockspace.h
index 3b41017..d29373d 100644
--- a/src/lockspace.h
+++ b/src/lockspace.h
@@ -7,7 +7,7 @@
*/
#ifndef __LOCKSPACE_H__
-#define __LOCKSPACE__H__
+#define __LOCKSPACE_H__
/* See resource.h for lock ordering between spaces_mutex and resource_mutex. */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.