Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/md/md.c
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | struct md_s { | ||||
/* MD_PRELOAD related fields */ | /* MD_PRELOAD related fields */ | ||||
u_char *pl_ptr; | u_char *pl_ptr; | ||||
size_t pl_len; | size_t pl_len; | ||||
/* MD_VNODE related fields */ | /* MD_VNODE related fields */ | ||||
struct vnode *vnode; | struct vnode *vnode; | ||||
char file[PATH_MAX]; | char file[PATH_MAX]; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
int cannot_dealloc; | |||||
/* MD_SWAP related fields */ | /* MD_SWAP related fields */ | ||||
vm_object_t object; | vm_object_t object; | ||||
}; | }; | ||||
static struct indir * | static struct indir * | ||||
new_indir(u_int shift) | new_indir(u_int shift) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Lines | mdstart_vnode(struct md_s *sc, struct bio *bp) | ||||
struct uio auio; | struct uio auio; | ||||
struct iovec aiov; | struct iovec aiov; | ||||
struct iovec *piov; | struct iovec *piov; | ||||
struct mount *mp; | struct mount *mp; | ||||
struct vnode *vp; | struct vnode *vp; | ||||
struct buf *pb; | struct buf *pb; | ||||
bus_dma_segment_t *vlist; | bus_dma_segment_t *vlist; | ||||
struct thread *td; | struct thread *td; | ||||
off_t len, zerosize; | off_t offset, len, zerosize; | ||||
int ma_offs; | int ma_offs; | ||||
switch (bp->bio_cmd) { | switch (bp->bio_cmd) { | ||||
case BIO_READ: | case BIO_READ: | ||||
auio.uio_rw = UIO_READ; | auio.uio_rw = UIO_READ; | ||||
break; | break; | ||||
case BIO_WRITE: | case BIO_WRITE: | ||||
case BIO_DELETE: | case BIO_DELETE: | ||||
Show All 21 Lines | mdstart_vnode(struct md_s *sc, struct bio *bp) | ||||
if (bp->bio_cmd == BIO_FLUSH) { | if (bp->bio_cmd == BIO_FLUSH) { | ||||
(void) vn_start_write(vp, &mp, V_WAIT); | (void) vn_start_write(vp, &mp, V_WAIT); | ||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | ||||
error = VOP_FSYNC(vp, MNT_WAIT, td); | error = VOP_FSYNC(vp, MNT_WAIT, td); | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
return (error); | return (error); | ||||
} | |||||
/* | |||||
* If it's DELETE, first try it via native VOP_ALLOCATE(VNA_OP_DEALLOC). | |||||
*/ | |||||
if (bp->bio_cmd == BIO_DELETE && sc->cannot_dealloc == 0) { | |||||
offset = bp->bio_offset; | |||||
len = bp->bio_length; | |||||
(void) vn_start_write(vp, &mp, V_WAIT); | |||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | |||||
error = VOP_ALLOCATE(vp, sc->cred, VNA_OP_DEALLOC, &offset, | |||||
&len); | |||||
VOP_UNLOCK(vp, 0); | |||||
vn_finished_write(mp); | |||||
if (error != EOPNOTSUPP) { | |||||
/* | |||||
* Request partially done, should not happen | |||||
* for the VNA_OP_DEALLOC. | |||||
*/ | |||||
KASSERT(!(error == 0 && len > 0), | |||||
("VOP_ALLOCATE(mode=VNA_OP_DEALLOC): partially " | |||||
"completed, offset + len changed from %jx/%jx to " | |||||
"%jx/%jx", bp->bio_offset, bp->bio_length, offset, | |||||
len)); | |||||
bp->bio_resid = len; | |||||
return (error); | |||||
} | |||||
/* | |||||
* VOP_ALLOCATE(mode=VNA_OP_DEALLOC) is not supported, fall | |||||
* through to the emulated case. | |||||
*/ | |||||
sc->cannot_dealloc = 1; | |||||
} | } | ||||
auio.uio_offset = (vm_ooffset_t)bp->bio_offset; | auio.uio_offset = (vm_ooffset_t)bp->bio_offset; | ||||
auio.uio_resid = bp->bio_length; | auio.uio_resid = bp->bio_length; | ||||
auio.uio_segflg = UIO_SYSSPACE; | auio.uio_segflg = UIO_SYSSPACE; | ||||
auio.uio_td = td; | auio.uio_td = td; | ||||
if (bp->bio_cmd == BIO_DELETE) { | if (bp->bio_cmd == BIO_DELETE) { | ||||
▲ Show 20 Lines • Show All 979 Lines • Show Last 20 Lines |