Fix fallocate call
authorWouter Verhelst <w@uter.be>
Wed, 21 Nov 2012 21:30:23 +0000 (22:30 +0100)
committerWouter Verhelst <w@uter.be>
Wed, 21 Nov 2012 21:30:23 +0000 (22:30 +0100)
If we want to use FALLOC_FL_PUNCH_HOLE, the documentation tells us we
also need to use FALLOC_FL_KEEP_SIZE.

Discovered-By: Nicolas Trangez
nbd-server.c

index 13a2dda2fac949ab0ed748a480549605043e0c51..a839543b3d97752fdd100068962154d15785f150 100644 (file)
@@ -1492,7 +1492,7 @@ int exptrim(struct nbd_request* req, CLIENT* client) {
                if(prev.startoff <= req->from) {
                        off_t curoff = req->from - prev.startoff;
                        off_t curlen = cur.startoff - prev.startoff - curoff;
-                       fallocate(prev.fhandle, FALLOC_FL_PUNCH_HOLE, curoff, curlen);
+                       fallocate(prev.fhandle, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, curoff, curlen);
                }
                prev = cur;
        } while(i < client->export->len && cur.startoff < (req->from + req->len));