Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2015 09:13:31 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r288750 - stable/10/sys/cam/ctl
Message-ID:  <201510050913.t959DVkw027591@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Oct  5 09:13:30 2015
New Revision: 288750
URL: https://svnweb.freebsd.org/changeset/base/288750

Log:
  MFC r287760: Improve read-only support.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/ctl/ctl_error.c
  stable/10/sys/cam/ctl/ctl_error.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 09:12:38 2015	(r288749)
+++ stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 09:13:30 2015	(r288750)
@@ -10848,9 +10848,7 @@ ctl_scsiio_lun_check(struct ctl_lun *lun
 	if (entry->pattern & CTL_LUN_PAT_WRITE) {
 		if (lun->be_lun &&
 		    lun->be_lun->flags & CTL_LUN_FLAG_READONLY) {
-			ctl_set_sense(ctsio, /*current_error*/ 1,
-			    /*sense_key*/ SSD_KEY_DATA_PROTECT,
-			    /*asc*/ 0x27, /*ascq*/ 0x01, SSD_ELEM_NONE);
+			ctl_set_hw_write_protected(ctsio);
 			retval = 1;
 			goto bailout;
 		}

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_block.c	Mon Oct  5 09:12:38 2015	(r288749)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c	Mon Oct  5 09:13:30 2015	(r288750)
@@ -511,6 +511,8 @@ ctl_be_block_biodone(struct bio *bio)
 			ctl_set_invalid_opcode(&io->scsiio);
 		} else if (error == ENOSPC || error == EDQUOT) {
 			ctl_set_space_alloc_fail(&io->scsiio);
+		} else if (error == EROFS || error == EACCES) {
+			ctl_set_hw_write_protected(&io->scsiio);
 		} else if (beio->bio_cmd == BIO_FLUSH) {
 			/* XXX KDM is there is a better error here? */
 			ctl_set_internal_failure(&io->scsiio,
@@ -723,6 +725,8 @@ ctl_be_block_dispatch_file(struct ctl_be
 		       (beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", error);
 		if (error == ENOSPC || error == EDQUOT) {
 			ctl_set_space_alloc_fail(&io->scsiio);
+		} else if (error == EROFS || error == EACCES) {
+			ctl_set_hw_write_protected(&io->scsiio);
 		} else
 			ctl_set_medium_error(&io->scsiio);
 		ctl_complete_beio(beio);
@@ -888,6 +892,8 @@ ctl_be_block_dispatch_zvol(struct ctl_be
 	if (error != 0) {
 		if (error == ENOSPC || error == EDQUOT) {
 			ctl_set_space_alloc_fail(&io->scsiio);
+		} else if (error == EROFS || error == EACCES) {
+			ctl_set_hw_write_protected(&io->scsiio);
 		} else
 			ctl_set_medium_error(&io->scsiio);
 		ctl_complete_beio(beio);

Modified: stable/10/sys/cam/ctl/ctl_cmd_table.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_cmd_table.c	Mon Oct  5 09:12:38 2015	(r288749)
+++ stable/10/sys/cam/ctl/ctl_cmd_table.c	Mon Oct  5 09:13:30 2015	(r288750)
@@ -768,7 +768,7 @@ const struct ctl_cmd_entry ctl_cmd_table
 /* 35 SYNCHRONIZE CACHE(10) */
 {ctl_sync_cache, CTL_SERIDX_SYNC, CTL_CMD_FLAG_OK_ON_SLUN |
 				  CTL_FLAG_DATA_NONE,
- CTL_LUN_PAT_NONE,
+ CTL_LUN_PAT_WRITE,
  10, {0x02, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}},
 
 /* 36 LOCK UNLOCK CACHE(10) */
@@ -1117,7 +1117,7 @@ const struct ctl_cmd_entry ctl_cmd_table
 /* 91 SYNCHRONIZE CACHE(16) */
 {ctl_sync_cache, CTL_SERIDX_SYNC, CTL_CMD_FLAG_OK_ON_SLUN |
 				  CTL_FLAG_DATA_NONE,
- CTL_LUN_PAT_NONE,
+ CTL_LUN_PAT_WRITE,
  16, {0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
 

Modified: stable/10/sys/cam/ctl/ctl_error.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_error.c	Mon Oct  5 09:12:38 2015	(r288749)
+++ stable/10/sys/cam/ctl/ctl_error.c	Mon Oct  5 09:13:30 2015	(r288750)
@@ -848,6 +848,18 @@ ctl_set_task_aborted(struct ctl_scsiio *
 }
 
 void
+ctl_set_hw_write_protected(struct ctl_scsiio *ctsio)
+{
+	/* "Hardware write protected" */
+	ctl_set_sense(ctsio,
+		      /*current_error*/ 1,
+		      /*sense_key*/ SSD_KEY_DATA_PROTECT,
+		      /*asc*/ 0x27,
+		      /*ascq*/ 0x01,
+		      SSD_ELEM_NONE);
+}
+
+void
 ctl_set_space_alloc_fail(struct ctl_scsiio *ctsio)
 {
 	/* "Space allocation failed write protect" */

Modified: stable/10/sys/cam/ctl/ctl_error.h
==============================================================================
--- stable/10/sys/cam/ctl/ctl_error.h	Mon Oct  5 09:12:38 2015	(r288749)
+++ stable/10/sys/cam/ctl/ctl_error.h	Mon Oct  5 09:13:30 2015	(r288750)
@@ -85,6 +85,7 @@ void ctl_set_reservation_conflict(struct
 void ctl_set_queue_full(struct ctl_scsiio *ctsio);
 void ctl_set_busy(struct ctl_scsiio *ctsio);
 void ctl_set_task_aborted(struct ctl_scsiio *ctsio);
+void ctl_set_hw_write_protected(struct ctl_scsiio *ctsio);
 void ctl_set_space_alloc_fail(struct ctl_scsiio *ctsio);
 void ctl_set_success(struct ctl_scsiio *ctsio);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510050913.t959DVkw027591>