From 84c5ce693a3660dc01d938cb3329b81631896a32 Mon Sep 17 00:00:00 2001 From: praks Date: Wed, 23 Jul 2008 21:58:06 -0700 Subject: 6728674 File events API should prevent unnecessary UNMOUNTED events if possible. --- usr/src/uts/common/fs/portfs/port_fop.c | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/usr/src/uts/common/fs/portfs/port_fop.c b/usr/src/uts/common/fs/portfs/port_fop.c index 4c68368e03..c4519e0c33 100644 --- a/usr/src/uts/common/fs/portfs/port_fop.c +++ b/usr/src/uts/common/fs/portfs/port_fop.c @@ -174,6 +174,8 @@ #include #include #include +#include +#include /* * For special case support of mnttab (/etc/mnttab). @@ -1961,6 +1963,27 @@ port_fop(vnode_t *vp, int op, int retval) } } +static int port_forceunmount(vfs_t *vfsp) +{ + char *fsname = vfssw[vfsp->vfs_fstype].vsw_name; + + if (fsname == NULL) { + return (0); + } + + if (strcmp(fsname, MNTTYPE_NFS) == 0) { + return (1); + } + + if (strcmp(fsname, MNTTYPE_NFS3) == 0) { + return (1); + } + + if (strcmp(fsname, MNTTYPE_NFS4) == 0) { + return (1); + } + return (0); +} /* * ----- the unmount filesystem op(fsem) hook. */ @@ -1972,6 +1995,9 @@ port_fop_unmount(fsemarg_t *vf, int flag, cred_t *cr) portfop_vfs_t *pvfsp, **ppvfsp; portfop_vp_t *pvp; int error; + int fmfs; + + fmfs = port_forceunmount(vfsp); mtx = &(portvfs_hash[PORTFOP_PVFSHASH(vfsp)].pvfshash_mutex); ppvfsp = &(portvfs_hash[PORTFOP_PVFSHASH(vfsp)].pvfshash_pvfsp); @@ -1984,6 +2010,16 @@ port_fop_unmount(fsemarg_t *vf, int flag, cred_t *cr) for (pvfsp = *ppvfsp; pvfsp->pvfs != vfsp; pvfsp = pvfsp->pvfs_next) ; + /* + * For some of the filesystems, allow unmounts to proceed only if + * there are no files being watched or it is a forced unmount. + */ + if (fmfs && !(flag & MS_FORCE) && + !list_is_empty(&pvfsp->pvfs_pvplist)) { + mutex_exit(mtx); + return (EBUSY); + } + /* * Indicate that the unmount is in process. Don't remove it yet. * The underlying filesystem unmount routine sets the VFS_UNMOUNTED -- cgit v1.2.3