git: 1fd57c5735ef - stable/14 - md: Merge two switch statements in mdstart_vnode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 30 Nov 2024 16:51:05 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=1fd57c5735ef2789bcc97b81dd1d73a400578fc7
commit 1fd57c5735ef2789bcc97b81dd1d73a400578fc7
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-05-10 20:43:23 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 13:55:57 +0000
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
(cherry picked from commit f75764fea34afe59f2db338b3e973eba626243ee)
---
sys/dev/md/md.c | 44 ++++++++++++++++++++------------------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 3285cfef830d..f6634c709225 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -889,23 +889,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;
@@ -922,7 +905,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);
@@ -931,11 +921,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;
@@ -983,7 +979,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);