summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-10-04 12:06:21 +1000
committerAmitay Isaacs <amitay@samba.org>2019-10-24 04:06:43 +0000
commit5539edfdbe69d1d5f084d06753cce8ed6e524999 (patch)
treeb5d131f6abfb8ebd731828c73f6fa070987f1ac5 /ctdb
parent496204feb0e2b6eb2f3d9a74e45596a3e74ad9b1 (diff)
downloadsamba-5539edfdbe69d1d5f084d06753cce8ed6e524999.tar.gz
ctdb-vacuum: Simplify recording of in-progress vacuuming child
There can only be one, so simplify the logic. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/include/ctdb_private.h2
-rw-r--r--ctdb/server/ctdb_vacuum.c20
2 files changed, 9 insertions, 13 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 69afef731ed..b42b32a3967 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -318,7 +318,7 @@ struct ctdb_context {
TALLOC_CTX *banning_ctx;
- struct ctdb_vacuum_child_context *vacuumers;
+ struct ctdb_vacuum_child_context *vacuumer;
/* mapping from pid to ctdb_client * */
struct ctdb_client_pid_list *client_pids;
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index 2512811b179..523dbbd5fec 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -48,7 +48,6 @@
enum vacuum_child_status { VACUUM_RUNNING, VACUUM_OK, VACUUM_ERROR, VACUUM_TIMEOUT};
struct ctdb_vacuum_child_context {
- struct ctdb_vacuum_child_context *next, *prev;
struct ctdb_vacuum_handle *vacuum_handle;
/* fd child writes status to */
int fd[2];
@@ -59,7 +58,6 @@ struct ctdb_vacuum_child_context {
struct ctdb_vacuum_handle {
struct ctdb_db_context *ctdb_db;
- struct ctdb_vacuum_child_context *child_ctx;
uint32_t fast_path_count;
};
@@ -1326,7 +1324,7 @@ static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx)
child_ctx->vacuum_handle->fast_path_count++;
}
- DLIST_REMOVE(ctdb->vacuumers, child_ctx);
+ ctdb->vacuumer = NULL;
tevent_add_timer(ctdb->ev, child_ctx->vacuum_handle,
timeval_current_ofs(get_vacuum_interval(ctdb_db), 0),
@@ -1408,7 +1406,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
* same time. If there is vacuuming child process active, delay
* new vacuuming event to stagger vacuuming events.
*/
- if (ctdb->vacuumers != NULL) {
+ if (ctdb->vacuumer != NULL) {
tevent_add_timer(ctdb->ev, vacuum_handle,
timeval_current_ofs(0, 500*1000),
ctdb_vacuum_event, vacuum_handle);
@@ -1476,7 +1474,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
child_ctx->status = VACUUM_RUNNING;
child_ctx->start_time = timeval_current();
- DLIST_ADD(ctdb->vacuumers, child_ctx);
+ ctdb->vacuumer = child_ctx;
talloc_set_destructor(child_ctx, vacuum_child_destructor);
/*
@@ -1507,19 +1505,17 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
TEVENT_FD_READ, vacuum_child_handler, child_ctx);
tevent_fd_set_auto_close(fde);
- vacuum_handle->child_ctx = child_ctx;
child_ctx->vacuum_handle = vacuum_handle;
}
void ctdb_stop_vacuuming(struct ctdb_context *ctdb)
{
- /* Simply free them all. */
- while (ctdb->vacuumers) {
- DEBUG(DEBUG_INFO, ("Aborting vacuuming for %s (%i)\n",
- ctdb->vacuumers->vacuum_handle->ctdb_db->db_name,
- (int)ctdb->vacuumers->child_pid));
+ if (ctdb->vacuumer != NULL) {
+ D_INFO("Aborting vacuuming for %s (%i)\n",
+ ctdb->vacuumer->vacuum_handle->ctdb_db->db_name,
+ (int)ctdb->vacuumer->child_pid);
/* vacuum_child_destructor kills it, removes from list */
- talloc_free(ctdb->vacuumers);
+ talloc_free(ctdb->vacuumer);
}
}