Print this page
5404 smbfs needs mmap support
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>


 864                     (SM_MAX_STATFSTIME * (hrtime_t)NANOSEC);
 865                 smi->smi_statvfsbuf = stvfs; /* struct assign! */
 866         }
 867 
 868         mutex_enter(&smi->smi_lock);
 869         if (smi->smi_status & SM_STATUS_STATFS_WANT)
 870                 cv_broadcast(&smi->smi_statvfs_cv);
 871         smi->smi_status &= ~(SM_STATUS_STATFS_BUSY | SM_STATUS_STATFS_WANT);
 872 
 873         /*
 874          * Copy the statvfs data to caller's buf.
 875          * Note: struct assignment
 876          */
 877 cache_hit:
 878         if (error == 0)
 879                 *sbp = smi->smi_statvfsbuf;
 880         mutex_exit(&smi->smi_lock);
 881         return (error);
 882 }
 883 
 884 static kmutex_t smbfs_syncbusy;
 885 
 886 /*
 887  * Flush dirty smbfs files for file system vfsp.
 888  * If vfsp == NULL, all smbfs files are flushed.
 889  */
 890 /*ARGSUSED*/
 891 static int
 892 smbfs_sync(vfs_t *vfsp, short flag, cred_t *cr)
 893 {

 894         /*
 895          * Cross-zone calls are OK here, since this translates to a
 896          * VOP_PUTPAGE(B_ASYNC), which gets picked up by the right zone.


 897          */
 898         if (!(flag & SYNC_ATTR) && mutex_tryenter(&smbfs_syncbusy) != 0) {
 899                 smbfs_rflush(vfsp, cr);
 900                 mutex_exit(&smbfs_syncbusy);






 901         }
 902 


 903         return (0);
 904 }
 905 
 906 /*
 907  * Initialization routine for VFS routines.  Should only be called once
 908  */
 909 int
 910 smbfs_vfsinit(void)
 911 {
 912         mutex_init(&smbfs_syncbusy, NULL, MUTEX_DEFAULT, NULL);
 913         return (0);
 914 }
 915 
 916 /*
 917  * Shutdown routine for VFS routines.  Should only be called once
 918  */
 919 void
 920 smbfs_vfsfini(void)
 921 {
 922         mutex_destroy(&smbfs_syncbusy);
 923 }
 924 
 925 void
 926 smbfs_freevfs(vfs_t *vfsp)
 927 {
 928         smbmntinfo_t    *smi;
 929 
 930         /* free up the resources */
 931         smi = VFTOSMI(vfsp);
 932 
 933         /*
 934          * By this time we should have already deleted the
 935          * smi kstats in the unmount code.  If they are still around
 936          * something is wrong
 937          */
 938         ASSERT(smi->smi_io_kstats == NULL);
 939 
 940         smbfs_zonelist_remove(smi);
 941 
 942         smbfs_free_smi(smi);




 864                     (SM_MAX_STATFSTIME * (hrtime_t)NANOSEC);
 865                 smi->smi_statvfsbuf = stvfs; /* struct assign! */
 866         }
 867 
 868         mutex_enter(&smi->smi_lock);
 869         if (smi->smi_status & SM_STATUS_STATFS_WANT)
 870                 cv_broadcast(&smi->smi_statvfs_cv);
 871         smi->smi_status &= ~(SM_STATUS_STATFS_BUSY | SM_STATUS_STATFS_WANT);
 872 
 873         /*
 874          * Copy the statvfs data to caller's buf.
 875          * Note: struct assignment
 876          */
 877 cache_hit:
 878         if (error == 0)
 879                 *sbp = smi->smi_statvfsbuf;
 880         mutex_exit(&smi->smi_lock);
 881         return (error);
 882 }
 883 


 884 /*
 885  * Flush dirty smbfs files for file system vfsp.
 886  * If vfsp == NULL, all smbfs files are flushed.
 887  */
 888 /*ARGSUSED*/
 889 static int
 890 smbfs_sync(vfs_t *vfsp, short flag, cred_t *cr)
 891 {
 892 
 893         /*
 894          * SYNC_ATTR is used by fsflush() to force old filesystems like UFS
 895          * to sync metadata, which they would otherwise cache indefinitely.
 896          * Semantically, the only requirement is that the sync be initiated.
 897          * Assume the server-side takes care of attribute sync.
 898          */
 899         if (flag & SYNC_ATTR)
 900                 return (0);
 901 
 902         if (vfsp == NULL) {
 903                 /*
 904                  * Flush ALL smbfs mounts in this zone.
 905                  */
 906                 smbfs_flushall(cr);
 907                 return (0);
 908         }
 909 
 910         smbfs_rflush(vfsp, cr);
 911 
 912         return (0);
 913 }
 914 
 915 /*
 916  * Initialization routine for VFS routines.  Should only be called once
 917  */
 918 int
 919 smbfs_vfsinit(void)
 920 {

 921         return (0);
 922 }
 923 
 924 /*
 925  * Shutdown routine for VFS routines.  Should only be called once
 926  */
 927 void
 928 smbfs_vfsfini(void)
 929 {

 930 }
 931 
 932 void
 933 smbfs_freevfs(vfs_t *vfsp)
 934 {
 935         smbmntinfo_t    *smi;
 936 
 937         /* free up the resources */
 938         smi = VFTOSMI(vfsp);
 939 
 940         /*
 941          * By this time we should have already deleted the
 942          * smi kstats in the unmount code.  If they are still around
 943          * something is wrong
 944          */
 945         ASSERT(smi->smi_io_kstats == NULL);
 946 
 947         smbfs_zonelist_remove(smi);
 948 
 949         smbfs_free_smi(smi);