Module Name:    src
Committed By:   jdolecek
Date:           Sun Jun  3 18:38:36 UTC 2018

Modified Files:
        src/sys/dev/ata: wd.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.438 -r1.439 src/sys/dev/ata/wd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.438 src/sys/dev/ata/wd.c:1.439
--- src/sys/dev/ata/wd.c:1.438	Sun Jan  7 11:37:30 2018
+++ src/sys/dev/ata/wd.c	Sun Jun  3 18:38:35 2018
@@ -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 @@ wdstart(device_t self)
 	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 @@ wdstart(device_t self)
 	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);
 }
 

Reply via email to