]> xenbits.xensource.com Git - xen.git/commitdiff
Add a transaction_started field in xenstored connection structure instead of
authorvhanquez@gwig.uk.xensource.com <vhanquez@gwig.uk.xensource.com>
Mon, 31 Jul 2006 09:30:36 +0000 (09:30 +0000)
committervhanquez@gwig.uk.xensource.com <vhanquez@gwig.uk.xensource.com>
Mon, 31 Jul 2006 09:30:36 +0000 (09:30 +0000)
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@xensource.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_core.h
tools/xenstore/xenstored_transaction.c

index 25330f9906bb9b61fb4d7feec25d9a38d1fe6f1d..2511e4a5fc863fffcab3fd76b2631d5864f3f8a1 100644 (file)
@@ -80,6 +80,7 @@ static void check_store(void);
 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(connwritefn_t *write, connreadfn_t *read)
        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;
index f16d01804798f4894b5df6a7548fc706d4623d04..0849e7ba7875360d1c0f67fd82646d36abdc1ca8 100644 (file)
@@ -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;
index a3f215725617efb3cc31b156bc936bc06ac28d94..fb20287f99df48a72a5d6e4e5d3a4c1fa0b01b7e 100644 (file)
@@ -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 connection *conn, struct buffered_data *in)
 {
        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 connection *conn, struct buffered_data *in)
                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 connection *conn, struct buffered_data *in)
        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 connection *conn, const char *arg)
 
        conn->transaction = NULL;
        list_del(&trans->list);
+       conn->transaction_started--;
 
        /* Attach transaction to arg for auto-cleanup */
        talloc_steal(arg, trans);