]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Fixes : #12018
authorxinxin shu <xinxin.shu@intel.com>
Tue, 16 Jun 2015 22:49:58 +0000 (06:49 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Mon, 13 Jul 2015 20:43:07 +0000 (04:43 +0800)
osd/OSD.cc : drop write if pool is full

Signed-off-by: xinxin shu <xinxin.shu@intel.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/osd_types.cc
src/osd/osd_types.h

index f6be098442c090514b6ee901e955442effaab245..fb9f8a7d99021d9eab044519cc5d94f952cb113b 100644 (file)
@@ -6119,6 +6119,7 @@ void OSD::handle_osd_map(MOSDMap *m)
       o->decode(bl);
       if (o->test_flag(CEPH_OSDMAP_FULL))
        last_marked_full = e;
+      set_pool_last_map_marked_full(o, e);
 
       hobject_t fulloid = get_osdmap_pobject_name(e);
       t.write(META_COLL, fulloid, 0, bl.length(), bl);
@@ -6152,6 +6153,7 @@ void OSD::handle_osd_map(MOSDMap *m)
 
       if (o->test_flag(CEPH_OSDMAP_FULL))
        last_marked_full = e;
+      set_pool_last_map_marked_full(o, e);
 
       bufferlist fbl;
       o->encode(fbl, inc.encode_features | CEPH_FEATURE_RESERVED);
@@ -8050,6 +8052,9 @@ void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap)
     }
   }
 
+  // calc actual pgid
+  pg_t _pgid = m->get_pg();
+  int64_t pool = _pgid.pool();
   if (op->may_write()) {
     // full?
     if ((service.check_failsafe_full() ||
@@ -8061,6 +8066,17 @@ void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap)
       return;
     }
 
+    const pg_pool_t *pi = osdmap->get_pg_pool(pool);
+    if (!pi) {
+      return;
+    }
+    // pool is full ?
+    map<int64_t, epoch_t> &pool_last_map_marked_full = superblock.pool_last_map_marked_full;
+    if (pi->has_flag(pg_pool_t::FLAG_FULL) || 
+       (pool_last_map_marked_full.count(pool) && (m->get_map_epoch() < pool_last_map_marked_full[pool]))) {
+      return;
+    }
+    
     // invalid?
     if (m->get_snapid() != CEPH_NOSNAP) {
       service.reply_op_error(op, -EINVAL);
@@ -8079,9 +8095,6 @@ void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap)
     }
   }
 
-  // calc actual pgid
-  pg_t _pgid = m->get_pg();
-  int64_t pool = _pgid.pool();
   if ((m->get_flags() & CEPH_OSD_FLAG_PGOP) == 0 &&
       osdmap->have_pg_pool(pool))
     _pgid = osdmap->raw_pg_to_pg(_pgid);
@@ -8744,3 +8757,17 @@ void OSD::PeeringWQ::_dequeue(list<PG*> *out) {
   }
   in_use.insert(got.begin(), got.end());
 }
+
+void OSD::set_pool_last_map_marked_full(OSDMap *o, epoch_t &e)
+{
+  map<int64_t, epoch_t> &pool_last_map_marked_full = superblock.pool_last_map_marked_full;
+  for (map<int64_t, pg_pool_t>::const_iterator it = o->get_pools().begin();
+       it != o->get_pools().end(); it++) {
+    bool exist = pool_last_map_marked_full.count(it->first);
+    if (it->second.has_flag(pg_pool_t::FLAG_FULL) && !exist)
+      pool_last_map_marked_full[it->first] = e;
+    if (it->second.has_flag(pg_pool_t::FLAG_FULL) &&
+      (exist && pool_last_map_marked_full.count(it->first) < e))
+       pool_last_map_marked_full[it->first] = e;
+    }
+}
index 85452057ca380f6afac510e3e95dc5a85489acc1..82fa3f881dc36c396607ebd43f05f3677aee1653 100644 (file)
@@ -1775,6 +1775,7 @@ private:
   void handle_osd_map(class MOSDMap *m);
   void note_down_osd(int osd);
   void note_up_osd(int osd);
+  void set_pool_last_map_marked_full(OSDMap *o, epoch_t &e);
   
   bool advance_pg(
     epoch_t advance_to, PG *pg,
index eeaab4db0ebb924370e7d07c8c63863aa5376661..23885931bffa8168a5f666e3866ac4893f82f21b 100644 (file)
@@ -3882,7 +3882,7 @@ ostream& operator<<(ostream& out, const osd_peer_stat_t &stat)
 
 void OSDSuperblock::encode(bufferlist &bl) const
 {
-  ENCODE_START(6, 5, bl);
+  ENCODE_START(7, 5, bl);
   ::encode(cluster_fsid, bl);
   ::encode(whoami, bl);
   ::encode(current_epoch, bl);
@@ -3894,6 +3894,7 @@ void OSDSuperblock::encode(bufferlist &bl) const
   ::encode(mounted, bl);
   ::encode(osd_fsid, bl);
   ::encode(last_map_marked_full, bl);
+  ::encode(pool_last_map_marked_full, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -3921,6 +3922,8 @@ void OSDSuperblock::decode(bufferlist::iterator &bl)
     ::decode(osd_fsid, bl);
   if (struct_v >= 6)
     ::decode(last_map_marked_full, bl);
+  if (struct_v >= 7)
+    ::decode(pool_last_map_marked_full, bl);
   DECODE_FINISH(bl);
 }
 
index c477f1d404c22f617f86bcf3e22dfdf483471572..6b4fbe3329e022dfcd2ed35ebea5cb26148f6680 100644 (file)
@@ -2684,6 +2684,7 @@ public:
   epoch_t mounted;     // last epoch i mounted
   epoch_t clean_thru;  // epoch i was active and clean thru
   epoch_t last_map_marked_full; // last epoch osdmap was marked full
+  map<int64_t, epoch_t> pool_last_map_marked_full; // last epoch pool was marked full
 
   OSDSuperblock() : 
     whoami(-1),