]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectStore: add allow_eio to read, stat, get_omap_header
authorSamuel Just <sam.just@inktank.com>
Mon, 1 Apr 2013 23:08:43 +0000 (16:08 -0700)
committerSamuel Just <sam.just@inktank.com>
Mon, 1 Apr 2013 23:27:31 +0000 (16:27 -0700)
This will allow enlightened callers to handle EIO.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.h

index 8b19a6171f0c55bc5094f034c22892b8c6f558da..c3a0cd852f20465641fcb59d4a4788c4c7724ba7 100644 (file)
@@ -193,7 +193,6 @@ int FileStore::lfn_stat(coll_t cid, const hobject_t& oid, struct stat *buf)
   r = ::stat(path->path(), buf);
   if (r < 0)
     r = -errno;
-  assert(!m_filestore_fail_eio || r != -EIO);
   return r;
 }
 
@@ -2716,9 +2715,11 @@ bool FileStore::exists(coll_t cid, const hobject_t& oid)
     return false;
 }
   
-int FileStore::stat(coll_t cid, const hobject_t& oid, struct stat *st)
+int FileStore::stat(
+  coll_t cid, const hobject_t& oid, struct stat *st, bool allow_eio)
 {
   int r = lfn_stat(cid, oid, st);
+  assert(allow_eio || !m_filestore_fail_eio || r != -EIO);
   if (r < 0) {
     dout(10) << "stat " << cid << "/" << oid
             << " = " << r << dendl;
@@ -2735,8 +2736,13 @@ int FileStore::stat(coll_t cid, const hobject_t& oid, struct stat *st)
   }
 }
 
-int FileStore::read(coll_t cid, const hobject_t& oid, 
-                    uint64_t offset, size_t len, bufferlist& bl)
+int FileStore::read(
+  coll_t cid,
+  const hobject_t& oid, 
+  uint64_t offset,
+  size_t len,
+  bufferlist& bl,
+  bool allow_eio)
 {
   int got;
 
@@ -2761,7 +2767,7 @@ int FileStore::read(coll_t cid, const hobject_t& oid,
   if (got < 0) {
     dout(10) << "FileStore::read(" << cid << "/" << oid << ") pread error: " << cpp_strerror(got) << dendl;
     lfn_close(fd);
-    assert(!m_filestore_fail_eio || got != -EIO);
+    assert(allow_eio || !m_filestore_fail_eio || got != -EIO);
     return got;
   }
   bptr.set_length(got);   // properly size the buffer
@@ -4507,8 +4513,11 @@ int FileStore::omap_get(coll_t c, const hobject_t &hoid,
   return 0;
 }
 
-int FileStore::omap_get_header(coll_t c, const hobject_t &hoid,
-                              bufferlist *bl)
+int FileStore::omap_get_header(
+  coll_t c,
+  const hobject_t &hoid,
+  bufferlist *bl,
+  bool allow_eio)
 {
   dout(15) << __func__ << " " << c << "/" << hoid << dendl;
   IndexedPath path;
@@ -4517,7 +4526,7 @@ int FileStore::omap_get_header(coll_t c, const hobject_t &hoid,
     return r;
   r = object_map->get_header(hoid, bl);
   if (r < 0 && r != -ENOENT) {
-    assert(!m_filestore_fail_eio || r != -EIO);
+    assert(allow_eio || !m_filestore_fail_eio || r != -EIO);
     return r;
   }
   return 0;
index 536c98b168ba89857385e160001186521f4a4c14..b73f2ad3f0cd4361ff65e62db991e87e2f48e49c 100644 (file)
@@ -364,8 +364,18 @@ public:
     return 0;
   }
   bool exists(coll_t cid, const hobject_t& oid);
-  int stat(coll_t cid, const hobject_t& oid, struct stat *st);
-  int read(coll_t cid, const hobject_t& oid, uint64_t offset, size_t len, bufferlist& bl);
+  int stat(
+    coll_t cid,
+    const hobject_t& oid,
+    struct stat *st,
+    bool allow_eio = false);
+  int read(
+    coll_t cid,
+    const hobject_t& oid,
+    uint64_t offset,
+    size_t len,
+    bufferlist& bl,
+    bool allow_eio = false);
   int fiemap(coll_t cid, const hobject_t& oid, uint64_t offset, size_t len, bufferlist& bl);
 
   int _touch(coll_t cid, const hobject_t& oid);
@@ -453,7 +463,11 @@ public:
   // omap (see ObjectStore.h for documentation)
   int omap_get(coll_t c, const hobject_t &hoid, bufferlist *header,
               map<string, bufferlist> *out);
-  int omap_get_header(coll_t c, const hobject_t &hoid, bufferlist *out);
+  int omap_get_header(
+    coll_t c,
+    const hobject_t &hoid,
+    bufferlist *out,
+    bool allow_eio = false);
   int omap_get_keys(coll_t c, const hobject_t &hoid, set<string> *keys);
   int omap_get_values(coll_t c, const hobject_t &hoid, const set<string> &keys,
                      map<string, bufferlist> *out);
index 47279f7644600ade0f4048dd9f9718636b19d17a..9f112647f8235fb16fa48b1e65cbe59e0fa36a87 100644 (file)
@@ -817,8 +817,20 @@ public:
 
   // objects
   virtual bool exists(coll_t cid, const hobject_t& oid) = 0;                   // useful?
-  virtual int stat(coll_t cid, const hobject_t& oid, struct stat *st) = 0;     // struct stat?
-  virtual int read(coll_t cid, const hobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) = 0;
+  virtual int stat(
+    coll_t cid,
+    const hobject_t& oid,
+    struct stat *st,
+    bool allow_eio = false) = 0; // struct stat?
+
+  virtual int read(
+    coll_t cid,
+    const hobject_t& oid,
+    uint64_t offset,
+    size_t len,
+    bufferlist& bl,
+    bool allow_eio = false) = 0;
+
   virtual int fiemap(coll_t cid, const hobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) = 0;
 
   virtual int getattr(coll_t cid, const hobject_t& oid, const char *name, bufferptr& value) = 0;
@@ -888,7 +900,8 @@ public:
   virtual int omap_get_header(
     coll_t c,                ///< [in] Collection containing hoid
     const hobject_t &hoid,   ///< [in] Object containing omap
-    bufferlist *header       ///< [out] omap header
+    bufferlist *header,      ///< [out] omap header
+    bool allow_eio = false ///< [in] don't assert on eio
     ) = 0;
 
   /// Get keys defined on hoid