Print this page
*** NO COMMENTS ***


 140 
 141 static smbnode_t *
 142 sn_hashfind(smbmntinfo_t *, const char *, int, avl_index_t *);
 143 
 144 static smbnode_t *
 145 make_smbnode(smbmntinfo_t *, const char *, int, int *);
 146 
 147 /*
 148  * Free the resources associated with an smbnode.
 149  * Note: This is different from smbfs_inactive
 150  *
 151  * NFS: nfs_subr.c:rinactive
 152  */
 153 static void
 154 sn_inactive(smbnode_t *np)
 155 {
 156         vsecattr_t      ovsa;
 157         cred_t          *oldcr;
 158         char            *orpath;
 159         int             orplen;

 160 
 161         /*
 162          * Flush and invalidate all pages (todo)
 163          * Free any held credentials and caches...
 164          * etc.  (See NFS code)
 165          */
 166         mutex_enter(&np->r_statelock);
 167 
 168         ovsa = np->r_secattr;
 169         np->r_secattr = smbfs_vsa0;
 170         np->r_sectime = 0;
 171 
 172         oldcr = np->r_cred;
 173         np->r_cred = NULL;
 174 
 175         orpath = np->n_rpath;
 176         orplen = np->n_rplen;
 177         np->n_rpath = NULL;
 178         np->n_rplen = 0;
 179 
 180         mutex_exit(&np->r_statelock);
 181 





 182         if (ovsa.vsa_aclentp != NULL)
 183                 kmem_free(ovsa.vsa_aclentp, ovsa.vsa_aclentsz);
 184 
 185         if (oldcr != NULL)
 186                 crfree(oldcr);
 187 
 188         if (orpath != NULL)
 189                 kmem_free(orpath, orplen + 1);
 190 }
 191 
 192 /*
 193  * Find and optionally create an smbnode for the passed
 194  * mountinfo, directory, separator, and name.  If the
 195  * desired smbnode already exists, return a reference.
 196  * If the file attributes pointer is non-null, the node
 197  * is created if necessary and linked into the AVL tree.
 198  *
 199  * Callers that need a node created but don't have the
 200  * real attributes pass smbfs_fattr0 to force creation.
 201  *


1018 
1019         vp = SMBTOV(np);
1020         vfsp = vp->v_vfsp;
1021 
1022         ASSERT(vp->v_count == 1);
1023         ASSERT(np->r_count == 0);
1024         ASSERT(np->r_mapcnt == 0);
1025         ASSERT(np->r_secattr.vsa_aclentp == NULL);
1026         ASSERT(np->r_cred == NULL);
1027         ASSERT(np->n_rpath == NULL);
1028         ASSERT(!(np->r_flags & RHASHED));
1029         ASSERT(np->r_freef == NULL && np->r_freeb == NULL);
1030         atomic_add_long((ulong_t *)&smbnodenew, -1);
1031         vn_invalid(vp);
1032         vn_free(vp);
1033         kmem_cache_free(smbnode_cache, np);
1034         VFS_RELE(vfsp);
1035 }
1036 
1037 /*

1038  * Flush all vnodes in this (or every) vfs.
1039  * Used by nfs_sync and by nfs_unmount.
1040  */
1041 /*ARGSUSED*/
1042 void
1043 smbfs_rflush(struct vfs *vfsp, cred_t *cr)
1044 {
1045         /* Todo: mmap support. */









































1046 }
1047 
1048 /* access cache */
1049 /* client handles */
1050 
1051 /*
1052  * initialize resources that are used by smbfs_subr.c
1053  * this is called from the _init() routine (by the way of smbfs_clntinit())
1054  *
1055  * NFS: nfs_subr.c:nfs_subrinit
1056  */
1057 int
1058 smbfs_subrinit(void)
1059 {
1060         ulong_t nsmbnode_max;
1061 
1062         /*
1063          * Allocate and initialize the smbnode cache
1064          */
1065         if (nsmbnode <= 0)




 140 
 141 static smbnode_t *
 142 sn_hashfind(smbmntinfo_t *, const char *, int, avl_index_t *);
 143 
 144 static smbnode_t *
 145 make_smbnode(smbmntinfo_t *, const char *, int, int *);
 146 
 147 /*
 148  * Free the resources associated with an smbnode.
 149  * Note: This is different from smbfs_inactive
 150  *
 151  * NFS: nfs_subr.c:rinactive
 152  */
 153 static void
 154 sn_inactive(smbnode_t *np)
 155 {
 156         vsecattr_t      ovsa;
 157         cred_t          *oldcr;
 158         char            *orpath;
 159         int             orplen;
 160         vnode_t         *vp;
 161 
 162         /*
 163          * Flush and invalidate all pages
 164          * Free any held credentials and caches...
 165          * etc.  (See NFS code)
 166          */
 167         mutex_enter(&np->r_statelock);
 168 
 169         ovsa = np->r_secattr;
 170         np->r_secattr = smbfs_vsa0;
 171         np->r_sectime = 0;
 172 
 173         oldcr = np->r_cred;
 174         np->r_cred = NULL;
 175 
 176         orpath = np->n_rpath;
 177         orplen = np->n_rplen;
 178         np->n_rpath = NULL;
 179         np->n_rplen = 0;
 180 
 181         mutex_exit(&np->r_statelock);
 182 
 183         vp = SMBTOV(np);
 184         if (vn_has_cached_data(vp)) {
 185                 smbfs_invalidate_pages(vp, (u_offset_t) 0, oldcr);
 186         }
 187 
 188         if (ovsa.vsa_aclentp != NULL)
 189                 kmem_free(ovsa.vsa_aclentp, ovsa.vsa_aclentsz);
 190 
 191         if (oldcr != NULL)
 192                 crfree(oldcr);
 193 
 194         if (orpath != NULL)
 195                 kmem_free(orpath, orplen + 1);
 196 }
 197 
 198 /*
 199  * Find and optionally create an smbnode for the passed
 200  * mountinfo, directory, separator, and name.  If the
 201  * desired smbnode already exists, return a reference.
 202  * If the file attributes pointer is non-null, the node
 203  * is created if necessary and linked into the AVL tree.
 204  *
 205  * Callers that need a node created but don't have the
 206  * real attributes pass smbfs_fattr0 to force creation.
 207  *


1024 
1025         vp = SMBTOV(np);
1026         vfsp = vp->v_vfsp;
1027 
1028         ASSERT(vp->v_count == 1);
1029         ASSERT(np->r_count == 0);
1030         ASSERT(np->r_mapcnt == 0);
1031         ASSERT(np->r_secattr.vsa_aclentp == NULL);
1032         ASSERT(np->r_cred == NULL);
1033         ASSERT(np->n_rpath == NULL);
1034         ASSERT(!(np->r_flags & RHASHED));
1035         ASSERT(np->r_freef == NULL && np->r_freeb == NULL);
1036         atomic_add_long((ulong_t *)&smbnodenew, -1);
1037         vn_invalid(vp);
1038         vn_free(vp);
1039         kmem_cache_free(smbnode_cache, np);
1040         VFS_RELE(vfsp);
1041 }
1042 
1043 /*
1044  * Correspond to rflush() in NFS.
1045  * Flush all vnodes in this (or every) vfs.
1046  * Used by smbfs_sync and by smbfs_unmount.
1047  */
1048 /*ARGSUSED*/
1049 void
1050 smbfs_rflush(struct vfs *vfsp, cred_t *cr) {
1051 
1052     smbmntinfo_t *mi;
1053     smbnode_t *np;
1054     vnode_t *vp;
1055 
1056     long num, cnt;
1057 
1058     vnode_t **vplist;
1059 
1060     if(vfsp == NULL)
1061         return;
1062 
1063     mi = VFTOSMI(vfsp);
1064 
1065     cnt = 0;
1066 
1067     num = mi->smi_hash_avl.avl_numnodes;
1068 
1069     vplist = kmem_alloc(num * sizeof (vnode_t*), KM_SLEEP);
1070 
1071     rw_enter(&mi->smi_hash_lk, RW_READER);
1072     for (np = avl_first(&mi->smi_hash_avl); np != NULL;
1073             np = avl_walk(&mi->smi_hash_avl, np, AVL_AFTER)) {
1074         vp = SMBTOV(np);
1075         if (vn_is_readonly(vp))
1076             continue;
1077 
1078         if (vn_has_cached_data(vp) && (np->r_flags & RDIRTY || np->r_mapcnt > 0)) {
1079             VN_HOLD(vp);
1080             vplist[cnt++] = vp;
1081             if (cnt == num)
1082                 break;
1083         }
1084     }
1085     rw_exit(&mi->smi_hash_lk);
1086 
1087     while (cnt-- > 0) {
1088         vp = vplist[cnt];
1089         (void) VOP_PUTPAGE(vp, 0, 0, 0, cr, NULL);
1090         VN_RELE(vp);
1091     }
1092 
1093     kmem_free(vplist, num * sizeof (vnode_t*));
1094 }
1095 
1096 /* access cache */
1097 /* client handles */
1098 
1099 /*
1100  * initialize resources that are used by smbfs_subr.c
1101  * this is called from the _init() routine (by the way of smbfs_clntinit())
1102  *
1103  * NFS: nfs_subr.c:nfs_subrinit
1104  */
1105 int
1106 smbfs_subrinit(void)
1107 {
1108         ulong_t nsmbnode_max;
1109 
1110         /*
1111          * Allocate and initialize the smbnode cache
1112          */
1113         if (nsmbnode <= 0)