From: Sam Lang Date: Thu, 29 Nov 2012 18:19:51 +0000 (-0600) Subject: client: Fix for #3490 and config option to test X-Git-Tag: v0.55~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7d27e2e95c8cb1bb3f5950ff224e49bfd353db9c;p=ceph.git 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 35cba96d3c60..72667cadc3b3 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 291fef401995..8699d789164b 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)