svn commit: r308076 - in stable/11: sys/cam/ctl usr.sbin/ctladm

Alexander Motin mav at FreeBSD.org
Sat Oct 29 08:43:36 UTC 2016


Author: mav
Date: Sat Oct 29 08:43:34 2016
New Revision: 308076
URL: https://svnweb.freebsd.org/changeset/base/308076

Log:
  MFC r307350: Add LUN options to limit UNMAP and WRITE SAME sizes.
  
  CTL itself has no limits on on UNMAP and WRITE SAME sizes.  But depending
  on backends large requests may take too much time.  To avoid that new
  configuration options allow to hint initiator maximal sizes it should not
  exceed.

Modified:
  stable/11/sys/cam/ctl/ctl.c
  stable/11/sys/cam/ctl/ctl.h
  stable/11/sys/cam/ctl/ctl_backend.c
  stable/11/usr.sbin/ctladm/ctladm.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cam/ctl/ctl.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl.c	Sat Oct 29 08:42:43 2016	(r308075)
+++ stable/11/sys/cam/ctl/ctl.c	Sat Oct 29 08:43:34 2016	(r308076)
@@ -9903,6 +9903,7 @@ ctl_inquiry_evpd_block_limits(struct ctl
 {
 	struct scsi_vpd_block_limits *bl_ptr;
 	struct ctl_lun *lun;
+	uint64_t ival;
 
 	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
 
@@ -9941,8 +9942,14 @@ ctl_inquiry_evpd_block_limits(struct ctl
 	if (lun != NULL) {
 		scsi_ulto4b(lun->be_lun->opttxferlen, bl_ptr->opt_txfer_len);
 		if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) {
-			scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_lba_cnt);
-			scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_blk_cnt);
+			ival = 0xffffffff;
+			ctl_get_opt_number(&lun->be_lun->options,
+			    "unmap_max_lba", &ival);
+			scsi_ulto4b(ival, bl_ptr->max_unmap_lba_cnt);
+			ival = 0xffffffff;
+			ctl_get_opt_number(&lun->be_lun->options,
+			    "unmap_max_descr", &ival);
+			scsi_ulto4b(ival, bl_ptr->max_unmap_blk_cnt);
 			if (lun->be_lun->ublockexp != 0) {
 				scsi_ulto4b((1 << lun->be_lun->ublockexp),
 				    bl_ptr->opt_unmap_grain);
@@ -9956,8 +9963,10 @@ ctl_inquiry_evpd_block_limits(struct ctl
 		scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity);
 		scsi_ulto4b(0, bl_ptr->max_atomic_transfer_length_with_atomic_boundary);
 		scsi_ulto4b(0, bl_ptr->max_atomic_boundary_size);
+		ival = UINT64_MAX;
+		ctl_get_opt_number(&lun->be_lun->options, "write_same_max_lba", &ival);
+		scsi_u64to8b(ival, bl_ptr->max_write_same_length);
 	}
-	scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length);
 
 	ctl_set_success(ctsio);
 	ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;

Modified: stable/11/sys/cam/ctl/ctl.h
==============================================================================
--- stable/11/sys/cam/ctl/ctl.h	Sat Oct 29 08:42:43 2016	(r308075)
+++ stable/11/sys/cam/ctl/ctl.h	Sat Oct 29 08:43:34 2016	(r308076)
@@ -217,6 +217,7 @@ void ctl_update_opts(ctl_options_t *opts
     struct ctl_be_arg *args);
 void ctl_free_opts(ctl_options_t *opts);
 char * ctl_get_opt(ctl_options_t *opts, const char *name);
+int ctl_get_opt_number(ctl_options_t *opts, const char *name, uint64_t *num);
 int ctl_expand_number(const char *buf, uint64_t *num);
 
 #endif	/* _KERNEL */

Modified: stable/11/sys/cam/ctl/ctl_backend.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl_backend.c	Sat Oct 29 08:42:43 2016	(r308075)
+++ stable/11/sys/cam/ctl/ctl_backend.c	Sat Oct 29 08:43:34 2016	(r308076)
@@ -243,3 +243,14 @@ ctl_get_opt(ctl_options_t *opts, const c
 	}
 	return (NULL);
 }
+
+int
+ctl_get_opt_number(ctl_options_t *opts, const char *name, uint64_t *val)
+{
+	const char *value;
+
+	value = ctl_get_opt(opts, name);
+	if (value == NULL)
+		return (-2);
+	return (ctl_expand_number(value, val));
+}

Modified: stable/11/usr.sbin/ctladm/ctladm.8
==============================================================================
--- stable/11/usr.sbin/ctladm/ctladm.8	Sat Oct 29 08:42:43 2016	(r308075)
+++ stable/11/usr.sbin/ctladm/ctladm.8	Sat Oct 29 08:43:34 2016	(r308076)
@@ -35,7 +35,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
 .\" $FreeBSD$
 .\"
-.Dd September 26, 2015
+.Dd October 15, 2016
 .Dt CTLADM 8
 .Os
 .Sh NAME
@@ -905,6 +905,13 @@ Specifies nominal form factor of the dev
 2 -- 3.5", 3 -- 2.5", 4 -- 1.8", 5 -- less then 1.8".
 .It Va unmap
 Set to "on", enables UNMAP support for the LUN, if supported by the backend.
+.It Va unmap_max_lba
+.It Va unmap_max_descr
+Specify maximum allowed number of LBAs and block descriptors per UNMAP
+command to report in Block Limits VPD page.
+.It Va write_same_max_lba
+Specify maximum allowed number of LBAs per WRITE SAME command to report
+in Block Limits VPD page.
 .It Va avail-threshold
 .It Va used-threshold
 .It Va pool-avail-threshold


More information about the svn-src-all mailing list