diff options
author | mckusick <mckusick@FreeBSD.org> | 1999-07-13 18:20:13 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 1999-07-13 18:20:13 +0000 |
commit | f091c51c34a496d3062026be39d6948fa02b6c6e (patch) | |
tree | 7cab0e079bf7fb1610e4cb41564952dc7ee44c83 | |
parent | 514e7c3963e88bf59518e2ba852c20fe7ca68df4 (diff) | |
download | FreeBSD-src-f091c51c34a496d3062026be39d6948fa02b6c6e.zip FreeBSD-src-f091c51c34a496d3062026be39d6948fa02b6c6e.tar.gz |
Create the macro DOINGASYNC to check whether the MNT_ASYNC flag has
been set for a mount point. Insert missing checks to ensure that all
write operations are done asynchronously when the MNT_ASYNC option
has been requested.
Submitted by: Craig A Soules <soules+@andrew.cmu.edu>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 3 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 14 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 21 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_readwrite.c | 9 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 31 |
8 files changed, 51 insertions, 39 deletions
diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index 9985449..77fe7b3 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.24 1998/10/13 15:45:43 bde Exp $ + * $Id: inode.h,v 1.25 1999/03/06 05:21:09 bde Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -147,6 +147,7 @@ struct indir { /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) +#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC) /* This overlays the fid structure (see mount.h). */ struct ufid { diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index 9985449..77fe7b3 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.24 1998/10/13 15:45:43 bde Exp $ + * $Id: inode.h,v 1.25 1999/03/06 05:21:09 bde Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -147,6 +147,7 @@ struct indir { /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) +#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC) /* This overlays the fid structure (see mount.h). */ struct ufid { diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 2410b92..5b3df8b 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95 - * $Id: ffs_balloc.c,v 1.21 1998/09/12 14:46:15 bde Exp $ + * $Id: ffs_balloc.c,v 1.22 1999/01/28 00:57:54 dillon Exp $ */ #include <sys/param.h> @@ -216,7 +216,9 @@ ffs_balloc(ap) * Write synchronously so that indirect blocks * never point at garbage. */ - if ((error = bwrite(bp)) != 0) + if (DOINGASYNC(vp)) + bdwrite(bp); + else if ((error = bwrite(bp)) != 0) goto fail; } allocib = &ip->i_ib[indirs[0].in_off]; diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index c80d0a5..0895173 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 - * $Id: ffs_inode.c,v 1.53 1999/01/28 00:57:54 dillon Exp $ + * $Id: ffs_inode.c,v 1.54 1999/05/02 23:56:48 alc Exp $ */ #include "opt_quota.h" @@ -107,7 +107,7 @@ ffs_update(vp, waitfor) panic("ffs_update: bad link cnt"); *((struct dinode *)bp->b_data + ino_to_fsbo(fs, ip->i_number)) = ip->i_din; - if (waitfor && (vp->v_mount->mnt_flag & MNT_ASYNC) == 0) { + if (waitfor && !DOINGASYNC(vp)) { return (bwrite(bp)); } else { if (bp->b_bufsize == fs->fs_bsize) @@ -218,8 +218,6 @@ ffs_truncate(vp, length, flags, cred, p) bp->b_flags |= B_CLUSTEROK; if (aflags & B_SYNC) bwrite(bp); - else if (ovp->v_mount->mnt_flag & MNT_ASYNC) - bdwrite(bp); else bawrite(bp); oip->i_flag |= IN_CHANGE | IN_UPDATE; @@ -256,8 +254,6 @@ ffs_truncate(vp, length, flags, cred, p) bp->b_flags |= B_CLUSTEROK; if (aflags & B_SYNC) bwrite(bp); - else if (ovp->v_mount->mnt_flag & MNT_ASYNC) - bdwrite(bp); else bawrite(bp); } @@ -472,12 +468,12 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize); bzero((caddr_t)&bap[last + 1], (u_int)(NINDIR(fs) - (last + 1)) * sizeof (ufs_daddr_t)); - if ((vp->v_mount->mnt_flag & MNT_ASYNC) == 0) { + if (DOINGASYNC(vp)) { + bawrite(bp); + } else { error = bwrite(bp); if (error) allerror = error; - } else { - bawrite(bp); } bap = copy; } diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 9985449..77fe7b3 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.24 1998/10/13 15:45:43 bde Exp $ + * $Id: inode.h,v 1.25 1999/03/06 05:21:09 bde Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -147,6 +147,7 @@ struct indir { /* Determine if soft dependencies are being done */ #define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP) +#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC) /* This overlays the fid structure (see mount.h). */ struct ufid { diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index dbbfefb..29e5227 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_lookup.c 8.15 (Berkeley) 6/16/95 - * $Id: ufs_lookup.c,v 1.27 1999/01/28 00:57:56 dillon Exp $ + * $Id: ufs_lookup.c,v 1.28 1999/06/16 23:27:51 mckusick Exp $ */ #include <sys/param.h> @@ -687,7 +687,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) if (dp->i_offset & (DIRBLKSIZ - 1)) panic("ufs_direnter: newblk"); flags = B_CLRBUF; - if (!DOINGSOFTDEP(dvp)) + if (!DOINGSOFTDEP(dvp) && !DOINGASYNC(dvp)) flags |= B_SYNC; if ((error = VOP_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ, cr, flags, &bp)) != 0) { @@ -718,10 +718,14 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) softdep_setup_directory_add(bp, dp, dp->i_offset, dirp->d_ino, newdirbp); bdwrite(bp); - } else { - error = VOP_BWRITE(bp->b_vp, bp); + return (UFS_UPDATE(dvp, 0)); + } + if (DOINGASYNC(dvp)) { + bdwrite(bp); + return (UFS_UPDATE(dvp, 0)); } - ret = UFS_UPDATE(dvp, !DOINGSOFTDEP(dvp)); + error = VOP_BWRITE(bp->b_vp, bp); + ret = UFS_UPDATE(dvp, 1); if (error == 0) return (ret); return (error); @@ -806,7 +810,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) dp->i_offset + (caddr_t)ep - dirbuf, dirp->d_ino, newdirbp); bdwrite(bp); } else { - if (dvp->v_mount->mnt_flag & MNT_ASYNC) { + if (DOINGASYNC(dvp)) { bdwrite(bp); error = 0; } else { @@ -897,8 +901,7 @@ out: ip->i_nlink--; if (flags & DOWHITEOUT) error = VOP_BWRITE(bp->b_vp, bp); - else if (dvp->v_mount->mnt_flag & MNT_ASYNC - && dp->i_count != 0) { + else if (DOINGASYNC(dvp) && dp->i_count != 0) { bdwrite(bp); error = 0; } else @@ -938,7 +941,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype, isrmdir) bdwrite(bp); } else { oip->i_nlink--; - if (vdp->v_mount->mnt_flag & MNT_ASYNC) { + if (DOINGASYNC(vdp)) { bdwrite(bp); error = 0; } else { diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 53f980a..51a934f 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 - * $Id: ufs_readwrite.c,v 1.58 1999/04/05 19:38:30 julian Exp $ + * $Id: ufs_readwrite.c,v 1.59 1999/07/08 06:06:00 mckusick Exp $ */ #define BLKSIZE(a, b, c) blksize(a, b, c) @@ -399,8 +399,7 @@ WRITE(ap) case VLNK: break; case VDIR: - if ((ioflag & IO_SYNC) == 0) - panic("%s: nonsync dir write", WRITE_S); + panic("%s: dir write", WRITE_S); break; default: panic("%s: type %p %d (%d,%d)", WRITE_S, vp, (int)vp->v_type, @@ -432,7 +431,9 @@ WRITE(ap) resid = uio->uio_resid; osize = ip->i_size; - flags = ioflag & IO_SYNC ? B_SYNC : 0; + flags = 0; + if ((ioflag & IO_SYNC) && !DOINGASYNC(vp)) + flags = B_SYNC; if (object && (object->flags & OBJ_OPT)) { vm_freeze_copyopts(object, diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 3526115..04006b7 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 - * $Id: ufs_vnops.c,v 1.114 1999/05/11 19:55:05 phk Exp $ + * $Id: ufs_vnops.c,v 1.115 1999/06/16 23:27:53 mckusick Exp $ */ #include "opt_quota.h" @@ -759,7 +759,7 @@ ufs_link(ap) ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(vp)) softdep_increase_linkcnt(ip); - error = UFS_UPDATE(vp, !DOINGSOFTDEP(vp)); + error = UFS_UPDATE(vp, !(DOINGSOFTDEP(vp) | DOINGASYNC(vp))); if (!error) { ufs_makedirentry(ip, cnp, &newdir); error = ufs_direnter(tdvp, vp, &newdir, cnp, NULL); @@ -884,7 +884,7 @@ ufs_rename(ap) struct inode *ip, *xp, *dp; struct direct newdir; int doingdirectory = 0, oldparent = 0, newparent = 0; - int error = 0; + int error = 0, ioflag; #ifdef DIAGNOSTIC if ((tcnp->cn_flags & HASBUF) == 0 || @@ -1027,7 +1027,8 @@ abortit: ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(fvp)) softdep_increase_linkcnt(ip); - if ((error = UFS_UPDATE(fvp, !DOINGSOFTDEP(fvp))) != 0) { + if ((error = UFS_UPDATE(fvp, !(DOINGSOFTDEP(fvp) | + DOINGASYNC(fvp)))) != 0) { VOP_UNLOCK(fvp, 0, p); goto bad; } @@ -1091,7 +1092,8 @@ abortit: dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_increase_linkcnt(dp); - error = UFS_UPDATE(tdvp, !DOINGSOFTDEP(tdvp)); + error = UFS_UPDATE(tdvp, !(DOINGSOFTDEP(tdvp) | + DOINGASYNC(tdvp))); if (error) goto bad; } @@ -1177,7 +1179,8 @@ abortit: if (!newparent) dp->i_nlink--; xp->i_nlink--; - if ((error = UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC, + ioflag = DOINGASYNC(tvp) ? 0 : IO_SYNC; + if ((error = UFS_TRUNCATE(tvp, (off_t)0, ioflag, tcnp->cn_cred, tcnp->cn_proc)) != 0) goto bad; } @@ -1384,7 +1387,7 @@ ufs_mkdir(ap) dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(dvp)) softdep_increase_linkcnt(dp); - error = UFS_UPDATE(tvp, !DOINGSOFTDEP(dvp)); + error = UFS_UPDATE(tvp, !(DOINGSOFTDEP(dvp) | DOINGASYNC(dvp))); if (error) goto bad; @@ -1420,7 +1423,8 @@ ufs_mkdir(ap) blkoff += DIRBLKSIZ; } } - if ((error = UFS_UPDATE(tvp, !DOINGSOFTDEP(tvp))) != 0) { + if ((error = UFS_UPDATE(tvp, !(DOINGSOFTDEP(tvp) | + DOINGASYNC(tvp)))) != 0) { (void)VOP_BWRITE(bp->b_vp, bp); goto bad; } @@ -1436,7 +1440,9 @@ ufs_mkdir(ap) * an appropriate ordering dependency to the buffer which ensures that * the buffer is written before the new name is written in the parent. */ - if (!DOINGSOFTDEP(dvp) && ((error = VOP_BWRITE(bp->b_vp, bp)) != 0)) + if (DOINGASYNC(dvp)) + bdwrite(bp); + else if (!DOINGSOFTDEP(dvp) && ((error = VOP_BWRITE(bp->b_vp, bp)))) goto bad; ufs_makedirentry(ip, cnp, &newdir); error = ufs_direnter(dvp, tvp, &newdir, cnp, bp); @@ -1477,7 +1483,7 @@ ufs_rmdir(ap) struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; struct inode *ip, *dp; - int error; + int error, ioflag; ip = VTOI(vp); dp = VTOI(dvp); @@ -1537,7 +1543,8 @@ ufs_rmdir(ap) if (!DOINGSOFTDEP(vp)) { dp->i_nlink--; ip->i_nlink--; - error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, + ioflag = DOINGASYNC(vp) ? 0 : IO_SYNC; + error = UFS_TRUNCATE(vp, (off_t)0, ioflag, cnp->cn_cred, cnp->cn_proc); } cache_purge(vp); @@ -2175,7 +2182,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) /* * Make sure inode goes to disk before directory entry. */ - error = UFS_UPDATE(tvp, !DOINGSOFTDEP(tvp)); + error = UFS_UPDATE(tvp, !(DOINGSOFTDEP(tvp) | DOINGASYNC(tvp))); if (error) goto bad; ufs_makedirentry(ip, cnp, &newdir); |