Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ata take mutex around check for pending flush, as th...



details:   https://anonhg.NetBSD.org/src/rev/7583156b8189
branches:  trunk
changeset: 319588:7583156b8189
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Jun 03 18:38:35 2018 +0000

description:
take mutex around check for pending flush, as the code before dksubr
conversion had, to avoid possible race

on my system doesn't really change behaviour, besides the test runs
being slightly faster (3x parallell pkgsrc archive extraction, up
to 5% difference), thought that can just be noise

done as part of investigation for PR kern/53183 by Sevan Janiyan

diffstat:

 sys/dev/ata/wd.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (40 lines):

diff -r dff5edbe38d7 -r 7583156b8189 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Sun Jun 03 16:09:31 2018 +0000
+++ b/sys/dev/ata/wd.c  Sun Jun 03 18:38:35 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $ */
+/*     $NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.438 2018/01/07 11:37:30 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.439 2018/06/03 18:38:35 jdolecek Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -765,6 +765,8 @@
        if (!device_is_active(dksc->sc_dev))
                return;
 
+       mutex_enter(&wd->sc_lock);
+
        /*
         * Do not queue any transfers until flush is finished, so that
         * once flush is pending, it will get handled as soon as xfer
@@ -773,9 +775,12 @@
        if (ISSET(wd->sc_flags, WDF_FLUSH_PEND)) {
                ATADEBUG_PRINT(("wdstart %s flush pend\n",
                    dksc->sc_xname), DEBUG_XFERS);
+               mutex_exit(&wd->sc_lock);
                return;
        }
 
+       mutex_exit(&wd->sc_lock);
+
        dk_start(dksc, NULL);
 }
 



Home | Main Index | Thread Index | Old Index