svn commit: r271505 - in head: sys/cam/ctl usr.sbin/ctladm

Alexander Motin mav at FreeBSD.org
Sat Sep 13 08:55:23 UTC 2014


Author: mav
Date: Sat Sep 13 08:55:22 2014
New Revision: 271505
URL: http://svnweb.freebsd.org/changeset/base/271505

Log:
  Add "readcache" and "writecache" LUN options to control default behavior.
  
  Default values are "on".  Disabling requires backend to support IO_DIRECT
  and IO_SYNC flags respectively, or some alternatives.

Modified:
  head/sys/cam/ctl/ctl.c
  head/usr.sbin/ctladm/ctladm.8

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Sat Sep 13 08:26:09 2014	(r271504)
+++ head/sys/cam/ctl/ctl.c	Sat Sep 13 08:55:22 2014	(r271505)
@@ -4095,6 +4095,7 @@ ctl_init_page_index(struct ctl_lun *lun)
 	int i;
 	struct ctl_page_index *page_index;
 	struct ctl_softc *softc;
+	const char *value;
 
 	memcpy(&lun->mode_pages.index, page_index_template,
 	       sizeof(page_index_template));
@@ -4244,26 +4245,31 @@ ctl_init_page_index(struct ctl_lun *lun)
 			break;
 		}
 		case SMS_CACHING_PAGE: {
+			struct scsi_caching_page *caching_page;
 
 			if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
 				panic("invalid subpage value %d",
 				      page_index->subpage);
-			/*
-			 * Defaults should be okay here, no calculations
-			 * needed.
-			 */
-			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_CURRENT],
+			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_DEFAULT],
 			       &caching_page_default,
 			       sizeof(caching_page_default));
 			memcpy(&lun->mode_pages.caching_page[
 			       CTL_PAGE_CHANGEABLE], &caching_page_changeable,
 			       sizeof(caching_page_changeable));
-			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_DEFAULT],
-			       &caching_page_default,
-			       sizeof(caching_page_default));
 			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_SAVED],
 			       &caching_page_default,
 			       sizeof(caching_page_default));
+			caching_page = &lun->mode_pages.caching_page[
+			    CTL_PAGE_SAVED];
+			value = ctl_get_opt(&lun->be_lun->options, "writecache");
+			if (value != NULL && strcmp(value, "off") == 0)
+				caching_page->flags1 &= ~SCP_WCE;
+			value = ctl_get_opt(&lun->be_lun->options, "readcache");
+			if (value != NULL && strcmp(value, "off") == 0)
+				caching_page->flags1 |= SCP_RCD;
+			memcpy(&lun->mode_pages.caching_page[CTL_PAGE_CURRENT],
+			       &lun->mode_pages.caching_page[CTL_PAGE_SAVED],
+			       sizeof(caching_page_default));
 			page_index->page_data =
 				(uint8_t *)lun->mode_pages.caching_page;
 			break;

Modified: head/usr.sbin/ctladm/ctladm.8
==============================================================================
--- head/usr.sbin/ctladm/ctladm.8	Sat Sep 13 08:26:09 2014	(r271504)
+++ head/usr.sbin/ctladm/ctladm.8	Sat Sep 13 08:55:22 2014	(r271505)
@@ -34,7 +34,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
 .\" $FreeBSD$
 .\"
-.Dd July 9, 2014
+.Dd September 13, 2014
 .Dt CTLADM 8
 .Os
 .Sh NAME
@@ -959,8 +959,12 @@ Setting to "on" allows EXTENDED COPY com
 other LUNs on this host, not accessible otherwise.
 This allows to offload copying between different iSCSI targets residing
 on the same host in trusted environments.
+.It Va readcache
+Set to "off", disables read caching for the LUN, if supported by the backend.
 .It Va unmap
-Set to "on", enables UNMAP support for the LUN.
+Set to "on", enables UNMAP support for the LUN, if supported by the backend.
+.It Va writecache
+Set to "off", disables write caching for the LUN, if supported by the backend.
 .El
 .Pp
 Options specific for block backend:


More information about the svn-src-head mailing list