aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2000-07-11 22:07:57 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2000-07-11 22:07:57 +0000
commitf2a2857bb34f5525f21ad016c25b20348d7a1fab (patch)
treeca1f94a427c4ab94cb5de2c2a7b557655d1a6376 /sys/kern/kern_sig.c
parentaa02fb5729dd652fa1da3f9e8e1152cca9010a1c (diff)
downloadsrc-f2a2857bb34f5525f21ad016c25b20348d7a1fab.tar.gz
src-f2a2857bb34f5525f21ad016c25b20348d7a1fab.zip
Add snapshots to the fast filesystem. Most of the changes support
the gating of system calls that cause modifications to the underlying filesystem. The gating can be enabled by any filesystem that needs to consistently suspend operations by adding the vop_stdgetwritemount to their set of vnops. Once gating is enabled, the function vfs_write_suspend stops all new write operations to a filesystem, allows any filesystem modifying system calls already in progress to complete, then sync's the filesystem to disk and returns. The function vfs_write_resume allows the suspended write operations to begin again. Gating is not added by default for all filesystems as for SMP systems it adds two extra locks to such critical kernel paths as the write system call. Thus, gating should only be added as needed. Details on the use and current status of snapshots in FFS can be found in /sys/ufs/ffs/README.snapshot so for brevity and timelyness is not included here. Unless and until you create a snapshot file, these changes should have no effect on your system (famous last words).
Notes
Notes: svn path=/head/; revision=62976
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index e96f47113b3a..2d87b630561c 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1599,6 +1599,7 @@ coredump(p)
struct nameidata nd;
struct vattr vattr;
int error, error1, flags;
+ struct mount *mp;
char *name; /* name of corefile */
off_t limit;
@@ -1619,6 +1620,7 @@ coredump(p)
if (limit == 0)
return 0;
+restart:
name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
flags = O_CREAT | FWRITE | O_NOFOLLOW;
@@ -1628,6 +1630,14 @@ coredump(p)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
+ if (vn_start_write(vp, &mp, V_NOWAIT) != 0) {
+ VOP_UNLOCK(vp, 0, p);
+ if ((error = vn_close(vp, FWRITE, cred, p)) != 0)
+ return (error);
+ if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
+ return (error);
+ goto restart;
+ }
/* Don't dump to non-regular files or files with links. */
if (vp->v_type != VREG ||
@@ -1647,6 +1657,7 @@ coredump(p)
out:
VOP_UNLOCK(vp, 0, p);
+ vn_finished_write(mp);
error1 = vn_close(vp, FWRITE, cred, p);
if (error == 0)
error = error1;