changeset 10995:33bbc4195426

6880784 Using format -e to change the disk cache settings does not update the device softstate, confusing sd
author bo zhou - Sun Microsystems - Beijing China <Bo.Zhou@Sun.COM>
date Sat, 07 Nov 2009 15:27:17 +0800
parents 6e5cc5c0a74f
children f4f8f596fbe7
files usr/src/uts/common/io/scsi/targets/sd.c
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/scsi/targets/sd.c	Fri Nov 06 22:58:25 2009 -0800
+++ b/usr/src/uts/common/io/scsi/targets/sd.c	Sat Nov 07 15:27:17 2009 +0800
@@ -22930,6 +22930,7 @@
 	case DKIOCSETWCE: {
 
 		int wce, sync_supported;
+		int cur_wce = 0;
 
 		if (ddi_copyin((void *)arg, &wce, sizeof (wce), flag)) {
 			err = EFAULT;
@@ -22962,6 +22963,18 @@
 
 		un->un_f_wcc_inprog = 1;
 
+		mutex_exit(SD_MUTEX(un));
+
+		/*
+		 * Get the current write cache state
+		 */
+		if ((err = sd_get_write_cache_enabled(ssc, &cur_wce)) != 0) {
+			break;
+		}
+
+		mutex_enter(SD_MUTEX(un));
+		un->un_f_write_cache_enabled = (cur_wce != 0);
+
 		if (un->un_f_write_cache_enabled && wce == 0) {
 			/*
 			 * Disable the write cache.  Don't clear