From: "Jim Schutt" <jaschut@sandia.gov>
To: Colin McCabe <cmccabe@alumni.cmu.edu>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 2/3] common/Throttle: Add timed_wait().
Date: Thu, 23 Jun 2011 09:53:09 -0600 [thread overview]
Message-ID: <4E036165.4000400@sandia.gov> (raw)
In-Reply-To: <BANLkTi=ehh8uK_8Zj08jFZGPH7nGU3AFsg@mail.gmail.com>
Hi Colin,
Colin McCabe wrote:
> On Wed, Jun 22, 2011 at 11:26 AM, Jim Schutt <jaschut@sandia.gov> wrote:
>> This will enable SimpleMessenger to send keepalives to clients while
>> blocked in the policy throttler.
>>
>> Signed-off-by: Jim Schutt <jaschut@sandia.gov>
>> ---
>> src/common/Throttle.h | 40 ++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 40 insertions(+), 0 deletions(-)
>
> This looks good. Only a small nitpick-- it's better not to pass
> utime_t by value, since it's a struct. There's a bunch of other code
> doing it, but it's better to pass a const reference. Also, I guess we
> need to rebase this because g_clock has been replaced by
> ceph_clock_now() in master. Should be easy though.
Given Sage's much cleaner approach to fixing the osd reset
issue, is this change useful on its own? If so, I'm happy
to fix it up and resubmit.
Let me know.
-- Jim
>
> cheers,
> Colin
>
>
>> diff --git a/src/common/Throttle.h b/src/common/Throttle.h
>> index 8fd2625..5a028cc 100644
>> --- a/src/common/Throttle.h
>> +++ b/src/common/Throttle.h
>> @@ -27,6 +27,9 @@ private:
>> ((c < max && count + c > max) || // normally stay under max
>> (c >= max && count > max)); // except for large c
>> }
>> +
>> + /* Returns true if it had to block/wait, false otherwise.
>> + */
>> bool _wait(int64_t c) {
>> bool waited = false;
>> if (_should_wait(c)) {
>> @@ -44,6 +47,28 @@ private:
>> return waited;
>> }
>>
>> + /* Returns true if it timed out while blocked/waiting,
>> + * false otherwise.
>> + */
>> + bool _timed_wait(utime_t interval, int64_t c) {
>> + if (_should_wait(c)) {
>> + utime_t timeout_at = g_clock.now() + interval;
>> + waiting += c;
>> + do {
>> + if (cond.WaitUntil(lock, timeout_at)) {
>> + waiting -= c;
>> + return true;
>> + }
>> + } while (_should_wait(c));
>> + waiting -= c;
>> +
>> + // wake up the next guy
>> + if (waiting)
>> + cond.SignalOne();
>> + }
>> + return false;
>> + }
>> +
>> public:
>> int64_t get_current() {
>> Mutex::Locker l(lock);
>> @@ -79,6 +104,21 @@ public:
>> count += c;
>> }
>>
>> + /* Returns true if it got the requested amount within
>> + * the specified interval, false otherwise.
>> + */
>> + bool timed_get(utime_t interval, int64_t c = 1, int64_t m = 0) {
>> + assert(c >= 0);
>> + Mutex::Locker l(lock);
>> + if (m) {
>> + assert(m > 0);
>> + _reset_max(m);
>> + }
>> + if (_timed_wait(interval, c)) return false;
>> + count += c;
>> + return true;
>> + }
>> +
>> /* Returns true if it successfully got the requested amount,
>> * or false if it would block.
>> */
>> --
>> 1.7.1
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
>
next prev parent reply other threads:[~2011-06-23 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-22 18:26 [PATCH 0/3] RFC: Enable clients to distinguish busy and unreachable OSDs Jim Schutt
2011-06-22 18:26 ` [PATCH] ceph: distinguish between unreachable and busy osds when resetting a connection Jim Schutt
2011-06-22 18:26 ` [PATCH 1/3] common/Throttle: Remove unused return type on Throttle::get() Jim Schutt
2011-06-22 18:26 ` [PATCH 2/3] common/Throttle: Add timed_wait() Jim Schutt
2011-06-23 11:02 ` Colin McCabe
2011-06-23 15:53 ` Jim Schutt [this message]
2011-06-23 17:14 ` Colin Patrick McCabe
2011-06-22 18:26 ` [PATCH 3/3] msgr: Send keepalive periodically when waiting in policy throttler Jim Schutt
2011-06-22 20:31 ` [PATCH 0/3] RFC: Enable clients to distinguish busy and unreachable OSDs Sage Weil
2011-06-22 21:22 ` Sage Weil
2011-06-23 14:22 ` Jim Schutt
2011-06-23 19:05 ` Jim Schutt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E036165.4000400@sandia.gov \
--to=jaschut@sandia.gov \
--cc=ceph-devel@vger.kernel.org \
--cc=cmccabe@alumni.cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.