From nobody Tue Feb 10 02:49:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1690196605; cv=none; d=zohomail.com; s=zohoarc; b=m4BZ4qwcEb1I8Tjhzw5Vop4lYR6Rexa6jgVtun3T6PAMM8xmYnnbv4L5QLSeco0IZCh9JbFI8xqbuayh/x7Tgus68oX8rqNYcz59lhwj1L41YwyZ2GtZOTK4a0Y/j0z949TFwRVrnGudoXVK+pEkPaB2x3LuekK01KsaP5H5acg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690196605; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+f/2hssl9+9pqd2iopuWIXDOp4+T2afqdOEfLUF2eXs=; b=Xo5z8QoXFBVUAzzSZftPB3qUWdRx/CHQz+3xVn0GDltqtQpr6pILHZ7tC5rkwseMrcdGOVTll4fYYuyVV/U9DFny0bMA+3T/fRiDoqM77xGyLQbyrNgoRo7+C2rBNBJfTPg0JV1dZQN0U1yPdLIfjf0F++9Zu2iCDkqxpOSOnl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690196605583591.3302101311399; Mon, 24 Jul 2023 04:03:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.568731.888573 (Exim 4.92) (envelope-from ) id 1qNtLD-0000cz-Fr; Mon, 24 Jul 2023 11:03:03 +0000 Received: by outflank-mailman (output) from mailman id 568731.888573; Mon, 24 Jul 2023 11:03:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNtLD-0000cm-Bf; Mon, 24 Jul 2023 11:03:03 +0000 Received: by outflank-mailman (input) for mailman id 568731; Mon, 24 Jul 2023 11:03:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qNtLC-0000KR-Dn for xen-devel@lists.xenproject.org; Mon, 24 Jul 2023 11:03:02 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a7f7b8d4-2a11-11ee-b23a-6b7b168915f2; Mon, 24 Jul 2023 13:03:01 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7E64F20695; Mon, 24 Jul 2023 11:03:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 47ED013476; Mon, 24 Jul 2023 11:03:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id shAlEGVavmRCYQAAMHmgww (envelope-from ); Mon, 24 Jul 2023 11:03:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a7f7b8d4-2a11-11ee-b23a-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1690196581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+f/2hssl9+9pqd2iopuWIXDOp4+T2afqdOEfLUF2eXs=; b=aZejtC3pt47Q/KokoffOLlIiVzv9E9jbRDtmAQpCNjbn1+pHDrGUjVKSZVSOpTv8CUXkf1 TsFDcBIhZ/bkaIyBM44hOASLTSdqWSLiw9BN+PKw6+2sa7MN7gaC3+ojczYCqBKjc4t7/L t/nFy8Q7mYpX2abMiB6Es6YImsmN+YQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v3 02/25] tools/xenstore: replace key in struct node with data base name Date: Mon, 24 Jul 2023 13:02:24 +0200 Message-Id: <20230724110247.10520-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230724110247.10520-1-jgross@suse.com> References: <20230724110247.10520-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1690196607917100003 Content-Type: text/plain; charset="utf-8" Instead of storing the TDB key in struct node, only store the name of the node used to access it in the data base. Associated with that change replace the key parameter of access_node() with the equivalent db_name. This is in preparation to replace TDB with a more simple data storage. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- tools/xenstore/xenstored_core.c | 19 +++++++++++++------ tools/xenstore/xenstored_core.h | 4 ++-- tools/xenstore/xenstored_transaction.c | 10 +++++----- tools/xenstore/xenstored_transaction.h | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index b7fdf16718..ba4798dd6e 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -821,18 +821,20 @@ int write_node_raw(struct connection *conn, TDB_DATA = *key, struct node *node, } =20 /* - * Write the node. If the node is written, caller can find the key used in - * node->key. This can later be used if the change needs to be reverted. + * Write the node. If the node is written, caller can find the DB name use= d in + * node->db_name. This can later be used if the change needs to be reverte= d. */ static int write_node(struct connection *conn, struct node *node, enum write_node_mode mode, bool no_quota_check) { int ret; + TDB_DATA key; =20 - if (access_node(conn, node, NODE_ACCESS_WRITE, &node->key)) + if (access_node(conn, node, NODE_ACCESS_WRITE, &node->db_name)) return errno; =20 - ret =3D write_node_raw(conn, &node->key, node, mode, no_quota_check); + set_tdb_key(node->db_name, &key); + ret =3D write_node_raw(conn, &key, node, mode, no_quota_check); if (ret && conn && conn->transaction) { /* * Reverting access_node() is hard, so just fail the @@ -1450,10 +1452,13 @@ nomem: =20 static void destroy_node_rm(struct connection *conn, struct node *node) { + TDB_DATA key; + if (streq(node->name, "/")) corrupt(NULL, "Destroying root node!"); =20 - do_tdb_delete(conn, &node->key, &node->acc); + set_tdb_key(node->db_name, &key); + do_tdb_delete(conn, &key, &node->acc); } =20 static int destroy_node(struct connection *conn, struct node *node) @@ -1643,10 +1648,11 @@ static int delnode_sub(const void *ctx, struct conn= ection *conn, const char *root =3D arg; bool watch_exact; int ret; + const char *db_name; TDB_DATA key; =20 /* Any error here will probably be repeated for all following calls. */ - ret =3D access_node(conn, node, NODE_ACCESS_DELETE, &key); + ret =3D access_node(conn, node, NODE_ACCESS_DELETE, &db_name); if (ret > 0) return WALK_TREE_SUCCESS_STOP; =20 @@ -1654,6 +1660,7 @@ static int delnode_sub(const void *ctx, struct connec= tion *conn, return WALK_TREE_ERROR_STOP; =20 /* In case of error stop the walk. */ + set_tdb_key(db_name, &key); if (!ret && do_tdb_delete(conn, &key, &node->acc)) return WALK_TREE_ERROR_STOP; =20 diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_cor= e.h index 19a81adc49..ec7a56a869 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -181,8 +181,8 @@ struct node_account_data { =20 struct node { const char *name; - /* Key used to update TDB */ - TDB_DATA key; + /* Name used to access data base. */ + const char *db_name; =20 /* Parent (optional) */ struct node *parent; diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xensto= red_transaction.c index baad9e472d..020b70d954 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -227,7 +227,7 @@ void transaction_prepend(struct connection *conn, const= char *name, * to be accessed in the data base. */ int access_node(struct connection *conn, struct node *node, - enum node_access_type type, TDB_DATA *key) + enum node_access_type type, const char **db_name) { struct accessed_node *i =3D NULL; struct transaction *trans; @@ -243,8 +243,8 @@ int access_node(struct connection *conn, struct node *n= ode, =20 if (!conn || !conn->transaction) { /* They're changing the global database. */ - if (key) - set_tdb_key(node->name, key); + if (db_name) + *db_name =3D node->name; return 0; } =20 @@ -308,8 +308,8 @@ int access_node(struct connection *conn, struct node *n= ode, /* Nothing to delete. */ return -1; =20 - if (key) { - set_tdb_key(i->trans_name, key); + if (db_name) { + *db_name =3D i->trans_name; if (type =3D=3D NODE_ACCESS_WRITE) i->ta_node =3D true; if (type =3D=3D NODE_ACCESS_DELETE) diff --git a/tools/xenstore/xenstored_transaction.h b/tools/xenstore/xensto= red_transaction.h index 883145163f..f6a2e2f7f5 100644 --- a/tools/xenstore/xenstored_transaction.h +++ b/tools/xenstore/xenstored_transaction.h @@ -41,7 +41,7 @@ void ta_node_created(struct transaction *trans); =20 /* This node was accessed. */ int __must_check access_node(struct connection *conn, struct node *node, - enum node_access_type type, TDB_DATA *key); + enum node_access_type type, const char **db_n= ame); =20 /* Queue watches for a modified node. */ void queue_watches(struct connection *conn, const char *name, bool watch_e= xact); --=20 2.35.3