[prev in list] [next in list] [prev in thread] [next in thread]
List: sanlock-devel
Subject: Re: sanlk-resetd lockspace registeration managment
From: David Teigland <teigland () redhat ! com>
Date: 2014-08-11 16:21:03
Message-ID: 20140811162103.GD12913 () redhat ! com
[Download RAW message or body]
On Sun, Aug 10, 2014 at 03:16:03PM -0400, Nir Soffer wrote:
> When unregistering lockspace (end xxxxx), the code assume that there is only
> one lockspace with that name, possibly leaving duplicates unwanted listeners.
> This assumption is ok, if the registration code did enforce this though.
ok
> I think that a new command, "clear", unregistering all lockspaces will
> solve this issue. vdsm will clear the listeners each time it connects to
> storage and maybe when going into maintenance mode.
You could also just restart sanlk-resetd.
Here's an untested patch that will re-register (end+reg) if the ls name
exists, and uses the command "sanlk-reset clear all" to unregister all ls
names that currently exist.
diff --git a/reset/sanlk_reset.c b/reset/sanlk_reset.c
index ddd7af20da1c..a69d1e35c2d0 100644
--- a/reset/sanlk_reset.c
+++ b/reset/sanlk_reset.c
@@ -463,6 +463,9 @@ static void usage(void)
printf("Update the local sanlk-resetd to not watch lockspaces for reset events:\n");
printf("%s end lockspace_name ...\n", prog_name);
printf("\n");
+ printf("Update the local sanlk-resetd to clear all lockspaces being watched:\n");
+ printf("%s clear all\n", prog_name);
+ printf("\n");
printf("Reset another host through a lockspace it is watching:\n");
printf("%s reset lockspace_name:host_id ...\n", prog_name);
printf(" --host-id | -i <num>\n");
@@ -562,7 +565,7 @@ int main(int argc, char *argv[])
* Update local sanlk-resetd.
*/
- if (!strcmp(cmd, "reg") || !strcmp(cmd, "end")) {
+ if (!strcmp(cmd, "reg") || !strcmp(cmd, "end") || !strcmp(cmd, "clear")) {
return update_local_daemon(cmd);
}
diff --git a/reset/sanlk_resetd.c b/reset/sanlk_resetd.c
index 0c0c0f8a53e0..538d3e232b12 100644
--- a/reset/sanlk_resetd.c
+++ b/reset/sanlk_resetd.c
@@ -251,6 +251,21 @@ static void set_event_out(char *ls_name, uint64_t event_out, uint64_t from_host,
log_error("set_event error %d ls %s", rv, ls_name);
}
+static int find_ls(char *name)
+{
+ int i;
+
+ for (i = 0; i < MAX_LS; i++) {
+ if (!ls_names[i])
+ continue;
+
+ if (!strcmp(name, ls_names[i]))
+ return i;
+ }
+
+ return -1;
+}
+
static int register_ls(int i)
{
int fd;
@@ -458,7 +473,7 @@ static void process_update(int fd)
return;
}
- buf[UPDATE_SIZE] = '\0';
+ buf[UPDATE_SIZE-1] = '\0';
rv = sscanf(buf, "%s %s", cmd, name);
if (rv != 2) {
@@ -469,6 +484,15 @@ static void process_update(int fd)
if (!strcmp(cmd, "reg")) {
log_debug("process_update reg %s", name);
+ /* if the name exists, end then reg */
+ i = find_ls(name);
+ if (i > -1) {
+ unregister_ls(i);
+ ls_names[i] = strdup(name);
+ register_ls(i);
+ return;
+ }
+
for (i = 0; i < MAX_LS; i++) {
if (ls_names[i])
continue;
@@ -487,6 +511,15 @@ static void process_update(int fd)
unregister_ls(i);
return;
}
+ } else if (!strcmp(cmd, "clear")) {
+ log_debug("process_update clear %s", name);
+
+ for (i = 0; i < MAX_LS; i++) {
+ if (!ls_names[i])
+ continue;
+ unregister_ls(i);
+ return;
+ }
} else {
log_debug("process_update cmd unknown");
}
_______________________________________________
sanlock-devel mailing list
sanlock-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sanlock-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic