enum osd_quota_local_flags *local_flags)
{
struct lquota_entry *lqe;
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
enum osd_quota_local_flags qtype_flag = 0;
- int rc, ret = -EINPROGRESS;
- ENTRY;
+ int rc = 0, ret = -EINPROGRESS;
+ long remaining;
+ ENTRY;
if (qid->lqi_qentry != NULL) {
/* we already had to deal with this id for this transaction */
lqe = qid->lqi_qentry;
lqe_write_unlock(lqe);
/* acquire quota space for the operation, cap overall wait time to
- * prevent a service thread from being stuck for too long */
- rc = wait_event_idle_timeout(
- lqe->lqe_waiters, qsd_acquire(env, lqe, space, &ret),
- cfs_time_seconds(qsd_wait_timeout(qqi->qqi_qsd)));
+ * prevent a service thread from being stuck for too long
+ */
+ remaining = cfs_time_seconds(qsd_wait_timeout(qqi->qqi_qsd));
+ add_wait_queue(&lqe->lqe_waiters, &wait);
+ do {
+ if (qsd_acquire(env, lqe, space, &ret))
+ break;
- if (rc > 0 && ret == 0) {
+ remaining = wait_woken(&wait, TASK_IDLE, remaining);
+ } while (remaining > 0);
+
+ if (remaining > 0 && ret == 0) {
qid->lqi_space += space;
rc = 0;
} else {
- if (rc > 0)
+ if (remaining > 0)
rc = ret;
- else if (rc == 0)
+ else if (remaining == 0)
rc = -ETIMEDOUT;
LQUOTA_DEBUG(lqe, "acquire quota failed:%d", rc);
if (local_flags && lqe->lqe_pending_write != 0)
/* Inform OSD layer that there are pending writes.
- * It might want to retry after a sync if appropriate */
+ * It might want to retry after a sync if appropriate
+ */
*local_flags |= QUOTA_FL_SYNC;
lqe_write_unlock(lqe);
/* convert recoverable error into -EINPROGRESS, client will
- * retry */
+ * retry
+ */
if (rc == -ETIMEDOUT || rc == -ENOTCONN || rc == -ENOLCK ||
rc == -EAGAIN || rc == -EINTR) {
rc = -EINPROGRESS;
} else if (rc == -ESRCH) {
rc = 0;
- LQUOTA_ERROR(lqe, "ID isn't enforced on master, it "
- "probably due to a legeal race, if this "
- "message is showing up constantly, there "
- "could be some inconsistence between "
- "master & slave, and quota reintegration "
- "needs be re-triggered.");
+ LQUOTA_ERROR(lqe,
+ "ID isn't enforced on master, it probably due to a legeal race, if this message is showing up constantly, there could be some inconsistence between master & slave, and quota reintegration needs be re-triggered.");
}
}
+ remove_wait_queue(&lqe->lqe_waiters, &wait);
if (local_flags != NULL) {
out_flags: