From: Zheng Li <dev@zheng.li>
To: xen-devel@lists.xenproject.org
Cc: Dave Scott <Dave.Scott@citrix.com>, Joe Jin <joe.jin@oracle.com>,
"Luis R. Rodriguez" <mcgrof@suse.com>,
Luonengjun <luonengjun@huawei.com>, Zheng Li <dev@zheng.li>,
Fanhenglong <fanhenglong@huawei.com>,
"Liuqiming (John)" <john.liuqiming@huawei.com>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: [PATCH v2 6/8] oxenstored: enable domain connection indexing based on eventchn port
Date: Tue, 16 Sep 2014 10:31:35 +0100 [thread overview]
Message-ID: <1410859897-31563-7-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1410859897-31563-1-git-send-email-dev@zheng.li>
Currently in xenstore connection database, we use a hash table of
(domid -> connection) to store domain connections. This allows fast indexing
based on dom ids.
This patch adds another dimention of fast indexing that is based on eventchn
port number. This is useful when doing selective connection processing
based on the port numbers of incoming events.
Signed-off-by: Zheng Li <dev@zheng.li>
---
tools/ocaml/xenstored/connections.ml | 26 ++++++++++++++++++++++----
tools/ocaml/xenstored/domain.ml | 1 +
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/tools/ocaml/xenstored/connections.ml b/tools/ocaml/xenstored/connections.ml
index 3e6a48b..1c8d911 100644
--- a/tools/ocaml/xenstored/connections.ml
+++ b/tools/ocaml/xenstored/connections.ml
@@ -20,10 +20,16 @@ let debug fmt = Logging.debug "connections" fmt
type t = {
anonymous: (Unix.file_descr, Connection.t) Hashtbl.t;
domains: (int, Connection.t) Hashtbl.t;
+ ports: (Xeneventchn.t, Connection.t) Hashtbl.t;
mutable watches: (string, Connection.watch list) Trie.t;
}
-let create () = { anonymous = Hashtbl.create 37; domains = Hashtbl.create 37; watches = Trie.create () }
+let create () = {
+ anonymous = Hashtbl.create 37;
+ domains = Hashtbl.create 37;
+ ports = Hashtbl.create 37;
+ watches = Trie.create ()
+}
let add_anonymous cons fd can_write =
let xbcon = Xenbus.Xb.open_fd fd in
@@ -33,7 +39,10 @@ let add_anonymous cons fd can_write =
let add_domain cons dom =
let xbcon = Xenbus.Xb.open_mmap (Domain.get_interface dom) (fun () -> Domain.notify dom) in
let con = Connection.create xbcon (Some dom) in
- Hashtbl.add cons.domains (Domain.get_id dom) con
+ Hashtbl.add cons.domains (Domain.get_id dom) con;
+ match Domain.get_port dom with
+ | Some p -> Hashtbl.add cons.ports p con;
+ | None -> ()
let select cons =
Hashtbl.fold
@@ -45,8 +54,11 @@ let select cons =
let find cons =
Hashtbl.find cons.anonymous
-let find_domain cons id =
- Hashtbl.find cons.domains id
+let find_domain cons =
+ Hashtbl.find cons.domains
+
+let find_domain_by_port cons port =
+ Hashtbl.find cons.ports port
let del_watches_of_con con watches =
match List.filter (fun w -> Connection.get_con w != con) watches with
@@ -65,6 +77,12 @@ let del_domain cons id =
try
let con = find_domain cons id in
Hashtbl.remove cons.domains id;
+ (match Connection.get_domain con with
+ | Some d ->
+ (match Domain.get_port d with
+ | Some p -> Hashtbl.remove cons.ports p
+ | None -> ())
+ | None -> ());
cons.watches <- Trie.map (del_watches_of_con con) cons.watches;
Connection.close con
with exn ->
diff --git a/tools/ocaml/xenstored/domain.ml b/tools/ocaml/xenstored/domain.ml
index 444069d..06d5749 100644
--- a/tools/ocaml/xenstored/domain.ml
+++ b/tools/ocaml/xenstored/domain.ml
@@ -35,6 +35,7 @@ let get_id domain = domain.id
let get_interface d = d.interface
let get_mfn d = d.mfn
let get_remote_port d = d.remote_port
+let get_port d = d.port
let is_bad_domain domain = domain.bad_client
let mark_as_bad domain = domain.bad_client <- true
--
2.1.0
next prev parent reply other threads:[~2014-09-16 17:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 9:31 Some oxenstored improvements (v2) Zheng Li
2014-09-16 9:31 ` [PATCH v2 1/8] oxenstored: add a poll-based select mechanism Zheng Li
2014-09-16 9:31 ` [PATCH v2 2/8] oxenstored: add facilities to raise the max open fds uplimit Zheng Li
2014-09-16 9:31 ` [PATCH v2 3/8] oxenstored: add a --use-select command line flag Zheng Li
2014-09-16 9:31 ` [PATCH v2 4/8] oxenstored: catch the error when a connection is already deleted Zheng Li
2014-09-16 9:31 ` [PATCH v2 5/8] oxenstored: use hash table to store socket connections Zheng Li
2014-09-16 9:31 ` Zheng Li [this message]
2014-09-16 9:31 ` [PATCH v2 7/8] oxenstored: only process domain connections that notify us by events Zheng Li
2014-09-16 9:31 ` [PATCH v2 8/8] oxenstored: fine tunning the recognition of domain connections with queued input/output Zheng Li
2014-09-23 14:32 ` Some oxenstored improvements (v2) Ian Jackson
2014-09-23 15:20 ` Zheng Li
2014-09-23 15:23 ` Dave Scott
2014-09-23 15:41 ` Ian Jackson
2014-09-23 15:57 ` Zheng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410859897-31563-7-git-send-email-dev@zheng.li \
--to=dev@zheng.li \
--cc=Dave.Scott@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=fanhenglong@huawei.com \
--cc=joe.jin@oracle.com \
--cc=john.liuqiming@huawei.com \
--cc=luonengjun@huawei.com \
--cc=mcgrof@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).