]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectMap: add interface for storing xattrs
authorSamuel Just <samuel.just@dreamhost.com>
Mon, 12 Mar 2012 23:52:58 +0000 (16:52 -0700)
committerSamuel Just <samuel.just@dreamhost.com>
Fri, 16 Mar 2012 18:29:00 +0000 (11:29 -0700)
Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/os/DBObjectMap.cc
src/os/DBObjectMap.h
src/os/FileStore.cc
src/os/ObjectMap.h
src/test/ObjectMap/test_object_map.cc

index 407de9877523600c094d1fd96cefadef1df85a8b..1f6d1e837c856f1a26b850a5409d17a1a1bc9788 100644 (file)
@@ -718,10 +718,10 @@ int DBObjectMap::check_keys(const hobject_t &hoid,
   return scan(header, keys, out, 0);
 }
 
-int DBObjectMap::clone_keys(const hobject_t &hoid,
-                           CollectionIndex::IndexedPath path,
-                           const hobject_t &target,
-                           CollectionIndex::IndexedPath target_path)
+int DBObjectMap::clone(const hobject_t &hoid,
+                      CollectionIndex::IndexedPath path,
+                      const hobject_t &target,
+                      CollectionIndex::IndexedPath target_path)
 {
   KeyValueDB::Transaction t = db->get_transaction();
   {
@@ -776,10 +776,10 @@ int DBObjectMap::clone_keys(const hobject_t &hoid,
   return db->submit_transaction(t);
 }
 
-int DBObjectMap::link_keys(const hobject_t &hoid,
-                          CollectionIndex::IndexedPath path,
-                          const hobject_t &target,
-                          CollectionIndex::IndexedPath target_path)
+int DBObjectMap::link(const hobject_t &hoid,
+                     CollectionIndex::IndexedPath path,
+                     const hobject_t &target,
+                     CollectionIndex::IndexedPath target_path)
 {
   KeyValueDB::Transaction t = db->get_transaction();
   {
index 236e8cfaf9f93918d5f97acb453d2e6f0eb4801a..e26d7351fb63cac57f905889ff77a61681c3c544 100644 (file)
@@ -136,14 +136,39 @@ public:
     set<string> *out
     );
 
-  int clone_keys(
+  int get_xattrs(
+    const hobject_t &hoid,
+    CollectionIndex::IndexedPath path,
+    const set<string> &to_get,
+    map<string, bufferlist> *out
+    );
+
+  int get_all_xattrs(
+    const hobject_t &hoid,
+    CollectionIndex::IndexedPath path,
+    set<string> *out
+    );
+
+  int set_xattrs(
+    const hobject_t &hoid,
+    CollectionIndex::IndexedPath path,
+    const map<string, bufferlist> &to_set
+    );
+
+  int remove_xattrs(
+    const hobject_t &hoid,
+    CollectionIndex::IndexedPath path,
+    const set<string> &to_remove
+    );
+
+  int clone(
     const hobject_t &hoid,
     CollectionIndex::IndexedPath path,
     const hobject_t &target,
     CollectionIndex::IndexedPath target_path
     );
 
-  int link_keys(
+  int link(
     const hobject_t &hoid,
     CollectionIndex::IndexedPath path,
     const hobject_t &target,
index 7f198dfd8f49a129b85a05f0bb467c125a5b2164..f0833631f2cc8652b8ab615e8050d93471b0d94f 100644 (file)
@@ -345,7 +345,7 @@ int FileStore::lfn_link(coll_t c, coll_t cid, const hobject_t& o)
   if (r < 0)
     return -errno;
 
-  r = object_map->link_keys(o, path_old, o, path_new);
+  r = object_map->link(o, path_old, o, path_new);
   if (r < 0)
     return r;
 
@@ -3060,8 +3060,8 @@ int FileStore::_clone(coll_t cid, const hobject_t& oldoid, const hobject_t& newo
   r = _do_clone_range(o, n, 0, st.st_size, 0);
   if (r < 0)
     r = -errno;
-  dout(20) << "objectmap_clone_keys" << dendl;
-  r = object_map->clone_keys(oldoid, from, newoid, to);
+  dout(20) << "objectmap clone" << dendl;
+  r = object_map->clone(oldoid, from, newoid, to);
 
   // clone is non-idempotent; record our work.
   _set_replay_guard(n, spos);
index 9627a03ea79e8e8c95de90dae0c890d2e49e6dd8..d274fdbabc1d1d31d48ebc909481324c03908df2 100644 (file)
@@ -93,8 +93,38 @@ public:
     set<string> *out                   ///< [out] Subset of keys defined on hoid
     ) = 0;
 
+  /// Get xattrs
+  virtual int get_xattrs(
+    const hobject_t &hoid,             ///< [in] object
+    CollectionIndex::IndexedPath path, ///< [in] path to hoid
+    const set<string> &to_get,         ///< [in] keys to get
+    map<string, bufferlist> *out       ///< [out] subset of attrs/vals defined
+    ) = 0;
+
+  /// Get all xattrs
+  virtual int get_all_xattrs(
+    const hobject_t &hoid,             ///< [in] object
+    CollectionIndex::IndexedPath path, ///< [in] path to hoid
+    set<string> *out       ///< [out] attrs and values
+    ) = 0;
+
+  /// set xattrs in to_set
+  virtual int set_xattrs(
+    const hobject_t &hoid,                ///< [in] object
+    CollectionIndex::IndexedPath path,    ///< [in] path to object
+    const map<string, bufferlist> &to_set ///< [in] attrs/values to set
+    ) = 0;
+
+  /// remove xattrs in to_remove
+  virtual int remove_xattrs(
+    const hobject_t &hoid,               ///< [in] object
+    CollectionIndex::IndexedPath path,   ///< [in] path to hoid
+    const set<string> &to_remove         ///< [in] attrs to remove
+    ) = 0;
+
+
   /// Clone keys efficiently from hoid map to target map
-  virtual int clone_keys(
+  virtual int clone(
     const hobject_t &hoid,             ///< [in] object containing map
     CollectionIndex::IndexedPath path, ///< [in] Path to hoid
     const hobject_t &target,           ///< [in] target of clone
@@ -102,7 +132,7 @@ public:
     ) { return 0; }
 
   /// Efficiently tie <target, target_path> to same key space as <hoid, path>
-  virtual int link_keys(
+  virtual int link(
     const hobject_t &hoid,             ///< [in] object containing map
     CollectionIndex::IndexedPath path, ///< [in] Path to hoid
     const hobject_t &target,           ///< [in] target of link
index 3c8ebd2b2d20842ab868b524acaa623e4ac4b3a7..33a086af572eb7052ffabcbcaddee223a2319fe1 100644 (file)
@@ -158,7 +158,7 @@ public:
 
   void clone(hobject_t hoid, CollectionIndex::IndexedPath path,
             hobject_t hoid2, CollectionIndex::IndexedPath path2) {
-    db->clone_keys(hoid, path, hoid2, path2);
+    db->clone(hoid, path, hoid2, path2);
   }
 
   void clear(const string &objname) {
@@ -431,7 +431,7 @@ TEST_F(ObjectMapTest, CloneOneObject) {
   ASSERT_EQ(r, 1);
   ASSERT_EQ(result, "bar");
 
-  db->clone_keys(hoid, path, hoid2, path);
+  db->clone(hoid, path, hoid2, path);
   r = get_key(hoid, path, "foo", &result);
   ASSERT_EQ(r, 1);
   ASSERT_EQ(result, "bar");
@@ -493,8 +493,8 @@ TEST_F(ObjectMapTest, OddEvenClone) {
     set_key(hoid, path, "foo" + num_str(i), "bar" + num_str(i));
   }
 
-  db->link_keys(hoid, path, hoid_link, path);
-  db->clone_keys(hoid, path, hoid2, path);
+  db->link(hoid, path, hoid_link, path);
+  db->clone(hoid, path, hoid2, path);
 
   int r = 0;
   for (unsigned i = 0; i < 1000; ++i) {