From 39402c0801f48b61d950339e15ca32df95228d93 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 22 Apr 2016 09:45:56 -0400 Subject: [PATCH] os: remove collection attr methods These have been deprecated since hammer, and were only kept so that you could do an offline upgrade from firefly. Bye bye! Signed-off-by: Sage Weil --- src/os/ObjectStore.h | 105 ------------------- src/os/Transaction.cc | 37 +------ src/os/filestore/FileStore.cc | 155 +---------------------------- src/os/filestore/FileStore.h | 7 -- src/osd/PG.cc | 1 - src/tools/ceph_objectstore_tool.cc | 23 ++--- 6 files changed, 8 insertions(+), 320 deletions(-) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index aacf642d546..789dfe5bb8d 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1473,73 +1473,6 @@ public: data.ops++; } - // NOTE: Collection attr operations are all DEPRECATED. new - // backends need not implement these at all. - - /// Set an xattr on a collection - void collection_setattr(const coll_t& cid, const string& name, - bufferlist& val) { - if (use_tbl) { - __u32 op = OP_COLL_SETATTR; - ::encode(op, tbl); - ::encode(cid, tbl); - ::encode(name, tbl); - ::encode(val, tbl); - } else { - Op* _op = _get_next_op(); - _op->op = OP_COLL_SETATTR; - _op->cid = _get_coll_id(cid); - ::encode(name, data_bl); - ::encode(val, data_bl); - } - data.ops++; - } - - /// Remove an xattr from a collection - void collection_rmattr(const coll_t& cid, const string& name) { - if (use_tbl) { - __u32 op = OP_COLL_RMATTR; - ::encode(op, tbl); - ::encode(cid, tbl); - ::encode(name, tbl); - } else { - Op* _op = _get_next_op(); - _op->op = OP_COLL_RMATTR; - _op->cid = _get_coll_id(cid); - ::encode(name, data_bl); - } - data.ops++; - } - /// Set multiple xattrs on a collection - void collection_setattrs(const coll_t& cid, map& aset) { - if (use_tbl) { - __u32 op = OP_COLL_SETATTRS; - ::encode(op, tbl); - ::encode(cid, tbl); - ::encode(aset, tbl); - } else { - Op* _op = _get_next_op(); - _op->op = OP_COLL_SETATTRS; - _op->cid = _get_coll_id(cid); - ::encode(aset, data_bl); - } - data.ops++; - } - /// Set multiple xattrs on a collection - void collection_setattrs(const coll_t& cid, map& aset) { - if (use_tbl) { - __u32 op = OP_COLL_SETATTRS; - ::encode(op, tbl); - ::encode(cid, tbl); - ::encode(aset, tbl); - } else { - Op* _op = _get_next_op(); - _op->op = OP_COLL_SETATTRS; - _op->cid = _get_coll_id(cid); - ::encode(aset, data_bl); - } - data.ops++; - } /// Remove omap from oid void omap_clear( coll_t cid, ///< [in] Collection containing oid @@ -2213,44 +2146,6 @@ public: * @returns true if it exists, false otherwise */ virtual bool collection_exists(const coll_t& c) = 0; - /** - * collection_getattr - get an xattr of a collection - * - * @param cid collection name - * @param name xattr name - * @param value pointer of buffer to receive value - * @param size size of buffer to receive value - * @returns 0 on success, negative error code on failure - */ - virtual int collection_getattr(const coll_t& cid, const char *name, - void *value, size_t size) { - return -EOPNOTSUPP; - } - - /** - * collection_getattr - get an xattr of a collection - * - * @param cid collection name - * @param name xattr name - * @param bl buffer to receive value - * @returns 0 on success, negative error code on failure - */ - virtual int collection_getattr(const coll_t& cid, const char *name, - bufferlist& bl) { - return -EOPNOTSUPP; - } - - /** - * collection_getattrs - get all xattrs of a collection - * - * @param cid collection name - * @param aset map of keys and buffers that contain the values - * @returns 0 on success, negative error code on failure - */ - virtual int collection_getattrs(const coll_t& cid, - map &aset) { - return -EOPNOTSUPP; - } /** * is a collection empty? diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index 60281049634..ed4aa13b165 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -338,41 +338,9 @@ void ObjectStore::Transaction::_build_actions_from_tbl() break; case Transaction::OP_COLL_SETATTR: - { - coll_t cid; - string name; - bufferlist bl; - - ::decode(cid, p); - ::decode(name, p); - ::decode(bl, p); - - collection_setattr(cid, name, bl); - } - break; - case Transaction::OP_COLL_SETATTRS: - { - coll_t cid; - map aset; - - ::decode(cid, p); - ::decode(aset, p); - - collection_setattrs(cid, aset); - } - break; - case Transaction::OP_COLL_RMATTR: - { - coll_t cid; - string name; - - ::decode(cid, p); - ::decode(name, p); - - collection_rmattr(cid, name); - } + assert(0 == "collection attr methods have been removed"); break; case Transaction::OP_STARTSYNC: @@ -1002,9 +970,6 @@ void ObjectStore::Transaction::generate_test_instances(listcreate_collection(c, 12); t->collection_move_rename(c, o2, c2, o3); t->remove_collection(c); - t->collection_setattr(c, string("this"), bl); - t->collection_rmattr(c, string("foo")); - t->collection_setattrs(c, m); o.push_back(t); } diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index c759f105c29..7939dfc195f 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -2785,27 +2785,8 @@ void FileStore::_do_transaction( break; case Transaction::OP_COLL_SETATTR: - { - coll_t cid = i.get_cid(op->cid); - string name = i.decode_string(); - bufferlist bl; - i.decode_bl(bl); - tracepoint(objectstore, coll_setattr_enter, osr_name); - if (_check_replay_guard(cid, spos) > 0) - r = _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length()); - tracepoint(objectstore, coll_setattr_exit, r); - } - break; - case Transaction::OP_COLL_RMATTR: - { - coll_t cid = i.get_cid(op->cid); - string name = i.decode_string(); - tracepoint(objectstore, coll_rmattr_enter, osr_name); - if (_check_replay_guard(cid, spos) > 0) - r = _collection_rmattr(cid, name.c_str()); - tracepoint(objectstore, coll_rmattr_exit, r); - } + assert(0 == "collection attr methods no longer implmented"); break; case Transaction::OP_STARTSYNC: @@ -4540,140 +4521,6 @@ int FileStore::_rmattrs(const coll_t& cid, const ghobject_t& oid, -// collections - -int FileStore::collection_getattr(const coll_t& c, const char *name, - void *value, size_t size) -{ - char fn[PATH_MAX]; - get_cdir(c, fn, sizeof(fn)); - dout(15) << "collection_getattr " << fn << " '" << name << "' len " << size << dendl; - int r; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - char n[PATH_MAX]; - get_attrname(name, n, PATH_MAX); - r = chain_fgetxattr(fd, n, value, size); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_getattr " << fn << " '" << name << "' len " << size << " = " << r << dendl; - assert(!m_filestore_fail_eio || r != -EIO); - return r; -} - -int FileStore::collection_getattr(const coll_t& c, const char *name, bufferlist& bl) -{ - char fn[PATH_MAX]; - get_cdir(c, fn, sizeof(fn)); - dout(15) << "collection_getattr " << fn << " '" << name << "'" << dendl; - char n[PATH_MAX]; - get_attrname(name, n, PATH_MAX); - buffer::ptr bp; - int r; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - r = _fgetattr(fd, n, bp); - bl.push_back(std::move(bp)); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_getattr " << fn << " '" << name << "' = " << r << dendl; - assert(!m_filestore_fail_eio || r != -EIO); - return r; -} - -int FileStore::collection_getattrs(const coll_t& cid, map& aset) -{ - char fn[PATH_MAX]; - get_cdir(cid, fn, sizeof(fn)); - dout(10) << "collection_getattrs " << fn << dendl; - int r = 0; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - r = _fgetattrs(fd, aset); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_getattrs " << fn << " = " << r << dendl; - assert(!m_filestore_fail_eio || r != -EIO); - return r; -} - - -int FileStore::_collection_setattr(const coll_t& c, const char *name, - const void *value, size_t size) -{ - char fn[PATH_MAX]; - get_cdir(c, fn, sizeof(fn)); - dout(10) << "collection_setattr " << fn << " '" << name << "' len " << size << dendl; - char n[PATH_MAX]; - int r; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - get_attrname(name, n, PATH_MAX); - r = chain_fsetxattr(fd, n, value, size); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_setattr " << fn << " '" << name << "' len " << size << " = " << r << dendl; - return r; -} - -int FileStore::_collection_rmattr(const coll_t& c, const char *name) -{ - char fn[PATH_MAX]; - get_cdir(c, fn, sizeof(fn)); - dout(15) << "collection_rmattr " << fn << dendl; - char n[PATH_MAX]; - get_attrname(name, n, PATH_MAX); - int r; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - r = chain_fremovexattr(fd, n); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_rmattr " << fn << " = " << r << dendl; - return r; -} - - -int FileStore::_collection_setattrs(const coll_t& cid, map& aset) -{ - char fn[PATH_MAX]; - get_cdir(cid, fn, sizeof(fn)); - dout(15) << "collection_setattrs " << fn << dendl; - int r = 0; - int fd = ::open(fn, O_RDONLY); - if (fd < 0) { - r = -errno; - goto out; - } - for (map::iterator p = aset.begin(); - p != aset.end(); - ++p) { - char n[PATH_MAX]; - get_attrname(p->first.c_str(), n, PATH_MAX); - r = chain_fsetxattr(fd, n, p->second.c_str(), p->second.length()); - if (r < 0) - break; - } - VOID_TEMP_FAILURE_RETRY(::close(fd)); - out: - dout(10) << "collection_setattrs " << fn << " = " << r << dendl; - return r; -} int FileStore::_collection_remove_recursive(const coll_t &cid, const SequencerPosition &spos) diff --git a/src/os/filestore/FileStore.h b/src/os/filestore/FileStore.h index b81dd0db548..af638d8cbd4 100644 --- a/src/os/filestore/FileStore.h +++ b/src/os/filestore/FileStore.h @@ -615,13 +615,6 @@ public: int _rmattrs(const coll_t& cid, const ghobject_t& oid, const SequencerPosition &spos); - 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(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); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 01975b14226..94b415b6281 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2756,7 +2756,6 @@ void PG::upgrade(ObjectStore *store) ghobject_t biginfo_oid(OSD::make_pg_biginfo_oid(pg_id)); t.remove(coll_t::meta(), log_oid); t.remove(coll_t::meta(), biginfo_oid); - t.collection_rmattr(coll, "info"); t.touch(coll, pgmeta_oid); map v; diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 74348bcf43b..128bea14d24 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -442,23 +442,12 @@ int mark_pg_for_removal(ObjectStore *fs, spg_t pgid, ObjectStore::Transaction *t cerr << __func__ << " error on read_info " << cpp_strerror(r) << std::endl; return r; } - if (struct_v < 8) { - // old xattr - cout << "setting legacy 'remove' xattr flag" << std::endl; - bufferlist one; - one.append('1'); - t->collection_setattr(coll, "remove", one); - cout << "remove " << coll_t::meta() << " " << log_oid << std::endl; - t->remove(coll_t::meta(), log_oid); - cout << "remove " << coll_t::meta() << " " << biginfo_oid << std::endl; - t->remove(coll_t::meta(), biginfo_oid); - } else { - // new omap key - cout << "setting '_remove' omap key" << std::endl; - map values; - ::encode((char)1, values["_remove"]); - t->omap_setkeys(coll, pgmeta_oid, values); - } + assert(struct_v >= 8); + // new omap key + cout << "setting '_remove' omap key" << std::endl; + map values; + ::encode((char)1, values["_remove"]); + t->omap_setkeys(coll, pgmeta_oid, values); return 0; } -- 2.47.3