mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
md: Replace BIO_DELETE emulation with vn_deallocate(9)
Both zero-filling and/or deallocation can be done with vn_deallocate(9). Sponsored by: The FreeBSD Foundation Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D28899
This commit is contained in:
parent
0a7d1fc6f6
commit
78267c2e70
1 changed files with 9 additions and 21 deletions
|
|
@ -875,7 +875,7 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
|||
struct buf *pb;
|
||||
bus_dma_segment_t *vlist;
|
||||
struct thread *td;
|
||||
off_t iolen, iostart, len, zerosize;
|
||||
off_t iolen, iostart, off, len;
|
||||
int ma_offs, npages;
|
||||
|
||||
switch (bp->bio_cmd) {
|
||||
|
|
@ -883,9 +883,9 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
|||
auio.uio_rw = UIO_READ;
|
||||
break;
|
||||
case BIO_WRITE:
|
||||
case BIO_DELETE:
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
break;
|
||||
case BIO_DELETE:
|
||||
case BIO_FLUSH:
|
||||
break;
|
||||
default:
|
||||
|
|
@ -897,6 +897,7 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
|||
pb = NULL;
|
||||
piov = NULL;
|
||||
ma_offs = bp->bio_ma_offset;
|
||||
off = bp->bio_offset;
|
||||
len = bp->bio_length;
|
||||
|
||||
/*
|
||||
|
|
@ -914,6 +915,11 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
|||
VOP_UNLOCK(vp);
|
||||
vn_finished_write(mp);
|
||||
return (error);
|
||||
} else if (bp->bio_cmd == BIO_DELETE) {
|
||||
error = vn_deallocate(vp, &off, &len, 0,
|
||||
sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred, NOCRED);
|
||||
bp->bio_resid = len;
|
||||
return (error);
|
||||
}
|
||||
|
||||
auio.uio_offset = (vm_ooffset_t)bp->bio_offset;
|
||||
|
|
@ -921,25 +927,7 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
|||
auio.uio_segflg = UIO_SYSSPACE;
|
||||
auio.uio_td = td;
|
||||
|
||||
if (bp->bio_cmd == BIO_DELETE) {
|
||||
/*
|
||||
* Emulate BIO_DELETE by writing zeros.
|
||||
*/
|
||||
zerosize = ZERO_REGION_SIZE -
|
||||
(ZERO_REGION_SIZE % sc->sectorsize);
|
||||
auio.uio_iovcnt = howmany(bp->bio_length, zerosize);
|
||||
piov = malloc(sizeof(*piov) * auio.uio_iovcnt, M_MD, M_WAITOK);
|
||||
auio.uio_iov = piov;
|
||||
while (len > 0) {
|
||||
piov->iov_base = __DECONST(void *, zero_region);
|
||||
piov->iov_len = len;
|
||||
if (len > zerosize)
|
||||
piov->iov_len = zerosize;
|
||||
len -= piov->iov_len;
|
||||
piov++;
|
||||
}
|
||||
piov = auio.uio_iov;
|
||||
} else if ((bp->bio_flags & BIO_VLIST) != 0) {
|
||||
if ((bp->bio_flags & BIO_VLIST) != 0) {
|
||||
piov = malloc(sizeof(*piov) * bp->bio_ma_n, M_MD, M_WAITOK);
|
||||
auio.uio_iov = piov;
|
||||
vlist = (bus_dma_segment_t *)bp->bio_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue