summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Lang <sam.lang@inktank.com>2012-11-29 12:19:51 -0600
committerSage Weil <sage@inktank.com>2012-11-29 15:04:06 -0800
commit7d27e2e95c8cb1bb3f5950ff224e49bfd353db9c (patch)
tree59a60430fce5b03402710eb65e8091dd6116609c
parentf9056f5bd7b2027b74269db169852dd7b915475c (diff)
downloadceph-7d27e2e95c8cb1bb3f5950ff224e49bfd353db9c.tar.gz
client: Fix for #3490 and config option to test
If the mds revokes our cache cap, and we follow the _read_sync() path, on a zero-byte file the osd returns ENOENT. We need to replace ENOENT with a return of 0 in this case. Signed-off-by: Sam Lang <sam.lang@inktank.com>
-rw-r--r--src/client/Client.cc6
-rw-r--r--src/common/config_opts.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc
index 35cba96d3c6..72667cadc3b 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -5406,6 +5406,7 @@ int Client::read(int fd, char *buf, loff_t size, loff_t offset)
int Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
{
+ const md_config_t *conf = cct->_conf;
Inode *in = f->inode;
//bool lazy = f->mode == CEPH_FILE_MODE_LAZY;
@@ -5422,7 +5423,7 @@ int Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
movepos = true;
}
- if (have & CEPH_CAP_FILE_CACHE)
+ if (!conf->client_debug_force_sync_read && have & CEPH_CAP_FILE_CACHE)
r = _read_async(f, offset, size, bl);
else
r = _read_sync(f, offset, size, bl);
@@ -5570,6 +5571,9 @@ int Client::_read_sync(Fh *f, uint64_t off, uint64_t len, bufferlist *bl)
flock.Unlock();
client_lock.Lock();
+ // if we get ENOENT from OSD, assume 0 bytes returned
+ if (r == -ENOENT)
+ r = 0;
if (r < 0)
return r;
if (tbl.length()) {
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index 291fef40199..8699d789164 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -181,6 +181,7 @@ OPTION(client_oc_max_dirty, OPT_INT, 1024*1024* 100) // MB * n (dirty OR tx.
OPTION(client_oc_target_dirty, OPT_INT, 1024*1024* 8) // target dirty (keep this smallish)
OPTION(client_oc_max_dirty_age, OPT_DOUBLE, 5.0) // max age in cache before writeback
OPTION(client_oc_max_objects, OPT_INT, 1000) // max objects in cache
+OPTION(client_debug_force_sync_read, OPT_BOOL, false) // always read synchronously (go to osds)
// note: the max amount of "in flight" dirty data is roughly (max - target)
OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent
OPTION(fuse_big_writes, OPT_BOOL, true)