summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpraks <none@none>2008-07-23 21:58:06 -0700
committerpraks <none@none>2008-07-23 21:58:06 -0700
commit84c5ce693a3660dc01d938cb3329b81631896a32 (patch)
tree49cd177be36ba2119da350c3656aad037897f1b1
parent1dbf84bbc2be2af44deef1b2516c784882925233 (diff)
downloadillumos-gate-84c5ce693a3660dc01d938cb3329b81631896a32.tar.gz
6728674 File events API should prevent unnecessary UNMOUNTED events if possible.
-rw-r--r--usr/src/uts/common/fs/portfs/port_fop.c36
1 files changed, 36 insertions, 0 deletions
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 <sys/fem.h>
#include <sys/vfs_opreg.h>
#include <sys/atomic.h>
+#include <sys/mount.h>
+#include <sys/mntent.h>
/*
* 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);
@@ -1985,6 +2011,16 @@ port_fop_unmount(fsemarg_t *vf, int flag, cred_t *cr)
;
/*
+ * 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
* flag on the vfs_t structure. But we call the filesystem unmount