This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
commit dbf6e4dd64d1b2d518ea9241d8921dec0464b60d Author: Claudio Fontana cfontana@suse.de AuthorDate: Fri Mar 13 12:29:02 2026 -0500
sanlock: add SANLK_REL_NO_DISK
this flag skips the on-disk portion of the release.
it is useful when the lease storage is removed by the lease holder prior to releasing the lease.
add -d 1 to allow this flag to be used with client spawn.
Signed-off-by: Claudio Fontana cfontana@suse.de --- src/cmd.c | 6 +++++- src/main.c | 15 ++++++++++++--- src/resource.c | 2 +- src/resource.h | 3 +++ src/sanlock.8 | 4 +++- src/sanlock_internal.h | 1 + src/sanlock_resource.h | 8 ++++++++ 7 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/cmd.c b/src/cmd.c index a483451..149d413 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -748,7 +748,11 @@ static void cmd_release(struct task *task, struct cmd_args *ca, uint32_t cmd)
for (i = 0; i < rem_tokens_count; i++) { token = rem_tokens[i]; - rv = release_token(task, token, resrename); + if (ca->header.cmd_flags & SANLK_REL_NO_DISK) { + rv = release_token_nodisk(task, token); + } else { + rv = release_token(task, token, resrename); + } if (rv < 0) result = rv; free_token(token); diff --git a/src/main.c b/src/main.c index d6f6fba..3bea4e8 100644 --- a/src/main.c +++ b/src/main.c @@ -2325,7 +2325,7 @@ static void print_usage(void) printf("sanlock client inq_lockspace -s LOCKSPACE\n"); printf("sanlock client rem_lockspace -s LOCKSPACE\n"); printf("sanlock client command -r RESOURCE [-h 0|1] -c <path> <args>\n"); - printf("sanlock client spawn -r RESOURCE [-h 0|1] [-O 0|1] [-P 0|1] -c COUNT CMD [ARG...] [-c COUNT CMD [ARG...]]\n"); + printf("sanlock client spawn -r RESOURCE [-h 0|1] [-O 0|1] [-P 0|1] [-d 0|1] -c COUNT CMD [ARG...] [-c COUNT CMD [ARG...]]\n"); printf("sanlock client acquire -r RESOURCE -p|-C <id>\n"); printf("sanlock client convert -r RESOURCE -p|-C <id>\n"); printf("sanlock client release -r RESOURCE -p|-C <id>\n"); @@ -2727,7 +2727,11 @@ static int read_command_line(int argc, char *argv[]) com.compare_and_write_opt0 = 1; break; case 'd': - com.he_data = strtoull(optionarg, NULL, 0); + if (com.action == ACT_SET_EVENT) { + com.he_data = strtoull(optionarg, NULL, 0); + } else { + com.no_disk = atoi(optionarg); + } break; case 'e': if (com.rindex_op) { @@ -3748,7 +3752,11 @@ static int do_spawn(void) * relies on POLLHUP as an asynchronous method to release the lease. */ log_tool("release"); - rv = sanlock_release(fd, -1, SANLK_REL_ALL, 0, NULL); + flags = SANLK_REL_ALL; + if (exit_code == 0) { + flags |= com.no_disk ? SANLK_REL_NO_DISK : 0; + } + rv = sanlock_release(fd, -1, flags, 0, NULL); log_tool("release done %d", rv); close(fd); if (rv < 0) { @@ -3951,6 +3959,7 @@ static int do_client(void) } flags |= com.orphan ? SANLK_REL_ORPHAN : 0; flags |= com.all ? SANLK_REL_ALL: 0; + flags |= com.no_disk ? SANLK_REL_NO_DISK : 0; rv = sanlock_release(-1, id, flags, com.res_count, com.res_args); log_tool("release done %d", rv); break; diff --git a/src/resource.c b/src/resource.c index f567c90..c255df2 100644 --- a/src/resource.c +++ b/src/resource.c @@ -1451,7 +1451,7 @@ static int release_token_nodisk_opened(struct task *task, struct token *token) return _release_token(task, token, NULL, 1, 1); }
-static int release_token_nodisk(struct task *task, struct token *token) +int release_token_nodisk(struct task *task, struct token *token) { return _release_token(task, token, NULL, 0, 1); } diff --git a/src/resource.h b/src/resource.h index b7802e1..5db54a1 100644 --- a/src/resource.h +++ b/src/resource.h @@ -39,6 +39,9 @@ int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags, int release_token(struct task *task, struct token *token, struct sanlk_resource *resrename);
+/* locks resource_mutex */ +int release_token_nodisk(struct task *task, struct token *token); + /* locks resource_mutex */ void release_token_async(struct token *token);
diff --git a/src/sanlock.8 b/src/sanlock.8 index 367f040..95d2a6d 100644 --- a/src/sanlock.8 +++ b/src/sanlock.8 @@ -207,7 +207,9 @@ After all processes are successfully executed, or at the first failure, the lease is released explicitly before exiting. Use -P 1 for persistent locks that will not be dropped if the spawn process dies while a child process is running. Use -h 1 to report a conflicting lock owner. Use -O 1 -to acquire an orphan lock. +to acquire an orphan lock. Use -d 1 to skip the on-disk resource lease +update when releasing the resource lease after all commands complete +successfully (useful when the commands have removed the lease storage.)
.BR "sanlock client acquire -r" " RESOURCE " \ \fB-p\fP " " \fIpid\fP diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h index 5ec3346..99f7250 100644 --- a/src/sanlock_internal.h +++ b/src/sanlock_internal.h @@ -494,6 +494,7 @@ struct command_line { struct sanlk_resource *res_args[SANLK_MAX_RESOURCES]; /* -r RESOURCE */ struct spawn_cmd *spawn_args; /* -c COUNT CMD [ARG...], for ACT_SPAWN */ int spawn_count; + int no_disk; };
EXTERN struct command_line com; diff --git a/src/sanlock_resource.h b/src/sanlock_resource.h index 7f0f6b7..b5ce78b 100644 --- a/src/sanlock_resource.h +++ b/src/sanlock_resource.h @@ -85,11 +85,19 @@ * If the resource name is set, then an * orphan with the matching resource name is * released. + * + * SANLK_REL_NO_DISK + * Skip the on-disk portion of release. + * + * Introduced to be able to remove the + * resource file or disk itself while holding + * the lease, to avoid ENOENT on release. */
#define SANLK_REL_ALL 0x00000001 #define SANLK_REL_RENAME 0x00000002 #define SANLK_REL_ORPHAN 0x00000004 +#define SANLK_REL_NO_DISK 0x00000008 /* SANLK_FOR_CLIENT_ID 0x00000010 defined above */
/*
sanlock-devel@lists.fedorahosted.org