]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix for #3490 and config option to test
authorSam Lang <sam.lang@inktank.com>
Thu, 29 Nov 2012 18:19:51 +0000 (12:19 -0600)
committerSage Weil <sage@inktank.com>
Thu, 29 Nov 2012 23:04:06 +0000 (15:04 -0800)
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>
src/client/Client.cc
src/common/config_opts.h

index 35cba96d3c607a09de6e9af9ea558745af16c04e..72667cadc3b3c9b0d8e1747d7bd0f79f86cea0c2 100644 (file)
@@ -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()) {
index 291fef401995485ef97e012074a28ff9804dcd87..8699d789164bdebb15605f27bfad72062cf9d0e3 100644 (file)
@@ -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)