* \param callback A handler function that runs when an event is deposited
* into the EQ. The constant value LNET_EQ_HANDLER_NONE can be used to
* indicate that no event handler is desired.
- * \param handle On successful return, this location will hold a handle for
- * the newly created EQ.
*
- * \retval 0 On success.
+ * \retval eq On successful return, the newly created EQ is returned.
+ * On failure, an error code encoded with ERR_PTR() is returned.
* \retval -EINVAL If an parameter is not valid.
* \retval -ENOMEM If memory for the EQ can't be allocated.
*
* \see lnet_eq_handler_t for the discussion on EQ handler semantics.
*/
-int
-LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
- struct lnet_handle_eq *handle)
+struct lnet_eq *
+LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback)
{
struct lnet_eq *eq;
/* count can be 0 if only need callback, we can eliminate
* overhead of enqueue event */
if (count == 0 && callback == LNET_EQ_HANDLER_NONE)
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
eq = lnet_eq_alloc();
if (eq == NULL)
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
if (count != 0) {
LIBCFS_ALLOC(eq->eq_events, count * sizeof(*eq->eq_events));
if (eq->eq_refs == NULL)
goto failed;
- /* MUST hold both exclusive lnet_res_lock */
- lnet_res_lock(LNET_LOCK_EX);
- /* NB: hold lnet_eq_wait_lock for EQ link/unlink, so we can do
- * both EQ lookup and poll event with only lnet_eq_wait_lock */
- lnet_eq_wait_lock();
-
- lnet_res_lh_initialize(&the_lnet.ln_eq_container, &eq->eq_lh);
- list_add(&eq->eq_list, &the_lnet.ln_eq_container.rec_active);
-
- lnet_eq_wait_unlock();
- lnet_res_unlock(LNET_LOCK_EX);
-
- lnet_eq2handle(handle, eq);
- return 0;
+ return eq;
failed:
if (eq->eq_events != NULL)
cfs_percpt_free(eq->eq_refs);
lnet_eq_free(eq);
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
}
EXPORT_SYMBOL(LNetEQAlloc);
* Release the resources associated with an event queue if it's idle;
* otherwise do nothing and it's up to the user to try again.
*
- * \param eqh A handle for the event queue to be released.
+ * \param eq The event queue to be released.
*
* \retval 0 If the EQ is not in use and freed.
- * \retval -ENOENT If \a eqh does not point to a valid EQ.
* \retval -EBUSY If the EQ is still in use by some MDs.
*/
int
-LNetEQFree(struct lnet_handle_eq eqh)
+LNetEQFree(struct lnet_eq *eq)
{
- struct lnet_eq *eq;
struct lnet_event *events = NULL;
int **refs = NULL;
int *ref;
* both EQ lookup and poll event with only lnet_eq_wait_lock */
lnet_eq_wait_lock();
- eq = lnet_handle2eq(&eqh);
- if (eq == NULL) {
- rc = -ENOENT;
- goto out;
- }
-
cfs_percpt_for_each(ref, i, eq->eq_refs) {
LASSERT(*ref >= 0);
if (*ref == 0)
size = eq->eq_size;
refs = eq->eq_refs;
- lnet_res_lh_invalidate(&eq->eq_lh);
- list_del(&eq->eq_list);
lnet_eq_free(eq);
out:
lnet_eq_wait_unlock();
* LNetEQPoll() provides a timeout to allow applications to poll, block for a
* fixed period, or block indefinitely.
*
- * \param eventqs,neq An array of EQ handles, and size of the array.
+ * \param eventqs,neq An array of lnet_eq, and size of the array.
* \param timeout Time in jiffies to wait for an event to occur on
* one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an
* infinite timeout.
* \retval -ENOENT If there's an invalid handle in \a eventqs.
*/
int
-LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout,
+LNetEQPoll(struct lnet_eq **eventqs, int neq, signed long timeout,
struct lnet_event *event, int *which)
{
int wait = 1;
for (;;) {
for (i = 0; i < neq; i++) {
- struct lnet_eq *eq = lnet_handle2eq(&eventqs[i]);
+ struct lnet_eq *eq = eventqs[i];
if (eq == NULL) {
lnet_eq_wait_unlock();