]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: optional 'force' parameter for request lock payload
authorJason Dillaman <dillaman@redhat.com>
Tue, 22 Mar 2016 00:12:55 +0000 (20:12 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 29 Mar 2016 19:12:28 +0000 (15:12 -0400)
This will be used when force promoting an image to primary -- when
rbd-mirror receives the forced request, it will immediately abort
playback.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageWatcher.cc
src/librbd/WatchNotifyTypes.cc
src/librbd/WatchNotifyTypes.h

index 8bb16c4e1b5abebab86c65f2572619abf29dcf69..9579723b2271091a4ccc10e2cc42c5a3ac22881a 100644 (file)
@@ -408,7 +408,7 @@ void ImageWatcher::notify_request_lock() {
   ldout(m_image_ctx.cct, 10) << this << " notify request lock" << dendl;
 
   bufferlist bl;
-  ::encode(NotifyMessage(RequestLockPayload(get_client_id())), bl);
+  ::encode(NotifyMessage(RequestLockPayload(get_client_id(), false)), bl);
   notify_lock_owner(std::move(bl), create_context_callback<
     ImageWatcher, &ImageWatcher::handle_request_lock>(this));
 }
@@ -616,7 +616,7 @@ bool ImageWatcher::handle_payload(const RequestLockPayload &payload,
 
     ldout(m_image_ctx.cct, 10) << this << " queuing release of exclusive lock"
                                << dendl;
-    m_image_ctx.get_exclusive_lock_policy()->lock_requested(false);
+    m_image_ctx.get_exclusive_lock_policy()->lock_requested(payload.force);
   }
   return true;
 }
index a40cdc7e29c000bdb3c2cbc37a79a4462c57f0af..65c334ae855f1639fcab845626e847c6fb854ede 100644 (file)
@@ -131,18 +131,23 @@ void ReleasedLockPayload::dump(Formatter *f) const {
 
 void RequestLockPayload::encode(bufferlist &bl) const {
   ::encode(client_id, bl);
+  ::encode(force, bl);
 }
 
 void RequestLockPayload::decode(__u8 version, bufferlist::iterator &iter) {
   if (version >= 2) {
     ::decode(client_id, iter);
   }
+  if (version >= 3) {
+    ::decode(force, iter);
+  }
 }
 
 void RequestLockPayload::dump(Formatter *f) const {
   f->open_object_section("client_id");
   client_id.dump(f);
   f->close_section();
+  f->dump_bool("force", force);
 }
 
 void HeaderUpdatePayload::encode(bufferlist &bl) const {
@@ -270,7 +275,7 @@ bool NotifyMessage::check_for_refresh() const {
 }
 
 void NotifyMessage::encode(bufferlist& bl) const {
-  ENCODE_START(2, 1, bl);
+  ENCODE_START(3, 1, bl);
   boost::apply_visitor(EncodePayloadVisitor(bl), payload);
   ENCODE_FINISH(bl);
 }
@@ -344,7 +349,7 @@ void NotifyMessage::dump(Formatter *f) const {
 void NotifyMessage::generate_test_instances(std::list<NotifyMessage *> &o) {
   o.push_back(new NotifyMessage(AcquiredLockPayload(ClientId(1, 2))));
   o.push_back(new NotifyMessage(ReleasedLockPayload(ClientId(1, 2))));
-  o.push_back(new NotifyMessage(RequestLockPayload(ClientId(1, 2))));
+  o.push_back(new NotifyMessage(RequestLockPayload(ClientId(1, 2), true)));
   o.push_back(new NotifyMessage(HeaderUpdatePayload()));
   o.push_back(new NotifyMessage(AsyncProgressPayload(AsyncRequestId(ClientId(0, 1), 2), 3, 4)));
   o.push_back(new NotifyMessage(AsyncCompletePayload(AsyncRequestId(ClientId(0, 1), 2), 3)));
index a587b231d66c5a53c15d370f745d8172077de429..813ff5fd49c684d2153bc445705cee32e7b5e909 100644 (file)
@@ -123,9 +123,12 @@ struct RequestLockPayload {
   static const bool CHECK_FOR_REFRESH = true;
 
   ClientId client_id;
+  bool force = false;
 
   RequestLockPayload() {}
-  RequestLockPayload(const ClientId &client_id_) : client_id(client_id_) {}
+  RequestLockPayload(const ClientId &client_id_, bool force_)
+    : client_id(client_id_), force(force_) {
+  }
 
   void encode(bufferlist &bl) const;
   void decode(__u8 version, bufferlist::iterator &iter);