Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dkwedge Return error in dkopen when dk_open_parent f...



details:   https://anonhg.NetBSD.org/src/rev/33b18e1692f1
branches:  trunk
changeset: 342531:33b18e1692f1
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Dec 27 00:47:47 2015 +0000

description:
Return error in dkopen when dk_open_parent fails. Also change dk_open_parent
to pass error code to caller.
XXX: Pullups

diffstat:

 sys/dev/dkwedge/dk.c |  31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diffs (99 lines):

diff -r bf4b76595828 -r 33b18e1692f1 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Sat Dec 26 23:14:08 2015 +0000
+++ b/sys/dev/dkwedge/dk.c      Sun Dec 27 00:47:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.86 2015/11/28 13:41:31 mlelstv Exp $  */
+/*     $NetBSD: dk.c,v 1.87 2015/12/27 00:47:47 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.86 2015/11/28 13:41:31 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.87 2015/12/27 00:47:47 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -102,7 +102,7 @@
 static int     dkwedge_detach(device_t, int);
 static void    dkwedge_delall1(struct disk *, bool);
 static int     dkwedge_del1(struct dkwedge_info *, int);
-static struct vnode *dk_open_parent(dev_t, int);
+static int     dk_open_parent(dev_t, int, struct vnode **);
 static int     dk_close_parent(struct vnode *, int);
 
 static dev_type_open(dkopen);
@@ -969,14 +969,15 @@
                isopen = true;
                ++pdk->dk_rawopens;
                bdvp = pdk->dk_rawvp;
+               error = 0;
        } else {
                isopen = false;
-               bdvp = dk_open_parent(bdev, FREAD);
+               error = dk_open_parent(bdev, FREAD, &bdvp);
        }
        mutex_exit(&pdk->dk_rawlock);
 
-       if (bdvp == NULL)
-               return EBUSY;
+       if (error)
+               return error;
 
        bp = getiobuf(bdvp, true);
        bp->b_flags = B_READ;
@@ -1021,25 +1022,25 @@
        return (dkwedges[unit]);
 }
 
-static struct vnode *
-dk_open_parent(dev_t dev, int mode)
+static int
+dk_open_parent(dev_t dev, int mode, struct vnode **vpp)
 {
        struct vnode *vp;
        int error;
 
        error = bdevvp(dev, &vp);
        if (error)
-               return NULL;
+               return error;
 
        error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        if (error) {
                vrele(vp);
-               return NULL;
+               return error;
        }
        error = VOP_OPEN(vp, mode, NOCRED);
        if (error) {
                vput(vp);
-               return NULL;
+               return error;
        }
 
        /* VOP_OPEN() doesn't do this for us. */
@@ -1051,7 +1052,9 @@
 
        VOP_UNLOCK(vp);
 
-       return vp;
+       *vpp = vp;
+
+       return 0;
 }
 
 static int
@@ -1091,8 +1094,8 @@
        if (sc->sc_dk.dk_openmask == 0) {
                if (sc->sc_parent->dk_rawopens == 0) {
                        KASSERT(sc->sc_parent->dk_rawvp == NULL);
-                       vp = dk_open_parent(sc->sc_pdev, FREAD | FWRITE);
-                       if (vp == NULL)
+                       error = dk_open_parent(sc->sc_pdev, FREAD | FWRITE, &vp);
+                       if (error)
                                goto popen_fail;
                        sc->sc_parent->dk_rawvp = vp;
                }



Home | Main Index | Thread Index | Old Index