Author: mav
Date: Sat Oct 15 10:29:33 2016
New Revision: 307350
URL: https://svnweb.freebsd.org/changeset/base/307350

Log:
  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.
  
  MFC after:    2 weeks

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

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c      Sat Oct 15 09:54:22 2016        (r307349)
+++ head/sys/cam/ctl/ctl.c      Sat Oct 15 10:29:33 2016        (r307350)
@@ -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: head/sys/cam/ctl/ctl.h
==============================================================================
--- head/sys/cam/ctl/ctl.h      Sat Oct 15 09:54:22 2016        (r307349)
+++ head/sys/cam/ctl/ctl.h      Sat Oct 15 10:29:33 2016        (r307350)
@@ -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: head/sys/cam/ctl/ctl_backend.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend.c      Sat Oct 15 09:54:22 2016        
(r307349)
+++ head/sys/cam/ctl/ctl_backend.c      Sat Oct 15 10:29:33 2016        
(r307350)
@@ -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: head/usr.sbin/ctladm/ctladm.8
==============================================================================
--- head/usr.sbin/ctladm/ctladm.8       Sat Oct 15 09:54:22 2016        
(r307349)
+++ head/usr.sbin/ctladm/ctladm.8       Sat Oct 15 10:29:33 2016        
(r307350)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to