Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


 835 
 836 /* ARGSUSED */
 837 static int
 838 mntopen(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
 839 {
 840         vnode_t *vp = *vpp;
 841         mntnode_t *nmnp;
 842 
 843         /*
 844          * Not allowed to open for writing, return error.
 845          */
 846         if (flag & FWRITE)
 847                 return (EPERM);
 848         /*
 849          * Create a new mnt/vnode for each open, this will give us a handle to
 850          * hang the snapshot on.
 851          */
 852         nmnp = mntgetnode(vp);
 853 
 854         *vpp = MTOV(nmnp);
 855         atomic_add_32(&MTOD(nmnp)->mnt_nopen, 1);
 856         VN_RELE(vp);
 857         return (0);
 858 }
 859 
 860 /* ARGSUSED */
 861 static int
 862 mntclose(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr,
 863         caller_context_t *ct)
 864 {
 865         mntnode_t *mnp = VTOM(vp);
 866 
 867         /* Clean up any locks or shares held by the current process */
 868         cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
 869         cleanshares(vp, ttoproc(curthread)->p_pid);
 870 
 871         if (count > 1)
 872                 return (0);
 873         if (vp->v_count == 1) {
 874                 rw_enter(&mnp->mnt_contents, RW_WRITER);
 875                 mntfs_freesnap(mnp, &mnp->mnt_read);
 876                 mntfs_freesnap(mnp, &mnp->mnt_ioctl);
 877                 rw_exit(&mnp->mnt_contents);
 878                 atomic_add_32(&MTOD(mnp)->mnt_nopen, -1);
 879         }
 880         return (0);
 881 }
 882 
 883 /* ARGSUSED */
 884 static int
 885 mntread(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cred, caller_context_t *ct)
 886 {
 887         mntnode_t *mnp = VTOM(vp);
 888         zone_t *zonep = MTOD(mnp)->mnt_zone_ref.zref_zone;
 889         mntsnap_t *snapp = &mnp->mnt_read;
 890         off_t off = uio->uio_offset;
 891         size_t len = uio->uio_resid;
 892         char *bufferp;
 893         size_t available, copylen;
 894         size_t written = 0;
 895         mntelem_t *elemp;
 896         krwlock_t *dblockp = &zonep->zone_mntfs_db_lock;
 897         int error = 0;
 898         off_t   ieoffset;




 835 
 836 /* ARGSUSED */
 837 static int
 838 mntopen(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
 839 {
 840         vnode_t *vp = *vpp;
 841         mntnode_t *nmnp;
 842 
 843         /*
 844          * Not allowed to open for writing, return error.
 845          */
 846         if (flag & FWRITE)
 847                 return (EPERM);
 848         /*
 849          * Create a new mnt/vnode for each open, this will give us a handle to
 850          * hang the snapshot on.
 851          */
 852         nmnp = mntgetnode(vp);
 853 
 854         *vpp = MTOV(nmnp);
 855         atomic_inc_32(&MTOD(nmnp)->mnt_nopen);
 856         VN_RELE(vp);
 857         return (0);
 858 }
 859 
 860 /* ARGSUSED */
 861 static int
 862 mntclose(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr,
 863         caller_context_t *ct)
 864 {
 865         mntnode_t *mnp = VTOM(vp);
 866 
 867         /* Clean up any locks or shares held by the current process */
 868         cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
 869         cleanshares(vp, ttoproc(curthread)->p_pid);
 870 
 871         if (count > 1)
 872                 return (0);
 873         if (vp->v_count == 1) {
 874                 rw_enter(&mnp->mnt_contents, RW_WRITER);
 875                 mntfs_freesnap(mnp, &mnp->mnt_read);
 876                 mntfs_freesnap(mnp, &mnp->mnt_ioctl);
 877                 rw_exit(&mnp->mnt_contents);
 878                 atomic_dec_32(&MTOD(mnp)->mnt_nopen);
 879         }
 880         return (0);
 881 }
 882 
 883 /* ARGSUSED */
 884 static int
 885 mntread(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cred, caller_context_t *ct)
 886 {
 887         mntnode_t *mnp = VTOM(vp);
 888         zone_t *zonep = MTOD(mnp)->mnt_zone_ref.zref_zone;
 889         mntsnap_t *snapp = &mnp->mnt_read;
 890         off_t off = uio->uio_offset;
 891         size_t len = uio->uio_resid;
 892         char *bufferp;
 893         size_t available, copylen;
 894         size_t written = 0;
 895         mntelem_t *elemp;
 896         krwlock_t *dblockp = &zonep->zone_mntfs_db_lock;
 897         int error = 0;
 898         off_t   ieoffset;