From a7fd123dd689aaf77b692633f2f88a47ac438880 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Mon, 25 Jan 2016 07:22:42 +0100 Subject: [PATCH] client: make statistics accessible via brick instance --- kernel/mars_client.c | 23 ++++++++++++----------- kernel/mars_client.h | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/mars_client.c b/kernel/mars_client.c index 476c1206..7cad05a7 100644 --- a/kernel/mars_client.c +++ b/kernel/mars_client.c @@ -487,15 +487,17 @@ void _hash_insert(struct client_output *output, struct client_mref_aspect *mref_ static void client_ref_io(struct client_output *output, struct mref_object *mref) { + struct client_brick *brick = output->brick; struct client_mref_aspect *mref_a; int error = -EINVAL; - mref_a = client_mref_get_aspect(output->brick, mref); + mref_a = client_mref_get_aspect(brick, mref); if (unlikely(!mref_a)) { goto error; } - while (output->brick->max_flying > 0 && atomic_read(&output->fly_count) > output->brick->max_flying) { + while (brick->max_flying > 0 && + atomic_read(&brick->fly_count) > brick->max_flying) { MARS_IO("sleeping request pos = %lld len = %d flags = %ux (flying = %d)\n", mref->ref_pos, mref->ref_len, mref->ref_flags, atomic_read(&output->fly_count)); @@ -506,12 +508,12 @@ static void client_ref_io(struct client_output *output, struct mref_object *mref #endif } - if (!output->brick->power.led_on) { + if (!brick->power.led_on) { MARS_ERR("IO submission on dead instance\n"); } atomic_inc(&mars_global_io_flying); - atomic_inc(&output->fly_count); + atomic_inc(&brick->fly_count); _mref_get(mref); mref_a->submit_jiffies = jiffies; @@ -644,7 +646,7 @@ int receiver_thread(void *data) client_ref_put(output, mref); - atomic_dec(&output->fly_count); + atomic_dec(&output->brick->fly_count); atomic_dec(&mars_global_io_flying); break; } @@ -764,13 +766,13 @@ void _do_timeout(struct client_output *output, struct list_head *anchor, int *ro mref->ref_len); } - atomic_inc(&output->timeout_count); + atomic_inc(&brick->timeout_count); SIMPLE_CALLBACK(mref, -ETIME); client_ref_put(output, mref); - atomic_dec(&output->fly_count); + atomic_dec(&brick->fly_count); atomic_dec(&mars_global_io_flying); } } @@ -1042,8 +1044,8 @@ char *client_statistics(struct client_brick *brick, int verbose) socket_count, brick->max_flying, brick->power.io_timeout, - atomic_read(&output->timeout_count), - atomic_read(&output->fly_count)); + atomic_read(&brick->timeout_count), + atomic_read(&brick->fly_count)); return res; } @@ -1051,8 +1053,7 @@ char *client_statistics(struct client_brick *brick, int verbose) static void client_reset_statistics(struct client_brick *brick) { - struct client_output *output = brick->outputs[0]; - atomic_set(&output->timeout_count, 0); + atomic_set(&brick->timeout_count, 0); } //////////////// object / aspect constructors / destructors /////////////// diff --git a/kernel/mars_client.h b/kernel/mars_client.h index e9c7225f..46dba237 100644 --- a/kernel/mars_client.h +++ b/kernel/mars_client.h @@ -59,6 +59,8 @@ struct client_brick { atomic_t sender_count; atomic_t receiver_count; int socket_count; + atomic_t fly_count; + atomic_t timeout_count; }; struct client_input { @@ -96,8 +98,6 @@ struct client_bundle { struct client_output { MARS_OUTPUT(client); - atomic_t fly_count; - atomic_t timeout_count; struct mutex mutex; struct list_head mref_list; int last_id;