From owner-svn-src-all@freebsd.org Sat Oct 29 08:45:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 722D5C24204; Sat, 29 Oct 2016 08:45:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49FD2B70; Sat, 29 Oct 2016 08:45:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9T8j7PL097237; Sat, 29 Oct 2016 08:45:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9T8j73m097233; Sat, 29 Oct 2016 08:45:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610290845.u9T8j73m097233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 29 Oct 2016 08:45:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r308078 - in stable/10: sys/cam/ctl usr.sbin/ctladm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2016 08:45:08 -0000 Author: mav Date: Sat Oct 29 08:45:06 2016 New Revision: 308078 URL: https://svnweb.freebsd.org/changeset/base/308078 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/10/sys/cam/ctl/ctl.c stable/10/sys/cam/ctl/ctl.h stable/10/sys/cam/ctl/ctl_backend.c stable/10/usr.sbin/ctladm/ctladm.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Sat Oct 29 08:44:09 2016 (r308077) +++ stable/10/sys/cam/ctl/ctl.c Sat Oct 29 08:45:06 2016 (r308078) @@ -9907,6 +9907,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; @@ -9945,8 +9946,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); @@ -9960,8 +9967,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/10/sys/cam/ctl/ctl.h ============================================================================== --- stable/10/sys/cam/ctl/ctl.h Sat Oct 29 08:44:09 2016 (r308077) +++ stable/10/sys/cam/ctl/ctl.h Sat Oct 29 08:45:06 2016 (r308078) @@ -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/10/sys/cam/ctl/ctl_backend.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend.c Sat Oct 29 08:44:09 2016 (r308077) +++ stable/10/sys/cam/ctl/ctl_backend.c Sat Oct 29 08:45:06 2016 (r308078) @@ -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/10/usr.sbin/ctladm/ctladm.8 ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.8 Sat Oct 29 08:44:09 2016 (r308077) +++ stable/10/usr.sbin/ctladm/ctladm.8 Sat Oct 29 08:45:06 2016 (r308078) @@ -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