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:
- assert(0 == "coll attributes no longer supported");
+ {
+ 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);
+ }
break;
case Transaction::OP_STARTSYNC:
return r;
}
+
+
+// collections
+
+int FileStore::collection_getattr(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(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(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(coll_t cid, map<string,bufferptr>& 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(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(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(coll_t cid, map<string,bufferptr>& 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<string,bufferptr>::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)
{
int _rmattrs(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<string,bufferptr> &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<string,bufferptr> &aset);
int _collection_remove_recursive(const coll_t &cid,
const SequencerPosition &spos);
OP_RMCOLL = 21, // cid
OP_COLL_ADD = 22, // cid, oldcid, oid
OP_COLL_REMOVE = 23, // cid, oid
- OP_COLL_SETATTR = 24, // cid, attrname, bl **DEPRECATED**
- OP_COLL_RMATTR = 25, // cid, attrname **DEPRECATED**
- OP_COLL_SETATTRS = 26, // cid, attrset **DEPRECATED**
+ OP_COLL_SETATTR = 24, // cid, attrname, bl
+ OP_COLL_RMATTR = 25, // cid, attrname
+ OP_COLL_SETATTRS = 26, // cid, attrset
OP_COLL_MOVE = 8, // newcid, oldcid, oid
OP_STARTSYNC = 27, // start a sync
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(coll_t cid, const string& name, bufferlist& val)
+ __attribute__ ((deprecated)) {
+ 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(coll_t cid, const string& name)
+ __attribute__ ((deprecated)) {
+ 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(coll_t cid, map<string,bufferptr>& aset)
+ __attribute__ ((deprecated)) {
+ 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(coll_t cid, map<string,bufferlist>& aset)
+ __attribute__ ((deprecated)) {
+ 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
* @returns true if it exists, false otherwise
*/
virtual bool collection_exists(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(coll_t cid, const char *name,
+ void *value, size_t size)
+ __attribute__ ((deprecated)) {
+ 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(coll_t cid, const char *name, bufferlist& bl)
+ __attribute__ ((deprecated)) {
+ 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(coll_t cid, map<string,bufferptr> &aset)
+ __attribute__ ((deprecated)) {
+ return -EOPNOTSUPP;
+ }
/**
* is a collection empty?
#include "ObjectStore.h"
#include "common/Formatter.h"
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
void ObjectStore::Transaction::_build_actions_from_tbl()
{
//used only for tbl encode
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<string,bufferptr> aset;
+
+ ::decode(cid, p);
+ ::decode(aset, p);
+
+ collection_setattrs(cid, aset);
+ }
+ break;
+
case Transaction::OP_COLL_RMATTR:
- assert(0 == "collection attrs no longer supported");
+ {
+ coll_t cid;
+ string name;
+
+ ::decode(cid, p);
+ ::decode(name, p);
+
+ collection_rmattr(cid, name);
+ }
break;
case Transaction::OP_STARTSYNC:
assert(ops == data.ops);
}
+#pragma GCC diagnostic pop
+#pragma GCC diagnostic warning "-Wpragmas"
+
void ObjectStore::Transaction::dump(ceph::Formatter *f)
{
f->open_array_section("ops");
f->close_section();
}
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
void ObjectStore::Transaction::generate_test_instances(list<ObjectStore::Transaction*>& o)
{
o.push_back(new Transaction);
t->create_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);
}
+#pragma GCC diagnostic pop
+#pragma GCC diagnostic warning "-Wpragmas"