summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/fs/specfs/spec_vnops.c25
-rw-r--r--sys/kern/subr_disk.c29
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c4
3 files changed, 26 insertions, 32 deletions
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
index 51c2792..9ae87c0 100644
--- a/sys/fs/specfs/spec_vnops.c
+++ b/sys/fs/specfs/spec_vnops.c
@@ -40,6 +40,7 @@
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/mutex.h>
#include <sys/conf.h>
#include <sys/bio.h>
#include <sys/buf.h>
@@ -493,6 +494,18 @@ loop2:
}
/*
+ * Mutex to use when delaying niced I/O bound processes in spec_strategy().
+ */
+static struct mtx strategy_mtx;
+static void
+strategy_init(void)
+{
+
+ mtx_init(&strategy_mtx, "strategy", NULL, MTX_DEF);
+}
+SYSINIT(strategy, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, strategy_init, NULL)
+
+/*
* Just call the device strategy routine
*/
static int
@@ -507,7 +520,17 @@ spec_strategy(ap)
struct mount *mp;
int error;
struct cdevsw *dsw;
-
+ struct thread *td = curthread;
+
+ /*
+ * Slow down disk requests for niced processes.
+ */
+ if (td && td->td_ksegrp->kg_nice > 0) {
+ mtx_lock(&strategy_mtx);
+ msleep(&strategy_mtx, &strategy_mtx,
+ PPAUSE | PCATCH | PDROP, "ioslow",
+ td->td_ksegrp->kg_nice);
+ }
bp = ap->a_bp;
vp = ap->a_vp;
if (bp->b_iocmd == BIO_WRITE) {
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index c61af99..d6943df 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -479,20 +479,6 @@ disk_err(struct bio *bp, const char *what, int blkdone, int nl)
printf("\n");
}
-#ifdef notquite
-/*
- * Mutex to use when delaying niced I/O bound processes in bioq_disksort().
- */
-static struct mtx dksort_mtx;
-static void
-dksort_init(void)
-{
-
- mtx_init(&dksort_mtx, "dksort", NULL, MTX_DEF);
-}
-SYSINIT(dksort, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dksort_init, NULL)
-#endif
-
/*
* Seek sort for disks.
*
@@ -517,21 +503,6 @@ bioq_disksort(bioq, bp)
struct bio *bn;
struct bio *be;
-#ifdef notquite
- struct thread *td = curthread;
-
- if (td && td->td_ksegrp->kg_nice > 0) {
- TAILQ_FOREACH(bn, &bioq->queue, bio_queue)
- if (BIOTOBUF(bp)->b_vp != BIOTOBUF(bn)->b_vp)
- break;
- if (bn != NULL) {
- mtx_lock(&dksort_mtx);
- msleep(&dksort_mtx, &dksort_mtx,
- PPAUSE | PCATCH | PDROP, "ioslow",
- td->td_ksegrp->kg_nice);
- }
- }
-#endif
if (!atomic_cmpset_int(&bioq->busy, 0, 1))
panic("Recursing in bioq_disksort()");
be = TAILQ_LAST(&bioq->queue, bio_queue);
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index 752822d..b22b193 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -493,8 +493,6 @@ out1:
* Resume operation on filesystem.
*/
vfs_write_resume(vp->v_mount);
- if (saved_nice > 0)
- td->td_ksegrp->kg_nice = saved_nice;
vn_start_write(NULL, &wrtmp, V_WAIT);
if (collectsnapstats && starttime.tv_sec > 0) {
nanotime(&endtime);
@@ -592,6 +590,8 @@ done:
free(copy_fs->fs_csp, M_UFSMNT);
bawrite(sbp);
out:
+ if (saved_nice > 0)
+ td->td_ksegrp->kg_nice = saved_nice;
if (fs->fs_active != 0) {
FREE(fs->fs_active, M_DEVBUF);
fs->fs_active = 0;
OpenPOWER on IntegriCloud