From: Samuel Just Date: Mon, 1 Apr 2013 23:08:43 +0000 (-0700) Subject: ObjectStore: add allow_eio to read, stat, get_omap_header X-Git-Tag: v0.62~113^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fcec1a06ddd92574dbacf0dbac1bf4be5170bdd2;p=ceph.git ObjectStore: add allow_eio to read, stat, get_omap_header This will allow enlightened callers to handle EIO. Signed-off-by: Samuel Just --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 8b19a6171f0..c3a0cd852f2 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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; diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 536c98b168b..b73f2ad3f0c 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -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 *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 *keys); int omap_get_values(coll_t c, const hobject_t &hoid, const set &keys, map *out); diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 47279f76446..9f112647f82 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -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