summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2005-09-30 01:30:01 +0000
committertruckman <truckman@FreeBSD.org>2005-09-30 01:30:01 +0000
commit414043e88df9287115e6133263316c8346532605 (patch)
tree1f814a73e0737d738ff28d17be42b438cdc748d5 /sys/ufs
parent3ddc14f22ce145bcd209c232cb62a7086e4e285d (diff)
downloadFreeBSD-src-414043e88df9287115e6133263316c8346532605.zip
FreeBSD-src-414043e88df9287115e6133263316c8346532605.tar.gz
Un-staticize runningbufwakeup() and staticize updateproc.
Add a new private thread flag to indicate that the thread should not sleep if runningbufspace is too large. Set this flag on the bufdaemon and syncer threads so that they skip the waitrunningbufspace() call in bufwrite() rather than than checking the proc pointer vs. the known proc pointers for these two threads. A way of preventing these threads from being starved for I/O but still placing limits on their outstanding I/O would be desirable. Set this flag in ffs_copyonwrite() to prevent bufwrite() calls from blocking on the runningbufspace check while holding snaplk. This prevents snaplk from being held for an arbitrarily long period of time if runningbufspace is high and greatly reduces the contention for snaplk. The disadvantage is that ffs_copyonwrite() can start a large amount of I/O if there are a large number of snapshots, which could cause a deadlock in other parts of the code. Call runningbufwakeup() in ffs_copyonwrite() to decrement runningbufspace before attempting to grab snaplk so that I/O requests waiting on snaplk are not counted in runningbufspace as being in-progress. Increment runningbufspace again before actually launching the original I/O request. Prior to the above two changes, the system could deadlock if enough I/O requests were blocked by snaplk to prevent runningbufspace from falling below lorunningspace and one of the bawrite() calls in ffs_copyonwrite() blocked in waitrunningbufspace() while holding snaplk. See <http://www.holm.cc/stress/log/cons143.html>
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index c134461..3e7e231 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -1998,6 +1998,12 @@ ffs_copyonwrite(devvp, bp)
return (0);
}
/*
+ * Since I/O on bp isn't yet in progress and it may be blocked
+ * for a long time waiting on snaplk, back it out of
+ * runningbufspace, possibly waking other threads waiting for space.
+ */
+ runningbufwakeup(bp);
+ /*
* Not in the precomputed list, so check the snapshots.
*/
retry:
@@ -2028,7 +2034,7 @@ retry:
goto retry;
}
snapshot_locked = 1;
- td->td_pflags |= TDP_COWINPROGRESS;
+ td->td_pflags |= TDP_COWINPROGRESS | TDP_NORUNNINGBUF;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp);
td->td_pflags &= ~TDP_COWINPROGRESS;
@@ -2065,7 +2071,7 @@ retry:
goto retry;
}
snapshot_locked = 1;
- td->td_pflags |= TDP_COWINPROGRESS;
+ td->td_pflags |= TDP_COWINPROGRESS | TDP_NORUNNINGBUF;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, 0, &cbp);
td->td_pflags &= ~TDP_COWINPROGRESS;
@@ -2120,10 +2126,16 @@ retry:
if (dopersistence && VTOI(vp)->i_effnlink > 0)
(void) ffs_syncvnode(vp, MNT_WAIT);
}
- if (snapshot_locked)
+ if (snapshot_locked) {
lockmgr(vp->v_vnlock, LK_RELEASE, NULL, td);
- else
+ td->td_pflags &= ~TDP_NORUNNINGBUF;
+ } else
VI_UNLOCK(devvp);
+ /*
+ * I/O on bp will now be started, so count it in runningbufspace.
+ */
+ if (bp->b_runningbufspace)
+ atomic_add_int(&runningbufspace, bp->b_runningbufspace);
return (error);
}
OpenPOWER on IntegriCloud