changeset 14042:e5bd6d1f1685

3505 Creating LU unconditionally enables write cache on backing store device Reviewed by: Vitaliy Gusev <vitaliy.gusev@nexenta.com> Reviewed by: Albert Lee <trisk@nexenta.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Ricard Lowe <richlowe@richlowe.net>
author Yuri Pankov <yuri.pankov@nexenta.com>
date Sun, 09 Jun 2013 14:38:37 +0400
parents cb4a51285eeb
children 0291cd939b43
files usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c
diffstat 1 files changed, 24 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c	Fri Jun 07 20:29:06 2013 -0800
+++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c	Sun Jun 09 14:38:37 2013 +0400
@@ -18,10 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- *
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  */
 
 #include <sys/conf.h>
@@ -1719,7 +1719,6 @@
 	char *namebuf;
 	sbd_lu_t *sl;
 	stmf_lu_t *lu;
-	sbd_status_t sret;
 	char *p;
 	int sz;
 	int alloc_sz;
@@ -1835,11 +1834,6 @@
 	if (slu->slu_write_protected) {
 		sl->sl_flags |= SL_WRITE_PROTECTED;
 	}
-	if (slu->slu_writeback_cache_disable) {
-		sl->sl_flags |= SL_WRITEBACK_CACHE_DISABLE |
-		    SL_SAVED_WRITE_CACHE_DISABLE;
-	}
-
 	if (slu->slu_blksize_valid) {
 		if ((slu->slu_blksize & (slu->slu_blksize - 1)) ||
 		    (slu->slu_blksize > (32 * 1024)) ||
@@ -1876,27 +1870,30 @@
 	}
 
 	/*
-	 * set write cache disable on the device
-	 * if it fails, we'll support it using sync/flush
+	 * Check if we were explicitly asked to disable/enable write
+	 * cache on the device, otherwise get current device setting.
 	 */
-	if (slu->slu_writeback_cache_disable) {
-		(void) sbd_wcd_set(1, sl);
-		wcd = 1;
-	/*
-	 * Attempt to set it to enable, if that fails and it was explicitly set
-	 * return an error, otherwise get the current setting and use that
-	 */
+	if (slu->slu_writeback_cache_disable_valid) {
+		if (slu->slu_writeback_cache_disable) {
+			/*
+			 * Set write cache disable on the device. If it fails,
+			 * we'll support it using sync/flush.
+			 */
+			(void) sbd_wcd_set(1, sl);
+			wcd = 1;
+		} else {
+			/*
+			 * Set write cache enable on the device. If it fails,
+			 * return an error.
+			 */
+			if (sbd_wcd_set(0, sl) != SBD_SUCCESS) {
+				*err_ret = SBD_RET_WRITE_CACHE_SET_FAILED;
+				ret = EFAULT;
+				goto scm_err_out;
+			}
+		}
 	} else {
-		sret = sbd_wcd_set(0, sl);
-		if (slu->slu_writeback_cache_disable_valid &&
-		    sret != SBD_SUCCESS) {
-			*err_ret = SBD_RET_WRITE_CACHE_SET_FAILED;
-			ret = EFAULT;
-			goto scm_err_out;
-		}
-		if (sret != SBD_SUCCESS) {
-			sbd_wcd_get(&wcd, sl);
-		}
+		sbd_wcd_get(&wcd, sl);
 	}
 
 	if (wcd) {