From 466fdb4c9ef462b1b271269df0f504b7e1ecd3f0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Mar 2008 11:06:50 -0800 Subject: [PATCH] client: require rd cap before checking size in Client::_read() --- src/TODO | 4 +++- src/client/Client.cc | 30 +++++++++--------------------- src/streamtest.cc | 4 ++-- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/TODO b/src/TODO index de67e0a4f34c4..1964dcfaf66e0 100644 --- a/src/TODO +++ b/src/TODO @@ -48,12 +48,14 @@ kernel client - send (+deliver!) unmount message osdmon -- allow fresh replacement osds. add osd_created in osdmap, probably - actually, MasterOSDMap? and clean out OSDMap, parsing in kernel client, etc. - monitor needs to monitor some osds... - bootstrap crush map crush +- rule naming + - would about a tuple of (type, minsize, maxsize, pool) for each rule? then we'd do a + quick 'search' to find the best rule given (pg_type, pg_size, pg_pool)... - xml import/export? - named storage "pools"? - generic rule definition diff --git a/src/client/Client.cc b/src/client/Client.cc index c4a07d7bc551f..6d84ba590fdd0 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2901,7 +2901,15 @@ int Client::_read(Fh *f, off_t offset, off_t size, bufferlist *bl) } bool lazy = f->mode == FILE_MODE_LAZY; - + + // wait for RD cap before checking size + while (!lazy && (in->file_caps() & CEPH_CAP_RD) == 0) { + dout(7) << " don't have read cap, waiting" << dendl; + Cond cond; + in->waitfor_read.push_back(&cond); + cond.Wait(client_lock); + } + // determine whether read range overlaps with file // ...ONLY if we're doing async io if (!lazy && (in->file_caps() & (CEPH_CAP_WRBUFFER|CEPH_CAP_RDCACHE))) { @@ -2932,29 +2940,9 @@ int Client::_read(Fh *f, off_t offset, off_t size, bufferlist *bl) if (g_conf.client_oc) { // object cache ON rvalue = r = in->fc.read(offset, size, *bl, client_lock); // may block. - - /* - if (in->inode.ino == 0x10000000075 && hackbuf) { - int s = MIN(size, bl->length()); - char *v = bl->c_str(); - for (int a=0; afile_caps() & CEPH_CAP_RD) == 0) { - dout(7) << " don't have read cap, waiting" << dendl; - Cond cond; - in->waitfor_read.push_back(&cond); - cond.Wait(client_lock); - } // lazy cap? while (lazy && (in->file_caps() & CEPH_CAP_LAZYIO) == 0) { dout(7) << " don't have lazy cap, waiting" << dendl; diff --git a/src/streamtest.cc b/src/streamtest.cc index 8ed72a14f4d13..0b7e30a9505f4 100644 --- a/src/streamtest.cc +++ b/src/streamtest.cc @@ -130,8 +130,8 @@ int main(int argc, const char **argv) if (now < next) { float s = next - now; s *= 1000 * 1000; // s -> us - //cout << "sleeping for " << s << std::endl; - usleep(s); + //cout << "sleeping for " << s << " us" << std::endl; + usleep((int)s); } } -- 2.39.5