bhyve: Use fspacectl(2) for BOP_DELETE on regular file images
bhyve can also make use of fspacectl(2) to implement BOP_DELETE with hole-punching. Since it is not desirable to do zero-filling for large DEALLOCATE/UNMAP range, candelete is not set if pathconf(2) indicates that the underlying file system does not support native VOP_DEALLOCATE(9). Sponsored by: The FreeBSD Foundation Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D28880
This commit is contained in:
parent
c18c74a87c
commit
3676512b60
@ -239,6 +239,7 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
|
||||
off_t arg[2];
|
||||
ssize_t clen, len, off, boff, voff;
|
||||
int i, err;
|
||||
struct spacectl_range range;
|
||||
|
||||
br = be->be_req;
|
||||
if (br->br_iovcnt <= 1)
|
||||
@ -336,8 +337,20 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
|
||||
err = errno;
|
||||
else
|
||||
br->br_resid = 0;
|
||||
} else
|
||||
err = EOPNOTSUPP;
|
||||
} else {
|
||||
range.r_offset = br->br_offset;
|
||||
range.r_len = br->br_resid;
|
||||
|
||||
while (range.r_len > 0) {
|
||||
if (fspacectl(bc->bc_fd, SPACECTL_DEALLOC,
|
||||
&range, 0, &range) != 0) {
|
||||
err = errno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (err == 0)
|
||||
br->br_resid = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
err = EINVAL;
|
||||
@ -566,8 +579,11 @@ blockif_open(nvlist_t *nvl, const char *ident)
|
||||
candelete = arg.value.i;
|
||||
if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0)
|
||||
geom = 1;
|
||||
} else
|
||||
} else {
|
||||
psectsz = sbuf.st_blksize;
|
||||
/* Avoid fallback implementation */
|
||||
candelete = fpathconf(fd, _PC_DEALLOC_PRESENT) == 1;
|
||||
}
|
||||
|
||||
#ifndef WITHOUT_CAPSICUM
|
||||
if (caph_ioctls_limit(fd, cmds, nitems(cmds)) == -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user