summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2012-03-25 00:02:37 +0000
committermckusick <mckusick@FreeBSD.org>2012-03-25 00:02:37 +0000
commite6ce77b8ea66bba7bcb79a01ae6d6cdff763ff4f (patch)
treec6eb532f373fe63d2db8d2cd447bf0bb69ae2d21
parentdfeac3e82445b83c514221770b5f546e26f11219 (diff)
downloadFreeBSD-src-e6ce77b8ea66bba7bcb79a01ae6d6cdff763ff4f.zip
FreeBSD-src-e6ce77b8ea66bba7bcb79a01ae6d6cdff763ff4f.tar.gz
Add a third flags argument to ffs_syncvnode to avoid a possible conflict
with MNT_WAIT flags that passed in its second argument. This will be MFC'ed together with r232351. Discussed with: kib
-rw-r--r--sys/ufs/ffs/ffs_balloc.c8
-rw-r--r--sys/ufs/ffs/ffs_extern.h7
-rw-r--r--sys/ufs/ffs/ffs_inode.c6
-rw-r--r--sys/ufs/ffs/ffs_rawread.c2
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c26
-rw-r--r--sys/ufs/ffs/ffs_softdep.c18
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c2
-rw-r--r--sys/ufs/ffs/ffs_vnops.c14
8 files changed, 40 insertions, 43 deletions
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index f6b078f..2a3327e 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -450,7 +450,7 @@ fail:
*
* XXX Still have to journal the free below
*/
- (void) ffs_syncvnode(vp, MNT_WAIT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, 0);
for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
blkp < allocblk; blkp++, lbns_remfree++) {
/*
@@ -497,7 +497,7 @@ fail:
dp->di_blocks -= btodb(deallocated);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
- (void) ffs_syncvnode(vp, MNT_WAIT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, 0);
/*
* After the buffers are invalidated and on-disk pointers are
* cleared, free the blocks.
@@ -994,7 +994,7 @@ fail:
*
* XXX Still have to journal the free below
*/
- (void) ffs_syncvnode(vp, MNT_WAIT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, 0);
for (deallocated = 0, blkp = allociblk, lbns_remfree = lbns;
blkp < allocblk; blkp++, lbns_remfree++) {
/*
@@ -1041,7 +1041,7 @@ fail:
dp->di_blocks -= btodb(deallocated);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
- (void) ffs_syncvnode(vp, MNT_WAIT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, 0);
/*
* After the buffers are invalidated and on-disk pointers are
* cleared, free the blocks.
diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h
index 258966c..bb37571 100644
--- a/sys/ufs/ffs/ffs_extern.h
+++ b/sys/ufs/ffs/ffs_extern.h
@@ -92,7 +92,7 @@ void ffs_snapshot_mount(struct mount *mp);
void ffs_snapshot_unmount(struct mount *mp);
void process_deferred_inactive(struct mount *mp);
void ffs_sync_snap(struct mount *, int);
-int ffs_syncvnode(struct vnode *vp, int waitfor);
+int ffs_syncvnode(struct vnode *vp, int waitfor, int flags);
int ffs_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *);
int ffs_update(struct vnode *, int);
int ffs_valloc(struct vnode *, int, struct ucred *, struct vnode **);
@@ -168,12 +168,11 @@ void softdep_freework(struct workhead *);
#define FLUSH_BLOCKS 3
#define FLUSH_BLOCKS_WAIT 4
/*
- * Flag to ffs_syncinode() to request flushing of data only,
+ * Flag to ffs_syncvnode() to request flushing of data only,
* but skip the ffs_update() on the inode itself. Used to avoid
* deadlock when flushing snapshot inodes while holding snaplk.
- * Avoid bit conflicts with MNT_WAIT values in sys/mount.h
*/
-#define NO_INO_UPDT 0x10
+#define NO_INO_UPDT 0x00000001
int ffs_rdonly(struct inode *);
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 9afbbe6..9d0144a 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -228,7 +228,7 @@ ffs_truncate(vp, length, flags, cred, td)
goto extclean;
needextclean = 1;
} else {
- if ((error = ffs_syncvnode(vp, MNT_WAIT)) != 0)
+ if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
return (error);
#ifdef QUOTA
(void) chkdq(ip, -extblocks, NOCRED, 0);
@@ -321,7 +321,7 @@ ffs_truncate(vp, length, flags, cred, td)
* rarely, we solve the problem by syncing the file
* so that it will have no data structures left.
*/
- if ((error = ffs_syncvnode(vp, MNT_WAIT)) != 0)
+ if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
return (error);
} else {
flags = IO_NORMAL | (needextclean ? IO_EXT: 0);
@@ -366,7 +366,7 @@ ffs_truncate(vp, length, flags, cred, td)
*/
if (DOINGSOFTDEP(vp) && lbn < NDADDR &&
fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize &&
- (error = ffs_syncvnode(vp, MNT_WAIT)) != 0)
+ (error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
return (error);
ip->i_size = length;
DIP_SET(ip, i_size, length);
diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c
index 6c30d14..f8e3e00 100644
--- a/sys/ufs/ffs/ffs_rawread.c
+++ b/sys/ufs/ffs/ffs_rawread.c
@@ -163,7 +163,7 @@ ffs_rawread_sync(struct vnode *vp)
/* Flush dirty buffers */
if (bo->bo_dirty.bv_cnt > 0) {
BO_UNLOCK(bo);
- if ((error = ffs_syncvnode(vp, MNT_WAIT)) != 0) {
+ if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0) {
if (upgraded != 0)
VOP_LOCK(vp, LK_DOWNGRADE);
vn_finished_write(mp);
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index c930f5d..dfd0040 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -362,7 +362,7 @@ restart:
goto out;
bawrite(nbp);
if (cg % 10 == 0)
- ffs_syncvnode(vp, MNT_WAIT);
+ ffs_syncvnode(vp, MNT_WAIT, 0);
}
/*
* Copy all the cylinder group maps. Although the
@@ -385,7 +385,7 @@ restart:
error = cgaccount(cg, vp, nbp, 1);
bawrite(nbp);
if (cg % 10 == 0)
- ffs_syncvnode(vp, MNT_WAIT);
+ ffs_syncvnode(vp, MNT_WAIT, 0);
if (error)
goto out;
}
@@ -400,7 +400,7 @@ restart:
* Since we have marked it as a snapshot it is safe to
* unlock it as no process will be allowed to write to it.
*/
- if ((error = ffs_syncvnode(vp, MNT_WAIT)) != 0)
+ if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
goto out;
VOP_UNLOCK(vp, 0);
/*
@@ -861,7 +861,7 @@ out:
MNT_IUNLOCK(mp);
if (error)
(void) ffs_truncate(vp, (off_t)0, 0, NOCRED, td);
- (void) ffs_syncvnode(vp, MNT_WAIT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, 0);
if (error)
vput(vp);
else
@@ -1714,7 +1714,7 @@ ffs_snapremove(vp)
* may find indirect pointers using the magic BLK_* values.
*/
if (DOINGSOFTDEP(vp))
- ffs_syncvnode(vp, MNT_WAIT);
+ ffs_syncvnode(vp, MNT_WAIT, 0);
#ifdef QUOTA
/*
* Reenable disk quotas for ex-snapshot file.
@@ -1908,7 +1908,7 @@ retry:
bawrite(cbp);
if ((vtype == VDIR || dopersistence) &&
ip->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
continue;
}
/*
@@ -1919,7 +1919,7 @@ retry:
bawrite(cbp);
if ((vtype == VDIR || dopersistence) &&
ip->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
break;
}
savedcbp = cbp;
@@ -1937,7 +1937,7 @@ retry:
bawrite(savedcbp);
if ((vtype == VDIR || dopersistence) &&
VTOI(vp)->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
}
/*
* If we have been unable to allocate a block in which to do
@@ -2000,7 +2000,7 @@ ffs_snapshot_mount(mp)
} else {
reason = "old format snapshot";
(void)ffs_truncate(vp, (off_t)0, 0, NOCRED, td);
- (void)ffs_syncvnode(vp, MNT_WAIT);
+ (void)ffs_syncvnode(vp, MNT_WAIT, 0);
}
printf("ffs_snapshot_mount: %s inode %d\n",
reason, fs->fs_snapinum[snaploc]);
@@ -2401,7 +2401,7 @@ ffs_copyonwrite(devvp, bp)
bawrite(cbp);
if ((devvp == bp->b_vp || bp->b_vp->v_type == VDIR ||
dopersistence) && ip->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
else
launched_async_io = 1;
continue;
@@ -2414,7 +2414,7 @@ ffs_copyonwrite(devvp, bp)
bawrite(cbp);
if ((devvp == bp->b_vp || bp->b_vp->v_type == VDIR ||
dopersistence) && ip->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
else
launched_async_io = 1;
break;
@@ -2434,7 +2434,7 @@ ffs_copyonwrite(devvp, bp)
bawrite(savedcbp);
if ((devvp == bp->b_vp || bp->b_vp->v_type == VDIR ||
dopersistence) && VTOI(vp)->i_effnlink > 0)
- (void) ffs_syncvnode(vp, MNT_WAIT|NO_INO_UPDT);
+ (void) ffs_syncvnode(vp, MNT_WAIT, NO_INO_UPDT);
else
launched_async_io = 1;
}
@@ -2484,7 +2484,7 @@ ffs_sync_snap(mp, waitfor)
}
TAILQ_FOREACH(ip, &sn->sn_head, i_nextsnap) {
vp = ITOV(ip);
- ffs_syncvnode(vp, waitfor|NO_INO_UPDT);
+ ffs_syncvnode(vp, waitfor, NO_INO_UPDT);
}
lockmgr(&sn->sn_lock, LK_RELEASE, NULL);
}
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 8797497..34567ca 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -2848,7 +2848,7 @@ softdep_prealloc(vp, waitok)
* work attached to it.
*/
if ((curthread->td_pflags & TDP_COWINPROGRESS) == 0)
- ffs_syncvnode(vp, waitok);
+ ffs_syncvnode(vp, waitok, 0);
ACQUIRE_LOCK(&lk);
process_removes(vp);
process_truncates(vp);
@@ -2887,8 +2887,8 @@ softdep_prelink(dvp, vp)
stat_journal_low++;
FREE_LOCK(&lk);
if (vp)
- ffs_syncvnode(vp, MNT_NOWAIT);
- ffs_syncvnode(dvp, MNT_WAIT);
+ ffs_syncvnode(vp, MNT_NOWAIT, 0);
+ ffs_syncvnode(dvp, MNT_WAIT, 0);
ACQUIRE_LOCK(&lk);
/* Process vp before dvp as it may create .. removes. */
if (vp) {
@@ -11841,8 +11841,8 @@ restart:
pagedep_new_block = pagedep->pd_state & NEWBLOCK;
FREE_LOCK(&lk);
locked = 0;
- if (pagedep_new_block &&
- (error = ffs_syncvnode(pvp, MNT_WAIT))) {
+ if (pagedep_new_block && (error =
+ ffs_syncvnode(pvp, MNT_WAIT, 0))) {
vput(pvp);
return (error);
}
@@ -12683,7 +12683,7 @@ retry:
MNT_ILOCK(mp);
continue;
}
- (void) ffs_syncvnode(lvp, MNT_NOWAIT);
+ (void) ffs_syncvnode(lvp, MNT_NOWAIT, 0);
vput(lvp);
MNT_ILOCK(mp);
}
@@ -12856,7 +12856,7 @@ clear_remove(td)
softdep_error("clear_remove: vget", error);
goto finish_write;
}
- if ((error = ffs_syncvnode(vp, MNT_NOWAIT)))
+ if ((error = ffs_syncvnode(vp, MNT_NOWAIT, 0)))
softdep_error("clear_remove: fsync", error);
bo = &vp->v_bufobj;
BO_LOCK(bo);
@@ -12939,10 +12939,10 @@ clear_inodedeps(td)
}
vfs_unbusy(mp);
if (ino == lastino) {
- if ((error = ffs_syncvnode(vp, MNT_WAIT)))
+ if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)))
softdep_error("clear_inodedeps: fsync1", error);
} else {
- if ((error = ffs_syncvnode(vp, MNT_NOWAIT)))
+ if ((error = ffs_syncvnode(vp, MNT_NOWAIT, 0)))
softdep_error("clear_inodedeps: fsync2", error);
BO_LOCK(&vp->v_bufobj);
drain_output(vp);
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index a12fd83..0475600 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1505,7 +1505,7 @@ loop:
}
continue;
}
- if ((error = ffs_syncvnode(vp, waitfor)) != 0)
+ if ((error = ffs_syncvnode(vp, waitfor, 0)) != 0)
allerror = error;
vput(vp);
MNT_ILOCK(mp);
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index d7fc089..4452991 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -184,7 +184,7 @@ ffs_fsync(struct vop_fsync_args *ap)
vp = ap->a_vp;
bo = &vp->v_bufobj;
retry:
- error = ffs_syncvnode(vp, ap->a_waitfor);
+ error = ffs_syncvnode(vp, ap->a_waitfor, 0);
if (error)
return (error);
if (ap->a_waitfor == MNT_WAIT && DOINGSOFTDEP(vp)) {
@@ -209,17 +209,15 @@ retry:
}
int
-ffs_syncvnode(struct vnode *vp, int waitfor)
+ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
{
struct inode *ip;
struct bufobj *bo;
struct buf *bp;
struct buf *nbp;
ufs_lbn_t lbn;
- int error, wait, passes, noupdate;
+ int error, wait, passes;
- noupdate = waitfor & NO_INO_UPDT;
- waitfor &= ~NO_INO_UPDT;
ip = VTOI(vp);
ip->i_flag &= ~IN_NEEDSYNC;
bo = &vp->v_bufobj;
@@ -302,7 +300,7 @@ next:
}
if (waitfor != MNT_WAIT) {
BO_UNLOCK(bo);
- if (noupdate)
+ if ((flags & NO_INO_UPDT) != 0)
return (0);
else
return (ffs_update(vp, 0));
@@ -322,7 +320,7 @@ next:
*/
if (bo->bo_dirty.bv_cnt > 0) {
/* Write the inode after sync passes to flush deps. */
- if (wait && DOINGSOFTDEP(vp) && noupdate == 0) {
+ if (wait && DOINGSOFTDEP(vp) && (flags & NO_INO_UPDT) == 0) {
BO_UNLOCK(bo);
ffs_update(vp, 1);
BO_LOCK(bo);
@@ -338,7 +336,7 @@ next:
}
BO_UNLOCK(bo);
error = 0;
- if (noupdate == 0)
+ if ((flags & NO_INO_UPDT) == 0)
error = ffs_update(vp, 1);
if (DOINGSUJ(vp))
softdep_journal_fsync(VTOI(vp));
OpenPOWER on IntegriCloud