Print this page
10084 fop_open() doesn't need to check for a NULL vnode


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2017, Joyent, Inc.
  25  * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  27  */
  28 
  29 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  30 /*        All Rights Reserved   */
  31 
  32 /*
  33  * University Copyright- Copyright (c) 1982, 1986, 1988
  34  * The Regents of the University of California
  35  * All Rights Reserved
  36  *
  37  * University Acknowledgment- Portions of this document are derived from
  38  * software developed by the University of California, Berkeley, and its
  39  * contributors.
  40  */
  41 
  42 #include <sys/types.h>
  43 #include <sys/param.h>
  44 #include <sys/t_lock.h>


3351         if (ret) {
3352                 /*
3353                  * Use the saved vp just in case the vnode ptr got trashed
3354                  * by the error.
3355                  */
3356                 VOPSTATS_UPDATE(vp, open);
3357                 if ((vp->v_type == VREG) && (mode & FREAD))
3358                         atomic_dec_32(&vp->v_rdcnt);
3359                 if ((vp->v_type == VREG) && (mode & FWRITE))
3360                         atomic_dec_32(&vp->v_wrcnt);
3361         } else {
3362                 /*
3363                  * Some filesystems will return a different vnode,
3364                  * but the same path was still used to open it.
3365                  * So if we do change the vnode and need to
3366                  * copy over the path, do so here, rather than special
3367                  * casing each filesystem. Adjust the vnode counts to
3368                  * reflect the vnode switch.
3369                  */
3370                 VOPSTATS_UPDATE(*vpp, open);
3371                 if (*vpp != vp && *vpp != NULL) {
3372                         vn_copypath(vp, *vpp);
3373                         if (((*vpp)->v_type == VREG) && (mode & FREAD))
3374                                 atomic_inc_32(&(*vpp)->v_rdcnt);
3375                         if ((vp->v_type == VREG) && (mode & FREAD))
3376                                 atomic_dec_32(&vp->v_rdcnt);
3377                         if (((*vpp)->v_type == VREG) && (mode & FWRITE))
3378                                 atomic_inc_32(&(*vpp)->v_wrcnt);
3379                         if ((vp->v_type == VREG) && (mode & FWRITE))
3380                                 atomic_dec_32(&vp->v_wrcnt);
3381                 }
3382         }
3383         VN_RELE(vp);
3384         return (ret);
3385 }
3386 
3387 int
3388 fop_close(
3389         vnode_t *vp,
3390         int flag,
3391         int count,




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2018, Joyent, Inc.
  25  * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  27  */
  28 
  29 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  30 /*        All Rights Reserved   */
  31 
  32 /*
  33  * University Copyright- Copyright (c) 1982, 1986, 1988
  34  * The Regents of the University of California
  35  * All Rights Reserved
  36  *
  37  * University Acknowledgment- Portions of this document are derived from
  38  * software developed by the University of California, Berkeley, and its
  39  * contributors.
  40  */
  41 
  42 #include <sys/types.h>
  43 #include <sys/param.h>
  44 #include <sys/t_lock.h>


3351         if (ret) {
3352                 /*
3353                  * Use the saved vp just in case the vnode ptr got trashed
3354                  * by the error.
3355                  */
3356                 VOPSTATS_UPDATE(vp, open);
3357                 if ((vp->v_type == VREG) && (mode & FREAD))
3358                         atomic_dec_32(&vp->v_rdcnt);
3359                 if ((vp->v_type == VREG) && (mode & FWRITE))
3360                         atomic_dec_32(&vp->v_wrcnt);
3361         } else {
3362                 /*
3363                  * Some filesystems will return a different vnode,
3364                  * but the same path was still used to open it.
3365                  * So if we do change the vnode and need to
3366                  * copy over the path, do so here, rather than special
3367                  * casing each filesystem. Adjust the vnode counts to
3368                  * reflect the vnode switch.
3369                  */
3370                 VOPSTATS_UPDATE(*vpp, open);
3371                 if (*vpp != vp) {
3372                         vn_copypath(vp, *vpp);
3373                         if (((*vpp)->v_type == VREG) && (mode & FREAD))
3374                                 atomic_inc_32(&(*vpp)->v_rdcnt);
3375                         if ((vp->v_type == VREG) && (mode & FREAD))
3376                                 atomic_dec_32(&vp->v_rdcnt);
3377                         if (((*vpp)->v_type == VREG) && (mode & FWRITE))
3378                                 atomic_inc_32(&(*vpp)->v_wrcnt);
3379                         if ((vp->v_type == VREG) && (mode & FWRITE))
3380                                 atomic_dec_32(&vp->v_wrcnt);
3381                 }
3382         }
3383         VN_RELE(vp);
3384         return (ret);
3385 }
3386 
3387 int
3388 fop_close(
3389         vnode_t *vp,
3390         int flag,
3391         int count,