rbd: tolerate -ENOENT for discard operations
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 7 Apr 2014 23:54:10 +0000 (16:54 -0700)
committerIlya Dryomov <idryomov@redhat.com>
Tue, 14 Oct 2014 17:03:33 +0000 (21:03 +0400)
Discard may try to delete an object from a non-layered image that does not exist.
If this occurs, the image already has no data in that range, so change the
result to success.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c

index de1520ccc0d46afdf5bbfefffa33e83913ce694c..835a96a09a6b13475e18e8067a0b11edcceda87d 100644 (file)
@@ -1767,6 +1767,9 @@ static void rbd_osd_discard_callback(struct rbd_obj_request *obj_request)
         * it to our originally-requested length.
         */
        obj_request->xferred = obj_request->length;
+       /* discarding a non-existent object is not a problem */
+       if (obj_request->result == -ENOENT)
+               obj_request->result = 0;
        obj_request_done_set(obj_request);
 }