From 18fe93c67762ef70cd88609e253ad65e2a832529 Mon Sep 17 00:00:00 2001 From: Evgeniy Firsov Date: Tue, 8 Dec 2015 12:25:38 -0800 Subject: [PATCH] osd: Pass coll_t by reference Signed-off-by: Evgeniy Firsov Conflicts: src/os/ObjectStore.h src/os/bluestore/BlueStore.cc src/os/bluestore/BlueStore.h src/os/memstore/MemStore.h --- src/os/ObjectStore.h | 92 ++++++++-------- src/os/bluestore/BlueStore.cc | 34 +++--- src/os/bluestore/BlueStore.h | 34 +++--- src/os/filestore/CollectionIndex.h | 8 +- src/os/filestore/FileStore.cc | 166 ++++++++++++++--------------- src/os/filestore/FileStore.h | 126 +++++++++++----------- src/os/kstore/KStore.cc | 30 +++--- src/os/kstore/KStore.h | 30 +++--- src/os/memstore/MemStore.cc | 72 ++++++------- src/os/memstore/MemStore.h | 74 ++++++------- 10 files changed, 336 insertions(+), 330 deletions(-) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index fa92061677aee..506eddcc2b7dc 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1052,7 +1052,7 @@ public: * Ensure the existance of an object in a collection. Create an * empty object if necessary */ - void touch(coll_t cid, const ghobject_t& oid) { + void touch(const coll_t& cid, const ghobject_t& oid) { if (use_tbl) { __u32 op = OP_TOUCH; ::encode(op, tbl); @@ -1076,7 +1076,7 @@ public: * ObjectStore will omit the untouched data and store it as a * "hole" in the file. */ - void write(coll_t cid, const ghobject_t& oid, uint64_t off, uint64_t len, + void write(const coll_t& cid, const ghobject_t& oid, uint64_t off, uint64_t len, const bufferlist& write_data, uint32_t flags = 0) { if (use_tbl) { __u32 op = OP_WRITE; @@ -1109,7 +1109,7 @@ public: * ObjectStore instances may optimize this to release the * underlying storage space. */ - void zero(coll_t cid, const ghobject_t& oid, uint64_t off, uint64_t len) { + void zero(const coll_t& cid, const ghobject_t& oid, uint64_t off, uint64_t len) { if (use_tbl) { __u32 op = OP_ZERO; ::encode(op, tbl); @@ -1128,7 +1128,7 @@ public: data.ops++; } /// Discard all data in the object beyond the specified size. - void truncate(coll_t cid, const ghobject_t& oid, uint64_t off) { + void truncate(const coll_t& cid, const ghobject_t& oid, uint64_t off) { if (use_tbl) { __u32 op = OP_TRUNCATE; ::encode(op, tbl); @@ -1145,7 +1145,7 @@ public: data.ops++; } /// Remove an object. All four parts of the object are removed. - void remove(coll_t cid, const ghobject_t& oid) { + void remove(const coll_t& cid, const ghobject_t& oid) { if (use_tbl) { __u32 op = OP_REMOVE; ::encode(op, tbl); @@ -1160,12 +1160,12 @@ public: data.ops++; } /// Set an xattr of an object - void setattr(coll_t cid, const ghobject_t& oid, const char* name, bufferlist& val) { + void setattr(const coll_t& cid, const ghobject_t& oid, const char* name, bufferlist& val) { string n(name); setattr(cid, oid, n, val); } /// Set an xattr of an object - void setattr(coll_t cid, const ghobject_t& oid, const string& s, bufferlist& val) { + void setattr(const coll_t& cid, const ghobject_t& oid, const string& s, bufferlist& val) { if (use_tbl) { __u32 op = OP_SETATTR; ::encode(op, tbl); @@ -1184,7 +1184,7 @@ public: data.ops++; } /// Set multiple xattrs of an object - void setattrs(coll_t cid, const ghobject_t& oid, map& attrset) { + void setattrs(const coll_t& cid, const ghobject_t& oid, map& attrset) { if (use_tbl) { __u32 op = OP_SETATTRS; ::encode(op, tbl); @@ -1201,7 +1201,7 @@ public: data.ops++; } /// Set multiple xattrs of an object - void setattrs(coll_t cid, const ghobject_t& oid, map& attrset) { + void setattrs(const coll_t& cid, const ghobject_t& oid, map& attrset) { if (use_tbl) { __u32 op = OP_SETATTRS; ::encode(op, tbl); @@ -1218,12 +1218,12 @@ public: data.ops++; } /// remove an xattr from an object - void rmattr(coll_t cid, const ghobject_t& oid, const char *name) { + void rmattr(const coll_t& cid, const ghobject_t& oid, const char *name) { string n(name); rmattr(cid, oid, n); } /// remove an xattr from an object - void rmattr(coll_t cid, const ghobject_t& oid, const string& s) { + void rmattr(const coll_t& cid, const ghobject_t& oid, const string& s) { if (use_tbl) { __u32 op = OP_RMATTR; ::encode(op, tbl); @@ -1240,7 +1240,7 @@ public: data.ops++; } /// remove all xattrs from an object - void rmattrs(coll_t cid, const ghobject_t& oid) { + void rmattrs(const coll_t& cid, const ghobject_t& oid) { if (use_tbl) { __u32 op = OP_RMATTRS; ::encode(op, tbl); @@ -1265,7 +1265,7 @@ public: * The destination named object may already exist, in * which case its previous contents are discarded. */ - void clone(coll_t cid, const ghobject_t& oid, ghobject_t noid) { + void clone(const coll_t& cid, const ghobject_t& oid, ghobject_t noid) { if (use_tbl) { __u32 op = OP_CLONE; ::encode(op, tbl); @@ -1288,7 +1288,7 @@ public: * portion of the data from the source object. None of the other * three parts of an object is copied from the source. */ - void clone_range(coll_t cid, const ghobject_t& oid, ghobject_t noid, + void clone_range(const coll_t& cid, const ghobject_t& oid, ghobject_t noid, uint64_t srcoff, uint64_t srclen, uint64_t dstoff) { if (use_tbl) { __u32 op = OP_CLONERANGE2; @@ -1312,7 +1312,7 @@ public: data.ops++; } /// Create the collection - void create_collection(coll_t cid, int bits) { + void create_collection(const coll_t& cid, int bits) { if (use_tbl) { __u32 op = OP_MKCOLL; ::encode(op, tbl); @@ -1334,7 +1334,7 @@ public: * @param hint - the hint payload, which contains the customized * data along with the hint type. */ - void collection_hint(coll_t cid, uint32_t type, const bufferlist& hint) { + void collection_hint(const coll_t& cid, uint32_t type, const bufferlist& hint) { if (use_tbl) { __u32 op = OP_COLL_HINT; ::encode(op, tbl); @@ -1352,7 +1352,7 @@ public: } /// remove the collection, the collection must be empty - void remove_collection(coll_t cid) { + void remove_collection(const coll_t& cid) { if (use_tbl) { __u32 op = OP_RMCOLL; ::encode(op, tbl); @@ -1364,7 +1364,7 @@ public: } data.ops++; } - void collection_move(coll_t cid, coll_t oldcid, const ghobject_t& oid) + void collection_move(const coll_t& cid, coll_t oldcid, const ghobject_t& oid) __attribute__ ((deprecated)) { // NOTE: we encode this as a fixed combo of ADD + REMOVE. they // always appear together, so this is effectively a single MOVE. @@ -1396,7 +1396,7 @@ public: } data.ops++; } - void collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, + void collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid, coll_t cid, const ghobject_t& oid) { if (use_tbl) { __u32 op = OP_COLL_MOVE_RENAME; @@ -1420,7 +1420,7 @@ public: // backends need not implement these at all. /// Set an xattr on a collection - void collection_setattr(coll_t cid, const string& name, bufferlist& val) + void collection_setattr(const coll_t& cid, const string& name, bufferlist& val) __attribute__ ((deprecated)) { if (use_tbl) { __u32 op = OP_COLL_SETATTR; @@ -1439,7 +1439,7 @@ public: } /// Remove an xattr from a collection - void collection_rmattr(coll_t cid, const string& name) + void collection_rmattr(const coll_t& cid, const string& name) __attribute__ ((deprecated)) { if (use_tbl) { __u32 op = OP_COLL_RMATTR; @@ -1455,7 +1455,7 @@ public: data.ops++; } /// Set multiple xattrs on a collection - void collection_setattrs(coll_t cid, map& aset) + void collection_setattrs(const coll_t& cid, map& aset) __attribute__ ((deprecated)) { if (use_tbl) { __u32 op = OP_COLL_SETATTRS; @@ -1471,7 +1471,7 @@ public: data.ops++; } /// Set multiple xattrs on a collection - void collection_setattrs(coll_t cid, map& aset) + void collection_setattrs(const coll_t& cid, map& aset) __attribute__ ((deprecated)) { if (use_tbl) { __u32 op = OP_COLL_SETATTRS; @@ -1506,7 +1506,7 @@ public: } /// Set keys on oid omap. Replaces duplicate keys. void omap_setkeys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object to update const map &attrset ///< [in] Replacement keys and values ) { @@ -1976,7 +1976,7 @@ public: * @param oid oid of object * @returns true if object exists, false otherwise */ - virtual bool exists(coll_t cid, const ghobject_t& oid) = 0; // useful? + virtual bool exists(const coll_t& cid, const ghobject_t& oid) = 0; // useful? virtual bool exists(CollectionHandle& c, const ghobject_t& oid) { return exists(c->get_cid(), oid); } @@ -1991,7 +1991,7 @@ public: * @returns 0 on success, negative error code on failure. */ virtual int stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio = false) = 0; // struct stat? @@ -2019,7 +2019,7 @@ public: * @returns number of bytes read on success, or negative error code on failure. */ virtual int read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -2053,7 +2053,7 @@ public: * @param bl output bufferlist for extent map information. * @returns 0 on success, negative error code on failure. */ - virtual int fiemap(coll_t cid, const ghobject_t& oid, + virtual int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) = 0; virtual int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) { @@ -2069,7 +2069,7 @@ public: * @param value place to put output result. * @returns 0 on success, negative error code on failure. */ - virtual int getattr(coll_t cid, const ghobject_t& oid, + virtual int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) = 0; virtual int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name, bufferptr& value) { @@ -2085,7 +2085,7 @@ public: * @param value place to put output result. * @returns 0 on success, negative error code on failure. */ - int getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferlist& value) { + int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferlist& value) { bufferptr bp; int r = getattr(cid, oid, name, bp); if (bp.length()) @@ -2117,7 +2117,7 @@ public: * @param aset place to put output result. * @returns 0 on success, negative error code on failure. */ - virtual int getattrs(coll_t cid, const ghobject_t& oid, + virtual int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset) = 0; virtual int getattrs(CollectionHandle &c, const ghobject_t& oid, map& aset) { @@ -2132,7 +2132,7 @@ public: * @param aset place to put output result. * @returns 0 on success, negative error code on failure. */ - int getattrs(coll_t cid, const ghobject_t& oid, map& aset) { + int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset) { map bmap; int r = getattrs(cid, oid, bmap); for (map::iterator i = bmap.begin(); @@ -2165,7 +2165,7 @@ public: */ virtual int list_collections(vector& ls) = 0; - virtual int collection_version_current(coll_t c, uint32_t *version) { + virtual int collection_version_current(const coll_t& c, uint32_t *version) { *version = 0; return 1; } @@ -2175,7 +2175,7 @@ public: * @param c collection * @returns true if it exists, false otherwise */ - virtual bool collection_exists(coll_t c) = 0; + virtual bool collection_exists(const coll_t& c) = 0; /** * collection_getattr - get an xattr of a collection * @@ -2185,7 +2185,7 @@ public: * @param size size of buffer to receive value * @returns 0 on success, negative error code on failure */ - virtual int collection_getattr(coll_t cid, const char *name, + virtual int collection_getattr(const coll_t& cid, const char *name, void *value, size_t size) __attribute__ ((deprecated)) { return -EOPNOTSUPP; @@ -2199,7 +2199,7 @@ public: * @param bl buffer to receive value * @returns 0 on success, negative error code on failure */ - virtual int collection_getattr(coll_t cid, const char *name, bufferlist& bl) + virtual int collection_getattr(const coll_t& cid, const char *name, bufferlist& bl) __attribute__ ((deprecated)) { return -EOPNOTSUPP; } @@ -2211,7 +2211,7 @@ public: * @param aset map of keys and buffers that contain the values * @returns 0 on success, negative error code on failure */ - virtual int collection_getattrs(coll_t cid, map &aset) + virtual int collection_getattrs(const coll_t& cid, map &aset) __attribute__ ((deprecated)) { return -EOPNOTSUPP; } @@ -2222,7 +2222,7 @@ public: * @param c collection * @returns true if empty, false otherwise */ - virtual bool collection_empty(coll_t c) = 0; + virtual bool collection_empty(const coll_t& c) = 0; /** * return the number of significant bits of the coll_t::pgid. @@ -2231,7 +2231,7 @@ public: * set. A lazy backend can choose not to store and report this (e.g., * FileStore). */ - virtual int collection_bits(coll_t c) { + virtual int collection_bits(const coll_t& c) { return -EOPNOTSUPP; } @@ -2248,7 +2248,7 @@ public: * @param next [out] next item sorts >= this value * @return zero on success, or negative error */ - virtual int collection_list(coll_t c, ghobject_t start, ghobject_t end, + virtual int collection_list(const coll_t& c, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next) = 0; virtual int collection_list(CollectionHandle &c, @@ -2262,7 +2262,7 @@ public: /// OMAP /// Get omap contents virtual int omap_get( - coll_t c, ///< [in] Collection containing oid + const coll_t& c, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -2278,7 +2278,7 @@ public: /// Get omap header virtual int omap_get_header( - coll_t c, ///< [in] Collection containing oid + const coll_t& c, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio = false ///< [in] don't assert on eio @@ -2294,7 +2294,7 @@ public: /// Get keys defined on oid virtual int omap_get_keys( - coll_t c, ///< [in] Collection containing oid + const coll_t& c, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ) = 0; @@ -2308,7 +2308,7 @@ public: /// Get key values virtual int omap_get_values( - coll_t c, ///< [in] Collection containing oid + const coll_t& c, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -2324,7 +2324,7 @@ public: /// Filters keys into out which are defined on oid virtual int omap_check_keys( - coll_t c, ///< [in] Collection containing oid + const coll_t& c, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid @@ -2348,7 +2348,7 @@ public: * @return iterator, null on error */ virtual ObjectMap::ObjectMapIterator get_omap_iterator( - coll_t c, ///< [in] collection + const coll_t& c, ///< [in] collection const ghobject_t &oid ///< [in] object ) = 0; virtual ObjectMap::ObjectMapIterator get_omap_iterator( diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 3a02b17ffb845..44b2a9c4efeaf 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2282,7 +2282,7 @@ int BlueStore::statfs(struct statfs *buf) // --------------- // cache -BlueStore::CollectionRef BlueStore::_get_collection(coll_t cid) +BlueStore::CollectionRef BlueStore::_get_collection(const coll_t& cid) { RWLock::RLocker l(coll_lock); ceph::unordered_map::iterator cp = coll_map.find(cid); @@ -2337,7 +2337,7 @@ ObjectStore::CollectionHandle BlueStore::open_collection(const coll_t& cid) return _get_collection(cid); } -bool BlueStore::exists(coll_t cid, const ghobject_t& oid) +bool BlueStore::exists(const coll_t& cid, const ghobject_t& oid) { CollectionHandle c = _get_collection(cid); if (!c) @@ -2359,7 +2359,7 @@ bool BlueStore::exists(CollectionHandle &c_, const ghobject_t& oid) } int BlueStore::stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio) @@ -2392,7 +2392,7 @@ int BlueStore::stat( } int BlueStore::read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t length, @@ -2595,7 +2595,7 @@ int BlueStore::_do_read( } int BlueStore::fiemap( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -2709,7 +2709,7 @@ int BlueStore::fiemap( } int BlueStore::getattr( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) @@ -2754,7 +2754,7 @@ int BlueStore::getattr( int BlueStore::getattrs( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, map& aset) { @@ -2799,13 +2799,13 @@ int BlueStore::list_collections(vector& ls) return 0; } -bool BlueStore::collection_exists(coll_t c) +bool BlueStore::collection_exists(const coll_t& c) { RWLock::RLocker l(coll_lock); return coll_map.count(c); } -bool BlueStore::collection_empty(coll_t cid) +bool BlueStore::collection_empty(const coll_t& cid) { dout(15) << __func__ << " " << cid << dendl; vector ls; @@ -2819,7 +2819,7 @@ bool BlueStore::collection_empty(coll_t cid) return empty; } -int BlueStore::collection_bits(coll_t cid) +int BlueStore::collection_bits(const coll_t& cid) { dout(15) << __func__ << " " << cid << dendl; CollectionRef c = _get_collection(cid); @@ -2831,7 +2831,7 @@ int BlueStore::collection_bits(coll_t cid) } int BlueStore::collection_list( - coll_t cid, ghobject_t start, ghobject_t end, + const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *pnext) { @@ -3053,7 +3053,7 @@ bufferlist BlueStore::OmapIteratorImpl::value() } int BlueStore::omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -3117,7 +3117,7 @@ int BlueStore::omap_get( } int BlueStore::omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio ///< [in] don't assert on eio @@ -3166,7 +3166,7 @@ int BlueStore::omap_get_header( } int BlueStore::omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ) @@ -3224,7 +3224,7 @@ int BlueStore::omap_get_keys( } int BlueStore::omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -3274,7 +3274,7 @@ int BlueStore::omap_get_values( } int BlueStore::omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid @@ -3327,7 +3327,7 @@ int BlueStore::omap_check_keys( } ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator( - coll_t cid, ///< [in] collection + const coll_t& cid, ///< [in] collection const ghobject_t &oid ///< [in] object ) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index a978da0eb9721..32c0e01a82ec9 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -539,7 +539,7 @@ private: KeyValueDB::Transaction t); void _commit_bluefs_freespace(const vector& extents); - CollectionRef _get_collection(coll_t cid); + CollectionRef _get_collection(const coll_t& cid); void _queue_reap_collection(CollectionRef& c); void _reap_collections(); @@ -624,10 +624,10 @@ public: public: int statfs(struct statfs *buf); - bool exists(coll_t cid, const ghobject_t& oid); + bool exists(const coll_t& cid, const ghobject_t& oid); bool exists(CollectionHandle &c, const ghobject_t& oid); int stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio = false) override; @@ -637,7 +637,7 @@ public: struct stat *st, bool allow_eio = false) override; int read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -659,17 +659,17 @@ public: bufferlist& bl, uint32_t op_flags = 0); - int fiemap(coll_t cid, const ghobject_t& oid, + int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override; int fiemap(CollectionHandle &c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override; - int getattr(coll_t cid, const ghobject_t& oid, const char *name, + int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) override; int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name, bufferptr& value) override; - int getattrs(coll_t cid, const ghobject_t& oid, + int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset) override; int getattrs(CollectionHandle &c, const ghobject_t& oid, map& aset) override; @@ -678,11 +678,11 @@ public: CollectionHandle open_collection(const coll_t &c) override; - bool collection_exists(coll_t c); - bool collection_empty(coll_t c); - int collection_bits(coll_t c); + bool collection_exists(const coll_t& c); + bool collection_empty(const coll_t& c); + int collection_bits(const coll_t& c); - int collection_list(coll_t cid, ghobject_t start, ghobject_t end, + int collection_list(const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next) override; int collection_list(CollectionHandle &c, ghobject_t start, ghobject_t end, @@ -690,7 +690,7 @@ public: vector *ls, ghobject_t *next) override; int omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -704,7 +704,7 @@ public: /// Get omap header int omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio = false ///< [in] don't assert on eio @@ -718,7 +718,7 @@ public: /// Get keys defined on oid int omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ) override; @@ -730,7 +730,7 @@ public: /// Get key values int omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -744,7 +744,7 @@ public: /// Filters keys into out which are defined on oid int omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid @@ -757,7 +757,7 @@ public: ) override; ObjectMap::ObjectMapIterator get_omap_iterator( - coll_t cid, ///< [in] collection + const coll_t& cid, ///< [in] collection const ghobject_t &oid ///< [in] object ) override; ObjectMap::ObjectMapIterator get_omap_iterator( diff --git a/src/os/filestore/CollectionIndex.h b/src/os/filestore/CollectionIndex.h index a9947cce531d0..63744cbd08dea 100644 --- a/src/os/filestore/CollectionIndex.h +++ b/src/os/filestore/CollectionIndex.h @@ -57,14 +57,14 @@ protected: /// Debugging Constructor Path( string path, ///< [in] Path to return. - coll_t coll) ///< [in] collection + const coll_t& coll) ///< [in] collection : full_path(path), parent_coll(coll) {} /// Getter for the stored path. const char *path() const { return full_path.c_str(); } /// Getter for collection - coll_t coll() const { return parent_coll; } + const coll_t& coll() const { return parent_coll; } /// Getter for parent CollectionIndex* get_index() const { @@ -78,7 +78,7 @@ protected: /// Type of returned paths typedef ceph::shared_ptr IndexedPath; - static IndexedPath get_testing_path(string path, coll_t collection) { + static IndexedPath get_testing_path(string path, const coll_t& collection) { return IndexedPath(new Path(path, collection)); } @@ -176,7 +176,7 @@ protected: /// Call prior to removing directory virtual int prep_delete() { return 0; } - CollectionIndex(coll_t collection): + CollectionIndex(const coll_t& collection): access_lock_name ("CollectionIndex::access_lock::" + collection.to_str()), access_lock(access_lock_name.c_str()) {} diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 7aa64ebffe5c5..499b5ae525248 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -150,20 +150,20 @@ ostream& operator<<(ostream& out, const FileStore::OpSequencer& s) return out << *s.parent; } -int FileStore::get_cdir(coll_t cid, char *s, int len) +int FileStore::get_cdir(const coll_t& cid, char *s, int len) { const string &cid_str(cid.to_str()); return snprintf(s, len, "%s/current/%s", basedir.c_str(), cid_str.c_str()); } -int FileStore::get_index(coll_t cid, Index *index) +int FileStore::get_index(const coll_t& cid, Index *index) { int r = index_manager.get_index(cid, basedir, index); assert(!m_filestore_fail_eio || r != -EIO); return r; } -int FileStore::init_index(coll_t cid) +int FileStore::init_index(const coll_t& cid) { char path[PATH_MAX]; get_cdir(cid, path, sizeof(path)); @@ -189,7 +189,7 @@ int FileStore::lfn_find(const ghobject_t& oid, const Index& index, IndexedPath * return 0; } -int FileStore::lfn_truncate(coll_t cid, const ghobject_t& oid, off_t length) +int FileStore::lfn_truncate(const coll_t& cid, const ghobject_t& oid, off_t length) { FDRef fd; int r = lfn_open(cid, oid, false, &fd); @@ -207,7 +207,7 @@ int FileStore::lfn_truncate(coll_t cid, const ghobject_t& oid, off_t length) return r; } -int FileStore::lfn_stat(coll_t cid, const ghobject_t& oid, struct stat *buf) +int FileStore::lfn_stat(const coll_t& cid, const ghobject_t& oid, struct stat *buf) { IndexedPath path; Index index; @@ -227,7 +227,7 @@ int FileStore::lfn_stat(coll_t cid, const ghobject_t& oid, struct stat *buf) return r; } -int FileStore::lfn_open(coll_t cid, +int FileStore::lfn_open(const coll_t& cid, const ghobject_t& oid, bool create, FDRef *outfd, @@ -337,7 +337,7 @@ void FileStore::lfn_close(FDRef fd) { } -int FileStore::lfn_link(coll_t c, coll_t newcid, const ghobject_t& o, const ghobject_t& newoid) +int FileStore::lfn_link(const coll_t& c, const coll_t& newcid, const ghobject_t& o, const ghobject_t& newoid) { Index index_new, index_old; IndexedPath path_new, path_old; @@ -439,7 +439,7 @@ int FileStore::lfn_link(coll_t c, coll_t newcid, const ghobject_t& o, const ghob return 0; } -int FileStore::lfn_unlink(coll_t cid, const ghobject_t& o, +int FileStore::lfn_unlink(const coll_t& cid, const ghobject_t& o, const SequencerPosition &spos, bool force_clear_omap) { @@ -2095,7 +2095,7 @@ int FileStore::_do_transactions( return 0; } -void FileStore::_set_global_replay_guard(coll_t cid, +void FileStore::_set_global_replay_guard(const coll_t& cid, const SequencerPosition &spos) { if (backend->can_checkpoint()) @@ -2143,7 +2143,7 @@ void FileStore::_set_global_replay_guard(coll_t cid, dout(10) << __func__ << ": " << spos << " done" << dendl; } -int FileStore::_check_global_replay_guard(coll_t cid, +int FileStore::_check_global_replay_guard(const coll_t& cid, const SequencerPosition& spos) { char fn[PATH_MAX]; @@ -2174,7 +2174,7 @@ int FileStore::_check_global_replay_guard(coll_t cid, } -void FileStore::_set_replay_guard(coll_t cid, +void FileStore::_set_replay_guard(const coll_t& cid, const SequencerPosition &spos, bool in_progress=false) { @@ -2231,7 +2231,7 @@ void FileStore::_set_replay_guard(int fd, dout(10) << "_set_replay_guard " << spos << " done" << dendl; } -void FileStore::_close_replay_guard(coll_t cid, +void FileStore::_close_replay_guard(const coll_t& cid, const SequencerPosition &spos) { char fn[PATH_MAX]; @@ -2274,7 +2274,7 @@ void FileStore::_close_replay_guard(int fd, const SequencerPosition& spos) dout(10) << "_close_replay_guard " << spos << " done" << dendl; } -int FileStore::_check_replay_guard(coll_t cid, ghobject_t oid, const SequencerPosition& spos) +int FileStore::_check_replay_guard(const coll_t& cid, ghobject_t oid, const SequencerPosition& spos) { if (!replaying || backend->can_checkpoint()) return 1; @@ -2294,7 +2294,7 @@ int FileStore::_check_replay_guard(coll_t cid, ghobject_t oid, const SequencerPo return ret; } -int FileStore::_check_replay_guard(coll_t cid, const SequencerPosition& spos) +int FileStore::_check_replay_guard(const coll_t& cid, const SequencerPosition& spos) { if (!replaying || backend->can_checkpoint()) return 1; @@ -2882,10 +2882,10 @@ void FileStore::_do_transaction( // -------------------- // objects -bool FileStore::exists(coll_t cid, const ghobject_t& oid) +bool FileStore::exists(const coll_t& _cid, const ghobject_t& oid) { - tracepoint(objectstore, exists_enter, cid.c_str()); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, exists_enter, _cid.c_str()); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); struct stat st; bool retval = stat(cid, oid, &st) == 0; tracepoint(objectstore, exists_exit, retval); @@ -2893,10 +2893,10 @@ bool FileStore::exists(coll_t cid, const ghobject_t& oid) } int FileStore::stat( - coll_t cid, const ghobject_t& oid, struct stat *st, bool allow_eio) + const coll_t& _cid, const ghobject_t& oid, struct stat *st, bool allow_eio) { - tracepoint(objectstore, stat_enter, cid.c_str()); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, stat_enter, _cid.c_str()); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); int r = lfn_stat(cid, oid, st); assert(allow_eio || !m_filestore_fail_eio || r != -EIO); if (r < 0) { @@ -2917,7 +2917,7 @@ int FileStore::stat( } int FileStore::read( - coll_t cid, + const coll_t& _cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -2926,8 +2926,8 @@ int FileStore::read( bool allow_eio) { int got; - tracepoint(objectstore, read_enter, cid.c_str(), offset, len); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, read_enter, _cid.c_str(), offset, len); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); dout(15) << "read " << cid << "/" << oid << " " << offset << "~" << len << dendl; @@ -3099,12 +3099,12 @@ int FileStore::_do_seek_hole_data(int fd, uint64_t offset, size_t len, #endif } -int FileStore::fiemap(coll_t cid, const ghobject_t& oid, +int FileStore::fiemap(const coll_t& _cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) { - tracepoint(objectstore, fiemap_enter, cid.c_str(), offset, len); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, fiemap_enter, _cid.c_str(), offset, len); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); if ((!backend->has_seek_data_hole() && !backend->has_fiemap()) || len <= (size_t)m_filestore_fiemap_threshold) { @@ -3148,7 +3148,7 @@ done: } -int FileStore::_remove(coll_t cid, const ghobject_t& oid, +int FileStore::_remove(const coll_t& cid, const ghobject_t& oid, const SequencerPosition &spos) { dout(15) << "remove " << cid << "/" << oid << dendl; @@ -3157,7 +3157,7 @@ int FileStore::_remove(coll_t cid, const ghobject_t& oid, return r; } -int FileStore::_truncate(coll_t cid, const ghobject_t& oid, uint64_t size) +int FileStore::_truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size) { dout(15) << "truncate " << cid << "/" << oid << " size " << size << dendl; int r = lfn_truncate(cid, oid, size); @@ -3166,7 +3166,7 @@ int FileStore::_truncate(coll_t cid, const ghobject_t& oid, uint64_t size) } -int FileStore::_touch(coll_t cid, const ghobject_t& oid) +int FileStore::_touch(const coll_t& cid, const ghobject_t& oid) { dout(15) << "touch " << cid << "/" << oid << dendl; @@ -3181,7 +3181,7 @@ int FileStore::_touch(coll_t cid, const ghobject_t& oid) return r; } -int FileStore::_write(coll_t cid, const ghobject_t& oid, +int FileStore::_write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl, uint32_t fadvise_flags) { @@ -3236,7 +3236,7 @@ int FileStore::_write(coll_t cid, const ghobject_t& oid, return r; } -int FileStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len) +int FileStore::_zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len) { dout(15) << "zero " << cid << "/" << oid << " " << offset << "~" << len << dendl; int ret = 0; @@ -3284,7 +3284,7 @@ int FileStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t return ret; } -int FileStore::_clone(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid, +int FileStore::_clone(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, const SequencerPosition& spos) { dout(15) << "clone " << cid << "/" << oldoid << " -> " << cid << "/" << newoid << dendl; @@ -3540,7 +3540,7 @@ int FileStore::_do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, u return r; } -int FileStore::_clone_range(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid, +int FileStore::_clone_range(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, uint64_t srcoff, uint64_t len, uint64_t dstoff, const SequencerPosition& spos) { @@ -4037,10 +4037,10 @@ bool FileStore::debug_mdata_eio(const ghobject_t &oid) { // objects -int FileStore::getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr &bp) +int FileStore::getattr(const coll_t& _cid, const ghobject_t& oid, const char *name, bufferptr &bp) { - tracepoint(objectstore, getattr_enter, cid.c_str()); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, getattr_enter, _cid.c_str()); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); dout(15) << "getattr " << cid << "/" << oid << " '" << name << "'" << dendl; FDRef fd; int r = lfn_open(cid, oid, false, &fd); @@ -4086,10 +4086,10 @@ int FileStore::getattr(coll_t cid, const ghobject_t& oid, const char *name, buff } } -int FileStore::getattrs(coll_t cid, const ghobject_t& oid, map& aset) +int FileStore::getattrs(const coll_t& _cid, const ghobject_t& oid, map& aset) { - tracepoint(objectstore, getattrs_enter, cid.c_str()); - _kludge_temp_object_collection(cid, oid); + tracepoint(objectstore, getattrs_enter, _cid.c_str()); + const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp(); set omap_attrs; map omap_aset; Index index; @@ -4161,7 +4161,7 @@ int FileStore::getattrs(coll_t cid, const ghobject_t& oid, map } } -int FileStore::_setattrs(coll_t cid, const ghobject_t& oid, map& aset, +int FileStore::_setattrs(const coll_t& cid, const ghobject_t& oid, map& aset, const SequencerPosition &spos) { map omap_set; @@ -4261,7 +4261,7 @@ int FileStore::_setattrs(coll_t cid, const ghobject_t& oid, map& aset) +int FileStore::collection_getattrs(const coll_t& cid, map& aset) { char fn[PATH_MAX]; get_cdir(cid, fn, sizeof(fn)); @@ -4443,7 +4443,7 @@ int FileStore::collection_getattrs(coll_t cid, map& aset) } -int FileStore::_collection_setattr(coll_t c, const char *name, +int FileStore::_collection_setattr(const coll_t& c, const char *name, const void *value, size_t size) { char fn[PATH_MAX]; @@ -4464,7 +4464,7 @@ int FileStore::_collection_setattr(coll_t c, const char *name, return r; } -int FileStore::_collection_rmattr(coll_t c, const char *name) +int FileStore::_collection_rmattr(const coll_t& c, const char *name) { char fn[PATH_MAX]; get_cdir(c, fn, sizeof(fn)); @@ -4485,7 +4485,7 @@ int FileStore::_collection_rmattr(coll_t c, const char *name) } -int FileStore::_collection_setattrs(coll_t cid, map& aset) +int FileStore::_collection_setattrs(const coll_t& cid, map& aset) { char fn[PATH_MAX]; get_cdir(cid, fn, sizeof(fn)); @@ -4544,7 +4544,7 @@ int FileStore::_collection_remove_recursive(const coll_t &cid, // -------------------------- // collections -int FileStore::collection_version_current(coll_t c, uint32_t *version) +int FileStore::collection_version_current(const coll_t& c, uint32_t *version) { Index index; int r = get_index(c, &index); @@ -4635,7 +4635,7 @@ int FileStore::list_collections(vector& ls, bool include_temp) return r; } -int FileStore::collection_stat(coll_t c, struct stat *st) +int FileStore::collection_stat(const coll_t& c, struct stat *st) { tracepoint(objectstore, collection_stat_enter, c.c_str()); char fn[PATH_MAX]; @@ -4650,7 +4650,7 @@ int FileStore::collection_stat(coll_t c, struct stat *st) return r; } -bool FileStore::collection_exists(coll_t c) +bool FileStore::collection_exists(const coll_t& c) { tracepoint(objectstore, collection_exists_enter, c.c_str()); struct stat st; @@ -4659,7 +4659,7 @@ bool FileStore::collection_exists(coll_t c) return ret; } -bool FileStore::collection_empty(coll_t c) +bool FileStore::collection_empty(const coll_t& c) { tracepoint(objectstore, collection_empty_enter, c.c_str()); dout(15) << "collection_empty " << c << dendl; @@ -4682,7 +4682,7 @@ bool FileStore::collection_empty(coll_t c) tracepoint(objectstore, collection_empty_exit, ret); return ret; } -int FileStore::collection_list(coll_t c, ghobject_t start, ghobject_t end, +int FileStore::collection_list(const coll_t& c, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next) { @@ -4762,12 +4762,12 @@ int FileStore::collection_list(coll_t c, ghobject_t start, ghobject_t end, return 0; } -int FileStore::omap_get(coll_t c, const ghobject_t &hoid, +int FileStore::omap_get(const coll_t& _c, const ghobject_t &hoid, bufferlist *header, map *out) { - tracepoint(objectstore, omap_get_enter, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, omap_get_enter, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; int r = get_index(c, &index); @@ -4790,13 +4790,13 @@ int FileStore::omap_get(coll_t c, const ghobject_t &hoid, } int FileStore::omap_get_header( - coll_t c, + const coll_t& _c, const ghobject_t &hoid, bufferlist *bl, bool allow_eio) { - tracepoint(objectstore, omap_get_header_enter, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, omap_get_header_enter, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; int r = get_index(c, &index); @@ -4818,10 +4818,10 @@ int FileStore::omap_get_header( return 0; } -int FileStore::omap_get_keys(coll_t c, const ghobject_t &hoid, set *keys) +int FileStore::omap_get_keys(const coll_t& _c, const ghobject_t &hoid, set *keys) { - tracepoint(objectstore, omap_get_keys_enter, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, omap_get_keys_enter, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; int r = get_index(c, &index); @@ -4843,12 +4843,12 @@ int FileStore::omap_get_keys(coll_t c, const ghobject_t &hoid, set *keys return 0; } -int FileStore::omap_get_values(coll_t c, const ghobject_t &hoid, +int FileStore::omap_get_values(const coll_t& _c, const ghobject_t &hoid, const set &keys, map *out) { - tracepoint(objectstore, omap_get_values_enter, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, omap_get_values_enter, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; const char *where = 0; @@ -4879,12 +4879,12 @@ int FileStore::omap_get_values(coll_t c, const ghobject_t &hoid, return r; } -int FileStore::omap_check_keys(coll_t c, const ghobject_t &hoid, +int FileStore::omap_check_keys(const coll_t& _c, const ghobject_t &hoid, const set &keys, set *out) { - tracepoint(objectstore, omap_check_keys_enter, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, omap_check_keys_enter, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; @@ -4907,11 +4907,11 @@ int FileStore::omap_check_keys(coll_t c, const ghobject_t &hoid, return 0; } -ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c, +ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(const coll_t& _c, const ghobject_t &hoid) { - tracepoint(objectstore, get_omap_iterator, c.c_str()); - _kludge_temp_object_collection(c, hoid); + tracepoint(objectstore, get_omap_iterator, _c.c_str()); + const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp(); dout(15) << __func__ << " " << c << "/" << hoid << dendl; Index index; int r = get_index(c, &index); @@ -4933,7 +4933,7 @@ ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c, return object_map->get_iterator(hoid); } -int FileStore::_collection_hint_expected_num_objs(coll_t c, uint32_t pg_num, +int FileStore::_collection_hint_expected_num_objs(const coll_t& c, uint32_t pg_num, uint64_t expected_num_objs, const SequencerPosition &spos) { @@ -4962,7 +4962,7 @@ int FileStore::_collection_hint_expected_num_objs(coll_t c, uint32_t pg_num, } int FileStore::_create_collection( - coll_t c, + const coll_t& c, const SequencerPosition &spos) { char fn[PATH_MAX]; @@ -4993,7 +4993,7 @@ int FileStore::_create_collection( return 0; } -int FileStore::_destroy_collection(coll_t c) +int FileStore::_destroy_collection(const coll_t& c) { int r = 0; char fn[PATH_MAX]; @@ -5034,7 +5034,7 @@ int FileStore::_destroy_collection(coll_t c) } -int FileStore::_collection_add(coll_t c, coll_t oldcid, const ghobject_t& o, +int FileStore::_collection_add(const coll_t& c, const coll_t& oldcid, const ghobject_t& o, const SequencerPosition& spos) { dout(15) << "collection_add " << c << "/" << o << " from " << oldcid << "/" << o << dendl; @@ -5082,7 +5082,7 @@ int FileStore::_collection_add(coll_t c, coll_t oldcid, const ghobject_t& o, return r; } -int FileStore::_collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, +int FileStore::_collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid, coll_t c, const ghobject_t& o, const SequencerPosition& spos) { @@ -5185,7 +5185,7 @@ void FileStore::_inject_failure() } } -int FileStore::_omap_clear(coll_t cid, const ghobject_t &hoid, +int FileStore::_omap_clear(const coll_t& cid, const ghobject_t &hoid, const SequencerPosition &spos) { dout(15) << __func__ << " " << cid << "/" << hoid << dendl; Index index; @@ -5205,7 +5205,7 @@ int FileStore::_omap_clear(coll_t cid, const ghobject_t &hoid, return 0; } -int FileStore::_omap_setkeys(coll_t cid, const ghobject_t &hoid, +int FileStore::_omap_setkeys(const coll_t& cid, const ghobject_t &hoid, const map &aset, const SequencerPosition &spos) { dout(15) << __func__ << " " << cid << "/" << hoid << dendl; @@ -5235,7 +5235,7 @@ skip: return r; } -int FileStore::_omap_rmkeys(coll_t cid, const ghobject_t &hoid, +int FileStore::_omap_rmkeys(const coll_t& cid, const ghobject_t &hoid, const set &keys, const SequencerPosition &spos) { dout(15) << __func__ << " " << cid << "/" << hoid << dendl; @@ -5262,7 +5262,7 @@ skip: return 0; } -int FileStore::_omap_rmkeyrange(coll_t cid, const ghobject_t &hoid, +int FileStore::_omap_rmkeyrange(const coll_t& cid, const ghobject_t &hoid, const string& first, const string& last, const SequencerPosition &spos) { dout(15) << __func__ << " " << cid << "/" << hoid << " [" << first << "," << last << "]" << dendl; @@ -5279,7 +5279,7 @@ int FileStore::_omap_rmkeyrange(coll_t cid, const ghobject_t &hoid, return _omap_rmkeys(cid, hoid, keys, spos); } -int FileStore::_omap_setheader(coll_t cid, const ghobject_t &hoid, +int FileStore::_omap_setheader(const coll_t& cid, const ghobject_t &hoid, const bufferlist &bl, const SequencerPosition &spos) { @@ -5298,7 +5298,7 @@ int FileStore::_omap_setheader(coll_t cid, const ghobject_t &hoid, return object_map->set_header(hoid, bl, &spos); } -int FileStore::_split_collection(coll_t cid, +int FileStore::_split_collection(const coll_t& cid, uint32_t bits, uint32_t rem, coll_t dest, @@ -5396,7 +5396,7 @@ int FileStore::_split_collection(coll_t cid, return r; } -int FileStore::_set_alloc_hint(coll_t cid, const ghobject_t& oid, +int FileStore::_set_alloc_hint(const coll_t& cid, const ghobject_t& oid, uint64_t expected_object_size, uint64_t expected_write_size) { diff --git a/src/os/filestore/FileStore.h b/src/os/filestore/FileStore.h index c3d8162236fa0..e84be6a869f82 100644 --- a/src/os/filestore/FileStore.h +++ b/src/os/filestore/FileStore.h @@ -137,9 +137,15 @@ private: // Indexed Collections IndexManager index_manager; - int get_index(coll_t c, Index *index); - int init_index(coll_t c); + int get_index(const coll_t& c, Index *index); + int init_index(const coll_t& c); + bool _need_temp_object_collection(const coll_t& cid, const ghobject_t& oid) { + // - normal temp case: cid is pg, object is temp (pool < -1) + // - hammer temp case: cid is pg (or already temp), object pool is -1 + return (cid.is_pg() && (oid.hobj.pool < -1 || + oid.hobj.pool == -1)); + } void _kludge_temp_object_collection(coll_t& cid, const ghobject_t& oid) { // - normal temp case: cid is pg, object is temp (pool < -1) // - hammer temp case: cid is pg (or already temp), object pool is -1 @@ -153,7 +159,7 @@ private: boost::scoped_ptr object_map; // helper fns - int get_cdir(coll_t cid, char *s, int len); + int get_cdir(const coll_t& cid, char *s, int len); /// read a uuid from fd int read_fsid(int fd, uuid_d *uuid); @@ -394,18 +400,18 @@ private: public: int lfn_find(const ghobject_t& oid, const Index& index, IndexedPath *path = NULL); - int lfn_truncate(coll_t cid, const ghobject_t& oid, off_t length); - int lfn_stat(coll_t cid, const ghobject_t& oid, struct stat *buf); + int lfn_truncate(const coll_t& cid, const ghobject_t& oid, off_t length); + int lfn_stat(const coll_t& cid, const ghobject_t& oid, struct stat *buf); int lfn_open( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, bool create, FDRef *outfd, Index *index = 0); void lfn_close(FDRef fd); - int lfn_link(coll_t c, coll_t newcid, const ghobject_t& o, const ghobject_t& newoid) ; - int lfn_unlink(coll_t cid, const ghobject_t& o, const SequencerPosition &spos, + int lfn_link(const coll_t& c, const coll_t& newcid, const ghobject_t& o, const ghobject_t& newoid) ; + int lfn_unlink(const coll_t& cid, const ghobject_t& o, const SequencerPosition &spos, bool force_clear_omap=false); public: @@ -487,15 +493,15 @@ public: const SequencerPosition& spos, const ghobject_t *oid=0, bool in_progress=false); - void _set_replay_guard(coll_t cid, + void _set_replay_guard(const coll_t& cid, const SequencerPosition& spos, bool in_progress); - void _set_global_replay_guard(coll_t cid, + void _set_global_replay_guard(const coll_t& cid, const SequencerPosition &spos); /// close a replay guard opened with in_progress=true void _close_replay_guard(int fd, const SequencerPosition& spos); - void _close_replay_guard(coll_t cid, const SequencerPosition& spos); + void _close_replay_guard(const coll_t& cid, const SequencerPosition& spos); /** * check replay guard xattr on given file @@ -514,23 +520,23 @@ public: * @return 1 if we can apply (maybe replay) this operation, -1 if spos has already been applied, 0 if it was in progress */ int _check_replay_guard(int fd, const SequencerPosition& spos); - int _check_replay_guard(coll_t cid, const SequencerPosition& spos); - int _check_replay_guard(coll_t cid, ghobject_t oid, const SequencerPosition& pos); - int _check_global_replay_guard(coll_t cid, const SequencerPosition& spos); + int _check_replay_guard(const coll_t& cid, const SequencerPosition& spos); + int _check_replay_guard(const coll_t& cid, ghobject_t oid, const SequencerPosition& pos); + int _check_global_replay_guard(const coll_t& cid, const SequencerPosition& spos); // ------------------ // objects int pick_object_revision_lt(ghobject_t& oid) { return 0; } - bool exists(coll_t cid, const ghobject_t& oid); + bool exists(const coll_t& cid, const ghobject_t& oid); int stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio = false); int read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -541,22 +547,22 @@ public: map *m); int _do_seek_hole_data(int fd, uint64_t offset, size_t len, map *m); - int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); + int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); - int _touch(coll_t cid, const ghobject_t& oid); - int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, + int _touch(const coll_t& cid, const ghobject_t& oid); + int _write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl, uint32_t fadvise_flags = 0); - int _zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len); - int _truncate(coll_t cid, const ghobject_t& oid, uint64_t size); - int _clone(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid, + int _zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len); + int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size); + int _clone(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, const SequencerPosition& spos); - int _clone_range(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid, + int _clone_range(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, uint64_t srcoff, uint64_t len, uint64_t dstoff, const SequencerPosition& spos); int _do_clone_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff); int _do_sparse_copy_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff); int _do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff, bool skip_sloppycrc=false); - int _remove(coll_t cid, const ghobject_t& oid, const SequencerPosition &spos); + int _remove(const coll_t& cid, const ghobject_t& oid, const SequencerPosition &spos); int _fgetattr(int fd, const char *name, bufferptr& bp); int _fgetattrs(int fd, map& aset); @@ -592,54 +598,54 @@ public: int snapshot(const string& name); // attrs - int getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr &bp); - int getattrs(coll_t cid, const ghobject_t& oid, map& aset); + int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr &bp); + int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset); - int _setattrs(coll_t cid, const ghobject_t& oid, map& aset, + int _setattrs(const coll_t& cid, const ghobject_t& oid, map& aset, const SequencerPosition &spos); - int _rmattr(coll_t cid, const ghobject_t& oid, const char *name, + int _rmattr(const coll_t& cid, const ghobject_t& oid, const char *name, const SequencerPosition &spos); - int _rmattrs(coll_t cid, const ghobject_t& oid, + int _rmattrs(const coll_t& cid, const ghobject_t& oid, const SequencerPosition &spos); - int collection_getattr(coll_t c, const char *name, void *value, size_t size); - int collection_getattr(coll_t c, const char *name, bufferlist& bl); - int collection_getattrs(coll_t cid, map &aset); + int collection_getattr(const coll_t& c, const char *name, void *value, size_t size); + int collection_getattr(const coll_t& c, const char *name, bufferlist& bl); + int collection_getattrs(const coll_t& cid, map &aset); - int _collection_setattr(coll_t c, const char *name, const void *value, size_t size); - int _collection_rmattr(coll_t c, const char *name); - int _collection_setattrs(coll_t cid, map &aset); + int _collection_setattr(const coll_t& c, const char *name, const void *value, size_t size); + int _collection_rmattr(const coll_t& c, const char *name); + int _collection_setattrs(const coll_t& cid, map &aset); int _collection_remove_recursive(const coll_t &cid, const SequencerPosition &spos); // collections - int collection_list(coll_t c, ghobject_t start, ghobject_t end, + int collection_list(const coll_t& c, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next); int list_collections(vector& ls); int list_collections(vector& ls, bool include_temp); - int collection_version_current(coll_t c, uint32_t *version); - int collection_stat(coll_t c, struct stat *st); - bool collection_exists(coll_t c); - bool collection_empty(coll_t c); + int collection_version_current(const coll_t& c, uint32_t *version); + int collection_stat(const coll_t& c, struct stat *st); + bool collection_exists(const coll_t& c); + bool collection_empty(const coll_t& c); // omap (see ObjectStore.h for documentation) - int omap_get(coll_t c, const ghobject_t &oid, bufferlist *header, + int omap_get(const coll_t& c, const ghobject_t &oid, bufferlist *header, map *out); int omap_get_header( - coll_t c, + const coll_t& c, const ghobject_t &oid, bufferlist *out, bool allow_eio = false); - int omap_get_keys(coll_t c, const ghobject_t &oid, set *keys); - int omap_get_values(coll_t c, const ghobject_t &oid, const set &keys, + int omap_get_keys(const coll_t& c, const ghobject_t &oid, set *keys); + int omap_get_values(const coll_t& c, const ghobject_t &oid, const set &keys, map *out); - int omap_check_keys(coll_t c, const ghobject_t &oid, const set &keys, + int omap_check_keys(const coll_t& c, const ghobject_t &oid, const set &keys, set *out); - ObjectMap::ObjectMapIterator get_omap_iterator(coll_t c, const ghobject_t &oid); + ObjectMap::ObjectMapIterator get_omap_iterator(const coll_t& c, const ghobject_t &oid); - int _create_collection(coll_t c, const SequencerPosition &spos); - int _destroy_collection(coll_t c); + int _create_collection(const coll_t& c, const SequencerPosition &spos); + int _destroy_collection(const coll_t& c); /** * Give an expected number of objects hint to the collection. * @@ -650,16 +656,16 @@ public: * * @return 0 on success, an error code otherwise */ - int _collection_hint_expected_num_objs(coll_t c, uint32_t pg_num, + int _collection_hint_expected_num_objs(const coll_t& c, uint32_t pg_num, uint64_t expected_num_objs, const SequencerPosition &spos); - int _collection_add(coll_t c, coll_t ocid, const ghobject_t& oid, + int _collection_add(const coll_t& c, const coll_t& ocid, const ghobject_t& oid, const SequencerPosition& spos); - int _collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, + int _collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid, coll_t c, const ghobject_t& o, const SequencerPosition& spos); - int _set_alloc_hint(coll_t cid, const ghobject_t& oid, + int _set_alloc_hint(const coll_t& cid, const ghobject_t& oid, uint64_t expected_object_size, uint64_t expected_write_size); @@ -671,21 +677,21 @@ private: void _inject_failure(); // omap - int _omap_clear(coll_t cid, const ghobject_t &oid, + int _omap_clear(const coll_t& cid, const ghobject_t &oid, const SequencerPosition &spos); - int _omap_setkeys(coll_t cid, const ghobject_t &oid, + int _omap_setkeys(const coll_t& cid, const ghobject_t &oid, const map &aset, const SequencerPosition &spos); - int _omap_rmkeys(coll_t cid, const ghobject_t &oid, const set &keys, + int _omap_rmkeys(const coll_t& cid, const ghobject_t &oid, const set &keys, const SequencerPosition &spos); - int _omap_rmkeyrange(coll_t cid, const ghobject_t &oid, + int _omap_rmkeyrange(const coll_t& cid, const ghobject_t &oid, const string& first, const string& last, const SequencerPosition &spos); - int _omap_setheader(coll_t cid, const ghobject_t &oid, const bufferlist &bl, + int _omap_setheader(const coll_t& cid, const ghobject_t &oid, const bufferlist &bl, const SequencerPosition &spos); - int _split_collection(coll_t cid, uint32_t bits, uint32_t rem, coll_t dest, + int _split_collection(const coll_t& cid, uint32_t bits, uint32_t rem, coll_t dest, const SequencerPosition &spos); - int _split_collection_create(coll_t cid, uint32_t bits, uint32_t rem, + int _split_collection_create(const coll_t& cid, uint32_t bits, uint32_t rem, coll_t dest, const SequencerPosition &spos); diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index dae95de193236..2027249268457 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -1439,7 +1439,7 @@ void KStore::_reap_collections() // --------------- // read operations -bool KStore::exists(coll_t cid, const ghobject_t& oid) +bool KStore::exists(const coll_t& cid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; CollectionRef c = _get_collection(cid); @@ -1453,7 +1453,7 @@ bool KStore::exists(coll_t cid, const ghobject_t& oid) } int KStore::stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio) @@ -1474,7 +1474,7 @@ int KStore::stat( } int KStore::read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t length, @@ -1589,7 +1589,7 @@ int KStore::_do_read( } int KStore::fiemap( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -1627,7 +1627,7 @@ int KStore::fiemap( } int KStore::getattr( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) @@ -1659,7 +1659,7 @@ int KStore::getattr( } int KStore::getattrs( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, map& aset) { @@ -1693,13 +1693,13 @@ int KStore::list_collections(vector& ls) return 0; } -bool KStore::collection_exists(coll_t c) +bool KStore::collection_exists(const coll_t& c) { RWLock::RLocker l(coll_lock); return coll_map.count(c); } -bool KStore::collection_empty(coll_t cid) +bool KStore::collection_empty(const coll_t& cid) { dout(15) << __func__ << " " << cid << dendl; vector ls; @@ -1714,7 +1714,7 @@ bool KStore::collection_empty(coll_t cid) } int KStore::collection_list( - coll_t cid, ghobject_t start, ghobject_t end, + const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *pnext) { @@ -1914,7 +1914,7 @@ bufferlist KStore::OmapIteratorImpl::value() } int KStore::omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -1964,7 +1964,7 @@ int KStore::omap_get( } int KStore::omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio ///< [in] don't assert on eio @@ -1999,7 +1999,7 @@ int KStore::omap_get_header( } int KStore::omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ) @@ -2044,7 +2044,7 @@ int KStore::omap_get_keys( } int KStore::omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -2080,7 +2080,7 @@ int KStore::omap_get_values( } int KStore::omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid @@ -2119,7 +2119,7 @@ int KStore::omap_check_keys( } ObjectMap::ObjectMapIterator KStore::get_omap_iterator( - coll_t cid, ///< [in] collection + const coll_t& cid, ///< [in] collection const ghobject_t &oid ///< [in] object ) { diff --git a/src/os/kstore/KStore.h b/src/os/kstore/KStore.h index b5664ffc3a477..c0d41ff22b49b 100644 --- a/src/os/kstore/KStore.h +++ b/src/os/kstore/KStore.h @@ -402,14 +402,14 @@ public: int statfs(struct statfs *buf); - bool exists(coll_t cid, const ghobject_t& oid); + bool exists(const coll_t& cid, const ghobject_t& oid); int stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio = false); // struct stat? int read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -423,20 +423,20 @@ public: bufferlist& bl, uint32_t op_flags = 0); - int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); - int getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr& value); - int getattrs(coll_t cid, const ghobject_t& oid, map& aset); + int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); + int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value); + int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset); int list_collections(vector& ls); - bool collection_exists(coll_t c); - bool collection_empty(coll_t c); + bool collection_exists(const coll_t& c); + bool collection_empty(const coll_t& c); - int collection_list(coll_t cid, ghobject_t start, ghobject_t end, + int collection_list(const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next); int omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -444,7 +444,7 @@ public: /// Get omap header int omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio = false ///< [in] don't assert on eio @@ -452,14 +452,14 @@ public: /// Get keys defined on oid int omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ); /// Get key values int omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -467,14 +467,14 @@ public: /// Filters keys into out which are defined on oid int omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid ); ObjectMap::ObjectMapIterator get_omap_iterator( - coll_t cid, ///< [in] collection + const coll_t& cid, ///< [in] collection const ghobject_t &oid ///< [in] object ); diff --git a/src/os/memstore/MemStore.cc b/src/os/memstore/MemStore.cc index 506af8ed5daa7..7d42c3f71e422 100644 --- a/src/os/memstore/MemStore.cc +++ b/src/os/memstore/MemStore.cc @@ -240,7 +240,7 @@ objectstore_perf_stat_t MemStore::get_cur_stats() return objectstore_perf_stat_t(); } -MemStore::CollectionRef MemStore::get_collection(coll_t cid) +MemStore::CollectionRef MemStore::get_collection(const coll_t& cid) { RWLock::RLocker l(coll_lock); ceph::unordered_map::iterator cp = coll_map.find(cid); @@ -253,7 +253,7 @@ MemStore::CollectionRef MemStore::get_collection(coll_t cid) // --------------- // read operations -bool MemStore::exists(coll_t cid, const ghobject_t& oid) +bool MemStore::exists(const coll_t& cid, const ghobject_t& oid) { CollectionHandle c = get_collection(cid); if (!c) @@ -274,7 +274,7 @@ bool MemStore::exists(CollectionHandle &c_, const ghobject_t& oid) } int MemStore::stat( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio) @@ -306,7 +306,7 @@ int MemStore::stat( } int MemStore::read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -348,7 +348,7 @@ int MemStore::read( return o->read(offset, l, bl); } -int MemStore::fiemap(coll_t cid, const ghobject_t& oid, +int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) { dout(10) << __func__ << " " << cid << " " << oid << " " << offset << "~" @@ -372,7 +372,7 @@ int MemStore::fiemap(coll_t cid, const ghobject_t& oid, return 0; } -int MemStore::getattr(coll_t cid, const ghobject_t& oid, +int MemStore::getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) { CollectionHandle c = get_collection(cid); @@ -400,7 +400,7 @@ int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid, return 0; } -int MemStore::getattrs(coll_t cid, const ghobject_t& oid, +int MemStore::getattrs(const coll_t& cid, const ghobject_t& oid, map& aset) { CollectionHandle c = get_collection(cid); @@ -437,14 +437,14 @@ int MemStore::list_collections(vector& ls) return 0; } -bool MemStore::collection_exists(coll_t cid) +bool MemStore::collection_exists(const coll_t& cid) { dout(10) << __func__ << " " << cid << dendl; RWLock::RLocker l(coll_lock); return coll_map.count(cid); } -bool MemStore::collection_empty(coll_t cid) +bool MemStore::collection_empty(const coll_t& cid) { dout(10) << __func__ << " " << cid << dendl; CollectionRef c = get_collection(cid); @@ -455,7 +455,7 @@ bool MemStore::collection_empty(coll_t cid) return c->object_map.empty(); } -int MemStore::collection_list(coll_t cid, ghobject_t start, ghobject_t end, +int MemStore::collection_list(const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next) { @@ -483,7 +483,7 @@ int MemStore::collection_list(coll_t cid, ghobject_t start, ghobject_t end, } int MemStore::omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -504,7 +504,7 @@ int MemStore::omap_get( } int MemStore::omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio ///< [in] don't assert on eio @@ -524,7 +524,7 @@ int MemStore::omap_get_header( } int MemStore::omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ) @@ -546,7 +546,7 @@ int MemStore::omap_get_keys( } int MemStore::omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -572,7 +572,7 @@ int MemStore::omap_get_values( } int MemStore::omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid @@ -597,7 +597,7 @@ int MemStore::omap_check_keys( return 0; } -ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(coll_t cid, +ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(const coll_t& cid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; @@ -994,7 +994,7 @@ void MemStore::_do_transaction(Transaction& t) } } -int MemStore::_touch(coll_t cid, const ghobject_t& oid) +int MemStore::_touch(const coll_t& cid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; CollectionRef c = get_collection(cid); @@ -1005,7 +1005,7 @@ int MemStore::_touch(coll_t cid, const ghobject_t& oid) return 0; } -int MemStore::_write(coll_t cid, const ghobject_t& oid, +int MemStore::_write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl, uint32_t fadvise_flags) { @@ -1025,7 +1025,7 @@ int MemStore::_write(coll_t cid, const ghobject_t& oid, return 0; } -int MemStore::_zero(coll_t cid, const ghobject_t& oid, +int MemStore::_zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len) { dout(10) << __func__ << " " << cid << " " << oid << " " << offset << "~" @@ -1037,7 +1037,7 @@ int MemStore::_zero(coll_t cid, const ghobject_t& oid, return _write(cid, oid, offset, len, bl); } -int MemStore::_truncate(coll_t cid, const ghobject_t& oid, uint64_t size) +int MemStore::_truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size) { dout(10) << __func__ << " " << cid << " " << oid << " " << size << dendl; CollectionRef c = get_collection(cid); @@ -1053,7 +1053,7 @@ int MemStore::_truncate(coll_t cid, const ghobject_t& oid, uint64_t size) return r; } -int MemStore::_remove(coll_t cid, const ghobject_t& oid) +int MemStore::_remove(const coll_t& cid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; CollectionRef c = get_collection(cid); @@ -1071,7 +1071,7 @@ int MemStore::_remove(coll_t cid, const ghobject_t& oid) return 0; } -int MemStore::_setattrs(coll_t cid, const ghobject_t& oid, +int MemStore::_setattrs(const coll_t& cid, const ghobject_t& oid, map& aset) { dout(10) << __func__ << " " << cid << " " << oid << dendl; @@ -1088,7 +1088,7 @@ int MemStore::_setattrs(coll_t cid, const ghobject_t& oid, return 0; } -int MemStore::_rmattr(coll_t cid, const ghobject_t& oid, const char *name) +int MemStore::_rmattr(const coll_t& cid, const ghobject_t& oid, const char *name) { dout(10) << __func__ << " " << cid << " " << oid << " " << name << dendl; CollectionRef c = get_collection(cid); @@ -1106,7 +1106,7 @@ int MemStore::_rmattr(coll_t cid, const ghobject_t& oid, const char *name) return 0; } -int MemStore::_rmattrs(coll_t cid, const ghobject_t& oid) +int MemStore::_rmattrs(const coll_t& cid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; CollectionRef c = get_collection(cid); @@ -1121,7 +1121,7 @@ int MemStore::_rmattrs(coll_t cid, const ghobject_t& oid) return 0; } -int MemStore::_clone(coll_t cid, const ghobject_t& oldoid, +int MemStore::_clone(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid) { dout(10) << __func__ << " " << cid << " " << oldoid @@ -1151,7 +1151,7 @@ int MemStore::_clone(coll_t cid, const ghobject_t& oldoid, return 0; } -int MemStore::_clone_range(coll_t cid, const ghobject_t& oldoid, +int MemStore::_clone_range(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, uint64_t srcoff, uint64_t len, uint64_t dstoff) { @@ -1179,7 +1179,7 @@ int MemStore::_clone_range(coll_t cid, const ghobject_t& oldoid, return len; } -int MemStore::_omap_clear(coll_t cid, const ghobject_t &oid) +int MemStore::_omap_clear(const coll_t& cid, const ghobject_t &oid) { dout(10) << __func__ << " " << cid << " " << oid << dendl; CollectionRef c = get_collection(cid); @@ -1195,7 +1195,7 @@ int MemStore::_omap_clear(coll_t cid, const ghobject_t &oid) return 0; } -int MemStore::_omap_setkeys(coll_t cid, const ghobject_t &oid, +int MemStore::_omap_setkeys(const coll_t& cid, const ghobject_t &oid, bufferlist& aset_bl) { dout(10) << __func__ << " " << cid << " " << oid << dendl; @@ -1218,7 +1218,7 @@ int MemStore::_omap_setkeys(coll_t cid, const ghobject_t &oid, return 0; } -int MemStore::_omap_rmkeys(coll_t cid, const ghobject_t &oid, +int MemStore::_omap_rmkeys(const coll_t& cid, const ghobject_t &oid, bufferlist& keys_bl) { dout(10) << __func__ << " " << cid << " " << oid << dendl; @@ -1241,7 +1241,7 @@ int MemStore::_omap_rmkeys(coll_t cid, const ghobject_t &oid, return 0; } -int MemStore::_omap_rmkeyrange(coll_t cid, const ghobject_t &oid, +int MemStore::_omap_rmkeyrange(const coll_t& cid, const ghobject_t &oid, const string& first, const string& last) { dout(10) << __func__ << " " << cid << " " << oid << " " << first @@ -1260,7 +1260,7 @@ int MemStore::_omap_rmkeyrange(coll_t cid, const ghobject_t &oid, return 0; } -int MemStore::_omap_setheader(coll_t cid, const ghobject_t &oid, +int MemStore::_omap_setheader(const coll_t& cid, const ghobject_t &oid, const bufferlist &bl) { dout(10) << __func__ << " " << cid << " " << oid << dendl; @@ -1276,7 +1276,7 @@ int MemStore::_omap_setheader(coll_t cid, const ghobject_t &oid, return 0; } -int MemStore::_create_collection(coll_t cid) +int MemStore::_create_collection(const coll_t& cid) { dout(10) << __func__ << " " << cid << dendl; RWLock::WLocker l(coll_lock); @@ -1287,7 +1287,7 @@ int MemStore::_create_collection(coll_t cid) return 0; } -int MemStore::_destroy_collection(coll_t cid) +int MemStore::_destroy_collection(const coll_t& cid) { dout(10) << __func__ << " " << cid << dendl; RWLock::WLocker l(coll_lock); @@ -1305,7 +1305,7 @@ int MemStore::_destroy_collection(coll_t cid) return 0; } -int MemStore::_collection_add(coll_t cid, coll_t ocid, const ghobject_t& oid) +int MemStore::_collection_add(const coll_t& cid, const coll_t& ocid, const ghobject_t& oid) { dout(10) << __func__ << " " << cid << " " << ocid << " " << oid << dendl; CollectionRef c = get_collection(cid); @@ -1327,7 +1327,7 @@ int MemStore::_collection_add(coll_t cid, coll_t ocid, const ghobject_t& oid) return 0; } -int MemStore::_collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, +int MemStore::_collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid, coll_t cid, const ghobject_t& oid) { dout(10) << __func__ << " " << oldcid << " " << oldoid << " -> " @@ -1371,7 +1371,7 @@ int MemStore::_collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, return r; } -int MemStore::_split_collection(coll_t cid, uint32_t bits, uint32_t match, +int MemStore::_split_collection(const coll_t& cid, uint32_t bits, uint32_t match, coll_t dest) { dout(10) << __func__ << " " << cid << " " << bits << " " << match << " " diff --git a/src/os/memstore/MemStore.h b/src/os/memstore/MemStore.h index 499b72dcd78dc..e1a4e56d65156 100644 --- a/src/os/memstore/MemStore.h +++ b/src/os/memstore/MemStore.h @@ -299,7 +299,7 @@ private: ceph::unordered_map coll_map; RWLock coll_lock; ///< rwlock to protect coll_map - CollectionRef get_collection(coll_t cid); + CollectionRef get_collection(const coll_t& cid); Finisher finisher; @@ -307,34 +307,34 @@ private: void _do_transaction(Transaction& t); - int _touch(coll_t cid, const ghobject_t& oid); - int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, + int _touch(const coll_t& cid, const ghobject_t& oid); + int _write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl, uint32_t fadvsie_flags = 0); - int _zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len); - int _truncate(coll_t cid, const ghobject_t& oid, uint64_t size); - int _remove(coll_t cid, const ghobject_t& oid); - int _setattrs(coll_t cid, const ghobject_t& oid, map& aset); - int _rmattr(coll_t cid, const ghobject_t& oid, const char *name); - int _rmattrs(coll_t cid, const ghobject_t& oid); - int _clone(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid); - int _clone_range(coll_t cid, const ghobject_t& oldoid, + int _zero(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len); + int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size); + int _remove(const coll_t& cid, const ghobject_t& oid); + int _setattrs(const coll_t& cid, const ghobject_t& oid, map& aset); + int _rmattr(const coll_t& cid, const ghobject_t& oid, const char *name); + int _rmattrs(const coll_t& cid, const ghobject_t& oid); + int _clone(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid); + int _clone_range(const coll_t& cid, const ghobject_t& oldoid, const ghobject_t& newoid, uint64_t srcoff, uint64_t len, uint64_t dstoff); - int _omap_clear(coll_t cid, const ghobject_t &oid); - int _omap_setkeys(coll_t cid, const ghobject_t &oid, bufferlist& aset_bl); - int _omap_rmkeys(coll_t cid, const ghobject_t &oid, bufferlist& keys_bl); - int _omap_rmkeyrange(coll_t cid, const ghobject_t &oid, + int _omap_clear(const coll_t& cid, const ghobject_t &oid); + int _omap_setkeys(const coll_t& cid, const ghobject_t &oid, bufferlist& aset_bl); + int _omap_rmkeys(const coll_t& cid, const ghobject_t &oid, bufferlist& keys_bl); + int _omap_rmkeyrange(const coll_t& cid, const ghobject_t &oid, const string& first, const string& last); - int _omap_setheader(coll_t cid, const ghobject_t &oid, const bufferlist &bl); + int _omap_setheader(const coll_t& cid, const ghobject_t &oid, const bufferlist &bl); - int _collection_hint_expected_num_objs(coll_t cid, uint32_t pg_num, + int _collection_hint_expected_num_objs(const coll_t& cid, uint32_t pg_num, uint64_t num_objs) const { return 0; } - int _create_collection(coll_t c); - int _destroy_collection(coll_t c); - int _collection_add(coll_t cid, coll_t ocid, const ghobject_t& oid); - int _collection_move_rename(coll_t oldcid, const ghobject_t& oldoid, + int _create_collection(const coll_t& c); + int _destroy_collection(const coll_t& c); + int _collection_add(const coll_t& cid, const coll_t& ocid, const ghobject_t& oid); + int _collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid, coll_t cid, const ghobject_t& o); - int _split_collection(coll_t cid, uint32_t bits, uint32_t rem, coll_t dest); + int _split_collection(const coll_t& cid, uint32_t bits, uint32_t rem, coll_t dest); int _save(); int _load(); @@ -385,14 +385,14 @@ public: int statfs(struct statfs *buf); - bool exists(coll_t cid, const ghobject_t& oid) override; + bool exists(const coll_t& cid, const ghobject_t& oid) override; bool exists(CollectionHandle &c, const ghobject_t& oid) override; - int stat(coll_t cid, const ghobject_t& oid, + int stat(const coll_t& cid, const ghobject_t& oid, struct stat *st, bool allow_eio = false) override; int stat(CollectionHandle &c, const ghobject_t& oid, struct stat *st, bool allow_eio = false) override; int read( - coll_t cid, + const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, @@ -407,12 +407,12 @@ public: bufferlist& bl, uint32_t op_flags = 0, bool allow_eio = false) override; - int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); - int getattr(coll_t cid, const ghobject_t& oid, const char *name, + int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl); + int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) override; int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name, bufferptr& value) override; - int getattrs(coll_t cid, const ghobject_t& oid, + int getattrs(const coll_t& cid, const ghobject_t& oid, map& aset) override; int getattrs(CollectionHandle &c, const ghobject_t& oid, map& aset) override; @@ -422,14 +422,14 @@ public: CollectionHandle open_collection(const coll_t& c) { return get_collection(c); } - bool collection_exists(coll_t c); - bool collection_empty(coll_t c); - int collection_list(coll_t cid, ghobject_t start, ghobject_t end, + bool collection_exists(const coll_t& c); + bool collection_empty(const coll_t& c); + int collection_list(const coll_t& cid, ghobject_t start, ghobject_t end, bool sort_bitwise, int max, vector *ls, ghobject_t *next); int omap_get( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header map *out /// < [out] Key to value map @@ -437,7 +437,7 @@ public: /// Get omap header int omap_get_header( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap bufferlist *header, ///< [out] omap header bool allow_eio = false ///< [in] don't assert on eio @@ -445,14 +445,14 @@ public: /// Get keys defined on oid int omap_get_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap set *keys ///< [out] Keys defined on oid ); /// Get key values int omap_get_values( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to get map *out ///< [out] Returned keys and values @@ -460,14 +460,14 @@ public: /// Filters keys into out which are defined on oid int omap_check_keys( - coll_t cid, ///< [in] Collection containing oid + const coll_t& cid, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap const set &keys, ///< [in] Keys to check set *out ///< [out] Subset of keys defined on oid ); ObjectMap::ObjectMapIterator get_omap_iterator( - coll_t cid, ///< [in] collection + const coll_t& cid, ///< [in] collection const ghobject_t &oid ///< [in] object ); -- 2.39.5