The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f75764fea34afe59f2db338b3e973eba626243ee

commit f75764fea34afe59f2db338b3e973eba626243ee
Author:     John Baldwin <j...@freebsd.org>
AuthorDate: 2024-05-10 20:43:23 +0000
Commit:     John Baldwin <j...@freebsd.org>
CommitDate: 2024-05-10 20:43:23 +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
---
 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 241517898ad4..267554031f23 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -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);

Reply via email to