[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/xenstore: rename do_tdb_delete() and change parameter type
commit 549c4238b939fd303e51b1005b03ec0767b4b174 Author: Juergen Gross <jgross@xxxxxxxx> AuthorDate: Mon Jul 24 13:02:26 2023 +0200 Commit: Julien Grall <julien@xxxxxxx> CommitDate: Thu Jul 27 22:02:02 2023 +0100 tools/xenstore: rename do_tdb_delete() and change parameter type Rename do_tdb_delete() to db_delete() and replace the key parameter with db_name specifying the name of the node in the data base. This is in preparation to replace TDB with a more simple data storage. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx> --- tools/xenstore/xenstored_core.c | 31 ++++++++++++++----------------- tools/xenstore/xenstored_core.h | 5 +++-- tools/xenstore/xenstored_transaction.c | 16 ++++++---------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 474bc57e73..aa3885682d 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -658,28 +658,31 @@ int do_tdb_write(struct connection *conn, TDB_DATA *key, TDB_DATA *data, return 0; } -int do_tdb_delete(struct connection *conn, TDB_DATA *key, - struct node_account_data *acc) +int db_delete(struct connection *conn, const char *name, + struct node_account_data *acc) { struct node_account_data tmp_acc; unsigned int domid; + TDB_DATA key; + + set_tdb_key(name, &key); if (!acc) { acc = &tmp_acc; acc->memory = -1; } - get_acc_data(key, acc); + get_acc_data(&key, acc); - if (tdb_delete(tdb_ctx, *key)) { + if (tdb_delete(tdb_ctx, key)) { errno = EIO; return errno; } - trace_tdb("delete %s\n", key->dptr); + trace_tdb("delete %s\n", name); if (acc->memory) { - domid = get_acc_domid(conn, key, acc->domid); - domain_memory_add_nochk(conn, domid, -acc->memory - key->dsize); + domid = get_acc_domid(conn, &key, acc->domid); + domain_memory_add_nochk(conn, domid, -acc->memory - key.dsize); } return 0; @@ -1454,13 +1457,10 @@ nomem: static void destroy_node_rm(struct connection *conn, struct node *node) { - TDB_DATA key; - if (streq(node->name, "/")) corrupt(NULL, "Destroying root node!"); - set_tdb_key(node->db_name, &key); - do_tdb_delete(conn, &key, &node->acc); + db_delete(conn, node->db_name, &node->acc); } static int destroy_node(struct connection *conn, struct node *node) @@ -1651,7 +1651,6 @@ static int delnode_sub(const void *ctx, struct connection *conn, bool watch_exact; int ret; const char *db_name; - TDB_DATA key; /* Any error here will probably be repeated for all following calls. */ ret = access_node(conn, node, NODE_ACCESS_DELETE, &db_name); @@ -1662,8 +1661,7 @@ static int delnode_sub(const void *ctx, struct connection *conn, return WALK_TREE_ERROR_STOP; /* In case of error stop the walk. */ - set_tdb_key(db_name, &key); - if (!ret && do_tdb_delete(conn, &key, &node->acc)) + if (!ret && db_delete(conn, db_name, &node->acc)) return WALK_TREE_ERROR_STOP; /* @@ -2489,9 +2487,8 @@ static int clean_store_(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA val, } if (!hashtable_search(reachable, name)) { log("clean_store: '%s' is orphaned!", name); - if (recovery) { - do_tdb_delete(NULL, &key, NULL); - } + if (recovery) + db_delete(NULL, name, NULL); } talloc_free(name); diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index ec7a56a869..1aae324c77 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -362,12 +362,13 @@ extern xengnttab_handle **xgt_handle; int remember_string(struct hashtable *hash, const char *str); +/* Data base access functions. */ void set_tdb_key(const char *name, TDB_DATA *key); int do_tdb_write(struct connection *conn, TDB_DATA *key, TDB_DATA *data, struct node_account_data *acc, enum write_node_mode mode, bool no_quota_check); -int do_tdb_delete(struct connection *conn, TDB_DATA *key, - struct node_account_data *acc); +int db_delete(struct connection *conn, const char *name, + struct node_account_data *acc); void conn_free_buffered_data(struct connection *conn); diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c index 36567db753..4a243369b0 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -384,8 +384,7 @@ static int finalize_transaction(struct connection *conn, /* Entries for unmodified nodes can be removed early. */ if (!i->modified) { if (i->ta_node) { - set_tdb_key(i->trans_name, &ta_key); - if (do_tdb_delete(conn, &ta_key, NULL)) + if (db_delete(conn, i->trans_name, NULL)) return EIO; } list_del(&i->list); @@ -394,7 +393,6 @@ static int finalize_transaction(struct connection *conn, } while ((i = list_top(&trans->accessed, struct accessed_node, list))) { - set_tdb_key(i->node, &key); if (i->ta_node) { set_tdb_key(i->trans_name, &ta_key); data = tdb_fetch(tdb_ctx, ta_key); @@ -407,10 +405,11 @@ static int finalize_transaction(struct connection *conn, hdr->generation = ++generation; mode = (i->generation == NO_GENERATION) ? NODE_CREATE : NODE_MODIFY; + set_tdb_key(i->node, &key); *is_corrupt |= do_tdb_write(conn, &key, &data, NULL, mode, true); talloc_free(data.dptr); - if (do_tdb_delete(conn, &ta_key, NULL)) + if (db_delete(conn, i->trans_name, NULL)) *is_corrupt = true; } else { *is_corrupt = true; @@ -423,7 +422,7 @@ static int finalize_transaction(struct connection *conn, */ *is_corrupt |= (i->generation == NO_GENERATION) ? false - : do_tdb_delete(conn, &key, NULL); + : db_delete(conn, i->node, NULL); } if (i->fire_watch) fire_watches(conn, trans, i->node, NULL, i->watch_exact, @@ -440,15 +439,12 @@ static int destroy_transaction(void *_transaction) { struct transaction *trans = _transaction; struct accessed_node *i; - TDB_DATA key; wrl_ntransactions--; trace_destroy(trans, "transaction"); while ((i = list_top(&trans->accessed, struct accessed_node, list))) { - if (i->ta_node) { - set_tdb_key(i->trans_name, &key); - do_tdb_delete(trans->conn, &key, NULL); - } + if (i->ta_node) + db_delete(trans->conn, i->trans_name, NULL); list_del(&i->list); talloc_free(i); } -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |