Add initial multithreading support and example
This is the basic support for doing i/o in a separate worker thread. It is still not threads safe but a start. Now we need to protect all variables such as outqueue, waitpdu and friends. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -37,21 +37,14 @@
|
||||
atomic_fetch_sub_explicit(&x, 1, memory_order_relaxed)
|
||||
#else /* HAVE_STDATOMIC_H */
|
||||
#define ATOMIC_INC(rpc, x) \
|
||||
if (rpc->multithreading_enabled) { \
|
||||
nfs_mt_mutex_lock(&rpc->atomic_int_mutex); \
|
||||
iscs_mt_mutex_lock(&iscs->atomic_int_mutex); \
|
||||
} \
|
||||
x++; \
|
||||
if (rpc->multithreading_enabled) { \
|
||||
nfs_mt_mutex_unlock(&rpc->atomic_int_mutex); \
|
||||
}
|
||||
iscsi_mt_mutex_unlock(&iscsi->atomic_int_mutex);
|
||||
#define ATOMIC_DEC(rpc, x) \
|
||||
if (rpc->multithreading_enabled) { \
|
||||
nfs_mt_mutex_lock(&rpc->atomic_int_mutex); \
|
||||
} \
|
||||
nfs_mt_mutex_lock(&rpc->atomic_int_mutex); \
|
||||
x--; \
|
||||
if (rpc->multithreading_enabled) { \
|
||||
nfs_mt_mutex_unlock(&rpc->atomic_int_mutex); \
|
||||
}
|
||||
nfs_mt_mutex_unlock(&rpc->atomic_int_mutex);
|
||||
#endif /* HAVE_STDATOMIC_H */
|
||||
#else /* HAVE_MULTITHREADING */
|
||||
/* no multithreading support, no need to protect the increment */
|
||||
@@ -223,9 +216,6 @@ struct iscsi_context {
|
||||
libiscsi_mutex_t iscsi_mutex;
|
||||
libiscsi_thread_t service_thread;
|
||||
int poll_timeout;
|
||||
//libnfs_mutex_t nfs4_open_counter_mutex;
|
||||
//libnfs_mutex_t nfs4_open_call_mutex;
|
||||
//struct nfs_thread_context *thread_ctx;
|
||||
#ifndef HAVE_STDATOMIC_H
|
||||
libiscsi_mutex_t atomic_int_mutex;
|
||||
#endif /* HAVE_STDATOMIC_H */
|
||||
|
||||
@@ -1702,6 +1702,18 @@ iscsi_set_fd_dup_cb(struct iscsi_context *iscsi,
|
||||
void (*cb)(struct iscsi_context *iscsi, void *opaque),
|
||||
void *opaque);
|
||||
|
||||
/*
|
||||
* MULTITHREADING
|
||||
*/
|
||||
/*
|
||||
* This function starts a separate service thread for multithreading support.
|
||||
*/
|
||||
EXTERN int iscsi_mt_service_thread_start(struct iscsi_context *iscsi);
|
||||
/*
|
||||
* Shutdown multithreading support.
|
||||
*/
|
||||
EXTERN void iscsi_mt_service_thread_stop(struct iscsi_context *iscsi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user