From: Yehuda Sadeh Date: Wed, 16 Jul 2014 19:23:31 +0000 (-0700) Subject: rgw: don't try to wait for pending if list is empty X-Git-Tag: v0.83~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b89ab5f78d2f87368aeda09fb1801dc7e36f2933;p=ceph.git rgw: don't try to wait for pending if list is empty Fixes: #8846 Backport: firefly, dumpling This was broken at ea68b9372319fd0bab40856db26528d36359102e. We ended up calling wait_pending_front() when pending list was empty. This commit also moves the need_to_wait check to a different place, where we actually throttle (and not just drain completed IOs). Reported-by: Sylvain Munaut Signed-off-by: Yehuda Sadeh (cherry picked from commit f9f2417d7db01ecf2425039539997901615816a9) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3fdb49209bae..7f26c68b7943 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1095,6 +1095,9 @@ struct put_obj_aio_info RGWPutObjProcessor_Aio::pop_pending() int RGWPutObjProcessor_Aio::wait_pending_front() { + if (pending.empty()) { + return 0; + } struct put_obj_aio_info info = pop_pending(); int ret = store->aio_wait(info.handle); return ret; @@ -1128,8 +1131,9 @@ int RGWPutObjProcessor_Aio::throttle_data(void *handle, bool need_to_wait) pending.push_back(info); } size_t orig_size = pending.size(); - while (pending_has_completed() - || need_to_wait) { + + /* first drain complete IOs */ + while (pending_has_completed()) { int r = wait_pending_front(); if (r < 0) return r; @@ -1142,10 +1146,14 @@ int RGWPutObjProcessor_Aio::throttle_data(void *handle, bool need_to_wait) max_chunks++; } - if (pending.size() > max_chunks) { + /* now throttle. Note that need_to_wait should only affect the first IO operation */ + if (pending.size() > max_chunks || + need_to_wait) { int r = wait_pending_front(); if (r < 0) return r; + + need_to_wait = false; } return 0; }