summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2022-02-08 09:35:17 +1100
committerMartin Schwenke <martins@samba.org>2022-07-28 10:09:34 +0000
commit2ecdbcb22c69a94576c054761053971774c52099 (patch)
tree5788f2b63b55591269621c8c4f12549613fa6ee7 /ctdb
parent7ab2e8f127859a436ceb24e7c0a5653ae79b2de5 (diff)
downloadsamba-2ecdbcb22c69a94576c054761053971774c52099.tar.gz
ctdb-mutex: Rename wait_for_lost to lock_io_check
This will be generalised to do more I/O-based checks. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_mutex_fcntl_helper.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/ctdb/server/ctdb_mutex_fcntl_helper.c b/ctdb/server/ctdb_mutex_fcntl_helper.c
index c8ed1b62c42..223fa258ec5 100644
--- a/ctdb/server/ctdb_mutex_fcntl_helper.c
+++ b/ctdb/server/ctdb_mutex_fcntl_helper.c
@@ -159,30 +159,30 @@ static bool wait_for_parent_recv(struct tevent_req *req, int *perr)
}
/*
- * Wait and check for lost lock - file removed or replaced
+ * Perform I/O on lock in a loop - complete when file removed or replaced
*/
-struct wait_for_lost_state {
+struct lock_io_check_state {
struct tevent_context *ev;
const char *lock_file;
ino_t inode;
unsigned long recheck_interval;
};
-static void wait_for_lost_check(struct tevent_req *subreq);
+static void lock_io_check_loop(struct tevent_req *subreq);
-static struct tevent_req *wait_for_lost_send(TALLOC_CTX *mem_ctx,
+static struct tevent_req *lock_io_check_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *lock_file,
int fd,
unsigned long recheck_interval)
{
struct tevent_req *req, *subreq;
- struct wait_for_lost_state *state;
+ struct lock_io_check_state *state;
struct stat sb;
int ret;
- req = tevent_req_create(mem_ctx, &state, struct wait_for_lost_state);
+ req = tevent_req_create(mem_ctx, &state, struct lock_io_check_state);
if (req == NULL) {
return NULL;
}
@@ -211,17 +211,17 @@ static struct tevent_req *wait_for_lost_send(TALLOC_CTX *mem_ctx,
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
- tevent_req_set_callback(subreq, wait_for_lost_check, req);
+ tevent_req_set_callback(subreq, lock_io_check_loop, req);
return req;
}
-static void wait_for_lost_check(struct tevent_req *subreq)
+static void lock_io_check_loop(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
- struct wait_for_lost_state *state = tevent_req_data(
- req, struct wait_for_lost_state);
+ struct lock_io_check_state *state = tevent_req_data(
+ req, struct lock_io_check_state);
bool status;
struct stat sb;
int ret;
@@ -261,10 +261,10 @@ static void wait_for_lost_check(struct tevent_req *subreq)
if (tevent_req_nomem(subreq, req)) {
return;
}
- tevent_req_set_callback(subreq, wait_for_lost_check, req);
+ tevent_req_set_callback(subreq, lock_io_check_loop, req);
}
-static bool wait_for_lost_recv(struct tevent_req *req, int *perr)
+static bool lock_io_check_recv(struct tevent_req *req, int *perr)
{
if (tevent_req_is_unix_error(req, perr)) {
return false;
@@ -274,14 +274,15 @@ static bool wait_for_lost_recv(struct tevent_req *req, int *perr)
}
/*
- * Wait for a reason to exit, indicating that the lock is lost
+ * Wait for a reason to exit, indicating that parent has exited or I/O
+ * on lock failed
*/
struct wait_for_exit_state {
};
static void wait_for_exit_parent_done(struct tevent_req *subreq);
-static void wait_for_exit_lost_done(struct tevent_req *subreq);
+static void wait_for_exit_io_check_done(struct tevent_req *subreq);
static struct tevent_req *wait_for_exit_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -305,7 +306,7 @@ static struct tevent_req *wait_for_exit_send(TALLOC_CTX *mem_ctx,
tevent_req_set_callback(subreq, wait_for_exit_parent_done, req);
if (recheck_interval > 0) {
- subreq = wait_for_lost_send(state,
+ subreq = lock_io_check_send(state,
ev,
lock_file,
fd,
@@ -313,7 +314,9 @@ static struct tevent_req *wait_for_exit_send(TALLOC_CTX *mem_ctx,
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
- tevent_req_set_callback(subreq, wait_for_exit_lost_done, req);
+ tevent_req_set_callback(subreq,
+ wait_for_exit_io_check_done,
+ req);
}
return req;
@@ -340,14 +343,14 @@ static void wait_for_exit_parent_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-static void wait_for_exit_lost_done(struct tevent_req *subreq)
+static void wait_for_exit_io_check_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
bool status;
int err;
- status = wait_for_lost_recv(subreq, &err);
+ status = lock_io_check_recv(subreq, &err);
TALLOC_FREE(subreq);
if (! status) {
/* Ignore error */