[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Add a transaction_started field in xenstored connection structure instead of



# HG changeset patch
# User vhanquez@xxxxxxxxxxxxxxxxxxxxx
# Node ID c471b326b75e587104e8328b57f6985b75e38577
# Parent  d2bf1a7cc1319d2e0379c3394a6c09ec2f0c51e1
Add a transaction_started field in xenstored connection structure instead of
browsing the list of transaction each time
Bump the default to 10, and make it configurable through the command line.

Signed-off-by: Vincent Hanquez <vincent@xxxxxxxxxxxxx>
---
 tools/xenstore/xenstored_core.c        |    9 ++++++++-
 tools/xenstore/xenstored_core.h        |    1 +
 tools/xenstore/xenstored_transaction.c |   10 ++++------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff -r d2bf1a7cc131 -r c471b326b75e tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Sat Jul 29 14:05:59 2006 +0100
+++ b/tools/xenstore/xenstored_core.c   Mon Jul 31 09:30:36 2006 +0000
@@ -80,6 +80,7 @@ int quota_nb_entry_per_domain = 1000;
 int quota_nb_entry_per_domain = 1000;
 int quota_nb_watch_per_domain = 128;
 int quota_max_entry_size = 2048; /* 2K */
+int quota_max_transaction = 10;
 
 #ifdef TESTING
 static bool failtest = false;
@@ -1342,6 +1343,7 @@ struct connection *new_connection(connwr
        new->write = write;
        new->read = read;
        new->can_write = true;
+       new->transaction_started = 0;
        INIT_LIST_HEAD(&new->out_list);
        INIT_LIST_HEAD(&new->watches);
        INIT_LIST_HEAD(&new->transaction_list);
@@ -1739,6 +1741,7 @@ static void usage(void)
 "  --entry-nb <nb>     limit the number of entries per domain,\n"
 "  --entry-size <size> limit the size of entry per domain, and\n"
 "  --entry-watch <nb>  limit the number of watches per domain,\n"
+"  --transaction <nb>  limit the number of transaction allowed per domain,\n"
 "  --no-recovery       to request that no recovery should be attempted when\n"
 "                      the store is corrupted (debug only),\n"
 "  --preserve-local    to request that /local is preserved on start-up,\n"
@@ -1755,6 +1758,7 @@ static struct option options[] = {
        { "output-pid", 0, NULL, 'P' },
        { "entry-size", 1, NULL, 'S' },
        { "trace-file", 1, NULL, 'T' },
+       { "transaction", 1, NULL, 't' },
        { "no-recovery", 0, NULL, 'R' },
        { "preserve-local", 0, NULL, 'L' },
        { "verbose", 0, NULL, 'V' },
@@ -1774,7 +1778,7 @@ int main(int argc, char *argv[])
        const char *pidfile = NULL;
        int evtchn_fd = -1;
 
-       while ((opt = getopt_long(argc, argv, "DE:F:HNPS:T:RLVW:", options,
+       while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options,
                                  NULL)) != -1) {
                switch (opt) {
                case 'D':
@@ -1804,6 +1808,9 @@ int main(int argc, char *argv[])
                case 'S':
                        quota_max_entry_size = strtol(optarg, NULL, 10);
                        break;
+               case 't':
+                       quota_max_transaction = strtol(optarg, NULL, 10);
+                       break;
                case 'T':
                        tracefile = optarg;
                        break;
diff -r d2bf1a7cc131 -r c471b326b75e tools/xenstore/xenstored_core.h
--- a/tools/xenstore/xenstored_core.h   Sat Jul 29 14:05:59 2006 +0100
+++ b/tools/xenstore/xenstored_core.h   Mon Jul 31 09:30:36 2006 +0000
@@ -79,6 +79,7 @@ struct connection
        /* List of in-progress transactions. */
        struct list_head transaction_list;
        uint32_t next_transaction_id;
+       unsigned int transaction_started;
 
        /* The domain I'm associated with, if any. */
        struct domain *domain;
diff -r d2bf1a7cc131 -r c471b326b75e tools/xenstore/xenstored_transaction.c
--- a/tools/xenstore/xenstored_transaction.c    Sat Jul 29 14:05:59 2006 +0100
+++ b/tools/xenstore/xenstored_transaction.c    Mon Jul 31 09:30:36 2006 +0000
@@ -66,6 +66,7 @@ struct transaction
        struct list_head changes;
 };
 
+extern int quota_max_transaction;
 static unsigned int generation;
 
 /* Return tdb context to use for this connection. */
@@ -125,7 +126,6 @@ void do_transaction_start(struct connect
 {
        struct transaction *trans, *exists;
        char id_str[20];
-       int started;
 
        /* We don't support nested transactions. */
        if (conn->transaction) {
@@ -133,11 +133,7 @@ void do_transaction_start(struct connect
                return;
        }
 
-       started = 0;
-       list_for_each_entry(trans, &conn->transaction_list, list)
-               started++;
-
-       if (started > 5) {
+       if (conn->transaction_started > quota_max_transaction) {
                send_error(conn, ENOSPC);
                return;
        }
@@ -166,6 +162,7 @@ void do_transaction_start(struct connect
        list_add_tail(&trans->list, &conn->transaction_list);
        talloc_steal(conn, trans);
        talloc_set_destructor(trans, destroy_transaction);
+       conn->transaction_started++;
 
        sprintf(id_str, "%u", trans->id);
        send_reply(conn, XS_TRANSACTION_START, id_str, strlen(id_str)+1);
@@ -188,6 +185,7 @@ void do_transaction_end(struct connectio
 
        conn->transaction = NULL;
        list_del(&trans->list);
+       conn->transaction_started--;
 
        /* Attach transaction to arg for auto-cleanup */
        talloc_steal(arg, trans);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.