]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Return EOPNOTSUPP if a set-alloc-hint occurs with OSDs that don't support 2543/head
authorDavid Zafman <dzafman@redhat.com>
Wed, 24 Sep 2014 23:02:21 +0000 (16:02 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 7 Oct 2014 21:01:04 +0000 (14:01 -0700)
Add CEPH_FEATURE_OSD_SET_ALLOC_HINT feature bit
Collect the intersection of all peer feature bits during peering
When handling CEPH_OSD_OP_SETALLOCHINT check that all OSDs support it
by checking for CEPH_FEATURE_OSD_SET_ALLOC_HINT feature bit.

Fixes: #9419
Backport: firefly

Signed-off-by: David Zafman <dzafman@redhat.com>
src/include/ceph_features.h
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.cc

index 3ee73fbab7d08251278599901291667813045f45..9b9ef5c0c87260a4d1311ad1e0eb41d1b1f9cad5 100644 (file)
@@ -53,6 +53,7 @@
 #define CEPH_FEATURE_MSGR_KEEPALIVE2   (1ULL<<42)
 #define CEPH_FEATURE_OSD_POOLRESEND    (1ULL<<43)
 #define CEPH_FEATURE_ERASURE_CODE_PLUGINS_V2 (1ULL<<44)
+#define CEPH_FEATURE_OSD_SET_ALLOC_HINT (1ULL<<45)
 
 /*
  * The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature
@@ -126,6 +127,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
         CEPH_FEATURE_MSGR_KEEPALIVE2 | \
         CEPH_FEATURE_OSD_POOLRESEND |  \
          CEPH_FEATURE_ERASURE_CODE_PLUGINS_V2 |   \
+         CEPH_FEATURE_OSD_SET_ALLOC_HINT |   \
         0ULL)
 
 #define CEPH_FEATURES_SUPPORTED_DEFAULT  CEPH_FEATURES_ALL
index 4e735b085f8ddf29ad47242d25b4daadfa1dde70..482df0024db51b500c2f74ab2d34a5065ed5943e 100644 (file)
@@ -7328,7 +7328,8 @@ void OSD::handle_pg_notify(OpRequestRef op)
       PG::CephPeeringEvtRef(
        new PG::CephPeeringEvt(
          it->first.epoch_sent, it->first.query_epoch,
-         PG::MNotifyRec(pg_shard_t(from, it->first.from), it->first)))
+         PG::MNotifyRec(pg_shard_t(from, it->first.from), it->first,
+          op->get_req()->get_connection()->get_features())))
       );
   }
 }
index ae04f3875d86aceb4f9acb9ddbf2aef9d6c96572..ad093f7fd81bf282d282a1fe55dadd9493b40573 100644 (file)
@@ -202,7 +202,8 @@ PG::PG(OSDService *o, OSDMapRef curmap,
   scrub_after_recovery(false),
   active_pushes(0),
   recovery_state(this),
-  pg_id(p)
+  pg_id(p),
+  peer_features((uint64_t)-1)
 {
 #ifdef PG_DEBUG_REFS
   osd->add_pgid(p, this);
@@ -6693,6 +6694,7 @@ PG::RecoveryState::GetInfo::GetInfo(my_context ctx)
   if (!prior_set.get())
     pg->build_prior(prior_set);
 
+  pg->reset_peer_features();
   get_infos();
   if (peer_info_requested.empty() && !prior_set->pg_down) {
     post_event(GotInfo());
@@ -6768,6 +6770,9 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in
       }
       get_infos();
     }
+    dout(20) << "Adding osd: " << infoevt.from.osd << " features: "
+      << hex << infoevt.features << dec << dendl;
+    pg->apply_peer_features(infoevt.features);
 
     // are we done getting everything?
     if (peer_info_requested.empty() && !prior_set->pg_down) {
@@ -6826,6 +6831,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in
          break;
        }
       }
+      dout(20) << "Common features: " << hex << pg->get_min_peer_features() << dec << dendl;
       post_event(GotInfo());
     }
   }
index 5f45e77ad8c997f4d4c890bc64071908a993b76d..f17f3aaa93ee2b29f55b81b7339a40990ef62d95 100644 (file)
@@ -1302,10 +1302,12 @@ public:
   struct MNotifyRec : boost::statechart::event< MNotifyRec > {
     pg_shard_t from;
     pg_notify_t notify;
-    MNotifyRec(pg_shard_t from, pg_notify_t &notify) :
-      from(from), notify(notify) {}
+    uint64_t features;
+    MNotifyRec(pg_shard_t from, pg_notify_t &notify, uint64_t f) :
+      from(from), notify(notify), features(f) {}
     void print(std::ostream *out) const {
-      *out << "MNotifyRec from " << from << " notify: " << notify;
+      *out << "MNotifyRec from " << from << " notify: " << notify
+        << " features: 0x" << hex << features << dec;
     }
   };
 
@@ -1988,11 +1990,16 @@ public:
   PG(const PG& rhs);
   PG& operator=(const PG& rhs);
   const spg_t pg_id;
+  uint64_t peer_features;
 
  public:
   const spg_t&      get_pgid() const { return pg_id; }
   int        get_nrep() const { return acting.size(); }
 
+  void reset_peer_features() { peer_features = (uint64_t)-1; }
+  uint64_t get_min_peer_features() { return peer_features; }
+  void apply_peer_features(uint64_t f) { peer_features &= f; }
+
   void init_primary_up_acting(
     const vector<int> &newup,
     const vector<int> &newacting,
index 44f4b92400ae3fdbc0c3d9e5b14a0b53f0bb381c..a9aebc6a2c3a427249050262aa5fa714cec1029a 100644 (file)
@@ -3800,6 +3800,10 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
       ++ctx->num_write;
       {
        tracepoint(osd, do_osd_op_pre_setallochint, soid.oid.name.c_str(), soid.snap.val, op.alloc_hint.expected_object_size, op.alloc_hint.expected_write_size);
+        if (!(get_min_peer_features() & CEPH_FEATURE_OSD_SET_ALLOC_HINT)) { 
+          result = -EOPNOTSUPP;
+          break;
+        }
         if (!obs.exists) {
           ctx->mod_desc.create();
           t->touch(soid);