1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-06 18:29:47 +00:00

md: Merge two switch statements in mdstart_vnode

While here, use bp->bio_cmd instead of auio.uio_rw to drive read vs
write behavior.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45155
This commit is contained in:
John Baldwin 2024-05-10 13:43:23 -07:00
parent 5120ea0d88
commit f75764fea3

View File

@ -887,23 +887,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
int ma_offs, npages;
bool mapped;
switch (bp->bio_cmd) {
case BIO_READ:
auio.uio_rw = UIO_READ;
break;
case BIO_WRITE:
auio.uio_rw = UIO_WRITE;
break;
case BIO_FLUSH:
break;
case BIO_DELETE:
if (sc->candelete)
break;
/* FALLTHROUGH */
default:
return (EOPNOTSUPP);
}
td = curthread;
vp = sc->vnode;
piov = NULL;
@ -920,7 +903,14 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
* still valid.
*/
if (bp->bio_cmd == BIO_FLUSH) {
switch (bp->bio_cmd) {
case BIO_READ:
auio.uio_rw = UIO_READ;
break;
case BIO_WRITE:
auio.uio_rw = UIO_WRITE;
break;
case BIO_FLUSH:
do {
(void)vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@ -929,11 +919,17 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
vn_finished_write(mp);
} while (error == ERELOOKUP);
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);
case BIO_DELETE:
if (sc->candelete) {
error = vn_deallocate(vp, &off, &len, 0,
sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred,
NOCRED);
bp->bio_resid = len;
return (error);
}
/* FALLTHROUGH */
default:
return (EOPNOTSUPP);
}
auio.uio_offset = (vm_ooffset_t)bp->bio_offset;
@ -981,7 +977,7 @@ unmapped_step:
auio.uio_iovcnt = 1;
}
iostart = auio.uio_offset;
if (auio.uio_rw == UIO_READ) {
if (bp->bio_cmd == BIO_READ) {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_READ(vp, &auio, 0, sc->cred);
VOP_UNLOCK(vp);