]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: optimize get_object_context.
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 16 Oct 2015 08:27:18 +0000 (16:27 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 19 Oct 2015 06:44:45 +0000 (14:44 +0800)
If soid didn't exist and soid is head or snapdir. In
get_snapset_context we can remove the useless objects_get_attr(SS_ATTR).
It mainly for create a new object.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 4ebeb6a6233daa85cdfecaf79eaa1225385f97aa..a95253a815befa6fde24c6db7d6e0c149fa022ba 100644 (file)
@@ -8476,7 +8476,7 @@ ObjectContextRef ReplicatedPG::get_object_context(const hobject_t& soid,
        // new object.
        object_info_t oi(soid);
        SnapSetContext *ssc = get_snapset_context(
-         soid, true, 0);
+         soid, true, 0, false);
        obc = create_object_context(oi, ssc);
        dout(10) << __func__ << ": " << obc << " " << soid
                 << " " << obc->rwstate
@@ -8856,7 +8856,8 @@ SnapSetContext *ReplicatedPG::create_snapset_context(const hobject_t& oid)
 SnapSetContext *ReplicatedPG::get_snapset_context(
   const hobject_t& oid,
   bool can_create,
-  map<string, bufferlist> *attrs)
+  map<string, bufferlist> *attrs,
+  bool oid_existed)
 {
   Mutex::Locker l(snapset_contexts_lock);
   SnapSetContext *ssc;
@@ -8871,9 +8872,12 @@ SnapSetContext *ReplicatedPG::get_snapset_context(
   } else {
     bufferlist bv;
     if (!attrs) {
-      int r = pgbackend->objects_get_attr(oid.get_head(), SS_ATTR, &bv);
+      int r = -ENOENT;
+      if (!(oid.is_head() && !oid_existed))
+       r = pgbackend->objects_get_attr(oid.get_head(), SS_ATTR, &bv);
       if (r < 0) {
        // try _snapset
+      if (!(oid.is_snapdir() && !oid_existed))
        r = pgbackend->objects_get_attr(oid.get_snapdir(), SS_ATTR, &bv);
        if (r < 0 && !can_create)
          return NULL;
index 04a6a45f7073a822b94ae6f69a9f4aacd64abe67..ddad540e27c10b873d0b256630e87035e93fa3f4 100644 (file)
@@ -1039,7 +1039,8 @@ protected:
   SnapSetContext *get_snapset_context(
     const hobject_t& oid,
     bool can_create,
-    map<string, bufferlist> *attrs = 0
+    map<string, bufferlist> *attrs = 0,
+    bool oid_existed = true //indicate this oid whether exsited in backend
     );
   void register_snapset_context(SnapSetContext *ssc) {
     Mutex::Locker l(snapset_contexts_lock);