diff options
author | mckusick <mckusick@FreeBSD.org> | 2000-07-11 22:07:57 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2000-07-11 22:07:57 +0000 |
commit | a3d0c189ea25a7af3dfab30112f5d8d65e214e1c (patch) | |
tree | c84458dcf49aaf90ff010ebc108cb3b6ca3c2f4a /sys/gnu | |
parent | c8c04452402a28eabd1ed8a1a06e0a14ac3d22c6 (diff) | |
download | FreeBSD-src-a3d0c189ea25a7af3dfab30112f5d8d65e214e1c.zip FreeBSD-src-a3d0c189ea25a7af3dfab30112f5d8d65e214e1c.tar.gz |
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).
Diffstat (limited to 'sys/gnu')
-rw-r--r-- | sys/gnu/ext2fs/ext2_bmap.c | 23 | ||||
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 1 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_bmap.c | 23 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 1 |
4 files changed, 34 insertions, 14 deletions
diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c index 9056340..ab4ac52 100644 --- a/sys/gnu/ext2fs/ext2_bmap.c +++ b/sys/gnu/ext2fs/ext2_bmap.c @@ -47,6 +47,7 @@ #include <sys/vnode.h> #include <sys/mount.h> #include <sys/resourcevar.h> +#include <sys/stat.h> #include <ufs/ufs/extattr.h> #include <ufs/ufs/quota.h> @@ -115,7 +116,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct indir a[NIADDR+1], *xap; ufs_daddr_t daddr; long metalbn; - int error, maxrun, num; + int error, num, maxrun = 0; ip = VTOI(vp); mp = vp->v_mount; @@ -127,6 +128,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) #endif if (runp) { + maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; *runp = 0; } @@ -134,7 +136,6 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) *runb = 0; } - maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; xap = ap == NULL ? a : ap; if (!nump) @@ -146,9 +147,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) num = *nump; if (num == 0) { *bnp = blkptrtodb(ump, ip->i_db[bn]); - if (*bnp == 0) - *bnp = -1; - else if (runp) { + if (*bnp == 0) { + if (ip->i_flags & SF_SNAPSHOT) + *bnp = blkptrtodb(ump, bn * ump->um_seqinc); + else + *bnp = -1; + } else if (runp) { daddr_t bnb = bn; for (++bn; bn < NDADDR && *runp < maxrun && is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]); @@ -226,8 +230,13 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) if (bp) bqrelse(bp); - daddr = blkptrtodb(ump, daddr); - *bnp = daddr == 0 ? -1 : daddr; + *bnp = blkptrtodb(ump, daddr); + if (*bnp == 0) { + if (ip->i_flags & SF_SNAPSHOT) + *bnp = blkptrtodb(ump, bn * ump->um_seqinc); + else + *bnp = -1; + } return (0); } diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index 83960b0..6417a10 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -84,6 +84,7 @@ struct inode { struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ + struct inode *i_copyonwrite; /* copy-on-write list */ /* * Side effects; used during directory lookup. */ diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c index 9056340..ab4ac52 100644 --- a/sys/gnu/fs/ext2fs/ext2_bmap.c +++ b/sys/gnu/fs/ext2fs/ext2_bmap.c @@ -47,6 +47,7 @@ #include <sys/vnode.h> #include <sys/mount.h> #include <sys/resourcevar.h> +#include <sys/stat.h> #include <ufs/ufs/extattr.h> #include <ufs/ufs/quota.h> @@ -115,7 +116,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct indir a[NIADDR+1], *xap; ufs_daddr_t daddr; long metalbn; - int error, maxrun, num; + int error, num, maxrun = 0; ip = VTOI(vp); mp = vp->v_mount; @@ -127,6 +128,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) #endif if (runp) { + maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; *runp = 0; } @@ -134,7 +136,6 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) *runb = 0; } - maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; xap = ap == NULL ? a : ap; if (!nump) @@ -146,9 +147,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) num = *nump; if (num == 0) { *bnp = blkptrtodb(ump, ip->i_db[bn]); - if (*bnp == 0) - *bnp = -1; - else if (runp) { + if (*bnp == 0) { + if (ip->i_flags & SF_SNAPSHOT) + *bnp = blkptrtodb(ump, bn * ump->um_seqinc); + else + *bnp = -1; + } else if (runp) { daddr_t bnb = bn; for (++bn; bn < NDADDR && *runp < maxrun && is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]); @@ -226,8 +230,13 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) if (bp) bqrelse(bp); - daddr = blkptrtodb(ump, daddr); - *bnp = daddr == 0 ? -1 : daddr; + *bnp = blkptrtodb(ump, daddr); + if (*bnp == 0) { + if (ip->i_flags & SF_SNAPSHOT) + *bnp = blkptrtodb(ump, bn * ump->um_seqinc); + else + *bnp = -1; + } return (0); } diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index 83960b0..6417a10 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -84,6 +84,7 @@ struct inode { struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ + struct inode *i_copyonwrite; /* copy-on-write list */ /* * Side effects; used during directory lookup. */ |