diff options
author | Sage Weil <sage@newdream.net> | 2008-10-09 07:05:35 +0200 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2008-10-09 19:14:04 +0200 |
commit | 903959ebea1998ac966d2513a6159176cc2e5679 (patch) | |
tree | b30b6dc8ca9c45a43df108ac71fbbfeba7608dcc | |
parent | todos (diff) | |
download | ceph-903959ebea1998ac966d2513a6159176cc2e5679.tar.xz ceph-903959ebea1998ac966d2513a6159176cc2e5679.zip |
filestore: fix collection attrs
Need to prepend user.ceph. to attr names...
-rw-r--r-- | src/os/FileStore.cc | 54 | ||||
-rw-r--r-- | src/os/FileStore.h | 1 |
2 files changed, 33 insertions, 22 deletions
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index dfb8ee5c263..c639186dead 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1554,7 +1554,9 @@ int FileStore::collection_getattr(coll_t c, const char *name, else { char fn[200]; get_cdir(c, fn); - r = do_getxattr(fn, name, value, size); + char n[200]; + get_attrname(name, n); + r = do_getxattr(fn, n, value, size); } return r < 0 ? -errno:r; } @@ -1565,13 +1567,24 @@ int FileStore::collection_getattr(coll_t c, const char *name, bufferlist& bl) if (fake_attrs) r = attrs.collection_getattr(c, name, bl); else { - char fn[200]; - get_cdir(c, fn); - r = do_getxattr(fn, name, NULL, 0); - if (r > 0) { - bl.push_back(buffer::create(r)); - r = do_getxattr(fn, name, bl.c_str(), r); - } + buffer::ptr bp; + r = collection_getattr(c, name, bp); + bl.push_back(bp); + } + return r; +} + +int FileStore::collection_getattr(coll_t c, const char *name, buffer::ptr& bp) +{ + int r; + char fn[200]; + get_cdir(c, fn); + char n[200]; + get_attrname(name, n); + r = do_getxattr(fn, n, NULL, 0); + if (r > 0) { + bp = buffer::create(r); + r = do_getxattr(fn, n, bp.c_str(), r); } return r < 0 ? -errno:r; } @@ -1585,19 +1598,14 @@ int FileStore::collection_getattrs(coll_t cid, map<string,bufferptr>& aset) char fn[100]; get_cdir(cid, fn); - char val[1000]; char names[1000]; int num = do_listxattr(fn, names, 1000); char *name = names; for (int i=0; i<num; i++) { dout(0) << "getattrs " << cid << " getting " << (i+1) << "/" << num << " '" << names << "'" << dendl; - int l = do_getxattr(fn, name, val, 1000); - dout(0) << "getattrs " << cid << " getting " << (i+1) << "/" << num << " '" << names << "' = " << l << " bytes" << dendl; - if (parse_attrname(&name)) { - aset[name] = buffer::create(l); - memcpy(aset[name].c_str(), val, l); - } + if (parse_attrname(&name)) + collection_getattr(cid, name, aset[name]); name += strlen(name) + 1; } r = 0; @@ -1615,7 +1623,9 @@ int FileStore::_collection_setattr(coll_t c, const char *name, else { char fn[200]; get_cdir(c, fn); - r = do_setxattr(fn, name, value, size); + char n[200]; + get_attrname(name, n); + r = do_setxattr(fn, n, value, size); } return r < 0 ? -errno:r; } @@ -1628,7 +1638,9 @@ int FileStore::_collection_rmattr(coll_t c, const char *name) else { char fn[200]; get_cdir(c, fn); - r = do_removexattr(fn, name); + char n[200]; + get_attrname(name, n); + r = do_removexattr(fn, n); } return r < 0 ? -errno:r; } @@ -1646,7 +1658,9 @@ int FileStore::_collection_setattrs(coll_t cid, map<string,bufferptr>& aset) for (map<string,bufferptr>::iterator p = aset.begin(); p != aset.end(); ++p) { - r = do_setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length()); + char n[200]; + get_attrname(p->first.c_str(), n); + r = do_setxattr(fn, n, p->second.c_str(), p->second.length()); if (r < 0) break; } } @@ -1670,10 +1684,6 @@ int FileStore::list_collections(vector<coll_t>& ls) struct dirent *de; while ((de = ::readdir(dir)) != 0) { - // parse - if (strlen(de->d_name) != 16) - continue; - errno = 0; coll_t c; if (parse_coll(de->d_name, c)) ls.push_back(c); diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 07da843e35a..5295a2e9fd8 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -123,6 +123,7 @@ class FileStore : public JournalingObjectStore { int _rmattr(coll_t cid, pobject_t oid, const char *name); int collection_getattr(coll_t c, const char *name, void *value, size_t size); + int collection_getattr(coll_t c, const char *name, buffer::ptr& bp); int collection_getattr(coll_t c, const char *name, bufferlist& bl); int collection_getattrs(coll_t cid, map<string,bufferptr> &aset); |