From 57e0de067a083ff0120c33c8f74847a905592220 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 27 Feb 2008 14:57:36 -0800 Subject: [PATCH] fakestore: fix collection_setattrs --- src/osd/FakeStore.cc | 25 ++++++++++++------------- src/osd/JournalingObjectStore.h | 11 +++++++++++ src/osd/ObjectStore.h | 7 +++++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/osd/FakeStore.cc b/src/osd/FakeStore.cc index 730be33ba8fbc..b91a415fc74b8 100644 --- a/src/osd/FakeStore.cc +++ b/src/osd/FakeStore.cc @@ -601,27 +601,26 @@ int FakeStore::collection_getattr(coll_t c, const char *name, return r; } -/* int FakeStore::collection_setattrs(coll_t cid, map& aset) { - if (fake_attrs) return attrs.collection_setattrs(cid, aset); - - char fn[100]; - get_cdir(cid, fn); - int r = 0; -#ifndef __CYGWIN__ - for (map::iterator p = aset.begin(); - p != aset.end(); + int r; + if (fake_attrs) + r = attrs.collection_setattrs(cid, aset); + else { + char fn[100]; + get_cdir(cid, fn); + int r = 0; + for (map::iterator p = aset.begin(); + p != aset.end(); ++p) { - r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0); - if (r < 0) break; + r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0); + if (r < 0) break; + } } -#endif if (r >= 0) journal_collection_setattrs(cid, aset, 0); return r; } -*/ int FakeStore::collection_getattrs(coll_t cid, map& aset) { diff --git a/src/osd/JournalingObjectStore.h b/src/osd/JournalingObjectStore.h index 03b3f458e8f73..f625d95f0b72c 100644 --- a/src/osd/JournalingObjectStore.h +++ b/src/osd/JournalingObjectStore.h @@ -192,6 +192,17 @@ protected: queue_commit_waiter(onsafe); } + void journal_collection_setattrs(coll_t cid, map& aset, Context *onsafe) { + if (journal) { + Transaction t; + t.collection_setattrs(cid, aset); + bufferlist bl; + t._encode(bl); + journal->submit_entry(super_epoch, bl, onsafe); + } else + queue_commit_waiter(onsafe); + } + void journal_sync(Context *onsafe) { if (journal) { // journal empty transaction diff --git a/src/osd/ObjectStore.h b/src/osd/ObjectStore.h index 4902d94925c69..94a9b87cf7481 100644 --- a/src/osd/ObjectStore.h +++ b/src/osd/ObjectStore.h @@ -96,6 +96,7 @@ public: static const int OP_COLL_REMOVE = 23; // cid, oid static const int OP_COLL_SETATTR = 24; // cid, attrname, attrval static const int OP_COLL_RMATTR = 25; // cid, attrname + static const int OP_COLL_SETATTRS = 26; // cid, attrset private: list ops; @@ -286,6 +287,12 @@ public: cids.push_back(cid); attrnames.push_back(name); } + void collection_setattrs(coll_t cid, map& aset) { + int op = OP_COLL_SETATTRS; + ops.push_back(op); + cids.push_back(cid); + pattrsets.push_back(&aset); + } // etc. -- 2.39.5