summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-03-16 07:01:33 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-03-17 17:16:46 +0530
commit3a83fdc459a620d5ce0360bcf5fa071118d5430f (patch)
tree9e7019e96e75cc28c8e47236be594cf9eed40d39 /xlators
parent3099d29e8e65554af31927c8f767b9b6103ca58e (diff)
IO-threads Cleanup: Change request queue into a struct list_head
This patch changes the per-thread request queue from a custom circular linked list, into the standard list.h list which is easier to understand and has a cleaner interface. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/io-threads/src/io-threads.c31
-rw-r--r--xlators/performance/io-threads/src/io-threads.h13
2 files changed, 20 insertions, 24 deletions
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 3d172f9b4fa..ce42a98348f 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -1020,19 +1020,15 @@ static void
iot_queue (iot_worker_t *worker,
call_stub_t *stub)
{
- iot_queue_t *queue;
+ iot_request_t *req = NULL;
- queue = CALLOC (1, sizeof (*queue));
- ERR_ABORT (queue);
- queue->stub = stub;
+ req = CALLOC (1, sizeof (iot_request_t));
+ ERR_ABORT (req);
+ req->stub = stub;
pthread_mutex_lock (&worker->qlock);
{
- queue->next = &worker->queue;
- queue->prev = worker->queue.prev;
-
- queue->next->prev = queue;
- queue->prev->next = queue;
+ list_add_tail (&req->list, &worker->rqlist);
/* dq_cond */
worker->queue_size++;
@@ -1047,25 +1043,24 @@ static call_stub_t *
iot_dequeue (iot_worker_t *worker)
{
call_stub_t *stub = NULL;
- iot_queue_t *queue = NULL;
+ iot_request_t *req = NULL;
pthread_mutex_lock (&worker->qlock);
{
while (!worker->queue_size)
pthread_cond_wait (&worker->dq_cond, &worker->qlock);
- queue = worker->queue.next;
- queue->next->prev = queue->prev;
- queue->prev->next = queue->next;
-
- stub = queue->stub;
+ list_for_each_entry (req, &worker->rqlist, list)
+ break;
+ list_del (&req->list);
+ stub = req->stub;
worker->queue_size--;
worker->dq++;
}
pthread_mutex_unlock (&worker->qlock);
- FREE (queue);
+ FREE (req);
return stub;
}
@@ -1101,9 +1096,7 @@ workers_init (iot_conf_t *conf)
worker->next->prev = worker;
worker->prev->next = worker;
- worker->queue.next = &worker->queue;
- worker->queue.prev = &worker->queue;
-
+ INIT_LIST_HEAD (&worker->rqlist);
pthread_mutex_init (&worker->qlock, NULL);
pthread_cond_init (&worker->dq_cond, NULL);
worker->conf = conf;
diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h
index 7606d0625d5..73a76fa8fe2 100644
--- a/xlators/performance/io-threads/src/io-threads.h
+++ b/xlators/performance/io-threads/src/io-threads.h
@@ -32,13 +32,14 @@
#include "dict.h"
#include "xlator.h"
#include "common-utils.h"
+#include "list.h"
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
struct iot_conf;
struct iot_worker;
-struct iot_queue;
+struct iot_request;
struct iot_local;
struct iot_file;
@@ -47,14 +48,16 @@ struct iot_local {
size_t frame_size;
};
-struct iot_queue {
- struct iot_queue *next, *prev;
+struct iot_request {
+ struct list_head list; /* Attaches this request to the list of
+ requests.
+ */
call_stub_t *stub;
};
struct iot_worker {
struct iot_worker *next, *prev;
- struct iot_queue queue;
+ struct list_head rqlist; /* List of requests assigned to me. */
struct iot_conf *conf;
int64_t q,dq;
pthread_cond_t dq_cond;
@@ -85,6 +88,6 @@ typedef struct iot_file iot_file_t;
typedef struct iot_conf iot_conf_t;
typedef struct iot_local iot_local_t;
typedef struct iot_worker iot_worker_t;
-typedef struct iot_queue iot_queue_t;
+typedef struct iot_request iot_request_t;
#endif /* __IOT_H */