]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: create+truncate for whole-object layered discards 21219/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 3 Apr 2018 15:53:09 +0000 (11:53 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 3 Apr 2018 15:53:54 +0000 (11:53 -0400)
A whole-object layered discard is implemented as a truncate rather
than a delete: a dummy object is needed to prevent the CoW machinery
from kicking in.  However, a truncate on a non-existent object is
a no-op.  If the object doesn't exist in HEAD, a discard request is
effectively ignored -- parent blocks are still seen afterwards.

A non-exclusive create on an existing object is also a no-op, so the
fix is to do a compound create+truncate instead.

(derived from commit 0514480b16b0a1e76a9ba31cc3ba58a32b7bee18)

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

index d33d3f4cdf8e87089b8423c80a84ac44ade953fb..13b0a1fa6ba758f1a125aa60d2a61c83c22653b7 100644 (file)
@@ -294,6 +294,7 @@ public:
 protected:
   virtual void add_write_ops(librados::ObjectWriteOperation *wr) {
     if (has_parent()) {
+      wr->create(false);
       wr->truncate(0);
     } else {
       wr->remove();
@@ -302,7 +303,7 @@ protected:
 
   virtual const char* get_write_type() const {
     if (has_parent()) {
-      return "remove (trunc)";
+      return "remove (create+trunc)";
     }
     return "remove";
   }