From 02cdfdd69aa5f84ff667bb2a2cb2a0387a3accba Mon Sep 17 00:00:00 2001 From: bo zhou - Sun Microsystems - Beijing China Date: Sat, 7 Nov 2009 15:27:17 +0800 Subject: 6880784 Using format -e to change the disk cache settings does not update the device softstate, confusing sd --- usr/src/uts/common/io/scsi/targets/sd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'usr/src/uts/common/io/scsi/targets/sd.c') diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c index 93b2d05519..cab4b1ab64 100644 --- a/usr/src/uts/common/io/scsi/targets/sd.c +++ b/usr/src/uts/common/io/scsi/targets/sd.c @@ -22930,6 +22930,7 @@ skip_ready_valid: 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 @@ skip_ready_valid: 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 -- cgit v1.2.3