From 3f3a4542887ba038231144be08b2c36d7cc83424 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 10 Oct 2011 21:11:09 +0200 Subject: [PATCH] client: duplicate arguments to "empty" clients Now you can do: fio --client=host1 --client=host2 --arg1 --arg2 --arg3 and arg1,2,3 are passed to both clients. If you do: fio --client=host1 --arg1 --client=host2 --arg2 --arg3 then arg1 is passed to host1, while arg2,3 are passed to host2. Signed-off-by: Jens Axboe --- client.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client.c b/client.c index 097fcc57..358903bb 100644 --- a/client.c +++ b/client.c @@ -28,6 +28,7 @@ struct client_eta { struct fio_client { struct flist_head list; struct flist_head hash_list; + struct flist_head arg_list; struct sockaddr_in addr; struct sockaddr_un addr_un; char *hostname; @@ -61,6 +62,8 @@ enum { static FLIST_HEAD(client_list); static FLIST_HEAD(eta_list); +static FLIST_HEAD(arg_list); + #define FIO_CLIENT_HASH_BITS 7 #define FIO_CLIENT_HASH_SZ (1 << FIO_CLIENT_HASH_BITS) #define FIO_CLIENT_HASH_MASK (FIO_CLIENT_HASH_SZ - 1) @@ -143,22 +146,47 @@ static void __fio_client_add_cmd_option(struct fio_client *client, void fio_client_add_cmd_option(void *cookie, const char *opt) { struct fio_client *client = cookie; + struct flist_head *entry; if (!client || !opt) return; __fio_client_add_cmd_option(client, opt); + + /* + * Duplicate arguments to shared client group + */ + flist_for_each(entry, &arg_list) { + client = flist_entry(entry, struct fio_client, arg_list); + + __fio_client_add_cmd_option(client, opt); + } } int fio_client_add(const char *hostname, void **cookie) { + struct fio_client *existing = *cookie; struct fio_client *client; + if (existing) { + /* + * We always add our "exec" name as the option, hence 1 + * means empty. + */ + if (existing->argc == 1) + flist_add_tail(&existing->arg_list, &arg_list); + else { + while (!flist_empty(&arg_list)) + flist_del_init(arg_list.next); + } + } + client = malloc(sizeof(*client)); memset(client, 0, sizeof(*client)); INIT_FLIST_HEAD(&client->list); INIT_FLIST_HEAD(&client->hash_list); + INIT_FLIST_HEAD(&client->arg_list); INIT_FLIST_HEAD(&client->eta_list); if (fio_server_parse_string(hostname, &client->hostname, -- 2.25.1