From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 08:38:44 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A37371E; Sun, 15 Feb 2015 08:38:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 44F8CB9B; Sun, 15 Feb 2015 08:38:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1F8ci5N002337; Sun, 15 Feb 2015 08:38:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1F8ciKA002336; Sun, 15 Feb 2015 08:38:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502150838.t1F8ciKA002336@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 15 Feb 2015 08:38:44 +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: r278793 - stable/10/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-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 08:38:44 -0000 Author: mav Date: Sun Feb 15 08:38:43 2015 New Revision: 278793 URL: https://svnweb.freebsd.org/changeset/base/278793 Log: MFC r278621: Fix man page to match real option names. Modified: stable/10/usr.sbin/ctladm/ctladm.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctladm/ctladm.8 ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.8 Sun Feb 15 07:47:18 2015 (r278792) +++ stable/10/usr.sbin/ctladm/ctladm.8 Sun Feb 15 08:38:43 2015 (r278793) @@ -1002,11 +1002,11 @@ Set to "off" to allow them be issued in Parallel issue of consecutive operations may confuse logic of the backing file system, hurting performance; but it may improve performance of backing stores without prefetch/write-back. -.It Va psectorsize -.It Va psectoroffset +.It Va pblocksize +.It Va pblockoffset Specify physical block size and offset of the device. -.It Va usectorsize -.It Va usectoroffset +.It Va ublocksize +.It Va ublockoffset Specify UNMAP block size and offset of the device. .It Va rpm .It Va rpm From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 08:52:10 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B2843DA3; Sun, 15 Feb 2015 08:52:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 9C940D31; Sun, 15 Feb 2015 08:52:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1F8qASO011049; Sun, 15 Feb 2015 08:52:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1F8qAvC011047; Sun, 15 Feb 2015 08:52:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502150852.t1F8qAvC011047@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 15 Feb 2015 08:52:10 +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: r278796 - in stable/10/sys/cam: ctl scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 08:52:10 -0000 Author: mav Date: Sun Feb 15 08:52:09 2015 New Revision: 278796 URL: https://svnweb.freebsd.org/changeset/base/278796 Log: MFC r277917 (by ken), r278598: Improve SCSI Extended Inquiry VPD page (0x86) support. sys/cam/scsi/scsi_all.h: In struct scsi_extended_inquiry_data: - Increase the length field to 2 bytes, as it is 2 bytes in SPC-4. - Add bit definitions for the various Activiate Microcode actions. - Add the Sequential Access Logical Block Protection support bit, since we need that in the sa(4) driver. (For modifications that will come later.) - Add definitions for the various Multi I_T Nexus Microcode Download modes. sys/cam/ctl/ctl.c: As of SPC-4, a single report of "REPORTED LUNS DATA HAS CHANGED" is to be given per I_T nexus. Once it is reported, the unit attention condition should be cleared for all LUNS attached to an I_T nexus. Previously that only happened when a REPORT LUNS command was processed. This behavior may be different (according to SAM-5) when the UA_INTLCK_CTRL bits are non-zero in the control mode page but CTL does not currently support that. So, in view of the spec, whenever we report a LUN inventory change unit attention, clear it on all LUNs for that particular I_T nexus. Add a new function, ctl_clear_ua() that will clear a unit attention on all LUNs for the given I_T nexus. One field in the extended inquiry data that we could potentially report at some point is the maximum supported sense data length. To do that, we would the SIM to report (via path inquiry perhaps) how much sense data it is able to send. Add comments to explain some of the bits that are set in the Extended Inquiry VPD page. Add a few comments to make it more clear which functions handle various VPD pages. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/sys/cam/scsi/scsi_all.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Sun Feb 15 08:44:30 2015 (r278795) +++ stable/10/sys/cam/ctl/ctl.c Sun Feb 15 08:52:09 2015 (r278796) @@ -31,7 +31,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * - * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl.c#8 $ + * $Id$ */ /* * CAM Target Layer, a SCSI device emulation subsystem. @@ -448,6 +448,8 @@ static int ctl_scsiio_lun_check(struct c struct ctl_scsiio *ctsio); //static int ctl_check_rtr(union ctl_io *pending_io, struct ctl_softc *softc); static void ctl_failover(void); +static void ctl_clear_ua(struct ctl_softc *ctl_softc, uint32_t initidx, + ctl_ua_type ua_type); static int ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio); static int ctl_scsiio(struct ctl_scsiio *ctsio); @@ -9435,6 +9437,7 @@ ctl_request_sense(struct ctl_scsiio *cts { struct scsi_request_sense *cdb; struct scsi_sense_data *sense_ptr; + struct ctl_softc *ctl_softc; struct ctl_lun *lun; uint32_t initidx; int have_error; @@ -9443,6 +9446,7 @@ ctl_request_sense(struct ctl_scsiio *cts cdb = (struct scsi_request_sense *)ctsio->cdb; + ctl_softc = control_softc; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; CTL_DEBUG_PRINT(("ctl_request_sense\n")); @@ -9528,6 +9532,14 @@ ctl_request_sense(struct ctl_scsiio *cts ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format); if (ua_type != CTL_UA_NONE) have_error = 1; + if (ua_type == CTL_UA_LUN_CHANGE) { + mtx_unlock(&lun->lun_lock); + mtx_lock(&ctl_softc->ctl_lock); + ctl_clear_ua(ctl_softc, initidx, ua_type); + mtx_unlock(&ctl_softc->ctl_lock); + mtx_lock(&lun->lun_lock); + } + } mtx_unlock(&lun->lun_lock); @@ -9595,6 +9607,9 @@ ctl_cmddt_inquiry(struct ctl_scsiio *cts } #endif +/* + * SCSI VPD page 0x00, the Supported VPD Pages page. + */ static int ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len) { @@ -9667,6 +9682,9 @@ ctl_inquiry_evpd_supported(struct ctl_sc return (CTL_RETVAL_COMPLETE); } +/* + * SCSI VPD page 0x80, the Unit Serial Number page. + */ static int ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) { @@ -9723,6 +9741,9 @@ ctl_inquiry_evpd_serial(struct ctl_scsii } +/* + * SCSI VPD page 0x86, the Extended INQUIRY Data page. + */ static int ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) { @@ -9760,10 +9781,33 @@ ctl_inquiry_evpd_eid(struct ctl_scsiio * else eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; - eid_ptr->page_length = data_len - 4; + scsi_ulto2b(data_len - 4, eid_ptr->page_length); + /* + * We support head of queue, ordered and simple tags. + */ eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; + /* + * Volatile cache supported. + */ eid_ptr->flags3 = SVPD_EID_V_SUP; + /* + * This means that we clear the REPORTED LUNS DATA HAS CHANGED unit + * attention for a particular IT nexus on all LUNs once we report + * it to that nexus once. This bit is required as of SPC-4. + */ + eid_ptr->flags4 = SVPD_EID_LUICLT; + + /* + * XXX KDM in order to correctly answer this, we would need + * information from the SIM to determine how much sense data it + * can send. So this would really be a path inquiry field, most + * likely. This can be set to a maximum of 252 according to SPC-4, + * but the hardware may or may not be able to support that much. + * 0 just means that the maximum sense data length is not reported. + */ + eid_ptr->max_sense_length = 0; + ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; ctsio->be_move_done = ctl_config_move_done; @@ -9822,6 +9866,9 @@ ctl_inquiry_evpd_mpp(struct ctl_scsiio * return (CTL_RETVAL_COMPLETE); } +/* + * SCSI VPD page 0x83, the Device Identification page. + */ static int ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) { @@ -10237,6 +10284,9 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio * return (CTL_RETVAL_COMPLETE); } +/* + * INQUIRY with the EVPD bit set. + */ static int ctl_inquiry_evpd(struct ctl_scsiio *ctsio) { @@ -10301,6 +10351,9 @@ err: return (retval); } +/* + * Standard INQUIRY data. + */ static int ctl_inquiry_std(struct ctl_scsiio *ctsio) { @@ -11470,6 +11523,24 @@ ctl_failover(void) mtx_unlock(&softc->ctl_lock); } +static void +ctl_clear_ua(struct ctl_softc *ctl_softc, uint32_t initidx, + ctl_ua_type ua_type) +{ + struct ctl_lun *lun; + ctl_ua_type *pu; + + mtx_assert(&ctl_softc->ctl_lock, MA_OWNED); + + STAILQ_FOREACH(lun, &ctl_softc->lun_list, links) { + mtx_lock(&lun->lun_lock); + pu = lun->pending_ua[initidx / CTL_MAX_INIT_PER_PORT]; + if (pu != NULL) + pu[initidx % CTL_MAX_INIT_PER_PORT] &= ~ua_type; + mtx_unlock(&lun->lun_lock); + } +} + static int ctl_scsiio_precheck(struct ctl_softc *softc, struct ctl_scsiio *ctsio) { Modified: stable/10/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/10/sys/cam/scsi/scsi_all.h Sun Feb 15 08:44:30 2015 (r278795) +++ stable/10/sys/cam/scsi/scsi_all.h Sun Feb 15 08:52:09 2015 (r278796) @@ -2112,10 +2112,15 @@ struct scsi_vpd_extended_inquiry_data uint8_t device; uint8_t page_code; #define SVPD_EXTENDED_INQUIRY_DATA 0x86 - uint8_t reserved; - uint8_t page_length; + uint8_t page_length[2]; uint8_t flags1; -#define SVPD_EID_AM 0xC0 + + /* These values are for direct access devices */ +#define SVPD_EID_AM_MASK 0xC0 +#define SVPD_EID_AM_DEFER 0x80 +#define SVPD_EID_AM_IMMED 0x40 +#define SVPD_EID_AM_UNDEFINED 0x00 +#define SVPD_EID_AM_RESERVED 0xc0 #define SVPD_EID_SPT 0x38 #define SVPD_EID_SPT_1 0x00 #define SVPD_EID_SPT_12 0x08 @@ -2124,9 +2129,14 @@ struct scsi_vpd_extended_inquiry_data #define SVPD_EID_SPT_3 0x20 #define SVPD_EID_SPT_23 0x28 #define SVPD_EID_SPT_123 0x38 + + /* These values are for sequential access devices */ +#define SVPD_EID_SA_SPT_LBP 0x08 + #define SVPD_EID_GRD_CHK 0x04 #define SVPD_EID_APP_CHK 0x02 #define SVPD_EID_REF_CHK 0x01 + uint8_t flags2; #define SVPD_EID_UASK_SUP 0x20 #define SVPD_EID_GROUP_SUP 0x10 @@ -2147,6 +2157,10 @@ struct scsi_vpd_extended_inquiry_data #define SVPD_EID_CBCS 0x01 uint8_t flags6; #define SVPD_EID_MULTI_I_T_FW 0x0F +#define SVPD_EID_MC_VENDOR_SPEC 0x00 +#define SVPD_EID_MC_MODE_1 0x01 +#define SVPD_EID_MC_MODE_2 0x02 +#define SVPD_EID_MC_MODE_3 0x03 uint8_t est[2]; uint8_t flags7; #define SVPD_EID_POA_SUP 0x80 From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 13:24:34 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0DEFFCD0; Sun, 15 Feb 2015 13:24:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 EAA40842; Sun, 15 Feb 2015 13:24:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FDOXo3036943; Sun, 15 Feb 2015 13:24:33 GMT (envelope-from rrs@FreeBSD.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FDOXlC036940; Sun, 15 Feb 2015 13:24:33 GMT (envelope-from rrs@FreeBSD.org) Message-Id: <201502151324.t1FDOXlC036940@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rrs set sender to rrs@FreeBSD.org using -f From: Randall Stewart Date: Sun, 15 Feb 2015 13:24:33 +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: r278800 - in stable/10/sys: kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 13:24:34 -0000 Author: rrs Date: Sun Feb 15 13:24:32 2015 New Revision: 278800 URL: https://svnweb.freebsd.org/changeset/base/278800 Log: MFC of r278469, r278623 278469: This fixes two conditions that can incur when migration is being done in the callout code and harmonizes the macro use.: 1) The callout_active() will lie. Basically if a migration is occuring and the callout is about to expire and the migration has been deferred, the callout_active will no longer return true until after the migration. This confuses and breaks callers that are doing callout_init(&c, 1); such as TCP. 2) The migration code had a bug in it where when migrating, if a two calls to callout_reset came in and they both collided with the callout on the wheel about to run, then the second call to callout_reset would corrupt the list the callout wheel uses putting the callout thread into a endless loop. 3) Per imp, I have fixed all the macro occurance in the code that were for the most part being ignored. 278623: This fixes a bug I in-advertantly inserted when I updated the callout code in my last commit. The cc_exec_next is used to track the next when a direct call is being made from callout. It is *never* used in the in-direct method. When macro-izing I made it so that it would separate out direct/vs/non-direct. This is incorrect and can cause panics as Peter Holm has found for me (Thanks so much Peter for all your help in this). What this change does is restore that behavior but also get rid of the cc_next from the array and instead make it be part of the base callout structure. This way no one else will get confused since we will never use it for non-direct. Sponsored by: Netflix Inc. Modified: stable/10/sys/kern/kern_timeout.c stable/10/sys/sys/callout.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_timeout.c ============================================================================== --- stable/10/sys/kern/kern_timeout.c Sun Feb 15 12:02:17 2015 (r278799) +++ stable/10/sys/kern/kern_timeout.c Sun Feb 15 13:24:32 2015 (r278800) @@ -122,7 +122,6 @@ u_int callwheelsize, callwheelmask; * the migrating callout is already running. */ struct cc_exec { - struct callout *cc_next; struct callout *cc_curr; #ifdef SMP void (*ce_migration_func)(void *); @@ -142,6 +141,7 @@ struct cc_exec { struct callout_cpu { struct mtx_padalign cc_lock; struct cc_exec cc_exec_entity[2]; + struct callout *cc_next; struct callout *cc_callout; struct callout_list *cc_callwheel; struct callout_tailq cc_expireq; @@ -153,26 +153,16 @@ struct callout_cpu { char cc_ktr_event_name[20]; }; -#define cc_exec_curr cc_exec_entity[0].cc_curr -#define cc_exec_next cc_exec_entity[0].cc_next -#define cc_exec_cancel cc_exec_entity[0].cc_cancel -#define cc_exec_waiting cc_exec_entity[0].cc_waiting -#define cc_exec_curr_dir cc_exec_entity[1].cc_curr -#define cc_exec_next_dir cc_exec_entity[1].cc_next -#define cc_exec_cancel_dir cc_exec_entity[1].cc_cancel -#define cc_exec_waiting_dir cc_exec_entity[1].cc_waiting - +#define cc_exec_curr(cc, dir) cc->cc_exec_entity[dir].cc_curr +#define cc_exec_next(cc) cc->cc_next +#define cc_exec_cancel(cc, dir) cc->cc_exec_entity[dir].cc_cancel +#define cc_exec_waiting(cc, dir) cc->cc_exec_entity[dir].cc_waiting #ifdef SMP -#define cc_migration_func cc_exec_entity[0].ce_migration_func -#define cc_migration_arg cc_exec_entity[0].ce_migration_arg -#define cc_migration_cpu cc_exec_entity[0].ce_migration_cpu -#define cc_migration_time cc_exec_entity[0].ce_migration_time -#define cc_migration_prec cc_exec_entity[0].ce_migration_prec -#define cc_migration_func_dir cc_exec_entity[1].ce_migration_func -#define cc_migration_arg_dir cc_exec_entity[1].ce_migration_arg -#define cc_migration_cpu_dir cc_exec_entity[1].ce_migration_cpu -#define cc_migration_time_dir cc_exec_entity[1].ce_migration_time -#define cc_migration_prec_dir cc_exec_entity[1].ce_migration_prec +#define cc_migration_func(cc, dir) cc->cc_exec_entity[dir].ce_migration_func +#define cc_migration_arg(cc, dir) cc->cc_exec_entity[dir].ce_migration_arg +#define cc_migration_cpu(cc, dir) cc->cc_exec_entity[dir].ce_migration_cpu +#define cc_migration_time(cc, dir) cc->cc_exec_entity[dir].ce_migration_time +#define cc_migration_prec(cc, dir) cc->cc_exec_entity[dir].ce_migration_prec struct callout_cpu cc_cpu[MAXCPU]; #define CPUBLOCK MAXCPU @@ -222,16 +212,15 @@ static void cc_cce_cleanup(struct callout_cpu *cc, int direct) { - cc->cc_exec_entity[direct].cc_curr = NULL; - cc->cc_exec_entity[direct].cc_next = NULL; - cc->cc_exec_entity[direct].cc_cancel = false; - cc->cc_exec_entity[direct].cc_waiting = false; + cc_exec_curr(cc, direct) = NULL; + cc_exec_cancel(cc, direct) = false; + cc_exec_waiting(cc, direct) = false; #ifdef SMP - cc->cc_exec_entity[direct].ce_migration_cpu = CPUBLOCK; - cc->cc_exec_entity[direct].ce_migration_time = 0; - cc->cc_exec_entity[direct].ce_migration_prec = 0; - cc->cc_exec_entity[direct].ce_migration_func = NULL; - cc->cc_exec_entity[direct].ce_migration_arg = NULL; + cc_migration_cpu(cc, direct) = CPUBLOCK; + cc_migration_time(cc, direct) = 0; + cc_migration_prec(cc, direct) = 0; + cc_migration_func(cc, direct) = NULL; + cc_migration_arg(cc, direct) = NULL; #endif } @@ -243,7 +232,7 @@ cc_cce_migrating(struct callout_cpu *cc, { #ifdef SMP - return (cc->cc_exec_entity[direct].ce_migration_cpu != CPUBLOCK); + return (cc_migration_cpu(cc, direct) != CPUBLOCK); #else return (0); #endif @@ -455,7 +444,7 @@ callout_process(sbintime_t now) #ifdef CALLOUT_PROFILING ++depth_dir; #endif - cc->cc_exec_next_dir = + cc_exec_next(cc) = LIST_NEXT(tmp, c_links.le); cc->cc_bucket = firstb & callwheelmask; LIST_REMOVE(tmp, c_links.le); @@ -464,7 +453,8 @@ callout_process(sbintime_t now) &mpcalls_dir, &lockcalls_dir, NULL, #endif 1); - tmp = cc->cc_exec_next_dir; + tmp = cc_exec_next(cc); + cc_exec_next(cc) = NULL; } else { tmpn = LIST_NEXT(tmp, c_links.le); LIST_REMOVE(tmp, c_links.le); @@ -557,8 +547,6 @@ callout_cc_add(struct callout *c, struct sbt = cc->cc_lastscan; c->c_arg = arg; c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING); - if (flags & C_DIRECT_EXEC) - c->c_flags |= CALLOUT_DIRECT; c->c_flags &= ~CALLOUT_PROCESSED; c->c_func = func; c->c_time = sbt; @@ -569,7 +557,7 @@ callout_cc_add(struct callout *c, struct (u_int)(c->c_precision & 0xffffffff)); LIST_INSERT_HEAD(&cc->cc_callwheel[bucket], c, c_links.le); if (cc->cc_bucket == bucket) - cc->cc_exec_next_dir = c; + cc_exec_next(cc) = c; #ifndef NO_EVENTTIMERS /* * Inform the eventtimers(4) subsystem there's a new callout @@ -642,8 +630,9 @@ softclock_call_cc(struct callout *c, str c->c_flags = CALLOUT_LOCAL_ALLOC; else c->c_flags &= ~CALLOUT_PENDING; - cc->cc_exec_entity[direct].cc_curr = c; - cc->cc_exec_entity[direct].cc_cancel = false; + + cc_exec_curr(cc, direct) = c; + cc_exec_cancel(cc, direct) = false; CC_UNLOCK(cc); if (c_lock != NULL) { class->lc_lock(c_lock, lock_status); @@ -651,12 +640,12 @@ softclock_call_cc(struct callout *c, str * The callout may have been cancelled * while we switched locks. */ - if (cc->cc_exec_entity[direct].cc_cancel) { + if (cc_exec_cancel(cc, direct)) { class->lc_unlock(c_lock); goto skip; } /* The callout cannot be stopped now. */ - cc->cc_exec_entity[direct].cc_cancel = true; + cc_exec_cancel(cc, direct) = true; if (c_lock == &Giant.lock_object) { #ifdef CALLOUT_PROFILING (*gcalls)++; @@ -707,9 +696,9 @@ softclock_call_cc(struct callout *c, str class->lc_unlock(c_lock); skip: CC_LOCK(cc); - KASSERT(cc->cc_exec_entity[direct].cc_curr == c, ("mishandled cc_curr")); - cc->cc_exec_entity[direct].cc_curr = NULL; - if (cc->cc_exec_entity[direct].cc_waiting) { + KASSERT(cc_exec_curr(cc, direct) == c, ("mishandled cc_curr")); + cc_exec_curr(cc, direct) = NULL; + if (cc_exec_waiting(cc, direct)) { /* * There is someone waiting for the * callout to complete. @@ -725,9 +714,9 @@ skip: */ c->c_flags &= ~CALLOUT_DFRMIGRATION; } - cc->cc_exec_entity[direct].cc_waiting = false; + cc_exec_waiting(cc, direct) = false; CC_UNLOCK(cc); - wakeup(&cc->cc_exec_entity[direct].cc_waiting); + wakeup(&cc_exec_waiting(cc, direct)); CC_LOCK(cc); } else if (cc_cce_migrating(cc, direct)) { KASSERT((c_flags & CALLOUT_LOCAL_ALLOC) == 0, @@ -737,11 +726,11 @@ skip: * If the callout was scheduled for * migration just perform it now. */ - new_cpu = cc->cc_exec_entity[direct].ce_migration_cpu; - new_time = cc->cc_exec_entity[direct].ce_migration_time; - new_prec = cc->cc_exec_entity[direct].ce_migration_prec; - new_func = cc->cc_exec_entity[direct].ce_migration_func; - new_arg = cc->cc_exec_entity[direct].ce_migration_arg; + new_cpu = cc_migration_cpu(cc, direct); + new_time = cc_migration_time(cc, direct); + new_prec = cc_migration_prec(cc, direct); + new_func = cc_migration_func(cc, direct); + new_arg = cc_migration_arg(cc, direct); cc_cce_cleanup(cc, direct); /* @@ -750,7 +739,7 @@ skip: * * As first thing, handle deferred callout stops. */ - if ((c->c_flags & CALLOUT_DFRMIGRATION) == 0) { + if (!callout_migrating(c)) { CTR3(KTR_CALLOUT, "deferred cancelled %p func %p arg %p", c, new_func, new_arg); @@ -972,19 +961,27 @@ callout_reset_sbt_on(struct callout *c, */ if (c->c_flags & CALLOUT_LOCAL_ALLOC) cpu = c->c_cpu; + /* + * This flag used to be added by callout_cc_add, but the + * first time you call this we could end up with the + * wrong direct flag if we don't do it before we add. + */ + if (flags & C_DIRECT_EXEC) { + c->c_flags |= CALLOUT_DIRECT; + } direct = (c->c_flags & CALLOUT_DIRECT) != 0; KASSERT(!direct || c->c_lock == NULL, ("%s: direct callout %p has lock", __func__, c)); cc = callout_lock(c); - if (cc->cc_exec_entity[direct].cc_curr == c) { + if (cc_exec_curr(cc, direct) == c) { /* * We're being asked to reschedule a callout which is * currently in progress. If there is a lock then we * can cancel the callout if it has not really started. */ - if (c->c_lock != NULL && !cc->cc_exec_entity[direct].cc_cancel) - cancelled = cc->cc_exec_entity[direct].cc_cancel = true; - if (cc->cc_exec_entity[direct].cc_waiting) { + if (c->c_lock != NULL && cc_exec_cancel(cc, direct)) + cancelled = cc_exec_cancel(cc, direct) = true; + if (cc_exec_waiting(cc, direct)) { /* * Someone has called callout_drain to kill this * callout. Don't reschedule. @@ -995,11 +992,30 @@ callout_reset_sbt_on(struct callout *c, CC_UNLOCK(cc); return (cancelled); } +#ifdef SMP + if (callout_migrating(c)) { + /* + * This only occurs when a second callout_reset_sbt_on + * is made after a previous one moved it into + * deferred migration (below). Note we do *not* change + * the prev_cpu even though the previous target may + * be different. + */ + cc_migration_cpu(cc, direct) = cpu; + cc_migration_time(cc, direct) = to_sbt; + cc_migration_prec(cc, direct) = precision; + cc_migration_func(cc, direct) = ftn; + cc_migration_arg(cc, direct) = arg; + cancelled = 1; + CC_UNLOCK(cc); + return (cancelled); + } +#endif } if (c->c_flags & CALLOUT_PENDING) { if ((c->c_flags & CALLOUT_PROCESSED) == 0) { - if (cc->cc_exec_next_dir == c) - cc->cc_exec_next_dir = LIST_NEXT(c, c_links.le); + if (cc_exec_next(cc) == c) + cc_exec_next(cc) = LIST_NEXT(c, c_links.le); LIST_REMOVE(c, c_links.le); } else TAILQ_REMOVE(&cc->cc_expireq, c, c_links.tqe); @@ -1014,15 +1030,29 @@ callout_reset_sbt_on(struct callout *c, * to a more appropriate moment. */ if (c->c_cpu != cpu) { - if (cc->cc_exec_entity[direct].cc_curr == c) { - cc->cc_exec_entity[direct].ce_migration_cpu = cpu; - cc->cc_exec_entity[direct].ce_migration_time - = to_sbt; - cc->cc_exec_entity[direct].ce_migration_prec - = precision; - cc->cc_exec_entity[direct].ce_migration_func = ftn; - cc->cc_exec_entity[direct].ce_migration_arg = arg; - c->c_flags |= CALLOUT_DFRMIGRATION; + if (cc_exec_curr(cc, direct) == c) { + /* + * Pending will have been removed since we are + * actually executing the callout on another + * CPU. That callout should be waiting on the + * lock the caller holds. If we set both + * active/and/pending after we return and the + * lock on the executing callout proceeds, it + * will then see pending is true and return. + * At the return from the actual callout execution + * the migration will occur in softclock_call_cc + * and this new callout will be placed on the + * new CPU via a call to callout_cpu_switch() which + * will get the lock on the right CPU followed + * by a call callout_cc_add() which will add it there. + * (see above in softclock_call_cc()). + */ + cc_migration_cpu(cc, direct) = cpu; + cc_migration_time(cc, direct) = to_sbt; + cc_migration_prec(cc, direct) = precision; + cc_migration_func(cc, direct) = ftn; + cc_migration_arg(cc, direct) = arg; + c->c_flags |= (CALLOUT_DFRMIGRATION | CALLOUT_ACTIVE | CALLOUT_PENDING); CTR6(KTR_CALLOUT, "migration of %p func %p arg %p in %d.%08x to %u deferred", c, c->c_func, c->c_arg, (int)(to_sbt >> 32), @@ -1066,6 +1096,7 @@ _callout_stop_safe(c, safe) struct callout_cpu *cc, *old_cc; struct lock_class *class; int direct, sq_locked, use_lock; + int not_on_a_list; /* * Some old subsystems don't hold Giant while running a callout_stop(), @@ -1087,6 +1118,26 @@ _callout_stop_safe(c, safe) again: cc = callout_lock(c); + if ((c->c_flags & (CALLOUT_DFRMIGRATION | CALLOUT_ACTIVE | CALLOUT_PENDING)) == + (CALLOUT_DFRMIGRATION | CALLOUT_ACTIVE | CALLOUT_PENDING)) { + /* + * Special case where this slipped in while we + * were migrating *as* the callout is about to + * execute. The caller probably holds the lock + * the callout wants. + * + * Get rid of the migration first. Then set + * the flag that tells this code *not* to + * try to remove it from any lists (its not + * on one yet). When the callout wheel runs, + * it will ignore this callout. + */ + c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_ACTIVE); + not_on_a_list = 1; + } else { + not_on_a_list = 0; + } + /* * If the callout was migrating while the callout cpu lock was * dropped, just drop the sleepqueue lock and check the states @@ -1095,7 +1146,7 @@ again: if (sq_locked != 0 && cc != old_cc) { #ifdef SMP CC_UNLOCK(cc); - sleepq_release(&old_cc->cc_exec_entity[direct].cc_waiting); + sleepq_release(&cc_exec_waiting(old_cc, direct)); sq_locked = 0; old_cc = NULL; goto again; @@ -1116,13 +1167,12 @@ again: * If it wasn't on the queue and it isn't the current * callout, then we can't stop it, so just bail. */ - if (cc->cc_exec_entity[direct].cc_curr != c) { + if (cc_exec_curr(cc, direct) != c) { CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); CC_UNLOCK(cc); if (sq_locked) - sleepq_release( - &cc->cc_exec_entity[direct].cc_waiting); + sleepq_release(&cc_exec_waiting(cc, direct)); return (0); } @@ -1133,7 +1183,7 @@ again: * just wait for the current invocation to * finish. */ - while (cc->cc_exec_entity[direct].cc_curr == c) { + while (cc_exec_curr(cc, direct) == c) { /* * Use direct calls to sleepqueue interface * instead of cv/msleep in order to avoid @@ -1154,7 +1204,7 @@ again: if (!sq_locked) { CC_UNLOCK(cc); sleepq_lock( - &cc->cc_exec_entity[direct].cc_waiting); + &cc_exec_waiting(cc, direct)); sq_locked = 1; old_cc = cc; goto again; @@ -1166,15 +1216,15 @@ again: * will be packed up, just let softclock() * take care of it. */ - cc->cc_exec_entity[direct].cc_waiting = true; + cc_exec_waiting(cc, direct) = true; DROP_GIANT(); CC_UNLOCK(cc); sleepq_add( - &cc->cc_exec_entity[direct].cc_waiting, + &cc_exec_waiting(cc, direct), &cc->cc_lock.lock_object, "codrain", SLEEPQ_SLEEP, 0); sleepq_wait( - &cc->cc_exec_entity[direct].cc_waiting, + &cc_exec_waiting(cc, direct), 0); sq_locked = 0; old_cc = NULL; @@ -1184,7 +1234,8 @@ again: CC_LOCK(cc); } } else if (use_lock && - !cc->cc_exec_entity[direct].cc_cancel) { + !cc_exec_cancel(cc, direct)) { + /* * The current callout is waiting for its * lock which we hold. Cancel the callout @@ -1192,7 +1243,7 @@ again: * lock, the callout will be skipped in * softclock(). */ - cc->cc_exec_entity[direct].cc_cancel = true; + cc_exec_cancel(cc, direct) = true; CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); KASSERT(!cc_cce_migrating(cc, direct), @@ -1200,12 +1251,34 @@ again: CC_UNLOCK(cc); KASSERT(!sq_locked, ("sleepqueue chain locked")); return (1); - } else if ((c->c_flags & CALLOUT_DFRMIGRATION) != 0) { + } else if (callout_migrating(c)) { + /* + * The callout is currently being serviced + * and the "next" callout is scheduled at + * its completion with a migration. We remove + * the migration flag so it *won't* get rescheduled, + * but we can't stop the one thats running so + * we return 0. + */ c->c_flags &= ~CALLOUT_DFRMIGRATION; +#ifdef SMP + /* + * We can't call cc_cce_cleanup here since + * if we do it will remove .ce_curr and + * its still running. This will prevent a + * reschedule of the callout when the + * execution completes. + */ + cc_migration_cpu(cc, direct) = CPUBLOCK; + cc_migration_time(cc, direct) = 0; + cc_migration_prec(cc, direct) = 0; + cc_migration_func(cc, direct) = NULL; + cc_migration_arg(cc, direct) = NULL; +#endif CTR3(KTR_CALLOUT, "postponing stop %p func %p arg %p", c, c->c_func, c->c_arg); CC_UNLOCK(cc); - return (1); + return (0); } CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); @@ -1214,20 +1287,21 @@ again: return (0); } if (sq_locked) - sleepq_release(&cc->cc_exec_entity[direct].cc_waiting); + sleepq_release(&cc_exec_waiting(cc, direct)); c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); - if ((c->c_flags & CALLOUT_PROCESSED) == 0) { - if (cc->cc_exec_next_dir == c) - cc->cc_exec_next_dir = LIST_NEXT(c, c_links.le); - LIST_REMOVE(c, c_links.le); - } else - TAILQ_REMOVE(&cc->cc_expireq, c, c_links.tqe); + if (not_on_a_list == 0) { + if ((c->c_flags & CALLOUT_PROCESSED) == 0) { + if (cc_exec_next(cc) == c) + cc_exec_next(cc) = LIST_NEXT(c, c_links.le); + LIST_REMOVE(c, c_links.le); + } else + TAILQ_REMOVE(&cc->cc_expireq, c, c_links.tqe); + } callout_cc_del(c, cc); - CC_UNLOCK(cc); return (1); } Modified: stable/10/sys/sys/callout.h ============================================================================== --- stable/10/sys/sys/callout.h Sun Feb 15 12:02:17 2015 (r278799) +++ stable/10/sys/sys/callout.h Sun Feb 15 13:24:32 2015 (r278800) @@ -64,6 +64,7 @@ struct callout_handle { #ifdef _KERNEL #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) +#define callout_migrating(c) ((c)->c_flags & CALLOUT_DFRMIGRATION) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) #define callout_drain(c) _callout_stop_safe(c, 1) void callout_init(struct callout *, int); From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 13:57:46 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 567BB2D9; Sun, 15 Feb 2015 13:57:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 36B8AAC4; Sun, 15 Feb 2015 13:57:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FDvkFd051921; Sun, 15 Feb 2015 13:57:46 GMT (envelope-from rrs@FreeBSD.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FDvjdu051912; Sun, 15 Feb 2015 13:57:45 GMT (envelope-from rrs@FreeBSD.org) Message-Id: <201502151357.t1FDvjdu051912@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rrs set sender to rrs@FreeBSD.org using -f From: Randall Stewart Date: Sun, 15 Feb 2015 13:57:45 +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: r278801 - in stable/10/sys: netinet netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 13:57:46 -0000 Author: rrs Date: Sun Feb 15 13:57:44 2015 New Revision: 278801 URL: https://svnweb.freebsd.org/changeset/base/278801 Log: MFC of r278472 This fixes a bug in the way that the LLE timers for nd6 and arp were being used. They basically would pass in the mutex to the callout_init. Because they used this method to the callout system, it was possible to "stop" the callout. When flushing the table and you stopped the running callout, the callout_stop code would return 1 indicating that it was going to stop the callout (that was about to run on the callout_wheel blocked by the function calling the stop). Now when 1 was returned, it would lower the reference count one extra time for the stopped timer, then a few lines later delete the memory. Of course the callout_wheel was stuck in the lock code and would then crash since it was accessing freed memory. By using callout_init(c, 1) we always get a 0 back and the reference counting bug does not rear its head. We do have to make a few adjustments to the callouts themselves though to make sure it does the proper thing if rescheduled as well as gets the lock. Sponsored by: Netflix Inc. Modified: stable/10/sys/netinet/if_ether.c stable/10/sys/netinet/in.c stable/10/sys/netinet6/in6.c stable/10/sys/netinet6/nd6.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/if_ether.c ============================================================================== --- stable/10/sys/netinet/if_ether.c Sun Feb 15 13:24:32 2015 (r278800) +++ stable/10/sys/netinet/if_ether.c Sun Feb 15 13:57:44 2015 (r278801) @@ -170,10 +170,28 @@ arptimer(void *arg) struct ifnet *ifp; if (lle->la_flags & LLE_STATIC) { - LLE_WUNLOCK(lle); return; } - + LLE_WLOCK(lle); + if (callout_pending(&lle->la_timer)) { + /* + * Here we are a bit odd here in the treatment of + * active/pending. If the pending bit is set, it got + * rescheduled before I ran. The active + * bit we ignore, since if it was stopped + * in ll_tablefree() and was currently running + * it would have return 0 so the code would + * not have deleted it since the callout could + * not be stopped so we want to go through + * with the delete here now. If the callout + * was restarted, the pending bit will be back on and + * we just want to bail since the callout_reset would + * return 1 and our reference would have been removed + * by arpresolve() below. + */ + LLE_WUNLOCK(lle); + return; + } ifp = lle->lle_tbl->llt_ifp; CURVNET_SET(ifp->if_vnet); Modified: stable/10/sys/netinet/in.c ============================================================================== --- stable/10/sys/netinet/in.c Sun Feb 15 13:24:32 2015 (r278800) +++ stable/10/sys/netinet/in.c Sun Feb 15 13:57:44 2015 (r278801) @@ -1263,8 +1263,7 @@ in_lltable_new(const struct sockaddr *l3 lle->base.lle_refcnt = 1; lle->base.lle_free = in_lltable_free; LLE_LOCK_INIT(&lle->base); - callout_init_rw(&lle->base.la_timer, &lle->base.lle_lock, - CALLOUT_RETURNUNLOCKED); + callout_init(&lle->base.la_timer, 1); return (&lle->base); } Modified: stable/10/sys/netinet6/in6.c ============================================================================== --- stable/10/sys/netinet6/in6.c Sun Feb 15 13:24:32 2015 (r278800) +++ stable/10/sys/netinet6/in6.c Sun Feb 15 13:57:44 2015 (r278801) @@ -2519,8 +2519,7 @@ in6_lltable_new(const struct sockaddr *l lle->base.lle_refcnt = 1; lle->base.lle_free = in6_lltable_free; LLE_LOCK_INIT(&lle->base); - callout_init_rw(&lle->base.ln_timer_ch, &lle->base.lle_lock, - CALLOUT_RETURNUNLOCKED); + callout_init(&lle->base.ln_timer_ch, 1); return (&lle->base); } Modified: stable/10/sys/netinet6/nd6.c ============================================================================== --- stable/10/sys/netinet6/nd6.c Sun Feb 15 13:24:32 2015 (r278800) +++ stable/10/sys/netinet6/nd6.c Sun Feb 15 13:57:44 2015 (r278801) @@ -466,9 +466,28 @@ nd6_llinfo_timer(void *arg) KASSERT(arg != NULL, ("%s: arg NULL", __func__)); ln = (struct llentry *)arg; - LLE_WLOCK_ASSERT(ln); + LLE_WLOCK(ln); + if (callout_pending(&ln->la_timer)) { + /* + * Here we are a bit odd here in the treatment of + * active/pending. If the pending bit is set, it got + * rescheduled before I ran. The active + * bit we ignore, since if it was stopped + * in ll_tablefree() and was currently running + * it would have return 0 so the code would + * not have deleted it since the callout could + * not be stopped so we want to go through + * with the delete here now. If the callout + * was restarted, the pending bit will be back on and + * we just want to bail since the callout_reset would + * return 1 and our reference would have been removed + * by nd6_llinfo_settimer_locked above since canceled + * would have been 1. + */ + LLE_WUNLOCK(ln); + return; + } ifp = ln->lle_tbl->llt_ifp; - CURVNET_SET(ifp->if_vnet); if (ln->ln_ntick > 0) { From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 20:02:31 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 30279208; Sun, 15 Feb 2015 20:02:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 19C47FDE; Sun, 15 Feb 2015 20:02:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FK2URV026159; Sun, 15 Feb 2015 20:02:30 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FK2Unl026157; Sun, 15 Feb 2015 20:02:30 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201502152002.t1FK2Unl026157@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 15 Feb 2015 20:02:30 +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: r278808 - in stable/10/sys/dev: malo mwl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 20:02:31 -0000 Author: marius Date: Sun Feb 15 20:02:29 2015 New Revision: 278808 URL: https://svnweb.freebsd.org/changeset/base/278808 Log: MFC: r278532 Fix compilation with GCC in the PAE case. Modified: stable/10/sys/dev/malo/if_malo.c stable/10/sys/dev/mwl/if_mwl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/malo/if_malo.c ============================================================================== --- stable/10/sys/dev/malo/if_malo.c Sun Feb 15 19:56:31 2015 (r278807) +++ stable/10/sys/dev/malo/if_malo.c Sun Feb 15 20:02:29 2015 (r278808) @@ -169,7 +169,7 @@ static void malo_bar0_write4(struct malo_softc *sc, bus_size_t off, uint32_t val) { DPRINTF(sc, MALO_DEBUG_FW, "%s: off 0x%jx val 0x%x\n", - __func__, (intmax_t)off, val); + __func__, (uintmax_t)off, val); bus_space_write_4(sc->malo_io0t, sc->malo_io0h, off, val); } @@ -521,9 +521,10 @@ malo_desc_setup(struct malo_softc *sc, c ds = dd->dd_desc; memset(ds, 0, dd->dd_desc_len); - DPRINTF(sc, MALO_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n", + DPRINTF(sc, MALO_DEBUG_RESET, + "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n", __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, - (caddr_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); + (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); return 0; fail2: @@ -891,10 +892,9 @@ malo_printrxbuf(const struct malo_rxbuf const struct malo_rxdesc *ds = bf->bf_desc; uint32_t status = le32toh(ds->status); - printf("R[%2u] (DS.V:%p DS.P:%p) NEXT:%08x DATA:%08x RC:%02x%s\n" + printf("R[%2u] (DS.V:%p DS.P:0x%jx) NEXT:%08x DATA:%08x RC:%02x%s\n" " STAT:%02x LEN:%04x SNR:%02x NF:%02x CHAN:%02x" - " RATE:%02x QOS:%04x\n", - ix, ds, (const struct malo_desc *)bf->bf_daddr, + " RATE:%02x QOS:%04x\n", ix, ds, (uintmax_t)bf->bf_daddr, le32toh(ds->physnext), le32toh(ds->physbuffdata), ds->rxcontrol, ds->rxcontrol != MALO_RXD_CTRL_DRIVER_OWN ? @@ -910,8 +910,7 @@ malo_printtxbuf(const struct malo_txbuf uint32_t status = le32toh(ds->status); printf("Q%u[%3u]", qnum, ix); - printf(" (DS.V:%p DS.P:%p)\n", - ds, (const struct malo_txdesc *)bf->bf_daddr); + printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr); printf(" NEXT:%08x DATA:%08x LEN:%04x STAT:%08x%s\n", le32toh(ds->physnext), le32toh(ds->pktptr), le16toh(ds->pktlen), status, Modified: stable/10/sys/dev/mwl/if_mwl.c ============================================================================== --- stable/10/sys/dev/mwl/if_mwl.c Sun Feb 15 19:56:31 2015 (r278807) +++ stable/10/sys/dev/mwl/if_mwl.c Sun Feb 15 20:02:29 2015 (r278808) @@ -2068,9 +2068,10 @@ mwl_desc_setup(struct mwl_softc *sc, con ds = dd->dd_desc; memset(ds, 0, dd->dd_desc_len); - DPRINTF(sc, MWL_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n", + DPRINTF(sc, MWL_DEBUG_RESET, + "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n", __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, - (caddr_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); + (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); return 0; fail2: @@ -4707,11 +4708,10 @@ mwl_printrxbuf(const struct mwl_rxbuf *b const struct mwl_rxdesc *ds = bf->bf_desc; uint32_t status = le32toh(ds->Status); - printf("R[%2u] (DS.V:%p DS.P:%p) NEXT:%08x DATA:%08x RC:%02x%s\n" + printf("R[%2u] (DS.V:%p DS.P:0x%jx) NEXT:%08x DATA:%08x RC:%02x%s\n" " STAT:%02x LEN:%04x RSSI:%02x CHAN:%02x RATE:%02x QOS:%04x HT:%04x\n", - ix, ds, (const struct mwl_desc *)bf->bf_daddr, - le32toh(ds->pPhysNext), le32toh(ds->pPhysBuffData), - ds->RxControl, + ix, ds, (uintmax_t)bf->bf_daddr, le32toh(ds->pPhysNext), + le32toh(ds->pPhysBuffData), ds->RxControl, ds->RxControl != EAGLE_RXD_CTRL_DRIVER_OWN ? "" : (status & EAGLE_RXD_STATUS_OK) ? " *" : " !", ds->Status, le16toh(ds->PktLen), ds->RSSI, ds->Channel, @@ -4725,8 +4725,7 @@ mwl_printtxbuf(const struct mwl_txbuf *b uint32_t status = le32toh(ds->Status); printf("Q%u[%3u]", qnum, ix); - printf(" (DS.V:%p DS.P:%p)\n", - ds, (const struct mwl_txdesc *)bf->bf_daddr); + printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr); printf(" NEXT:%08x DATA:%08x LEN:%04x STAT:%08x%s\n", le32toh(ds->pPhysNext), le32toh(ds->PktPtr), le16toh(ds->PktLen), status, From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 20:53:52 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EE43CE4E; Sun, 15 Feb 2015 20:53:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 D841B6B4; Sun, 15 Feb 2015 20:53:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FKrp68050243; Sun, 15 Feb 2015 20:53:51 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FKrpQw050242; Sun, 15 Feb 2015 20:53:51 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201502152053.t1FKrpQw050242@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 15 Feb 2015 20:53:51 +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: r278812 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 20:53:52 -0000 Author: marius Date: Sun Feb 15 20:53:50 2015 New Revision: 278812 URL: https://svnweb.freebsd.org/changeset/base/278812 Log: MFC: r266990 (missed in r265946) Fix build UDP-Lite with VIMAGE enabled when building with gcc. Modified: stable/10/sys/netinet/udp_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/udp_var.h ============================================================================== --- stable/10/sys/netinet/udp_var.h Sun Feb 15 20:43:32 2015 (r278811) +++ stable/10/sys/netinet/udp_var.h Sun Feb 15 20:53:50 2015 (r278812) @@ -129,6 +129,7 @@ void kmod_udpstat_inc(int statnum); #define UDPCTL_MAXID 6 #ifdef _KERNEL +#include SYSCTL_DECL(_net_inet_udp); extern struct pr_usrreqs udp_usrreqs; From owner-svn-src-stable-10@FreeBSD.ORG Sun Feb 15 20:55:27 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 76A14F8D; Sun, 15 Feb 2015 20:55:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 566D76C2; Sun, 15 Feb 2015 20:55:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FKtRqA050560; Sun, 15 Feb 2015 20:55:27 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FKtRcU050559; Sun, 15 Feb 2015 20:55:27 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201502152055.t1FKtRcU050559@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 15 Feb 2015 20:55:27 +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: r278813 - stable/10/sys/dev/hwpmc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 20:55:27 -0000 Author: emaste Date: Sun Feb 15 20:55:26 2015 New Revision: 278813 URL: https://svnweb.freebsd.org/changeset/base/278813 Log: Clamp too large hwpmc callchaindepth to maximum If the depth requested by the user is too large, it's better to provide the maximum than the smaller default. MFC of: r274766 Sponsored by: The FreeBSD Foundation Modified: stable/10/sys/dev/hwpmc/hwpmc_mod.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- stable/10/sys/dev/hwpmc/hwpmc_mod.c Sun Feb 15 20:53:50 2015 (r278812) +++ stable/10/sys/dev/hwpmc/hwpmc_mod.c Sun Feb 15 20:55:26 2015 (r278813) @@ -4753,8 +4753,9 @@ pmc_initialize(void) if (pmc_callchaindepth <= 0 || pmc_callchaindepth > PMC_CALLCHAIN_DEPTH_MAX) { (void) printf("hwpmc: tunable \"callchaindepth\"=%d out of " - "range.\n", pmc_callchaindepth); - pmc_callchaindepth = PMC_CALLCHAIN_DEPTH; + "range - using %d.\n", pmc_callchaindepth, + PMC_CALLCHAIN_DEPTH_MAX); + pmc_callchaindepth = PMC_CALLCHAIN_DEPTH_MAX; } md = pmc_md_initialize(); From owner-svn-src-stable-10@FreeBSD.ORG Mon Feb 16 20:58:21 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ACE44D7A; Mon, 16 Feb 2015 20:58:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 96C0EF0E; Mon, 16 Feb 2015 20:58:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1GKwLs7040102; Mon, 16 Feb 2015 20:58:21 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1GKwLCM040099; Mon, 16 Feb 2015 20:58:21 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502162058.t1GKwLCM040099@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 16 Feb 2015 20:58:21 +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: r278863 - in stable/10/sys/dev/usb: . serial X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Feb 2015 20:58:21 -0000 Author: dchagin Date: Mon Feb 16 20:58:20 2015 New Revision: 278863 URL: https://svnweb.freebsd.org/changeset/base/278863 Log: MFC r278379: Add Neoway WM620 module ID. Modified: stable/10/sys/dev/usb/serial/u3g.c stable/10/sys/dev/usb/usbdevs Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/10/sys/dev/usb/serial/u3g.c Mon Feb 16 20:55:37 2015 (r278862) +++ stable/10/sys/dev/usb/serial/u3g.c Mon Feb 16 20:58:20 2015 (r278863) @@ -398,6 +398,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(QUALCOMM2, AC8700, 0), U3G_DEV(QUALCOMM2, MF330, 0), U3G_DEV(QUALCOMM2, SIM5218, 0), + U3G_DEV(QUALCOMM2, WM620, 0), U3G_DEV(QUALCOMM2, VW110L, U3GINIT_SCSIEJECT), U3G_DEV(QUALCOMM2, GOBI2000_QDL, 0), U3G_DEV(QUALCOMM2, GOBI2000, 0), Modified: stable/10/sys/dev/usb/usbdevs ============================================================================== --- stable/10/sys/dev/usb/usbdevs Mon Feb 16 20:55:37 2015 (r278862) +++ stable/10/sys/dev/usb/usbdevs Mon Feb 16 20:58:20 2015 (r278863) @@ -3575,6 +3575,7 @@ product QUALCOMM2 CDMA_MSM 0x3196 CDMA T product QUALCOMM2 AC8700 0x6000 AC8700 product QUALCOMM2 VW110L 0x1000 Vertex Wireless 110L modem product QUALCOMM2 SIM5218 0x9000 SIM5218 +product QUALCOMM2 WM620 0x9002 Neoway WM620 product QUALCOMM2 GOBI2000_QDL 0x9204 Qualcomm Gobi 2000 QDL product QUALCOMM2 GOBI2000 0x9205 Qualcomm Gobi 2000 modem product QUALCOMM2 VT80N 0x6500 Venus VT80N From owner-svn-src-stable-10@FreeBSD.ORG Mon Feb 16 22:33:46 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4399DDF3; Mon, 16 Feb 2015 22:33:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 2C4BAC73; Mon, 16 Feb 2015 22:33:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1GMXkrH090198; Mon, 16 Feb 2015 22:33:46 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1GMXjQb090193; Mon, 16 Feb 2015 22:33:45 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201502162233.t1GMXjQb090193@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Mon, 16 Feb 2015 22:33:44 +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: r278872 - stable/10/sys/dev/ipmi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Feb 2015 22:33:46 -0000 Author: scottl Date: Mon Feb 16 22:33:44 2015 New Revision: 278872 URL: https://svnweb.freebsd.org/changeset/base/278872 Log: MFC r278321 Use direct hardware access for internal requests for KCS and SMIC. In particular, updates to the watchdog should no longer sleep. - Add a new IPMI_IO_LOCK for low-level I/O access. Use this for kcs_polled_request() and smic_polled_request(). - Add a new backend callback "ipmi_driver_request" to handle a driver request. The new callback performs the request sychronously for KCS and SMIC. SSIF still defers the work to the worker thread since the worker thread sleeps during request processing anyway. - Allocate driver requests on the stack rather than using malloc(). Submitted by: jhb Modified: stable/10/sys/dev/ipmi/ipmi.c stable/10/sys/dev/ipmi/ipmi_kcs.c stable/10/sys/dev/ipmi/ipmi_smic.c stable/10/sys/dev/ipmi/ipmi_ssif.c stable/10/sys/dev/ipmi/ipmivars.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ipmi/ipmi.c ============================================================================== --- stable/10/sys/dev/ipmi/ipmi.c Mon Feb 16 22:18:43 2015 (r278871) +++ stable/10/sys/dev/ipmi/ipmi.c Mon Feb 16 22:33:44 2015 (r278872) @@ -49,6 +49,23 @@ __FBSDID("$FreeBSD$"); #include #endif +/* + * Driver request structures are allocated on the stack via alloca() to + * avoid calling malloc(), especially for the watchdog handler. + * To avoid too much stack growth, a previously allocated structure can + * be reused via IPMI_INIT_DRIVER_REQUEST(), but the caller should ensure + * that there is adequate reply/request space in the original allocation. + */ +#define IPMI_INIT_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen) \ + bzero((req), sizeof(struct ipmi_request)); \ + ipmi_init_request((req), NULL, 0, (addr), (cmd), (reqlen), (replylen)) + +#define IPMI_ALLOC_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen) \ + (req) = __builtin_alloca(sizeof(struct ipmi_request) + \ + (reqlen) + (replylen)); \ + IPMI_INIT_DRIVER_REQUEST((req), (addr), (cmd), (reqlen), \ + (replylen)) + #ifdef IPMB static int ipmi_ipmb_checksum(u_char, int); static int ipmi_ipmb_send_message(device_t, u_char, u_char, u_char, @@ -181,8 +198,8 @@ ipmi_dtor(void *arg) */ dev->ipmi_closing = 1; while (dev->ipmi_requests > 0) { - msleep(&dev->ipmi_requests, &sc->ipmi_lock, PWAIT, - "ipmidrain", 0); + msleep(&dev->ipmi_requests, &sc->ipmi_requests_lock, + PWAIT, "ipmidrain", 0); ipmi_purge_completed_requests(dev); } } @@ -215,7 +232,7 @@ ipmi_ipmb_send_message(device_t dev, u_c u_char slave_addr = 0x52; int error; - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_SEND_MSG, data_len + 8, 0); req->ir_request[0] = channel; req->ir_request[1] = slave_addr; @@ -231,7 +248,6 @@ ipmi_ipmb_send_message(device_t dev, u_c ipmi_submit_driver_request(sc, req); error = req->ir_error; - ipmi_free_request(req); return (error); } @@ -243,7 +259,7 @@ ipmi_handle_attn(struct ipmi_softc *sc) int error; device_printf(sc->ipmi_dev, "BMC has a message\n"); - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_MSG_FLAGS, 0, 1); ipmi_submit_driver_request(sc, req); @@ -257,9 +273,7 @@ ipmi_handle_attn(struct ipmi_softc *sc) "watchdog about to go off"); } if (req->ir_reply[0] & IPMI_MSG_AVAILABLE) { - ipmi_free_request(req); - - req = ipmi_alloc_driver_request( + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_MSG, 0, 16); @@ -268,7 +282,6 @@ ipmi_handle_attn(struct ipmi_softc *sc) } } error = req->ir_error; - ipmi_free_request(req); return (error); } @@ -478,15 +491,11 @@ ipmi_ioctl(struct cdev *cdev, u_long cmd * Request management. */ -/* Allocate a new request with request and reply buffers. */ -struct ipmi_request * -ipmi_alloc_request(struct ipmi_device *dev, long msgid, uint8_t addr, - uint8_t command, size_t requestlen, size_t replylen) +static __inline void +ipmi_init_request(struct ipmi_request *req, struct ipmi_device *dev, long msgid, + uint8_t addr, uint8_t command, size_t requestlen, size_t replylen) { - struct ipmi_request *req; - req = malloc(sizeof(struct ipmi_request) + requestlen + replylen, - M_IPMI, M_WAITOK | M_ZERO); req->ir_owner = dev; req->ir_msgid = msgid; req->ir_addr = addr; @@ -499,6 +508,18 @@ ipmi_alloc_request(struct ipmi_device *d req->ir_reply = (char *)&req[1] + requestlen; req->ir_replybuflen = replylen; } +} + +/* Allocate a new request with request and reply buffers. */ +struct ipmi_request * +ipmi_alloc_request(struct ipmi_device *dev, long msgid, uint8_t addr, + uint8_t command, size_t requestlen, size_t replylen) +{ + struct ipmi_request *req; + + req = malloc(sizeof(struct ipmi_request) + requestlen + replylen, + M_IPMI, M_WAITOK | M_ZERO); + ipmi_init_request(req, dev, msgid, addr, command, requestlen, replylen); return (req); } @@ -533,21 +554,13 @@ ipmi_complete_request(struct ipmi_softc } } -/* Enqueue an internal driver request and wait until it is completed. */ +/* Perform an internal driver request. */ int ipmi_submit_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo) { - int error; - IPMI_LOCK(sc); - error = sc->ipmi_enqueue_request(sc, req); - if (error == 0) - error = msleep(req, &sc->ipmi_lock, 0, "ipmireq", timo); - if (error == 0) - error = req->ir_error; - IPMI_UNLOCK(sc); - return (error); + return (sc->ipmi_driver_request(sc, req, timo)); } /* @@ -564,7 +577,7 @@ ipmi_dequeue_request(struct ipmi_softc * IPMI_LOCK_ASSERT(sc); while (!sc->ipmi_detaching && TAILQ_EMPTY(&sc->ipmi_pending_requests)) - cv_wait(&sc->ipmi_request_added, &sc->ipmi_lock); + cv_wait(&sc->ipmi_request_added, &sc->ipmi_requests_lock); if (sc->ipmi_detaching) return (NULL); @@ -598,7 +611,7 @@ ipmi_set_watchdog(struct ipmi_softc *sc, if (sec > 0xffff / 10) return (EINVAL); - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_SET_WDOG, 6, 0); if (sec) { @@ -622,9 +635,7 @@ ipmi_set_watchdog(struct ipmi_softc *sc, if (error) device_printf(sc->ipmi_dev, "Failed to set watchdog\n"); else if (sec) { - ipmi_free_request(req); - - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_RESET_WDOG, 0, 0); error = ipmi_submit_driver_request(sc, req, 0); @@ -633,7 +644,6 @@ ipmi_set_watchdog(struct ipmi_softc *sc, "Failed to reset watchdog\n"); } - ipmi_free_request(req); return (error); /* dump_watchdog(sc); @@ -680,7 +690,8 @@ ipmi_startup(void *arg) dev = sc->ipmi_dev; /* Initialize interface-independent state. */ - mtx_init(&sc->ipmi_lock, device_get_nameunit(dev), "ipmi", MTX_DEF); + mtx_init(&sc->ipmi_requests_lock, "ipmi requests", NULL, MTX_DEF); + mtx_init(&sc->ipmi_io_lock, "ipmi io", NULL, MTX_DEF); cv_init(&sc->ipmi_request_added, "ipmireq"); TAILQ_INIT(&sc->ipmi_pending_requests); @@ -693,28 +704,24 @@ ipmi_startup(void *arg) } /* Send a GET_DEVICE_ID request. */ - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_DEVICE_ID, 0, 15); error = ipmi_submit_driver_request(sc, req, MAX_TIMEOUT); if (error == EWOULDBLOCK) { device_printf(dev, "Timed out waiting for GET_DEVICE_ID\n"); - ipmi_free_request(req); return; } else if (error) { device_printf(dev, "Failed GET_DEVICE_ID: %d\n", error); - ipmi_free_request(req); return; } else if (req->ir_compcode != 0) { device_printf(dev, "Bad completion code for GET_DEVICE_ID: %d\n", req->ir_compcode); - ipmi_free_request(req); return; } else if (req->ir_replylen < 5) { device_printf(dev, "Short reply for GET_DEVICE_ID: %d\n", req->ir_replylen); - ipmi_free_request(req); return; } @@ -724,9 +731,7 @@ ipmi_startup(void *arg) req->ir_reply[2] & 0x7f, req->ir_reply[3] >> 4, req->ir_reply[3] & 0x0f, req->ir_reply[4] & 0x0f, req->ir_reply[4] >> 4); - ipmi_free_request(req); - - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_CLEAR_FLAGS, 1, 0); ipmi_submit_driver_request(sc, req, 0); @@ -738,25 +743,21 @@ ipmi_startup(void *arg) if (req->ir_compcode == 0xc1) { device_printf(dev, "Clear flags illegal\n"); } - ipmi_free_request(req); for (i = 0; i < 8; i++) { - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_CHANNEL_INFO, 1, 0); req->ir_request[0] = i; ipmi_submit_driver_request(sc, req, 0); - if (req->ir_compcode != 0) { - ipmi_free_request(req); + if (req->ir_compcode != 0) break; - } - ipmi_free_request(req); } device_printf(dev, "Number of channels %d\n", i); /* probe for watchdog */ - req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_WDOG, 0, 0); ipmi_submit_driver_request(sc, req, 0); @@ -767,7 +768,6 @@ ipmi_startup(void *arg) sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER(watchdog_list, ipmi_wd_event, sc, 0); } - ipmi_free_request(req); sc->ipmi_cdev = make_dev(&ipmi_cdevsw, device_get_unit(dev), UID_ROOT, GID_OPERATOR, 0660, "ipmi%d", device_get_unit(dev)); @@ -834,14 +834,16 @@ ipmi_detach(device_t dev) sc->ipmi_detaching = 1; if (sc->ipmi_kthread) { cv_broadcast(&sc->ipmi_request_added); - msleep(sc->ipmi_kthread, &sc->ipmi_lock, 0, "ipmi_wait", 0); + msleep(sc->ipmi_kthread, &sc->ipmi_requests_lock, 0, + "ipmi_wait", 0); } IPMI_UNLOCK(sc); if (sc->ipmi_irq) bus_teardown_intr(dev, sc->ipmi_irq_res, sc->ipmi_irq); ipmi_release_resources(dev); - mtx_destroy(&sc->ipmi_lock); + mtx_destroy(&sc->ipmi_io_lock); + mtx_destroy(&sc->ipmi_requests_lock); return (0); } Modified: stable/10/sys/dev/ipmi/ipmi_kcs.c ============================================================================== --- stable/10/sys/dev/ipmi/ipmi_kcs.c Mon Feb 16 22:18:43 2015 (r278871) +++ stable/10/sys/dev/ipmi/ipmi_kcs.c Mon Feb 16 22:33:44 2015 (r278872) @@ -321,6 +321,8 @@ kcs_polled_request(struct ipmi_softc *sc u_char *cp, data; int i, state; + IPMI_IO_LOCK(sc); + /* Send the request. */ if (!kcs_start_write(sc)) { device_printf(sc->ipmi_dev, "KCS: Failed to start write\n"); @@ -444,6 +446,7 @@ kcs_polled_request(struct ipmi_softc *sc } i++; } + IPMI_IO_UNLOCK(sc); req->ir_replylen = i; #ifdef KCS_DEBUG device_printf(sc->ipmi_dev, "KCS: READ finished (%d bytes)\n", i); @@ -457,6 +460,7 @@ kcs_polled_request(struct ipmi_softc *sc return (1); fail: kcs_error(sc); + IPMI_IO_UNLOCK(sc); return (0); } @@ -492,6 +496,21 @@ kcs_startup(struct ipmi_softc *sc) device_get_nameunit(sc->ipmi_dev))); } +static int +kcs_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo) +{ + int i, ok; + + ok = 0; + for (i = 0; i < 3 && !ok; i++) + ok = kcs_polled_request(sc, req); + if (ok) + req->ir_error = 0; + else + req->ir_error = EIO; + return (req->ir_error); +} + int ipmi_kcs_attach(struct ipmi_softc *sc) { @@ -500,6 +519,7 @@ ipmi_kcs_attach(struct ipmi_softc *sc) /* Setup function pointers. */ sc->ipmi_startup = kcs_startup; sc->ipmi_enqueue_request = ipmi_polled_enqueue_request; + sc->ipmi_driver_request = kcs_driver_request; /* See if we can talk to the controller. */ status = INB(sc, KCS_CTL_STS); Modified: stable/10/sys/dev/ipmi/ipmi_smic.c ============================================================================== --- stable/10/sys/dev/ipmi/ipmi_smic.c Mon Feb 16 22:18:43 2015 (r278871) +++ stable/10/sys/dev/ipmi/ipmi_smic.c Mon Feb 16 22:33:44 2015 (r278872) @@ -364,8 +364,11 @@ smic_loop(void *arg) while ((req = ipmi_dequeue_request(sc)) != NULL) { IPMI_UNLOCK(sc); ok = 0; - for (i = 0; i < 3 && !ok; i++) + for (i = 0; i < 3 && !ok; i++) { + IPMI_IO_LOCK(sc); ok = smic_polled_request(sc, req); + IPMI_IO_UNLOCK(sc); + } if (ok) req->ir_error = 0; else @@ -385,6 +388,24 @@ smic_startup(struct ipmi_softc *sc) "%s: smic", device_get_nameunit(sc->ipmi_dev))); } +static int +smic_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo) +{ + int i, ok; + + ok = 0; + for (i = 0; i < 3 && !ok; i++) { + IPMI_IO_LOCK(sc); + ok = smic_polled_request(sc, req); + IPMI_IO_UNLOCK(sc); + } + if (ok) + req->ir_error = 0; + else + req->ir_error = EIO; + return (req->ir_error); +} + int ipmi_smic_attach(struct ipmi_softc *sc) { @@ -393,6 +414,7 @@ ipmi_smic_attach(struct ipmi_softc *sc) /* Setup function pointers. */ sc->ipmi_startup = smic_startup; sc->ipmi_enqueue_request = ipmi_polled_enqueue_request; + sc->ipmi_driver_request = smic_driver_request; /* See if we can talk to the controller. */ flags = INB(sc, SMIC_FLAGS); Modified: stable/10/sys/dev/ipmi/ipmi_ssif.c ============================================================================== --- stable/10/sys/dev/ipmi/ipmi_ssif.c Mon Feb 16 22:18:43 2015 (r278871) +++ stable/10/sys/dev/ipmi/ipmi_ssif.c Mon Feb 16 22:33:44 2015 (r278872) @@ -359,6 +359,22 @@ ssif_startup(struct ipmi_softc *sc) "%s: ssif", device_get_nameunit(sc->ipmi_dev))); } +static int +ssif_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo) +{ + int error; + + IPMI_LOCK(sc); + error = ipmi_polled_enqueue_request(sc, req); + if (error == 0) + error = msleep(req, &sc->ipmi_requests_lock, 0, "ipmireq", + timo); + if (error == 0) + error = req->ir_error; + IPMI_UNLOCK(sc); + return (error); +} + int ipmi_ssif_attach(struct ipmi_softc *sc, device_t smbus, int smbus_address) { @@ -370,6 +386,7 @@ ipmi_ssif_attach(struct ipmi_softc *sc, /* Setup function pointers. */ sc->ipmi_startup = ssif_startup; sc->ipmi_enqueue_request = ipmi_polled_enqueue_request; + sc->ipmi_driver_request = ssif_driver_request; return (0); } Modified: stable/10/sys/dev/ipmi/ipmivars.h ============================================================================== --- stable/10/sys/dev/ipmi/ipmivars.h Mon Feb 16 22:18:43 2015 (r278871) +++ stable/10/sys/dev/ipmi/ipmivars.h Mon Feb 16 22:33:44 2015 (r278872) @@ -95,6 +95,7 @@ struct ipmi_softc { } _iface; int ipmi_io_rid; int ipmi_io_type; + struct mtx ipmi_io_lock; struct resource *ipmi_io_res[MAX_RES]; int ipmi_io_spacing; int ipmi_irq_rid; @@ -107,12 +108,13 @@ struct ipmi_softc { eventhandler_tag ipmi_watchdog_tag; int ipmi_watchdog_active; struct intr_config_hook ipmi_ich; - struct mtx ipmi_lock; + struct mtx ipmi_requests_lock; struct cv ipmi_request_added; struct proc *ipmi_kthread; driver_intr_t *ipmi_intr; int (*ipmi_startup)(struct ipmi_softc *); int (*ipmi_enqueue_request)(struct ipmi_softc *, struct ipmi_request *); + int (*ipmi_driver_request)(struct ipmi_softc *, struct ipmi_request *, int); }; #define ipmi_ssif_smbus_address _iface.ssif.smbus_address @@ -183,12 +185,13 @@ struct ipmi_ipmb { #define IPMI_ADDR(netfn, lun) ((netfn) << 2 | (lun)) #define IPMI_REPLY_ADDR(addr) ((addr) + 0x4) -#define IPMI_LOCK(sc) mtx_lock(&(sc)->ipmi_lock) -#define IPMI_UNLOCK(sc) mtx_unlock(&(sc)->ipmi_lock) -#define IPMI_LOCK_ASSERT(sc) mtx_assert(&(sc)->ipmi_lock, MA_OWNED) - -#define ipmi_alloc_driver_request(addr, cmd, reqlen, replylen) \ - ipmi_alloc_request(NULL, 0, (addr), (cmd), (reqlen), (replylen)) +#define IPMI_LOCK(sc) mtx_lock(&(sc)->ipmi_requests_lock) +#define IPMI_UNLOCK(sc) mtx_unlock(&(sc)->ipmi_requests_lock) +#define IPMI_LOCK_ASSERT(sc) mtx_assert(&(sc)->ipmi_requests_lock, MA_OWNED) + +#define IPMI_IO_LOCK(sc) mtx_lock(&(sc)->ipmi_io_lock) +#define IPMI_IO_UNLOCK(sc) mtx_unlock(&(sc)->ipmi_io_lock) +#define IPMI_IO_LOCK_ASSERT(sc) mtx_assert(&(sc)->ipmi_io_lock, MA_OWNED) #if __FreeBSD_version < 601105 #define bus_read_1(r, o) \ From owner-svn-src-stable-10@FreeBSD.ORG Tue Feb 17 01:03:09 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 31C5FDB5; Tue, 17 Feb 2015 01:03:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 12277D62; Tue, 17 Feb 2015 01:03:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H138vg062030; Tue, 17 Feb 2015 01:03:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H1378J062022; Tue, 17 Feb 2015 01:03:07 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502170103.t1H1378J062022@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 17 Feb 2015 01:03: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: r278875 - in stable/10/lib: libc/gen libc/include libc/sys libthr/thread X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 01:03:09 -0000 Author: kib Date: Tue Feb 17 01:03:06 2015 New Revision: 278875 URL: https://svnweb.freebsd.org/changeset/base/278875 Log: MFC r278751: Properly interpose libc spinlocks, was missed in r276630. Modified: stable/10/lib/libc/gen/_spinlock_stub.c stable/10/lib/libc/include/libc_private.h stable/10/lib/libc/sys/interposing_table.c stable/10/lib/libthr/thread/thr_private.h stable/10/lib/libthr/thread/thr_spinlock.c stable/10/lib/libthr/thread/thr_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/_spinlock_stub.c ============================================================================== --- stable/10/lib/libc/gen/_spinlock_stub.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/gen/_spinlock_stub.c Tue Feb 17 01:03:06 2015 (r278875) @@ -33,51 +33,48 @@ __FBSDID("$FreeBSD$"); #include #include "spinlock.h" +#include "libc_private.h" long _atomic_lock_stub(volatile long *); void _spinlock_stub(spinlock_t *); void _spinunlock_stub(spinlock_t *); void _spinlock_debug_stub(spinlock_t *, char *, int); -/* - * Declare weak definitions in case the application is not linked - * with libpthread. - */ __weak_reference(_atomic_lock_stub, _atomic_lock); -__weak_reference(_spinlock_stub, _spinlock); -__weak_reference(_spinunlock_stub, _spinunlock); -__weak_reference(_spinlock_debug_stub, _spinlock_debug); - -/* - * This function is a stub for the _atomic_lock function in libpthread. - */ + long _atomic_lock_stub(volatile long *lck __unused) { return (0L); } +__weak_reference(_spinlock, _spinlock_debug); +#pragma weak _spinlock +void +_spinlock(spinlock_t *lck) +{ + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock]) + (lck); -/* - * This function is a stub for the spinlock function in libpthread. - */ +} + +#pragma weak _spinlock void -_spinlock_stub(spinlock_t *lck __unused) +_spinunlock(spinlock_t *lck) { + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock]) + (lck); + } -/* - * This function is a stub for the spinunlock function in libpthread. - */ void -_spinunlock_stub(spinlock_t *lck __unused) +__libc_spinlock_stub(spinlock_t *lck __unused) { } -/* - * This function is a stub for the debug spinlock function in libpthread. - */ void -_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int lineno __unused) +__libc_spinunlock_stub(spinlock_t *lck __unused) { } Modified: stable/10/lib/libc/include/libc_private.h ============================================================================== --- stable/10/lib/libc/include/libc_private.h Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/include/libc_private.h Tue Feb 17 01:03:06 2015 (r278875) @@ -95,6 +95,9 @@ do { \ _SPINUNLOCK(&__stdio_thread_lock); \ } while (0) +void __libc_spinlock_stub(struct _spinlock *); +void __libc_spinunlock_stub(struct _spinlock *); + /* * Indexes into the pthread jump table. * @@ -216,6 +219,8 @@ enum { INTERPOS_write, INTERPOS_writev, INTERPOS__pthread_mutex_init_calloc_cb, + INTERPOS_spinlock, + INTERPOS_spinunlock, INTERPOS_MAX }; Modified: stable/10/lib/libc/sys/interposing_table.c ============================================================================== --- stable/10/lib/libc/sys/interposing_table.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/sys/interposing_table.c Tue Feb 17 01:03:06 2015 (r278875) @@ -73,6 +73,8 @@ interpos_func_t __libc_interposing[INTER SLOT(write, __sys_write), SLOT(writev, __sys_writev), SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub), + SLOT(spinlock, __libc_spinlock_stub), + SLOT(spinunlock, __libc_spinunlock_stub), }; #undef SLOT Modified: stable/10/lib/libthr/thread/thr_private.h ============================================================================== --- stable/10/lib/libthr/thread/thr_private.h Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_private.h Tue Feb 17 01:03:06 2015 (r278875) @@ -928,6 +928,10 @@ int __thr_sigwait(const sigset_t *set, i int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info); int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp); +struct _spinlock; +void __thr_spinunlock(struct _spinlock *lck); +void __thr_spinlock(struct _spinlock *lck); + __END_DECLS #endif /* !_THR_PRIVATE_H */ Modified: stable/10/lib/libthr/thread/thr_spinlock.c ============================================================================== --- stable/10/lib/libthr/thread/thr_spinlock.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_spinlock.c Tue Feb 17 01:03:06 2015 (r278875) @@ -61,7 +61,7 @@ static void init_spinlock(spinlock_t *lc */ void -_spinunlock(spinlock_t *lck) +__thr_spinunlock(spinlock_t *lck) { struct spinlock_extra *_extra; @@ -70,7 +70,7 @@ _spinunlock(spinlock_t *lck) } void -_spinlock(spinlock_t *lck) +__thr_spinlock(spinlock_t *lck) { struct spinlock_extra *_extra; @@ -84,12 +84,6 @@ _spinlock(spinlock_t *lck) THR_UMUTEX_LOCK(_get_curthread(), &_extra->lock); } -void -_spinlock_debug(spinlock_t *lck, char *fname __unused, int lineno __unused) -{ - _spinlock(lck); -} - static void init_spinlock(spinlock_t *lck) { Modified: stable/10/lib/libthr/thread/thr_syscalls.c ============================================================================== --- stable/10/lib/libthr/thread/thr_syscalls.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_syscalls.c Tue Feb 17 01:03:06 2015 (r278875) @@ -597,6 +597,8 @@ __thr_interpose_libc(void) SLOT(wait4); SLOT(write); SLOT(writev); + SLOT(spinlock); + SLOT(spinunlock); #undef SLOT *(__libc_interposing_slot( INTERPOS__pthread_mutex_init_calloc_cb)) = From owner-svn-src-stable-10@FreeBSD.ORG Tue Feb 17 17:34:46 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CE61CCE9; Tue, 17 Feb 2015 17:34:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B87CD647; Tue, 17 Feb 2015 17:34:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HHYkeJ035510; Tue, 17 Feb 2015 17:34:46 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HHYksZ035509; Tue, 17 Feb 2015 17:34:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502171734.t1HHYksZ035509@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 17 Feb 2015 17:34:46 +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: r278906 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 17:34:46 -0000 Author: mav Date: Tue Feb 17 17:34:45 2015 New Revision: 278906 URL: https://svnweb.freebsd.org/changeset/base/278906 Log: MFC r278500: Do not abort already aborted tasks. This fixes abort of new tasks with the same tags as previously aborted, but still remaining on the queue. Modified: stable/10/sys/cam/ctl/ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Tue Feb 17 16:01:00 2015 (r278905) +++ stable/10/sys/cam/ctl/ctl.c Tue Feb 17 17:34:45 2015 (r278906) @@ -12176,64 +12176,57 @@ ctl_abort_task(union ctl_io *io) printf("%s\n", sbuf_data(&sb)); #endif - if ((xio->io_hdr.nexus.targ_port == io->io_hdr.nexus.targ_port) - && (xio->io_hdr.nexus.initid.id == - io->io_hdr.nexus.initid.id)) { - /* - * If the abort says that the task is untagged, the - * task in the queue must be untagged. Otherwise, - * we just check to see whether the tag numbers - * match. This is because the QLogic firmware - * doesn't pass back the tag type in an abort - * request. - */ + if ((xio->io_hdr.nexus.targ_port != io->io_hdr.nexus.targ_port) + || (xio->io_hdr.nexus.initid.id != io->io_hdr.nexus.initid.id) + || (xio->io_hdr.flags & CTL_FLAG_ABORT)) + continue; + + /* + * If the abort says that the task is untagged, the + * task in the queue must be untagged. Otherwise, + * we just check to see whether the tag numbers + * match. This is because the QLogic firmware + * doesn't pass back the tag type in an abort + * request. + */ #if 0 - if (((xio->scsiio.tag_type == CTL_TAG_UNTAGGED) - && (io->taskio.tag_type == CTL_TAG_UNTAGGED)) - || (xio->scsiio.tag_num == io->taskio.tag_num)) { + if (((xio->scsiio.tag_type == CTL_TAG_UNTAGGED) + && (io->taskio.tag_type == CTL_TAG_UNTAGGED)) + || (xio->scsiio.tag_num == io->taskio.tag_num)) { #endif - /* - * XXX KDM we've got problems with FC, because it - * doesn't send down a tag type with aborts. So we - * can only really go by the tag number... - * This may cause problems with parallel SCSI. - * Need to figure that out!! - */ - if (xio->scsiio.tag_num == io->taskio.tag_num) { - xio->io_hdr.flags |= CTL_FLAG_ABORT; - found = 1; - if ((io->io_hdr.flags & - CTL_FLAG_FROM_OTHER_SC) == 0 && - !(lun->flags & CTL_LUN_PRIMARY_SC)) { - union ctl_ha_msg msg_info; - - io->io_hdr.flags |= - CTL_FLAG_SENT_2OTHER_SC; - msg_info.hdr.nexus = io->io_hdr.nexus; - msg_info.task.task_action = - CTL_TASK_ABORT_TASK; - msg_info.task.tag_num = - io->taskio.tag_num; - msg_info.task.tag_type = - io->taskio.tag_type; - msg_info.hdr.msg_type = - CTL_MSG_MANAGE_TASKS; - msg_info.hdr.original_sc = NULL; - msg_info.hdr.serializing_sc = NULL; + /* + * XXX KDM we've got problems with FC, because it + * doesn't send down a tag type with aborts. So we + * can only really go by the tag number... + * This may cause problems with parallel SCSI. + * Need to figure that out!! + */ + if (xio->scsiio.tag_num == io->taskio.tag_num) { + xio->io_hdr.flags |= CTL_FLAG_ABORT; + found = 1; + if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) == 0 && + !(lun->flags & CTL_LUN_PRIMARY_SC)) { + union ctl_ha_msg msg_info; + + io->io_hdr.flags |= CTL_FLAG_SENT_2OTHER_SC; + msg_info.hdr.nexus = io->io_hdr.nexus; + msg_info.task.task_action = CTL_TASK_ABORT_TASK; + msg_info.task.tag_num = io->taskio.tag_num; + msg_info.task.tag_type = io->taskio.tag_type; + msg_info.hdr.msg_type = CTL_MSG_MANAGE_TASKS; + msg_info.hdr.original_sc = NULL; + msg_info.hdr.serializing_sc = NULL; #if 0 - printf("Sent Abort to other side\n"); + printf("Sent Abort to other side\n"); #endif - if (CTL_HA_STATUS_SUCCESS != - ctl_ha_msg_send(CTL_HA_CHAN_CTL, - (void *)&msg_info, - sizeof(msg_info), 0)) { - } + if (ctl_ha_msg_send(CTL_HA_CHAN_CTL, + (void *)&msg_info, sizeof(msg_info), 0) != + CTL_HA_STATUS_SUCCESS) { } + } #if 0 - printf("ctl_abort_task: found I/O to abort\n"); + printf("ctl_abort_task: found I/O to abort\n"); #endif - break; - } } } mtx_unlock(&lun->lun_lock); From owner-svn-src-stable-10@FreeBSD.ORG Tue Feb 17 19:14:17 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8CBF474C; Tue, 17 Feb 2015 19:14:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 77918383; Tue, 17 Feb 2015 19:14:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HJEH6L082917; Tue, 17 Feb 2015 19:14:17 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HJEH57082916; Tue, 17 Feb 2015 19:14:17 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201502171914.t1HJEH57082916@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 17 Feb 2015 19:14:17 +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: r278910 - stable/10/lib/libc/regex X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 19:14:17 -0000 Author: delphij Date: Tue Feb 17 19:14:16 2015 New Revision: 278910 URL: https://svnweb.freebsd.org/changeset/base/278910 Log: MFC r278739: Disallow pattern spaces which would cause intermediate calculations to overflow size_t. Obtained from: DragonFly (2841837793bd095a82f477e9c370cfe6cfb3862c dillon) Security: CERT VU#695940 Modified: stable/10/lib/libc/regex/regcomp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/regex/regcomp.c ============================================================================== --- stable/10/lib/libc/regex/regcomp.c Tue Feb 17 18:33:17 2015 (r278909) +++ stable/10/lib/libc/regex/regcomp.c Tue Feb 17 19:14:16 2015 (r278910) @@ -192,6 +192,7 @@ regcomp(regex_t * __restrict preg, struct parse *p = &pa; int i; size_t len; + size_t maxlen; #ifdef REDEBUG # define GOODFLAGS(f) (f) #else @@ -213,7 +214,23 @@ regcomp(regex_t * __restrict preg, g = (struct re_guts *)malloc(sizeof(struct re_guts)); if (g == NULL) return(REG_ESPACE); + /* + * Limit the pattern space to avoid a 32-bit overflow on buffer + * extension. Also avoid any signed overflow in case of conversion + * so make the real limit based on a 31-bit overflow. + * + * Likely not applicable on 64-bit systems but handle the case + * generically (who are we to stop people from using ~715MB+ + * patterns?). + */ + maxlen = ((size_t)-1 >> 1) / sizeof(sop) * 2 / 3; + if (len >= maxlen) { + free((char *)g); + return(REG_ESPACE); + } p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + assert(p->ssize >= len); + p->strip = (sop *)malloc(p->ssize * sizeof(sop)); p->slen = 0; if (p->strip == NULL) { From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 08:04:05 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E5076D8; Wed, 18 Feb 2015 08:04:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 18B7AF58; Wed, 18 Feb 2015 08:04:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I8448Y024583; Wed, 18 Feb 2015 08:04:04 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I844un024582; Wed, 18 Feb 2015 08:04:04 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502180804.t1I844un024582@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Feb 2015 08:04:04 +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: r278946 - stable/10/sys/x86/iommu X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 08:04:05 -0000 Author: kib Date: Wed Feb 18 08:04:03 2015 New Revision: 278946 URL: https://svnweb.freebsd.org/changeset/base/278946 Log: MFC r278605: vm_page_lookup() accepts read-locked object. Modified: stable/10/sys/x86/iommu/intel_utils.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/iommu/intel_utils.c ============================================================================== --- stable/10/sys/x86/iommu/intel_utils.c Wed Feb 18 07:34:32 2015 (r278945) +++ stable/10/sys/x86/iommu/intel_utils.c Wed Feb 18 08:04:03 2015 (r278946) @@ -408,11 +408,9 @@ dmar_load_root_entry_ptr(struct dmar_uni */ DMAR_ASSERT_LOCKED(unit); - /* VM_OBJECT_RLOCK(unit->ctx_obj); */ - VM_OBJECT_WLOCK(unit->ctx_obj); + VM_OBJECT_RLOCK(unit->ctx_obj); root_entry = vm_page_lookup(unit->ctx_obj, 0); - /* VM_OBJECT_RUNLOCK(unit->ctx_obj); */ - VM_OBJECT_WUNLOCK(unit->ctx_obj); + VM_OBJECT_RUNLOCK(unit->ctx_obj); dmar_write8(unit, DMAR_RTADDR_REG, VM_PAGE_TO_PHYS(root_entry)); dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd | DMAR_GCMD_SRTP); /* XXXKIB should have a timeout */ From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 08:06:37 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6986C82A; Wed, 18 Feb 2015 08:06:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 5361DF6C; Wed, 18 Feb 2015 08:06:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I86b6w025002; Wed, 18 Feb 2015 08:06:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I86a8Z025000; Wed, 18 Feb 2015 08:06:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502180806.t1I86a8Z025000@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Feb 2015 08:06:36 +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: r278947 - stable/10/sys/x86/iommu X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 08:06:37 -0000 Author: kib Date: Wed Feb 18 08:06:36 2015 New Revision: 278947 URL: https://svnweb.freebsd.org/changeset/base/278947 Log: MFC r278606: Registers definitions for the new capabilities. Modified: stable/10/sys/x86/iommu/intel_drv.c stable/10/sys/x86/iommu/intel_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/iommu/intel_drv.c ============================================================================== --- stable/10/sys/x86/iommu/intel_drv.c Wed Feb 18 08:04:03 2015 (r278946) +++ stable/10/sys/x86/iommu/intel_drv.c Wed Feb 18 08:06:36 2015 (r278947) @@ -375,7 +375,7 @@ dmar_print_caps(device_t dev, struct dma caphi = unit->hw_cap >> 32; device_printf(dev, "cap=%b,", (u_int)unit->hw_cap, "\020\004AFL\005WBF\006PLMR\007PHMR\010CM\027ZLR\030ISOCH"); - printf("%b, ", caphi, "\020\010PSI\027DWD\030DRD"); + printf("%b, ", caphi, "\020\010PSI\027DWD\030DRD\031FL1GP\034PSI"); printf("ndoms=%d, sagaw=%d, mgaw=%d, fro=%d, nfr=%d, superp=%d", DMAR_CAP_ND(unit->hw_cap), DMAR_CAP_SAGAW(unit->hw_cap), DMAR_CAP_MGAW(unit->hw_cap), DMAR_CAP_FRO(unit->hw_cap), @@ -385,8 +385,9 @@ dmar_print_caps(device_t dev, struct dma printf("\n"); ecaphi = unit->hw_ecap >> 32; device_printf(dev, "ecap=%b,", (u_int)unit->hw_ecap, - "\020\001C\002QI\003DI\004IR\005EIM\007PT\010SC"); - printf("%b, ", ecaphi, "\020"); + "\020\001C\002QI\003DI\004IR\005EIM\007PT\010SC\031ECS\032MTS" + "\033NEST\034DIS\035PASID\036PRS\037ERS\040SRS"); + printf("%b, ", ecaphi, "\020\002NWFS\003EAFS"); printf("mhmw=%d, iro=%d\n", DMAR_ECAP_MHMV(unit->hw_ecap), DMAR_ECAP_IRO(unit->hw_ecap)); } Modified: stable/10/sys/x86/iommu/intel_reg.h ============================================================================== --- stable/10/sys/x86/iommu/intel_reg.h Wed Feb 18 08:04:03 2015 (r278946) +++ stable/10/sys/x86/iommu/intel_reg.h Wed Feb 18 08:06:36 2015 (r278947) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 The FreeBSD Foundation + * Copyright (c) 2013-2015 The FreeBSD Foundation * All rights reserved. * * This software was developed by Konstantin Belousov @@ -79,6 +79,47 @@ typedef struct dmar_pte { #define DMAR_PTE_ADDR_MASK 0xffffffffff000 /* Address Mask */ #define DMAR_PTE_TM (1ULL << 62) /* Transient Mapping */ +typedef struct dmar_irte { + uint64_t irte1; + uint64_t irte2; +} dmar_irte_t; +/* Source Validation Type */ +#define DMAR_IRTE2_SVT_NONE (0ULL << (82 - 64)) +#define DMAR_IRTE2_SVT_RID (1ULL << (82 - 64)) +#define DMAR_IRTE2_SVT_BUS (2ULL << (82 - 64)) +/* Source-id Qualifier */ +#define DMAR_IRTE2_SQ_RID (0ULL << (80 - 64)) +#define DMAR_IRTE2_SQ_RID_N2 (1ULL << (80 - 64)) +#define DMAR_IRTE2_SQ_RID_N21 (2ULL << (80 - 64)) +#define DMAR_IRTE2_SQ_RID_N210 (3ULL << (80 - 64)) +/* Source Identifier */ +#define DMAR_IRTE2_SID_RID(x) ((uint64_t)(x)) +#define DMAR_IRTE2_SID_BUS(start, end) ((((uint64_t)(start)) << 8) | (end)) +/* Destination Id */ +#define DMAR_IRTE1_DST_xAPIC(x) (((uint64_t)(x)) << 40) +#define DMAR_IRTE1_DST_x2APIC(x) (((uint64_t)(x)) << 32) +/* Vector */ +#define DMAR_IRTE1_V(x) (((uint64_t)x) << 16) +#define DMAR_IRTE1_IM_POSTED (1ULL << 15) /* Posted */ +/* Delivery Mode */ +#define DMAR_IRTE1_DLM_FM (0ULL << 5) +#define DMAR_IRTE1_DLM_LP (1ULL << 5 +#define DMAR_IRTE1_DLM_SMI (2ULL << 5) +#define DMAR_IRTE1_DLM_NMI (4ULL << 5) +#define DMAR_IRTE1_DLM_INIT (5ULL << 5) +#define DMAR_IRTE1_DLM_ExtINT (7ULL << 5) +/* Trigger Mode */ +#define DMAR_IRTE1_TM_EDGE (0ULL << 4) +#define DMAR_IRTE1_TM_LEVEL (1ULL << 4) +/* Redirection Hint */ +#define DMAR_IRTE1_RH_DIRECT (0ULL << 3) +#define DMAR_IRTE1_RH_SELECT (1ULL << 3) +/* Destination Mode */ +#define DMAR_IRTE1_DM_PHYSICAL (0ULL << 2) +#define DMAR_IRTE1_DM_LOGICAL (1ULL << 2) +#define DMAR_IRTE1_FPD (1ULL << 1) /* Fault Processing Disable */ +#define DMAR_IRTE1_P (1ULL) /* Present */ + /* Version register */ #define DMAR_VER_REG 0 #define DMAR_MAJOR_VER(x) (((x) >> 4) & 0xf) @@ -86,6 +127,8 @@ typedef struct dmar_pte { /* Capabilities register */ #define DMAR_CAP_REG 0x8 +#define DMAR_CAP_PI (1ULL << 59) /* Posted Interrupts */ +#define DMAR_CAP_FL1GP (1ULL << 56) /* First Level 1GByte Page */ #define DMAR_CAP_DRD (1ULL << 55) /* DMA Read Draining */ #define DMAR_CAP_DWD (1ULL << 54) /* DMA Write Draining */ #define DMAR_CAP_MAMV(x) ((u_int)(((x) >> 48) & 0x3f)) @@ -120,6 +163,17 @@ typedef struct dmar_pte { /* Extended Capabilities register */ #define DMAR_ECAP_REG 0x10 +#define DMAR_ECAP_PSS(x) (((x) >> 35) & 0xf) /* PASID Size Supported */ +#define DMAR_ECAP_EAFS (1ULL << 34) /* Extended Accessed Flag */ +#define DMAR_ECAP_NWFS (1ULL << 33) /* No Write Flag */ +#define DMAR_ECAP_SRS (1ULL << 31) /* Supervisor Request */ +#define DMAR_ECAP_ERS (1ULL << 30) /* Execute Request */ +#define DMAR_ECAP_PRS (1ULL << 29) /* Page Request */ +#define DMAR_ECAP_PASID (1ULL << 28) /* Process Address Space Id */ +#define DMAR_ECAP_DIS (1ULL << 27) /* Deferred Invalidate */ +#define DMAR_ECAP_NEST (1ULL << 26) /* Nested Translation */ +#define DMAR_ECAP_MTS (1ULL << 25) /* Memory Type */ +#define DMAR_ECAP_ECS (1ULL << 24) /* Extended Context */ #define DMAR_ECAP_MHMV(x) ((u_int)(((x) >> 20) & 0xf)) /* Maximum Handle Mask Value */ #define DMAR_ECAP_IRO(x) ((u_int)(((x) >> 8) & 0x3ff)) @@ -283,6 +337,11 @@ typedef struct dmar_pte { #define DMAR_IQ_DESCR_IOTLB_DR (1 << 7) /* Drain Reads */ #define DMAR_IQ_DESCR_IOTLB_DID(x) (((uint32_t)(x)) << 16) /* Domain Id */ +#define DMAR_IQ_DESCR_IEC_INV 0x4 /* Invalidate Interrupt Entry Cache */ +#define DMAR_IQ_DESCR_IEC_IDX (1 << 4) /* Index-Selective Invalidation */ +#define DMAR_IQ_DESCR_IEC_IIDX(x) (((uint64_t)x) << 32) /* Interrupt Index */ +#define DMAR_IQ_DESCR_IEC_IM(x) ((x) << 27) /* Index Mask */ + #define DMAR_IQ_DESCR_WAIT_ID 0x5 /* Invalidation Wait Descriptor */ #define DMAR_IQ_DESCR_WAIT_IF (1 << 4) /* Interrupt Flag */ #define DMAR_IQ_DESCR_WAIT_SW (1 << 5) /* Status Write */ @@ -326,5 +385,8 @@ typedef struct dmar_pte { /* Interrupt Remapping Table Address register */ #define DMAR_IRTA_REG 0xb8 +#define DMAR_IRTA_EIME (1 << 11) /* Extended Interrupt Mode + Enable */ +#define DMAR_IRTA_S_MASK 0xf /* Size Mask */ #endif From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 08:08:10 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E2439964; Wed, 18 Feb 2015 08:08:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 CCA11F82; Wed, 18 Feb 2015 08:08:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I88Aln025230; Wed, 18 Feb 2015 08:08:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I88AdP025229; Wed, 18 Feb 2015 08:08:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502180808.t1I88AdP025229@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Feb 2015 08:08:10 +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: r278948 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 08:08:11 -0000 Author: kib Date: Wed Feb 18 08:08:09 2015 New Revision: 278948 URL: https://svnweb.freebsd.org/changeset/base/278948 Log: MFC r278794: Return with the process locked. Modified: stable/10/sys/kern/kern_procctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_procctl.c ============================================================================== --- stable/10/sys/kern/kern_procctl.c Wed Feb 18 08:06:36 2015 (r278947) +++ stable/10/sys/kern/kern_procctl.c Wed Feb 18 08:08:09 2015 (r278948) @@ -239,13 +239,13 @@ reap_kill(struct thread *td, struct proc int error, error1; sx_assert(&proctree_lock, SX_LOCKED); - PROC_UNLOCK(p); if (IN_CAPABILITY_MODE(td)) return (ECAPMODE); if (rk->rk_sig <= 0 || rk->rk_sig > _SIG_MAXSIG) return (EINVAL); if ((rk->rk_flags & ~REAPER_KILL_CHILDREN) != 0) return (EINVAL); + PROC_UNLOCK(p); reap = (p->p_treeflag & P_TREE_REAPER) == 0 ? p->p_reaper : p; ksiginfo_init(&ksi); ksi.ksi_signo = rk->rk_sig; From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 08:10:14 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 80B61AB3; Wed, 18 Feb 2015 08:10:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 6B036F96; Wed, 18 Feb 2015 08:10:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1I8AEVi025587; Wed, 18 Feb 2015 08:10:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1I8AEeY025586; Wed, 18 Feb 2015 08:10:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502180810.t1I8AEeY025586@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Feb 2015 08:10:14 +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: r278949 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 08:10:14 -0000 Author: kib Date: Wed Feb 18 08:10:13 2015 New Revision: 278949 URL: https://svnweb.freebsd.org/changeset/base/278949 Log: MFC r278795: Reparenting done by debugger attach can leave reaper without direct children. Handle the situation instead asserting that it is impossible. Modified: stable/10/sys/kern/kern_procctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_procctl.c ============================================================================== --- stable/10/sys/kern/kern_procctl.c Wed Feb 18 08:08:09 2015 (r278948) +++ stable/10/sys/kern/kern_procctl.c Wed Feb 18 08:10:13 2015 (r278949) @@ -160,7 +160,7 @@ static int reap_status(struct thread *td, struct proc *p, struct procctl_reaper_status *rs) { - struct proc *reap, *p2; + struct proc *reap, *p2, *first_p; sx_assert(&proctree_lock, SX_LOCKED); bzero(rs, sizeof(*rs)); @@ -176,8 +176,10 @@ reap_status(struct thread *td, struct pr rs->rs_descendants = 0; rs->rs_children = 0; if (!LIST_EMPTY(&reap->p_reaplist)) { - KASSERT(!LIST_EMPTY(&reap->p_children), ("no children")); - rs->rs_pid = LIST_FIRST(&reap->p_children)->p_pid; + first_p = LIST_FIRST(&reap->p_children); + if (first_p == NULL) + first_p = LIST_FIRST(&reap->p_reaplist); + rs->rs_pid = first_p->p_pid; LIST_FOREACH(p2, &reap->p_reaplist, p_reapsibling) { if (proc_realparent(p2) == reap) rs->rs_children++; From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 16:28:56 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2FBF8FA0; Wed, 18 Feb 2015 16:28:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 174CCF97; Wed, 18 Feb 2015 16:28:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1IGSt9E070096; Wed, 18 Feb 2015 16:28:55 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1IGSt1J070095; Wed, 18 Feb 2015 16:28:55 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201502181628.t1IGSt1J070095@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 18 Feb 2015 16:28:55 +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: r278961 - stable/10/usr.sbin/binmiscctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 16:28:56 -0000 Author: sbruno Date: Wed Feb 18 16:28:55 2015 New Revision: 278961 URL: https://svnweb.freebsd.org/changeset/base/278961 Log: MFC r278827 Check for required arguments before accessing argv[0] and core dumping. Modified: stable/10/usr.sbin/binmiscctl/binmiscctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/binmiscctl/binmiscctl.c ============================================================================== --- stable/10/usr.sbin/binmiscctl/binmiscctl.c Wed Feb 18 15:25:25 2015 (r278960) +++ stable/10/usr.sbin/binmiscctl/binmiscctl.c Wed Feb 18 16:28:55 2015 (r278961) @@ -371,8 +371,10 @@ add_cmd(__unused int argc, char *argv[], } int -name_cmd(__unused int argc, char *argv[], ximgact_binmisc_entry_t *xbe) +name_cmd(int argc, char *argv[], ximgact_binmisc_entry_t *xbe) { + if (argc == 0) + usage("Required argument missing\n"); if (strlen(argv[0]) > IBE_NAME_MAX) usage("'%s' string length longer than IBE_NAME_MAX (%d)", IBE_NAME_MAX); From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 19:42:38 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6EB4CCAD; Wed, 18 Feb 2015 19:42:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 58F6CD26; Wed, 18 Feb 2015 19:42:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1IJgcdm065414; Wed, 18 Feb 2015 19:42:38 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1IJgcrY065413; Wed, 18 Feb 2015 19:42:38 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201502181942.t1IJgcrY065413@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 18 Feb 2015 19:42:38 +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: r278968 - stable/10/usr.bin/mkimg X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 19:42:38 -0000 Author: emaste Date: Wed Feb 18 19:42:37 2015 New Revision: 278968 URL: https://svnweb.freebsd.org/changeset/base/278968 Log: MFC r276893: mkimg: Add MBR EFI partition type Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.bin/mkimg/mbr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mkimg/mbr.c ============================================================================== --- stable/10/usr.bin/mkimg/mbr.c Wed Feb 18 19:35:32 2015 (r278967) +++ stable/10/usr.bin/mkimg/mbr.c Wed Feb 18 19:42:37 2015 (r278968) @@ -42,9 +42,13 @@ __FBSDID("$FreeBSD$"); #ifndef DOSPTYP_FAT32 #define DOSPTYP_FAT32 0x0b #endif +#ifndef DOSPTYP_EFI +#define DOSPTYP_EFI 0xef +#endif static struct mkimg_alias mbr_aliases[] = { { ALIAS_EBR, ALIAS_INT2TYPE(DOSPTYP_EXT) }, + { ALIAS_EFI, ALIAS_INT2TYPE(DOSPTYP_EFI) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, { ALIAS_NONE, 0 } /* Keep last! */ From owner-svn-src-stable-10@FreeBSD.ORG Wed Feb 18 23:08:15 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 92510321; Wed, 18 Feb 2015 23:08:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 72B31DF3; Wed, 18 Feb 2015 23:08:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1IN8FhX063046; Wed, 18 Feb 2015 23:08:15 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1IN8EQF063038; Wed, 18 Feb 2015 23:08:14 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201502182308.t1IN8EQF063038@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Wed, 18 Feb 2015 23:08:14 +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: r278974 - in stable/10/sys: cam cam/scsi sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2015 23:08:15 -0000 Author: ken Date: Wed Feb 18 23:08:13 2015 New Revision: 278974 URL: https://svnweb.freebsd.org/changeset/base/278974 Log: MFC 278228: The __FreeBSD_version has been changed to 1001508 for the addition of the CDAI_TYPE_EXT_INQ request type. ------------------------------------------------------------------------ r278228 | ken | 2015-02-04 17:12:21 -0700 (Wed, 04 Feb 2015) | 32 lines Add support for probing the SCSI VPD Extended Inquiry page (0x86). This VPD page is effectively an extension of the standard Inquiry data page, and includes lots of additional bits. This commit includes support for probing the page in the SCSI probe code, and an additional request type for the XPT_DEV_ADVINFO CCB. CTL already supports the Extended Inquiry page. Support for querying this page in the sa(4) driver will come later. sys/cam/scsi/scsi_xpt.c: Probe the Extended Inquiry page, if the device supports it, and return it in response to a XPT_DEV_ADVINFO CCB if it is requested. sys/cam/scsi/cam_ccb.h: Define a new advanced information CCB data type, CDAI_TYPE_EXT_INQ. sys/cam/cam_xpt.c: Free the extended inquiry data in a device when the device goes away. sys/cam/cam_xpt_internal.h: Add an extended inquiry data pointer and length to struct cam_ed. sys/sys/param.h Bump __FreeBSD_version for the addition of the new CDAI_TYPE_EXT_INQ advanced information type. Sponsored by: Spectra Logic MFC after: 1 week ------------------------------------------------------------------------ Sponsored by: Spectra Logic Modified: stable/10/sys/cam/cam_ccb.h stable/10/sys/cam/cam_xpt.c stable/10/sys/cam/cam_xpt_internal.h stable/10/sys/cam/scsi/scsi_xpt.c stable/10/sys/sys/param.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/cam_ccb.h ============================================================================== --- stable/10/sys/cam/cam_ccb.h Wed Feb 18 22:29:52 2015 (r278973) +++ stable/10/sys/cam/cam_ccb.h Wed Feb 18 23:08:13 2015 (r278974) @@ -1152,6 +1152,7 @@ struct ccb_dev_advinfo { #define CDAI_TYPE_SERIAL_NUM 2 #define CDAI_TYPE_PHYS_PATH 3 #define CDAI_TYPE_RCAPLONG 4 +#define CDAI_TYPE_EXT_INQ 5 off_t bufsiz; /* IN: Size of external buffer */ #define CAM_SCSI_DEVID_MAXLEN 65536 /* length in buffer is an uint16_t */ off_t provsiz; /* OUT: Size required/used */ Modified: stable/10/sys/cam/cam_xpt.c ============================================================================== --- stable/10/sys/cam/cam_xpt.c Wed Feb 18 22:29:52 2015 (r278973) +++ stable/10/sys/cam/cam_xpt.c Wed Feb 18 23:08:13 2015 (r278974) @@ -4793,6 +4793,7 @@ xpt_release_device(struct cam_ed *device */ free(device->supported_vpds, M_CAMXPT); free(device->device_id, M_CAMXPT); + free(device->ext_inq, M_CAMXPT); free(device->physpath, M_CAMXPT); free(device->rcap_buf, M_CAMXPT); free(device->serial_num, M_CAMXPT); Modified: stable/10/sys/cam/cam_xpt_internal.h ============================================================================== --- stable/10/sys/cam/cam_xpt_internal.h Wed Feb 18 22:29:52 2015 (r278973) +++ stable/10/sys/cam/cam_xpt_internal.h Wed Feb 18 23:08:13 2015 (r278974) @@ -83,6 +83,8 @@ struct cam_ed { uint8_t supported_vpds_len; uint32_t device_id_len; uint8_t *device_id; + uint32_t ext_inq_len; + uint8_t *ext_inq; uint8_t physpath_len; uint8_t *physpath; /* physical path string form */ uint32_t rcap_len; Modified: stable/10/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_xpt.c Wed Feb 18 22:29:52 2015 (r278973) +++ stable/10/sys/cam/scsi/scsi_xpt.c Wed Feb 18 23:08:13 2015 (r278974) @@ -142,6 +142,7 @@ typedef enum { PROBE_MODE_SENSE, PROBE_SUPPORTED_VPD_LIST, PROBE_DEVICE_ID, + PROBE_EXTENDED_INQUIRY, PROBE_SERIAL_NUM, PROBE_TUR_FOR_NEGOTIATION, PROBE_INQUIRY_BASIC_DV1, @@ -159,6 +160,7 @@ static char *probe_action_text[] = { "PROBE_MODE_SENSE", "PROBE_SUPPORTED_VPD_LIST", "PROBE_DEVICE_ID", + "PROBE_EXTENDED_INQUIRY", "PROBE_SERIAL_NUM", "PROBE_TUR_FOR_NEGOTIATION", "PROBE_INQUIRY_BASIC_DV1", @@ -926,6 +928,34 @@ done: } goto done; } + case PROBE_EXTENDED_INQUIRY: + { + struct scsi_vpd_extended_inquiry_data *ext_inq; + + ext_inq = NULL; + if (scsi_vpd_supported_page(periph, SVPD_EXTENDED_INQUIRY_DATA)) + ext_inq = malloc(sizeof(*ext_inq), M_CAMXPT, + M_NOWAIT | M_ZERO); + + if (ext_inq != NULL) { + scsi_inquiry(csio, + /*retries*/4, + probedone, + MSG_SIMPLE_Q_TAG, + (uint8_t *)ext_inq, + sizeof(*ext_inq), + /*evpd*/TRUE, + SVPD_EXTENDED_INQUIRY_DATA, + SSD_MIN_SIZE, + /*timeout*/60 * 1000); + break; + } + /* + * We'll have to do without, let our probedone + * routine finish up for us. + */ + goto done; + } case PROBE_SERIAL_NUM: { struct scsi_vpd_unit_serial_number *serial_buf; @@ -1457,6 +1487,50 @@ out: if (devid && length == 0) free(devid, M_CAMXPT); xpt_release_ccb(done_ccb); + PROBE_SET_ACTION(softc, PROBE_EXTENDED_INQUIRY); + xpt_schedule(periph, priority); + goto out; + } + case PROBE_EXTENDED_INQUIRY: { + struct scsi_vpd_extended_inquiry_data *ext_inq; + struct ccb_scsiio *csio; + int32_t length = 0; + + csio = &done_ccb->csio; + ext_inq = (struct scsi_vpd_extended_inquiry_data *) + csio->data_ptr; + if (path->device->ext_inq != NULL) { + path->device->ext_inq_len = 0; + free(path->device->ext_inq, M_CAMXPT); + path->device->ext_inq = NULL; + } + + if (ext_inq == NULL) { + /* Don't process the command as it was never sent */ + } else if (CCB_COMPLETED_OK(csio->ccb_h)) { + length = scsi_2btoul(ext_inq->page_length) + + __offsetof(struct scsi_vpd_extended_inquiry_data, + flags1); + length = min(length, sizeof(*ext_inq)); + length -= csio->resid; + if (length > 0) { + path->device->ext_inq_len = length; + path->device->ext_inq = (uint8_t *)ext_inq; + } + } else if (cam_periph_error(done_ccb, 0, + SF_RETRY_UA, + &softc->saved_ccb) == ERESTART) { + return; + } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { + /* Don't wedge the queue */ + xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, + /*run_queue*/TRUE); + } + + /* Free the device id space if we don't use it */ + if (ext_inq && length <= 0) + free(ext_inq, M_CAMXPT); + xpt_release_ccb(done_ccb); PROBE_SET_ACTION(softc, PROBE_SERIAL_NUM); xpt_schedule(periph, priority); goto out; @@ -2486,6 +2560,21 @@ scsi_dev_advinfo(union ccb *start_ccb) memcpy(cdai->buf, device->rcap_buf, amt); } break; + case CDAI_TYPE_EXT_INQ: + /* + * We fetch extended inquiry data during probe, if + * available. We don't allow changing it. + */ + if (cdai->flags & CDAI_FLAG_STORE) + return; + cdai->provsiz = device->ext_inq_len; + if (device->ext_inq_len == 0) + break; + amt = device->ext_inq_len; + if (cdai->provsiz > cdai->bufsiz) + amt = cdai->bufsiz; + memcpy(cdai->buf, device->ext_inq, amt); + break; default: return; } Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Wed Feb 18 22:29:52 2015 (r278973) +++ stable/10/sys/sys/param.h Wed Feb 18 23:08:13 2015 (r278974) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1001507 /* Master, propagated to newvers */ +#define __FreeBSD_version 1001508 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 02:56:35 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 00C6C725; Thu, 19 Feb 2015 02:56:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 DF693BDE; Thu, 19 Feb 2015 02:56:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1J2uYXw072175; Thu, 19 Feb 2015 02:56:34 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1J2uYGD072174; Thu, 19 Feb 2015 02:56:34 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201502190256.t1J2uYGD072174@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 Feb 2015 02:56:34 +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: r278982 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 02:56:35 -0000 Author: emaste Date: Thu Feb 19 02:56:34 2015 New Revision: 278982 URL: https://svnweb.freebsd.org/changeset/base/278982 Log: MFC r275140: Increase default and maximum callchain depths Bump the default from 16 to 32, to accommodate kernel flamegraphs. Bump the maximum from 32 to 128, to accommodate deep user stacks. Sponsored by: The FreeBSD Foundation Modified: stable/10/sys/sys/pmc.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/pmc.h ============================================================================== --- stable/10/sys/sys/pmc.h Thu Feb 19 01:51:17 2015 (r278981) +++ stable/10/sys/sys/pmc.h Thu Feb 19 02:56:34 2015 (r278982) @@ -349,7 +349,7 @@ enum pmc_ops { #define PMC_F_NEEDS_LOGFILE 0x00020000 /*needs log file */ #define PMC_F_ATTACH_DONE 0x00040000 /*attached at least once */ -#define PMC_CALLCHAIN_DEPTH_MAX 32 +#define PMC_CALLCHAIN_DEPTH_MAX 128 #define PMC_CC_F_USERSPACE 0x01 /*userspace callchain*/ @@ -605,7 +605,7 @@ struct pmc_op_getdyneventinfo { #define PMC_LOG_BUFFER_SIZE 4 #define PMC_NLOGBUFFERS 1024 #define PMC_NSAMPLES 1024 -#define PMC_CALLCHAIN_DEPTH 16 +#define PMC_CALLCHAIN_DEPTH 32 #define PMC_SYSCTL_NAME_PREFIX "kern." PMC_MODULE_NAME "." From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 03:57:52 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E1FE22FA; Thu, 19 Feb 2015 03:57:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 C9DF52C1; Thu, 19 Feb 2015 03:57:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1J3vpCU001380; Thu, 19 Feb 2015 03:57:51 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1J3vm1p001360; Thu, 19 Feb 2015 03:57:48 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502190357.t1J3vm1p001360@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 19 Feb 2015 03:57:48 +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: r278985 - in stable/10: release release/amd64 release/i386 release/scripts release/tools share/man/man7 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 03:57:52 -0000 Author: gjb Date: Thu Feb 19 03:57:47 2015 New Revision: 278985 URL: https://svnweb.freebsd.org/changeset/base/278985 Log: MFC r277458, r277536, r277606, r277609, r277836, r277839, r278118, r278119, r278206, r278502: r277458: Move virtual machine / cloud provider targets and options from release/Makefile to their own Makefile. Add glue to allow enabling building cloud provider VM images by default. Add a 'vm-cloudware' target, used to drive all targets in CLOUDTARGETS. Add examples for WITH_CLOUDWARE to release.conf.sample. Add WITH_CLOUDWARE evaluation to RELEASE_RMAKEFLAGS. Rewrite to consolidate VM image build scripts into one. Fix duplicated mkimg(1) call in vm_create_disk(). Add primitive (untested) PowerPC/PowerPC64 VM image support. Note: As it is currently written, the /boot/pmbr and /boot/{gptboot,boot1.hfs} use the build host and not the target build. Fixing this is likely going to be a hack in itself. mount(8) and umount(8) devfs(5) as needed. Change path for mk-vmimage.sh from ${TARGET}/ to scripts/ now that it is consolidated into one file. Fix paths for the base image and output disk image files. Set the boot partition type to 'apple-boot' for powerpc. In vm_install_base(), copy the host resolv.conf into the build chroot before attempting to do anything that requires working DNS (i.e., pkg bootstrap). In vm_extra_pre_umount(), remove the resolv.conf before the disk image is unmounted from the backing md(4). Silence errors when umounting the chroot's /dev, since it probably doesn't exist when we're running this. Unmount filesystems before attempting to destroy the md which holds them. Unmount filesystem and destroy md before we read the vnode from disk and package it into a disk image. Otherwise we end up packaging an unclean filesystem. Merge duplicative vm-CLOUDTYPE targets before additional duplication gets added by the impending arrival of ec2 and gcloud. Add NOSWAP option which can be set by a vmimage.conf file to specify that no swap space should be created in the image. This will be used by EC2 builds, since FreeBSD/EC2 allocates swap space on "ephemeral" disks which are physically attached to the Xen host node. In vm_extra_install_packages(), only bootstrap pkg(8) if VM_EXTRA_PACKAGES is empty. In vm_extra_pre_umount(), cleanup downloaded packages if pkg(8) was bootstrapped earlier. In vm_extra_install_base(), do not install waagent in the openstack image, because it is not used. This appears to be a copy mistake. Remove vm_extra_install_base() from the openstack.conf entirely, since it does not need to be overridden. Enable password-less sudo for openstack images. Update the VM_EXTRA_PACKAGES list for the openstack images. Remove vm_extra_install_base() for the Azure image, now that the waagent exists in the ports tree. Add sysutils/azure-agent to the VM_EXTRA_PACKAGES list. In vm_extra_pre_umount(), remove the explicit pkg(8) install list, as dependencies are resolved by sysutils/azure-agent. Add a 'list-cloudware' target to print the list of supported CLOUDWARE values and a description. Add the AZURE_DESC and OPENSTACK_DESC descriptions. Update release(7) Add 'list-vmtargets' target, which produces a list of all supported VM and cloud provider images. Add VHD_DESC, VMDK_DESC, QCOW2_DESC, RAW_DESC image descriptions. Update release(7) to document the list-vmtargets target. Add initial support for the GCE (Google Compute Engine) cloud hosting provider image. Remove the console setting from rc.conf(5), which is not used there. While here, set console to include vidconsole in the loader.conf(5). Remove the pkg-clean(8) call from vm_extra_pre_umount() since the function is often overridden. Add vm_extra_pkg_rmcache() to call pkg-clean(8) to avoid duplicated code. Move resolv.conf(5) removal back to vm_extra_pre_umount() where it belongs. The GCE image needs resolv.conf(5) to exist (created as part of the image setup), so it cannot be removed. Comment the line that configures ttys(5) to 'off', which makes it impossible to test that the image boots. Add a note explaining why the line is commented, and not (yet) removed entirely. Move the 'install' bits that are specific to virtual machine images from the Makefile to Makefile.vm. Rename the 'install' target to 'release-install', and add a new 'vm-install' target. Add a new 'install' target that invokes the new targets. Add WITH_CLOUDWARE to the list of make(1) variables for the release build. Remove hw.vga.textmode=1 from the VM image loader.conf, which was included during test builds and not intended to be included when merging this project branch back to head. Remove mk-azure.sh, which is no longer needed. r277536: Rename the 'release' target to 'real-release', and add two targets, 'vm-release' and 'cloudware-release', that are invoked if WITH_VMIMAGES and WITH_CLOUDWARE are not empty. This fixes an issue where 'make release' would not build the cloud provider targets because CLOUDWARE was not yet set. Move the WITH_VMIMAGES and WITH_CLOUDWARE targets to Makefile.vm. Note: There is no 'cloudware-install' target yet, since some of the disk image names may need to be specific to the provider, so this is probably best handled by the build scripts. r277606: Provide a recipe of "true" for building the "release" target once its prerequisites are satisfied, in order to avoid having an implicit rule triggered by the presence of release.sh. r277609: When iterating through VMFORMATS, the VMBASE file is not removed or truncated to a zero-size file, which if used to create more than one disk image format, can result in accidental pollution of the target formatted disk image. Instead of using a single VMBASE image (vm.img, by default), use a single base file for each format, named as VMFORMAT.img, which produces VMBASE.VMFORMAT as the final formatted image. r277836: Rename the 'system' target to 'disc1', which is specific to the disc1.iso installer image. Replace 'system' with 'release' in CLEANFILES, and add 'disc1' to CLEANDIRS. Ensure the 'dvd' target depends on 'packagesystem'. Fix 'mini-memstick.img' prerequisite, which should be the 'bootonly' target, not 'disc1' (previously 'system'). Use .TARGET as the target installation directory for the disc1.iso and bootonly.iso images, which now expand to 'disc1' and 'bootonly' respectively, mimicking the behavior of the 'dvd' target. Remove '@true' from the 'release' target, and instead use 'touch ${.TARGET}' to prevent multiple iterations of 'make release' from clobbering previously-built installer medium. r277839: Update release(7) to reflect renaming the 'system' target to 'disc1'. r278118: Move service_enable="YES" rc.conf(5) additions to VM_RC_LIST and deduplicate. Evaluate if firstboot_freebsd_update should be enabled based on UNAME_r, because it is not supported for the -CURRENT or -STABLE branches. r278119: Use ifconfig_DEFAULT="" instead of hard-coding vtnet(4) r278206: Bump copyright after r277458. r278502: In scripts/mk-vmimage.sh, prevent incorrect usage() by defaulting VMCONFIG to /dev/null, and additionally ensuring VMCONFIG is not a character device before it is sourced. While here, be sure to exit if usage() is called. This should effectively be no-op, but the usage() output was discovered while investigating a larger issue. * Several changes local to stable/10 were needed in order to handle UEFI images that are specific to this branch. Tested with: stable/10@r278906 Sponsored by: The FreeBSD Foundation Added: stable/10/release/Makefile.vm (contents, props changed) stable/10/release/scripts/mk-vmimage.sh (contents, props changed) stable/10/release/tools/gce.conf (contents, props changed) stable/10/release/tools/openstack.conf (contents, props changed) stable/10/release/tools/vmimage.subr (contents, props changed) Deleted: stable/10/release/amd64/mk-azure.sh stable/10/release/amd64/mk-vmimage.sh stable/10/release/i386/mk-azure.sh stable/10/release/i386/mk-vmimage.sh Modified: stable/10/release/Makefile stable/10/release/release.conf.sample stable/10/release/release.sh stable/10/release/tools/azure.conf stable/10/share/man/man7/release.7 Directory Properties: stable/10/ (props changed) Modified: stable/10/release/Makefile ============================================================================== --- stable/10/release/Makefile Thu Feb 19 03:32:48 2015 (r278984) +++ stable/10/release/Makefile Thu Feb 19 03:57:47 2015 (r278985) @@ -8,8 +8,13 @@ # memstick: Builds memory stick image (memstick.img) # mini-memstick: Builds minimal memory stick image (mini-memstick.img) # ftp: Sets up FTP distribution area (ftp) -# release: Build all media and FTP distribution area -# install: Copies all release media into ${DESTDIR} +# release: Invokes real-release, vm-release, and cloudware-release targets +# real-release: Build all media and FTP distribution area +# vm-release: Build all virtual machine image targets +# cloudware-release: Build all cloud hosting provider targets +# install: Invokes the release-install and vm-install targets +# release-install: Copies all release installation media into ${DESTDIR} +# vm-install: Copies all virtual machine images into ${DESTDIR} # # Variables affecting the build process: # WORLDDIR: location of src tree -- must have built world and default kernel @@ -26,6 +31,7 @@ # WITH_VMIMAGES: if set, build virtual machine images with the release # WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images # with xz(1) (extremely time consuming) +# WITH_CLOUDWARE: if set, build cloud hosting disk images with the release # TARGET/TARGET_ARCH: architecture of built release # @@ -119,13 +125,7 @@ IMAGES+= uefi-dvd1.iso . endif .endif -VMTARGETS= vm-base vm-image -VMFORMATS?= vhd vmdk qcow2 raw -VMSIZE?= 20G -VMBASE?= vm -AZURECONF?= ${.CURDIR}/tools/azure.conf - -CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES} +CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES} .if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) . for I in ${IMAGES} CLEANFILES+= ${I}.xz @@ -134,22 +134,7 @@ CLEANFILES+= ${I}.xz .if defined(WITH_DVD) && !empty(WITH_DVD) CLEANFILES+= pkg-stage .endif -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) -CLEANFILES+= ${VMBASE}.img -. for FORMAT in ${VMFORMATS} -CLEANFILES+= ${VMBASE}.${FORMAT} -. endfor -.endif -CLEANDIRS= dist ftp release bootonly dvd -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) -CLEANDIRS+= ${VMTARGETS} -.endif -.if exists(${.CURDIR}/${TARGET}/mk-azure.sh) -CLEANFILES+= ${OSRELEASE}.vhd \ - ${OSRELEASE}.vhd.raw \ - azure.img -CLEANDIRS+= vm-azure -.endif +CLEANDIRS= dist ftp disc1 bootonly dvd beforeclean: chflags -R noschg . .include @@ -196,50 +181,50 @@ reldoc: .endfor cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc -system: packagesystem +disc1: packagesystem # Install system - mkdir -p release + mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ - DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \ + DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \ WITHOUT_PROFILE=1 WITHOUT_SENDMAIL=1 WITHOUT_ATF=1 WITHOUT_LIB32=1 # Copy distfiles - mkdir -p release/usr/freebsd-dist - cp *.txz MANIFEST release/usr/freebsd-dist + mkdir -p ${.TARGET}/usr/freebsd-dist + cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist # Copy documentation, if generated .if !defined(NODOC) - cp reldoc/* release + cp reldoc/* ${.TARGET} .endif # Set up installation environment - ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf - echo sendmail_enable=\"NONE\" > release/etc/rc.conf - echo hostid_enable=\"NO\" >> release/etc/rc.conf - cp ${.CURDIR}/rc.local release/etc + ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf + echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf + echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf + cp ${.CURDIR}/rc.local ${.TARGET}/etc touch ${.TARGET} bootonly: packagesystem # Install system - mkdir -p bootonly + mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ - DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \ + DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_AMD=1 WITHOUT_AT=1 \ WITHOUT_GAMES=1 WITHOUT_GROFF=1 \ WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \ WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \ WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \ WITHOUT_KERNEL_SYMBOLS=1 # Copy manifest only (no distfiles) to get checksums - mkdir -p bootonly/usr/freebsd-dist - cp MANIFEST bootonly/usr/freebsd-dist + mkdir -p ${.TARGET}/usr/freebsd-dist + cp MANIFEST ${.TARGET}/usr/freebsd-dist # Copy documentation, if generated .if !defined(NODOC) - cp reldoc/* bootonly + cp reldoc/* ${.TARGET} .endif # Set up installation environment - ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf - echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf - echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf - cp ${.CURDIR}/rc.local bootonly/etc + ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf + echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf + echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf + cp ${.CURDIR}/rc.local ${.TARGET}/etc -dvd: +dvd: packagesystem # Install system mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ @@ -259,13 +244,13 @@ dvd: touch ${.TARGET} release.iso: disc1.iso -disc1.iso: system - sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} release +disc1.iso: disc1 + sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1 -uefi-disc1.iso: system +uefi-disc1.iso: disc1 .if exists(${.CURDIR}/${TARGET}/mkisoimages-uefi.sh) sh ${.CURDIR}/${TARGET}/mkisoimages-uefi.sh -b ${VOLUME_LABEL}_UEFICD \ - ${.TARGET} release + ${.TARGET} disc1 .endif uefi-bootonly.iso: bootonly @@ -287,21 +272,21 @@ bootonly.iso: bootonly sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly memstick: memstick.img -memstick.img: system - sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET} +memstick.img: disc1 + sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET} mini-memstick: mini-memstick.img -mini-memstick.img: system +mini-memstick.img: bootonly sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET} uefi-memstick: uefi-memstick.img -uefi-memstick.img: system +uefi-memstick.img: disc1 .if exists(${.CURDIR}/${TARGET}/make-uefi-memstick.sh) - sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh release ${.TARGET} + sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh disc1 ${.TARGET} .endif uefi-mini-memstick: uefi-mini-memstick.img -uefi-mini-memstick.img: system +uefi-mini-memstick.img: bootonly .if exists(${.CURDIR}/${TARGET}/make-uefi-memstick.sh) sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh bootonly ${.TARGET} .endif @@ -327,14 +312,16 @@ ftp: packagesystem mkdir -p ftp cp *.txz MANIFEST ftp -release: +release: real-release vm-release cloudware-release + touch ${.TARGET} + +real-release: ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) - ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS} -.endif -install: +install: release-install vm-install + +release-install: .if defined(DESTDIR) && !empty(DESTDIR) mkdir -p ${DESTDIR} .endif @@ -347,52 +334,5 @@ install: .endfor cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5 -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) - mkdir -p ${DESTDIR}/vmimages -. for FORMAT in ${VMFORMATS} - cp -p ${VMBASE}.${FORMAT} \ - ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} -. endfor -. if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES) -# This is very time consuming, so defer it after the images are moved to -# the DESTDIR. -. for FORMAT in ${VMFORMATS} - # Don't keep the originals. There is a copy in ${.OBJDIR} if needed. - ${XZCMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} -. endfor -. endif - cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \ - ${DESTDIR}/vmimages/CHECKSUM.SHA256 - cd ${DESTDIR}/vmimages && md5 ${OSRELEASE}* > \ - ${DESTDIR}/vmimages/CHECKSUM.MD5 -.endif - -vm-base: -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) -. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh) - env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ - ${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \ - ${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE} -. endif -.endif - touch ${.TARGET} -vm-image: vm-base -.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) -. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh) -. for FORMAT in ${VMFORMATS} - env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ - ${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \ - ${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT} -. endfor -. endif -.endif - touch ${.TARGET} - -vm-azure: -.if exists(${.CURDIR}/${TARGET}/mk-azure.sh) - env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} AZURECONF=${AZURECONF} \ - ${.CURDIR}/${TARGET}/mk-azure.sh ${.TARGET} azure.img \ - ${WORLDDIR} ${.TARGET} ${VMSIZE} ${OSRELEASE}.vhd -.endif - touch ${.TARGET} +.include "${.CURDIR}/Makefile.vm" Added: stable/10/release/Makefile.vm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/release/Makefile.vm Thu Feb 19 03:57:47 2015 (r278985) @@ -0,0 +1,121 @@ +# +# $FreeBSD$ +# +# +# Makefile for building virtual machine and cloud provider disk images. +# + +VMTARGETS= vm-image +VMFORMATS?= vhd vmdk qcow2 raw +VMSIZE?= 20G +VMBASE?= vm + +VHD_DESC= Azure, VirtualPC, Hyper-V, Xen disk image +VMDK_DESC= VMWare, VirtualBox disk image +QCOW2_DESC= Qemu, KVM disk image +RAW_DESC= Unformatted raw disk image + +CLOUDWARE?= AZURE \ + GCE \ + OPENSTACK +AZURE_FORMAT= vhdf +AZURE_DESC= Microsoft Azure platform image +GCE_FORMAT= raw +GCE_DESC= Google Compute Engine image +OPENSTACK_FORMAT=qcow2 +OPENSTACK_DESC= OpenStack platform image + +.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) +. for _CW in ${CLOUDWARE} +CLOUDTARGETS+= vm-${_CW:tl} +CLEANDIRS+= vm-${_CW:tl} +CLEANFILES+= ${_CW:tl}.img \ + ${_CW:tl}.${${_CW:tu}_FORMAT} \ + ${_CW:tl}.${${_CW:tu}_FORMAT}.raw +${_CW:tu}IMAGE= ${_CW:tl}.${${_CW:tu}_FORMAT} +. if exists(${.CURDIR}/tools/${_CW:tl}.conf) && !defined(${_CW:tu}CONF) +${_CW:tu}CONF?= ${.CURDIR}/tools/${_CW:tl}.conf +. endif + +vm-${_CW:tl}: + mkdir -p ${.OBJDIR}/${.TARGET} + env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${.CURDIR}/scripts/mk-vmimage.sh \ + -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \ + -i ${.OBJDIR}/${_CW:tl}.img -s ${VMSIZE} -f ${${_CW}_FORMAT} \ + -S ${WORLDDIR} -o ${.OBJDIR}/${${_CW}IMAGE} -c ${${_CW}CONF} + touch ${.TARGET} +. endfor +.endif + +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +CLEANDIRS+= ${VMTARGETS} +. for FORMAT in ${VMFORMATS} +CLEANFILES+= ${FORMAT}.img +CLEANFILES+= ${VMBASE}.${FORMAT} +. endfor +.endif + +vm-base: vm-image + +vm-image: +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +. for FORMAT in ${VMFORMATS} + mkdir -p ${.OBJDIR}/${.TARGET} + env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${.CURDIR}/scripts/mk-vmimage.sh \ + -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \ + -i ${.OBJDIR}/${FORMAT}.img -s ${VMSIZE} -f ${FORMAT} \ + -S ${WORLDDIR} -o ${.OBJDIR}/${VMBASE}.${FORMAT} +. endfor +.endif + touch ${.TARGET} + +vm-cloudware: ${CLOUDTARGETS} + +list-vmtargets: list-cloudware + @${ECHO} + @${ECHO} "Supported virtual machine disk image formats:" +.for FORMAT in ${VMFORMATS:tu} + @${ECHO} " ${FORMAT:tl}: ${${FORMAT}_DESC}" +.endfor + +list-cloudware: +.if !empty(CLOUDWARE) + @${ECHO} + @${ECHO} "Supported cloud hosting provider images:" +. for _CW in ${CLOUDWARE} + @${ECHO} " ${_CW:tu}: ${${_CW:tu}_DESC}" +. endfor +.endif + +vm-install: +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) + mkdir -p ${DESTDIR}/vmimages +. for FORMAT in ${VMFORMATS} + cp -p ${VMBASE}.${FORMAT} \ + ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} +. endfor +. if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES) +# This is very time consuming, so defer it after the images are moved to +# the DESTDIR. +. for FORMAT in ${VMFORMATS} + # Don't keep the originals. There is a copy in ${.OBJDIR} if needed. + ${XZCMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} +. endfor +. endif + cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \ + ${DESTDIR}/vmimages/CHECKSUM.SHA256 + cd ${DESTDIR}/vmimages && md5 ${OSRELEASE}* > \ + ${DESTDIR}/vmimages/CHECKSUM.MD5 +.endif + +vm-release: +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS} +.endif + +cloudware-release: +.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${CLOUDTARGETS} +.endif Modified: stable/10/release/release.conf.sample ============================================================================== --- stable/10/release/release.conf.sample Thu Feb 19 03:32:48 2015 (r278984) +++ stable/10/release/release.conf.sample Thu Feb 19 03:57:47 2015 (r278985) @@ -93,3 +93,11 @@ PORTBRANCH="ports/head@rHEAD" ## image formats to create. Valid values are listed in the mkimg(1) ## manual page, as well as 'mkimg --formats' output. #VMFORMATS="vhdf vmdk qcow2 raw" + +## Set to a non-empty value to build virtual machine images for various +## cloud providers as part of the release build. +#WITH_CLOUDWARE= + +## If WITH_CLOUDWARE is set to a non-empty value, this is a list of providers +## to create disk images. +#CLOUDWARE="AZURE OPENSTACK" Modified: stable/10/release/release.sh ============================================================================== --- stable/10/release/release.sh Thu Feb 19 03:32:48 2015 (r278984) +++ stable/10/release/release.sh Thu Feb 19 03:57:47 2015 (r278985) @@ -1,6 +1,6 @@ #!/bin/sh #- -# Copyright (c) 2013, 2014 The FreeBSD Foundation +# Copyright (c) 2013-2015 The FreeBSD Foundation # Copyright (c) 2013 Glen Barber # Copyright (c) 2011 Nathan Whitehorn # All rights reserved. @@ -90,6 +90,10 @@ WITH_COMPRESSED_IMAGES= WITH_VMIMAGES= WITH_COMPRESSED_VMIMAGES= +# Set to non-empty value to build virtual machine images for various +# cloud providers as part of the release. +WITH_CLOUDWARE= + usage() { echo "Usage: $0 [-c release.conf]" exit 1 @@ -173,7 +177,8 @@ CHROOT_DMAKEFLAGS="${CONF_FILES}" RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \ - ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES}" + ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \ + WITH_CLOUDWARE=${WITH_CLOUDWARE}" # Force src checkout if configured FORCE_SRC_KEY= Added: stable/10/release/scripts/mk-vmimage.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/release/scripts/mk-vmimage.sh Thu Feb 19 03:57:47 2015 (r278985) @@ -0,0 +1,111 @@ +#!/bin/sh +#- +# Copyright (c) 2014 The FreeBSD Foundation +# All rights reserved. +# +# This software was developed by Glen Barber under sponsorship +# from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# mk-vmimage.sh: Create virtual machine disk images in various formats. +# +# $FreeBSD$ +# + +usage() { + echo "${0} usage:" + echo "${@}" + return 1 +} + +main() { + local arg + VMCONFIG="/dev/null" + while getopts "C:c:d:f:i:o:s:S:" arg; do + case "${arg}" in + C) + VMBUILDCONF="${OPTARG}" + ;; + c) + VMCONFIG="${OPTARG}" + ;; + d) + DESTDIR="${OPTARG}" + ;; + f) + VMFORMAT="${OPTARG}" + ;; + i) + VMBASE="${OPTARG}" + ;; + o) + VMIMAGE="${OPTARG}" + ;; + s) + VMSIZE="${OPTARG}" + ;; + S) + WORLDDIR="${OPTARG}" + ;; + *) + ;; + esac + done + shift $(( ${OPTIND} - 1)) + + if [ -z "${VMBASE}" -o \ + -z "${WORLDDIR}" -o \ + -z "${DESTDIR}" -o \ + -z "${VMSIZE}" -o \ + -z "${VMIMAGE}" ]; + then + usage || exit 0 + fi + + if [ -z "${VMBUILDCONF}" ] || [ ! -e "${VMBUILDCONF}" ]; then + echo "Must provide the path to vmimage.subr." + return 1 + fi + + . "${VMBUILDCONF}" + + if [ ! -z "${VMCONFIG}" ] && [ ! -c "${VMCONFIG}" ]; then + . "${VMCONFIG}" + fi + + vm_create_base + vm_install_base + vm_extra_install_base + vm_extra_install_packages + vm_extra_install_ports + vm_extra_enable_services + vm_extra_pre_umount + vm_extra_pkg_rmcache + cleanup + vm_create_disk || return 0 + vm_extra_create_disk + + return 0 +} + +main "$@" Modified: stable/10/release/tools/azure.conf ============================================================================== --- stable/10/release/tools/azure.conf Thu Feb 19 03:32:48 2015 (r278984) +++ stable/10/release/tools/azure.conf Thu Feb 19 03:57:47 2015 (r278985) @@ -6,9 +6,37 @@ # Set to a list of packages to install. # Example: #export VM_EXTRA_PACKAGES="www/apache24" -export VM_EXTRA_PACKAGES= +export VM_EXTRA_PACKAGES="sysutils/azure-agent" # Set to a list of third-party software to enable in rc.conf(5). # Example: #export VM_RC_LIST="apache24" export VM_RC_LIST= + +vm_extra_pre_umount() { + chroot ${DESTDIR} /usr/sbin/waagent -verbose -install + yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision + echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf + echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf + echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf + + rm -f ${DESTDIR}/etc/resolv.conf + + return 0 +} + +vm_extra_create_disk() { + if [ ! -x "/usr/local/bin/qemu-img" ]; then + env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel + fi + + mv ${VMIMAGE} ${VMIMAGE}.raw + size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',') + size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) )) + qemu-img resize ${VMIMAGE}.raw ${size} + qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE} + + return 0 +} Added: stable/10/release/tools/gce.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/release/tools/gce.conf Thu Feb 19 03:57:47 2015 (r278985) @@ -0,0 +1,100 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# Set to a list of packages to install. +export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \ + google-cloud-sdk google-daemon panicmail sudo firstboot-growfs \ + google-startup-scripts" + +# Set to a list of third-party software to enable in rc.conf(5). +export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \ + firstboot_pkgs google_startup" + +vm_extra_install_base() { + echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf + echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf + echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf +} + +vm_extra_pre_umount() { + cat << EOF >> ${DESTDIR}/etc/rc.conf +dumpdev="AUTO" +ifconfig_DEFAULT="SYNCDHCP mtu 1460" +ntpd_sync_on_start="YES" +case \$(uname -r) in + *-BETA*|*-RC*|*-RELEASE*) + firstboot_freebsd_update_enable="YES" + ;; + *) + ;; +esac +# need to fill in something here +#firstboot_pkgs_list="" +panicmail_autosubmit="YES" +EOF + + cat << EOF >> ${DESTDIR}/boot/loader.conf +autoboot_delay="-1" +beastie_disable="YES" +loader_logo="none" +hw.memtest.tests="0" +console="comconsole,vidconsole" +hw.vtnet.mq_disable=1 +kern.timecounter.hardware=ACPI-safe +aesni_load="YES" +nvme_load="YES" +EOF + + echo '169.254.169.254 metadata.google.internal metadata' > \ + ${DESTDIR}/etc/hosts + + # overwrite ntp.conf + cat << EOF > ${DESTDIR}/etc/ntp.conf +server metadata.google.internal iburst + +restrict default kod nomodify notrap nopeer noquery +restrict -6 default kod nomodify notrap nopeer noquery + +restrict 127.0.0.1 +restrict -6 ::1 +restrict 127.127.1.0 +EOF + + cat << EOF >> ${DESTDIR}/etc/syslog.conf +*.err;kern.warning;auth.notice;mail.crit /dev/console +EOF + + cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config +ChallengeResponseAuthentication no +X11Forwarding no +AcceptEnv LANG +Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc +AllowAgentForwarding no +ClientAliveInterval 420 +EOF + + cat << EOF >> ${DESTDIR}/etc/crontab +0 3 * * * root /usr/sbin/freebsd-update cron +EOF + + cat << EOF >> ${DESTDIR}/etc/sysctl.conf +net.inet.icmp.drop_redirect=1 +net.inet.ip.redirect=0 +net.inet.tcp.blackhole=2 +net.inet.udp.blackhole=1 +kern.ipc.somaxconn=1024 +debug.trace_on_panic=1 +debug.debugger_on_panic=0 +EOF + + ## XXX: Verify this is needed. I do not see this requirement + ## in the docs, and it impairs the ability to boot-test a copy + ## of the image prior to packaging for upload to GCE. + #sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys + + touch ${DESTDIR}/firstboot + + return 0 +} Added: stable/10/release/tools/openstack.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/release/tools/openstack.conf Thu Feb 19 03:57:47 2015 (r278985) @@ -0,0 +1,25 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# Set to a list of packages to install. +export VM_EXTRA_PACKAGES="net/cloud-init devel/py-pbr devel/py-iso8601 \ + net/py-eventlet net/py-netaddr comms/py-serial devel/py-six \ + devel/py-babel net/py-oauth net/py-netifaces" + +# Set to a list of third-party software to enable in rc.conf(5). +export VM_RC_LIST="cloudinit" + +vm_extra_pre_umount() { + echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf + echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf + + # Openstack wants sudo(8) usable by default without a password. + echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> \ + ${DESTDIR}/usr/local/etc/sudoers.d/cloud-init + + rm -f ${DESTDIR}/etc/resolv.conf + + return 0 +} Added: stable/10/release/tools/vmimage.subr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/release/tools/vmimage.subr Thu Feb 19 03:57:47 2015 (r278985) @@ -0,0 +1,185 @@ +#!/bin/sh +# +# $FreeBSD$ +# +# +# Common functions for virtual machine image build scripts. +# + +export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" +trap "cleanup" INT QUIT TRAP ABRT TERM + +write_partition_layout() { + if [ -z "${NOSWAP}" ]; then + SWAPOPT="-p freebsd-swap/swapfs::1G" + fi + + case "${TARGET}:${TARGET_ARCH}" in + amd64:amd64 | i386:i386) + mkimg -s gpt -b /boot/pmbr \ + -p freebsd-boot/bootfs:=/boot/gptboot \ + ${SWAPOPT} \ + -p freebsd-ufs/rootfs:=${VMBASE} \ + -o ${VMIMAGE} + ;; + powerpc:powerpc*) + mkimg -s apm \ + -p apple-boot/bootfs:=/boot/boot1.hfs \ + ${SWAPOPT} \ + -p freebsd-ufs/rootfs:=${VMBASE} \ + -o ${VMIMAGE} + ;; + *) + # ENOTSUPP + return 1 + ;; + esac + + return 0 +} + +err() { + printf "${@}\n" + cleanup + return 1 +} + +cleanup() { + umount ${DESTDIR}/dev 2>/dev/null + umount ${DESTDIR} + if [ ! -z "${mddev}" ]; then + mdconfig -d -u ${mddev} + fi + + return 0 +} + +vm_create_base() { + # Creates the UFS root filesystem for the virtual machine disk, + # written to the formatted disk image with mkimg(1). + + mkdir -p ${DESTDIR} + truncate -s ${VMSIZE} ${VMBASE} + mddev=$(mdconfig -f ${VMBASE}) + newfs -j /dev/${mddev} + mount /dev/${mddev} ${DESTDIR} + + return 0 +} + +vm_install_base() { + # Installs the FreeBSD userland/kernel to the virtual machine disk. + + cd ${WORLDDIR} && \ + make DESTDIR=${DESTDIR} \ + installworld installkernel distribution || \ + err "\n\nCannot install the base system to ${DESTDIR}." + + echo '# Custom /etc/fstab for FreeBSD VM images' \ + > ${DESTDIR}/etc/fstab + echo '/dev/gpt/rootfs / ufs rw 1 1' \ + >> ${DESTDIR}/etc/fstab + if [ -z "${NOSWAP}" ]; then + echo '/dev/gpt/swapfs none swap sw 0 0' \ + >> ${DESTDIR}/etc/fstab + fi + + mkdir -p ${DESTDIR}/dev + mount -t devfs devfs ${DESTDIR}/dev + chroot ${DESTDIR} /usr/bin/newaliases + chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart + umount ${DESTDIR}/dev + + cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf + + return 0 +} + +vm_extra_install_base() { + # Prototype. When overridden, runs extra post-installworld commands + # as needed, based on the target virtual machine image or cloud + # provider image target. + + return 0 +} + +vm_extra_enable_services() { + if [ ! -z "${VM_RC_LIST}" ]; then + for _rcvar in ${VM_RC_LIST}; do + echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf + done + fi + + return 0 +} + +vm_extra_install_packages() { + if [ -z "${VM_EXTRA_PACKAGES}" ]; then + return 0 + fi + mkdir -p ${DESTDIR}/dev + mount -t devfs devfs ${DESTDIR}/dev + chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + /usr/sbin/pkg bootstrap -y + chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} + umount ${DESTDIR}/dev + + return 0 +} + +vm_extra_install_ports() { + # Prototype. When overridden, installs additional ports within the + # virtual machine environment. + + return 0 +} + +vm_extra_pre_umount() { + # Prototype. When overridden, installs additional ports within the + # virtual machine environment. + + rm -f ${DESTDIR}/etc/resolv.conf + return 0 +} + +vm_extra_pkg_rmcache() { + if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then + chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + /usr/local/sbin/pkg clean -y -a + fi + + return 0 +} + +vm_umount_base() { + i=0 + sync + while ! umount ${DESTDIR}/dev ${DESTDIR}; do + i=$(( $i + 1 )) + if [ $i -ge 10 ]; then + # This should never happen. But, it has happened. + msg="Cannot umount(8) ${DESTDIR}\n" + msg="${msg}Something has gone horribly wrong." + err "${msg}" + fi + sleep 1 + done + + return 0 +} + +vm_create_disk() { + echo "Creating image... Please wait." + echo + + write_partition_layout || return 1 + + return 0 +} + +vm_extra_create_disk() { + + return 0 +} + Modified: stable/10/share/man/man7/release.7 ============================================================================== --- stable/10/share/man/man7/release.7 Thu Feb 19 03:32:48 2015 (r278984) +++ stable/10/share/man/man7/release.7 Thu Feb 19 03:57:47 2015 (r278985) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2014 +.Dd January 28, 2015 .Dt RELEASE 7 .Os .Sh NAME @@ -406,6 +406,57 @@ See for valid format values .Pq requires version 20140927 or later . .El +.Pp +For a list of supported +.Va VMFORMATS +values +.Pq including cloud hosting provider formats +along with a brief description, run: +.Bd -literal -offset indent +cd /usr/src +make -C release list-vmtargets +.Ed +.Sh CLOUD HOSTING MACHINE IMAGES +The +.Fx +release build tools support building virtual machine images for various +cloud hosting providers, each with their own specific configuration to +include support for each hosting provider by default. +.Pp +The following +.Xr make 1 +environment variables are supported: +.Pp +.Bl -tag -width Ev +.It Va CLOUDWARE +Set to a list of one or more cloud hosting providers, enclosed in quotes. +Requires +.Va WITH_CLOUDWARE +to also be set. +.It Va WITH_CLOUDWARE +Set to a non-empty value to enable building virtual machine images +for various cloud hosting providers. +Requires +.Va CLOUDWARE +to also be set. +.El +.Pp +Additionally, the +.Va CLOUDWARE +and +.Va WITH_CLOUDWARE +variables can be added to +.Pa release.conf , +and used in conjunction with +.Pa release.sh . +.Pp +For a list of supported +.Va CLOUDWARE +values, run: +.Bd -literal -offset indent +cd /usr/src +make -C release list-cloudware +.Ed .Sh MAKEFILE TARGETS The release makefile .Pq Pa src/release/Makefile @@ -470,6 +521,23 @@ target requires the .Va WITH_VMIMAGES .Xr make 1 envirionment variable to be set to a non-null value. +.It Cm vm-cloudware +Builds +.Fx +virtual machine images for various cloud hosting providers. +See +.Qq CLOUD HOSTING MACHINE IMAGES +for implementation details. +.It Cm list-cloudware +Displays the list of valid +.Va CLOUDWARE +values. +.It Cm list-vmtargets +Displays the list of valid +.Va VMFORMAT +and +.Va CLOUDWARE +values. .El .Pp Major subtargets called by targets above: @@ -478,7 +546,7 @@ Major subtargets called by targets above Generates all the distribution archives .Pq base, kernel, ports, doc applicable on this platform. -.It Cm system +.It Cm disc1 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 09:30:43 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E9272E4E; Thu, 19 Feb 2015 09:30:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B95E48FA; Thu, 19 Feb 2015 09:30:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1J9UhjZ056914; Thu, 19 Feb 2015 09:30:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1J9Uhr9056913; Thu, 19 Feb 2015 09:30:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502190930.t1J9Uhr9056913@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Feb 2015 09:30:43 +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: r278990 - stable/10/lib/libthr X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 09:30:44 -0000 Author: kib Date: Thu Feb 19 09:30:42 2015 New Revision: 278990 URL: https://svnweb.freebsd.org/changeset/base/278990 Log: MFC r278627: Update libthr(3) man page to reflect the work done to support dlopen. Modified: stable/10/lib/libthr/libthr.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libthr/libthr.3 ============================================================================== --- stable/10/lib/libthr/libthr.3 Thu Feb 19 09:02:53 2015 (r278989) +++ stable/10/lib/libthr/libthr.3 Thu Feb 19 09:30:42 2015 (r278990) @@ -1,5 +1,5 @@ .\" Copyright (c) 2005 Robert N. M. Watson -.\" Copyright (c) 2014 The FreeBSD Foundation, Inc. +.\" Copyright (c) 2014,2015 The FreeBSD Foundation, Inc. .\" All rights reserved. .\" .\" Part of this documentation was written by @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 26, 2014 +.Dd February 12, 2015 .Dt LIBTHR 3 .Os .Sh NAME @@ -200,45 +200,25 @@ Bigger values reduce the frequency of th The value must be between 0 and 255. .El .Sh INTERACTION WITH RUN-TIME LINKER -The +On load, .Nm -library must appear before -.Li libc -in the global order of depended objects. -.Pp -Loading -.Nm -with the -.Xr dlopen 3 -call in the process after the program binary is activated -is not supported, and causes miscellaneous and hard-to-diagnose misbehaviour. -This is due to -.Nm -interposing several important -.Li libc -symbols to provide thread-safe services. -In particular, -.Dv errno -and the locking stubs from -.Li libc -are affected. -This requirement is currently not enforced. -.Pp -If the program loads any modules at run-time, and those modules may require -threading services, the main program binary must be linked with -.Li libpthread , -even if it does not require any services from the library. +installs interposing handlers into the hooks exported by +.Li libc . +The interposers provide real locking implementation instead of the +stubs for single-threaded processes in +.Li , +cancellation support and some modifications to the signal operations. .Pp .Nm cannot be unloaded; the .Xr dlclose 3 function does not perform any action when called with a handle for .Nm . -One of the reasons is that the interposing of +One of the reasons is that the internal interposing of .Li libc functions cannot be undone. .Sh SIGNALS -The implementation also interposes the user-installed +The implementation interposes the user-installed .Xr signal 3 handlers. This interposing is done to postpone signal delivery to threads which From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 13:06:40 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 19DD1400; Thu, 19 Feb 2015 13:06:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 DF4E41E1; Thu, 19 Feb 2015 13:06:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JD6d9U061292; Thu, 19 Feb 2015 13:06:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JD6dn8061291; Thu, 19 Feb 2015 13:06:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191306.t1JD6dn8061291@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 13:06:39 +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: r278999 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 13:06:40 -0000 Author: mav Date: Thu Feb 19 13:06:38 2015 New Revision: 278999 URL: https://svnweb.freebsd.org/changeset/base/278999 Log: MFC r278619: Make WRITE SAME commands respect physical block size. This change by 2-3 times improves performance of misaligned WRITE SAME commands by avoiding unneeded read-modify-write cycles inside ZFS. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 12:47:48 2015 (r278998) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 13:06:38 2015 (r278999) @@ -1190,7 +1190,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b struct ctl_be_block_io *beio; struct ctl_be_block_softc *softc; struct ctl_lba_len_flags *lbalen; - uint64_t len_left, lba; + uint64_t len_left, lba, pb, pbo, adj; int i, seglen; uint8_t *buf, *end; @@ -1244,6 +1244,8 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b DPRINTF("WRITE SAME at LBA %jx len %u\n", (uintmax_t)lbalen->lba, lbalen->len); + pb = (uint64_t)be_lun->blocksize << be_lun->pblockexp; + pbo = pb - (uint64_t)be_lun->blocksize * be_lun->pblockoff; len_left = (uint64_t)lbalen->len * be_lun->blocksize; for (i = 0, lba = 0; i < CTLBLK_MAX_SEGS && len_left > 0; i++) { @@ -1251,7 +1253,15 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b * Setup the S/G entry for this chunk. */ seglen = MIN(CTLBLK_MAX_SEG, len_left); - seglen -= seglen % be_lun->blocksize; + if (pb > be_lun->blocksize) { + adj = ((lbalen->lba + lba) * be_lun->blocksize + + seglen - pbo) % pb; + if (seglen > adj) + seglen -= adj; + else + seglen -= seglen % be_lun->blocksize; + } else + seglen -= seglen % be_lun->blocksize; beio->sg_segs[i].len = seglen; beio->sg_segs[i].addr = uma_zalloc(be_lun->lun_zone, M_WAITOK); From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:26:50 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EAE9B4B1; Thu, 19 Feb 2015 14:26:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 D520DC82; Thu, 19 Feb 2015 14:26:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEQofi099552; Thu, 19 Feb 2015 14:26:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEQoOm099551; Thu, 19 Feb 2015 14:26:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191426.t1JEQoOm099551@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:26:50 +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: r279000 - stable/10/usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:26:51 -0000 Author: mav Date: Thu Feb 19 14:26:49 2015 New Revision: 279000 URL: https://svnweb.freebsd.org/changeset/base/279000 Log: MFC r274804: In conf_apply() remove iSCSI ports from kernel before removing LUNs. Previous order confused initiators with messages about "removed" LUNs during simple ctld restart without any real config change. After this commit initiators only reestablish lost connection, receive "Power on occurred" UNIT ATTENTION status and continue normal operation. Modified: stable/10/usr.sbin/ctld/ctld.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 13:06:38 2015 (r278999) +++ stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:26:49 2015 (r279000) @@ -1664,6 +1664,16 @@ conf_apply(struct conf *oldconf, struct */ newtarg = target_find(newconf, oldtarg->t_name); if (newtarg == NULL) { + error = kernel_port_remove(oldtarg); + if (error != 0) { + log_warnx("failed to remove target %s", + oldtarg->t_name); + /* + * XXX: Uncomment after fixing the root cause. + * + * cumulated_error++; + */ + } TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next, tmplun) { log_debugx("target %s not found in new " @@ -1680,16 +1690,6 @@ conf_apply(struct conf *oldconf, struct cumulated_error++; } } - error = kernel_port_remove(oldtarg); - if (error != 0) { - log_warnx("failed to remove target %s", - oldtarg->t_name); - /* - * XXX: Uncomment after fixing the root cause. - * - * cumulated_error++; - */ - } continue; } From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:28:49 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E674D5FC; Thu, 19 Feb 2015 14:28:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 D02BBC96; Thu, 19 Feb 2015 14:28:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JESnkC099832; Thu, 19 Feb 2015 14:28:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JESmUW099827; Thu, 19 Feb 2015 14:28:48 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191428.t1JESmUW099827@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:28:48 +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: r279001 - in stable/10: sys/dev/iscsi usr.sbin/ctld usr.sbin/iscsid X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:28:50 -0000 Author: mav Date: Thu Feb 19 14:28:47 2015 New Revision: 279001 URL: https://svnweb.freebsd.org/changeset/base/279001 Log: MFC r274853: For both iSCSI initiator and target increase socket buffer sizes before establishing connection. This is a workaround for Chelsio TOE driver, that does not update socket buffer size in hardware after connection established, and unless that is done beforehand, kernel code will stuck, attempting to send/receive full PDU at once. Modified: stable/10/sys/dev/iscsi/icl.c stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/iscsid/iscsid.c stable/10/usr.sbin/iscsid/iscsid.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/iscsi/icl.c ============================================================================== --- stable/10/sys/dev/iscsi/icl.c Thu Feb 19 14:26:49 2015 (r279000) +++ stable/10/sys/dev/iscsi/icl.c Thu Feb 19 14:28:47 2015 (r279001) @@ -1204,6 +1204,8 @@ icl_conn_start(struct icl_conn *ic) icl_conn_close(ic); return (error); } + ic->ic_socket->so_snd.sb_flags |= SB_AUTOSIZE; + ic->ic_socket->so_rcv.sb_flags |= SB_AUTOSIZE; /* * Disable Nagle. Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:26:49 2015 (r279000) +++ stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:28:47 2015 (r279001) @@ -1604,7 +1604,7 @@ conf_apply(struct conf *oldconf, struct struct portal *oldp, *newp; struct isns *oldns, *newns; pid_t otherpid; - int changed, cumulated_error = 0, error; + int changed, cumulated_error = 0, error, sockbuf; int one = 1; if (oldconf->conf_debug != newconf->conf_debug) { @@ -1901,6 +1901,16 @@ conf_apply(struct conf *oldconf, struct cumulated_error++; continue; } + sockbuf = SOCKBUF_SIZE; + if (setsockopt(newp->p_socket, SOL_SOCKET, SO_RCVBUF, + &sockbuf, sizeof(sockbuf)) == -1) + log_warn("setsockopt(SO_RCVBUF) failed " + "for %s", newp->p_listen); + sockbuf = SOCKBUF_SIZE; + if (setsockopt(newp->p_socket, SOL_SOCKET, SO_SNDBUF, + &sockbuf, sizeof(sockbuf)) == -1) + log_warn("setsockopt(SO_SNDBUF) failed " + "for %s", newp->p_listen); error = setsockopt(newp->p_socket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); if (error != 0) { Modified: stable/10/usr.sbin/ctld/ctld.h ============================================================================== --- stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:26:49 2015 (r279000) +++ stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:28:47 2015 (r279001) @@ -48,6 +48,7 @@ #define MAX_NAME_LEN 223 #define MAX_DATA_SEGMENT_LENGTH (128 * 1024) #define MAX_BURST_LENGTH 16776192 +#define SOCKBUF_SIZE 1048576 struct auth { TAILQ_ENTRY(auth) a_next; Modified: stable/10/usr.sbin/iscsid/iscsid.c ============================================================================== --- stable/10/usr.sbin/iscsid/iscsid.c Thu Feb 19 14:26:49 2015 (r279000) +++ stable/10/usr.sbin/iscsid/iscsid.c Thu Feb 19 14:28:47 2015 (r279001) @@ -160,7 +160,7 @@ connection_new(unsigned int session_id, #ifdef ICL_KERNEL_PROXY struct iscsi_daemon_connect idc; #endif - int error; + int error, sockbuf; conn = calloc(1, sizeof(*conn)); if (conn == NULL) @@ -237,6 +237,14 @@ connection_new(unsigned int session_id, fail(conn, strerror(errno)); log_err(1, "failed to create socket for %s", from_addr); } + sockbuf = SOCKBUF_SIZE; + if (setsockopt(conn->conn_socket, SOL_SOCKET, SO_RCVBUF, + &sockbuf, sizeof(sockbuf)) == -1) + log_warn("setsockopt(SO_RCVBUF) failed"); + sockbuf = SOCKBUF_SIZE; + if (setsockopt(conn->conn_socket, SOL_SOCKET, SO_SNDBUF, + &sockbuf, sizeof(sockbuf)) == -1) + log_warn("setsockopt(SO_SNDBUF) failed"); if (from_ai != NULL) { error = bind(conn->conn_socket, from_ai->ai_addr, from_ai->ai_addrlen); Modified: stable/10/usr.sbin/iscsid/iscsid.h ============================================================================== --- stable/10/usr.sbin/iscsid/iscsid.h Thu Feb 19 14:26:49 2015 (r279000) +++ stable/10/usr.sbin/iscsid/iscsid.h Thu Feb 19 14:28:47 2015 (r279001) @@ -44,6 +44,7 @@ #define CONN_DIGEST_CRC32C 1 #define CONN_MUTUAL_CHALLENGE_LEN 1024 +#define SOCKBUF_SIZE 1048576 struct connection { int conn_iscsi_fd; From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:31:20 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5F62C7CC; Thu, 19 Feb 2015 14:31:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 4886AD3D; Thu, 19 Feb 2015 14:31:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEVKC5003849; Thu, 19 Feb 2015 14:31:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEVHbh003831; Thu, 19 Feb 2015 14:31:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191431.t1JEVHbh003831@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:31:17 +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: r279002 - in stable/10: sys/cam/ctl usr.sbin/ctladm usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:31:20 -0000 Author: mav Date: Thu Feb 19 14:31:16 2015 New Revision: 279002 URL: https://svnweb.freebsd.org/changeset/base/279002 Log: MFC r278037: CTL LUN mapping rewrite. Replace iSCSI-specific LUN mapping mechanism with new one, working for any ports. By default all ports are created without LUN mapping, exposing all CTL LUNs as before. But, if needed, LUN mapping can be manually set on per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2). The next step will be to teach ctld to work with FibreChannel ports also. Respecting additional flexibility of the new mechanism, ctl.conf now allows alternative syntax for LUN definition. LUNs can now be defined in global context, and then referenced from targets by unique name, as needed. It allows same LUN to be exposed several times via multiple targets. While there, increase limit for LUNs per target in ctld from 256 to 1024. Some initiators do not support LUNs above 255, but that is not our problem. Relnotes: yes Sponsored by: iXsystems, Inc. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/sys/cam/ctl/ctl_frontend.c stable/10/sys/cam/ctl/ctl_frontend.h stable/10/sys/cam/ctl/ctl_frontend_iscsi.c stable/10/sys/cam/ctl/ctl_frontend_iscsi.h stable/10/sys/cam/ctl/ctl_ioctl.h stable/10/sys/cam/ctl/ctl_private.h stable/10/sys/cam/ctl/ctl_tpc_local.c stable/10/usr.sbin/ctladm/ctladm.8 stable/10/usr.sbin/ctladm/ctladm.c stable/10/usr.sbin/ctld/ctl.conf.5 stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/ctld/kernel.c stable/10/usr.sbin/ctld/parse.y Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl.c Thu Feb 19 14:31:16 2015 (r279002) @@ -400,12 +400,11 @@ static int ctl_ioctl_fill_ooa(struct ctl struct ctl_ooa_entry *kern_entries); static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td); -static uint32_t ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun); -static uint32_t ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun); static int ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *lun, struct ctl_be_lun *be_lun, struct ctl_id target_id); static int ctl_free_lun(struct ctl_lun *lun); static void ctl_create_lun(struct ctl_be_lun *be_lun); +static struct ctl_port * ctl_io_port(struct ctl_io_hdr *io_hdr); /** static void ctl_failover_change_pages(struct ctl_softc *softc, struct ctl_scsiio *ctsio, int master); @@ -3413,6 +3412,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, struct ctl_lun_list *list; struct ctl_option *opt; int j; + uint32_t plun; list = (struct ctl_lun_list *)addr; @@ -3493,6 +3493,18 @@ ctl_ioctl(struct cdev *dev, u_long cmd, break; } + if (port->lun_map != NULL) { + sbuf_printf(sb, "\ton\n"); + for (j = 0; j < CTL_MAX_LUNS; j++) { + plun = ctl_lun_map_from_port(port, j); + if (plun >= CTL_MAX_LUNS) + continue; + sbuf_printf(sb, + "\t%u\n", + j, plun); + } + } + for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) { if (port->wwpn_iid[j].in_use == 0 || (port->wwpn_iid[j].wwpn == 0 && @@ -3540,6 +3552,38 @@ ctl_ioctl(struct cdev *dev, u_long cmd, sbuf_delete(sb); break; } + case CTL_LUN_MAP: { + struct ctl_lun_map *lm = (struct ctl_lun_map *)addr; + struct ctl_port *port; + + mtx_lock(&softc->ctl_lock); + if (lm->port >= CTL_MAX_PORTS || + (port = softc->ctl_ports[lm->port]) == NULL) { + mtx_unlock(&softc->ctl_lock); + return (ENXIO); + } + if (lm->plun < CTL_MAX_LUNS) { + if (lm->lun == UINT32_MAX) + retval = ctl_lun_map_unset(port, lm->plun); + else if (lm->lun < CTL_MAX_LUNS && + softc->ctl_luns[lm->lun] != NULL) + retval = ctl_lun_map_set(port, lm->plun, lm->lun); + else { + mtx_unlock(&softc->ctl_lock); + return (ENXIO); + } + } else if (lm->plun == UINT32_MAX) { + if (lm->lun == UINT32_MAX) + retval = ctl_lun_map_deinit(port); + else + retval = ctl_lun_map_init(port); + } else { + mtx_unlock(&softc->ctl_lock); + return (ENXIO); + } + mtx_unlock(&softc->ctl_lock); + break; + } default: { /* XXX KDM should we fix this? */ #if 0 @@ -3604,35 +3648,106 @@ ctl_port_idx(int port_num) return(port_num - CTL_MAX_PORTS); } -static uint32_t -ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun_id) +int +ctl_lun_map_init(struct ctl_port *port) +{ + uint32_t i; + + if (port->lun_map == NULL) + port->lun_map = malloc(sizeof(uint32_t) * CTL_MAX_LUNS, + M_CTL, M_NOWAIT); + if (port->lun_map == NULL) + return (ENOMEM); + for (i = 0; i < CTL_MAX_LUNS; i++) + port->lun_map[i] = UINT32_MAX; + return (0); +} + +int +ctl_lun_map_deinit(struct ctl_port *port) +{ + + if (port->lun_map == NULL) + return (0); + free(port->lun_map, M_CTL); + port->lun_map = NULL; + return (0); +} + +int +ctl_lun_map_set(struct ctl_port *port, uint32_t plun, uint32_t glun) +{ + int status; + + if (port->lun_map == NULL) { + status = ctl_lun_map_init(port); + if (status != 0) + return (status); + } + port->lun_map[plun] = glun; + return (0); +} + +int +ctl_lun_map_unset(struct ctl_port *port, uint32_t plun) +{ + + if (port->lun_map == NULL) + return (0); + port->lun_map[plun] = UINT32_MAX; + return (0); +} + +int +ctl_lun_map_unsetg(struct ctl_port *port, uint32_t glun) +{ + int i; + + if (port->lun_map == NULL) + return (0); + for (i = 0; i < CTL_MAX_LUNS; i++) { + if (port->lun_map[i] == glun) + port->lun_map[i] = UINT32_MAX; + } + return (0); +} + +uint32_t +ctl_lun_map_from_port(struct ctl_port *port, uint32_t lun_id) { - struct ctl_port *port; - port = softc->ctl_ports[ctl_port_idx(port_num)]; if (port == NULL) return (UINT32_MAX); - if (port->lun_map == NULL) + if (port->lun_map == NULL || lun_id >= CTL_MAX_LUNS) return (lun_id); - return (port->lun_map(port->targ_lun_arg, lun_id)); + return (port->lun_map[lun_id]); } -static uint32_t -ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun_id) +uint32_t +ctl_lun_map_to_port(struct ctl_port *port, uint32_t lun_id) { - struct ctl_port *port; uint32_t i; - port = softc->ctl_ports[ctl_port_idx(port_num)]; + if (port == NULL) + return (UINT32_MAX); if (port->lun_map == NULL) return (lun_id); for (i = 0; i < CTL_MAX_LUNS; i++) { - if (port->lun_map(port->targ_lun_arg, i) == lun_id) + if (port->lun_map[i] == lun_id) return (i); } return (UINT32_MAX); } +static struct ctl_port * +ctl_io_port(struct ctl_io_hdr *io_hdr) +{ + int port_num; + + port_num = io_hdr->nexus.targ_port; + return (control_softc->ctl_ports[ctl_port_idx(port_num)]); +} + /* * Note: This only works for bitmask sizes that are at least 32 bits, and * that are a power of 2. @@ -4678,9 +4793,7 @@ static int ctl_free_lun(struct ctl_lun *lun) { struct ctl_softc *softc; -#if 0 struct ctl_port *port; -#endif struct ctl_lun *nlun; int i; @@ -4688,6 +4801,9 @@ ctl_free_lun(struct ctl_lun *lun) mtx_assert(&softc->ctl_lock, MA_OWNED); + STAILQ_FOREACH(port, &softc->port_list, links) + ctl_lun_map_unsetg(port, lun->lun); + STAILQ_REMOVE(&softc->lun_list, lun, ctl_lun, links); ctl_clear_mask(softc->ctl_lun_mask, lun->lun); @@ -7345,8 +7461,7 @@ ctl_report_tagret_port_groups(struct ctl STAILQ_FOREACH(port, &softc->port_list, links) { if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; - if (ctl_map_lun_back(softc, port->targ_port, lun->lun) >= - CTL_MAX_LUNS) + if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS) continue; num_target_ports++; } @@ -7419,8 +7534,7 @@ ctl_report_tagret_port_groups(struct ctl STAILQ_FOREACH(port, &softc->port_list, links) { if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; - if (ctl_map_lun_back(softc, port->targ_port, lun->lun) - >= CTL_MAX_LUNS) + if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS) continue; p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS; scsi_ulto2b(p, tpg_desc->descriptors[pc]. @@ -9262,6 +9376,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio struct scsi_report_luns *cdb; struct scsi_report_luns_data *lun_data; struct ctl_lun *lun, *request_lun; + struct ctl_port *port; int num_luns, retval; uint32_t alloc_len, lun_datalen; int num_filled, well_known; @@ -9318,6 +9433,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio request_lun = (struct ctl_lun *) ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + port = ctl_io_port(&ctsio->io_hdr); lun_datalen = sizeof(*lun_data) + (num_luns * sizeof(struct scsi_report_luns_lundata)); @@ -9330,8 +9446,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio mtx_lock(&softc->ctl_lock); for (targ_lun_id = 0, num_filled = 0; targ_lun_id < CTL_MAX_LUNS && num_filled < num_luns; targ_lun_id++) { - lun_id = ctl_map_lun(softc, ctsio->io_hdr.nexus.targ_port, - targ_lun_id); + lun_id = ctl_lun_map_from_port(port, targ_lun_id); if (lun_id >= CTL_MAX_LUNS) continue; lun = softc->ctl_luns[lun_id]; @@ -10016,8 +10131,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; if (lun != NULL && - ctl_map_lun_back(softc, port->targ_port, lun->lun) >= - CTL_MAX_LUNS) + ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS) continue; num_target_ports++; if (port->init_devid) @@ -10070,8 +10184,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; if (lun != NULL && - ctl_map_lun_back(softc, port->targ_port, lun->lun) - >= CTL_MAX_LUNS) + ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS) continue; p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS; scsi_ulto2b(p, pd->relative_port_id); @@ -13741,6 +13854,7 @@ int ctl_queue_sense(union ctl_io *io) { struct ctl_lun *lun; + struct ctl_port *port; struct ctl_softc *softc; uint32_t initidx, targ_lun; @@ -13761,8 +13875,8 @@ ctl_queue_sense(union ctl_io *io) * If we don't have a LUN for this, just toss the sense * information. */ - targ_lun = io->io_hdr.nexus.targ_lun; - targ_lun = ctl_map_lun(softc, io->io_hdr.nexus.targ_port, targ_lun); + port = ctl_io_port(&ctsio->io_hdr); + targ_lun = ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); if ((targ_lun < CTL_MAX_LUNS) && (softc->ctl_luns[targ_lun] != NULL)) lun = softc->ctl_luns[targ_lun]; @@ -13802,6 +13916,7 @@ bailout: int ctl_queue(union ctl_io *io) { + struct ctl_port *port; CTL_DEBUG_PRINT(("ctl_queue cdb[0]=%02X\n", io->scsiio.cdb[0])); @@ -13811,9 +13926,9 @@ ctl_queue(union ctl_io *io) #endif /* CTL_TIME_IO */ /* Map FE-specific LUN ID into global one. */ + port = ctl_io_port(&io->io_hdr); io->io_hdr.nexus.targ_mapped_lun = - ctl_map_lun(control_softc, io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.targ_lun); + ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); switch (io->io_hdr.io_type) { case CTL_IO_SCSI: Modified: stable/10/sys/cam/ctl/ctl_frontend.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_frontend.c Thu Feb 19 14:31:16 2015 (r279002) @@ -234,6 +234,7 @@ ctl_port_deregister(struct ctl_port *por ctl_pool_free(pool); ctl_free_opts(&port->options); + ctl_lun_map_deinit(port); free(port->port_devid, M_CTL); port->port_devid = NULL; free(port->target_devid, M_CTL); Modified: stable/10/sys/cam/ctl/ctl_frontend.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend.h Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_frontend.h Thu Feb 19 14:31:16 2015 (r279002) @@ -51,7 +51,6 @@ typedef void (*fe_shutdown_t)(void); typedef void (*port_func_t)(void *onoff_arg); typedef int (*port_info_func_t)(void *onoff_arg, struct sbuf *sb); typedef int (*lun_func_t)(void *arg, struct ctl_id targ_id, int lun_id); -typedef uint32_t (*lun_map_func_t)(void *arg, uint32_t lun_id); typedef int (*fe_ioctl_t)(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td); @@ -226,7 +225,7 @@ struct ctl_port { void *onoff_arg; /* passed to CTL */ lun_func_t lun_enable; /* passed to CTL */ lun_func_t lun_disable; /* passed to CTL */ - lun_map_func_t lun_map; /* passed to CTL */ + uint32_t *lun_map; /* passed to CTL */ void *targ_lun_arg; /* passed to CTL */ void (*fe_datamove)(union ctl_io *io); /* passed to CTL */ void (*fe_done)(union ctl_io *io); /* passed to CTL */ Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Thu Feb 19 14:31:16 2015 (r279002) @@ -154,7 +154,6 @@ static int cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id); static int cfiscsi_lun_disable(void *arg, struct ctl_id target_id, int lun_id); -static uint32_t cfiscsi_lun_map(void *arg, uint32_t lun); static int cfiscsi_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td); static void cfiscsi_datamove(union ctl_io *io); @@ -2033,7 +2032,6 @@ cfiscsi_ioctl_port_create(struct ctl_req port->onoff_arg = ct; port->lun_enable = cfiscsi_lun_enable; port->lun_disable = cfiscsi_lun_disable; - port->lun_map = cfiscsi_lun_map; port->targ_lun_arg = ct; port->fe_datamove = cfiscsi_datamove; port->fe_done = cfiscsi_done; @@ -2083,7 +2081,7 @@ cfiscsi_ioctl_port_create(struct ctl_req free(port->target_devid, M_CFISCSI); req->status = CTL_LUN_ERROR; snprintf(req->error_str, sizeof(req->error_str), - "ctl_frontend_register() failed with error %d", retval); + "ctl_port_register() failed with error %d", retval); return; } done: @@ -2261,7 +2259,6 @@ cfiscsi_target_find_or_create(struct cfi const char *alias) { struct cfiscsi_target *ct, *newct; - int i; if (name[0] == '\0' || strlen(name) >= CTL_ISCSI_NAME_LEN) return (NULL); @@ -2279,9 +2276,6 @@ cfiscsi_target_find_or_create(struct cfi return (ct); } - for (i = 0; i < CTL_MAX_LUNS; i++) - newct->ct_luns[i] = UINT32_MAX; - strlcpy(newct->ct_name, name, sizeof(newct->ct_name)); if (alias != NULL) strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias)); @@ -2296,108 +2290,17 @@ cfiscsi_target_find_or_create(struct cfi return (newct); } -/* - * Takes LUN from the target space and returns LUN from the CTL space. - */ -static uint32_t -cfiscsi_lun_map(void *arg, uint32_t lun) -{ - struct cfiscsi_target *ct = arg; - - if (lun >= CTL_MAX_LUNS) { - CFISCSI_DEBUG("requested lun number %d is higher " - "than maximum %d", lun, CTL_MAX_LUNS - 1); - return (UINT32_MAX); - } - return (ct->ct_luns[lun]); -} - -static int -cfiscsi_target_set_lun(struct cfiscsi_target *ct, - unsigned long lun_id, unsigned long ctl_lun_id) -{ - - if (lun_id >= CTL_MAX_LUNS) { - CFISCSI_WARN("requested lun number %ld is higher " - "than maximum %d", lun_id, CTL_MAX_LUNS - 1); - return (-1); - } - - if (ct->ct_luns[lun_id] < CTL_MAX_LUNS) { - /* - * CTL calls cfiscsi_lun_enable() twice for each LUN - once - * when the LUN is created, and a second time just before - * the port is brought online; don't emit warnings - * for that case. - */ - if (ct->ct_luns[lun_id] == ctl_lun_id) - return (0); - CFISCSI_WARN("lun %ld already allocated", lun_id); - return (-1); - } - -#if 0 - CFISCSI_DEBUG("adding mapping for lun %ld, target %s " - "to ctl lun %ld", lun_id, ct->ct_name, ctl_lun_id); -#endif - - ct->ct_luns[lun_id] = ctl_lun_id; - - return (0); -} - static int cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id) { - struct cfiscsi_softc *softc; - struct cfiscsi_target *ct; - const char *target = NULL; - const char *lun = NULL; - unsigned long tmp; - - ct = (struct cfiscsi_target *)arg; - softc = ct->ct_softc; - - target = ctl_get_opt(&control_softc->ctl_luns[lun_id]->be_lun->options, - "cfiscsi_target"); - lun = ctl_get_opt(&control_softc->ctl_luns[lun_id]->be_lun->options, - "cfiscsi_lun"); - - if (target == NULL && lun == NULL) - return (0); - - if (target == NULL || lun == NULL) { - CFISCSI_WARN("lun added with cfiscsi_target, but without " - "cfiscsi_lun, or the other way around; ignoring"); - return (0); - } - - if (strcmp(target, ct->ct_name) != 0) - return (0); - tmp = strtoul(lun, NULL, 10); - cfiscsi_target_set_lun(ct, tmp, lun_id); return (0); } static int cfiscsi_lun_disable(void *arg, struct ctl_id target_id, int lun_id) { - struct cfiscsi_softc *softc; - struct cfiscsi_target *ct; - int i; - - ct = (struct cfiscsi_target *)arg; - softc = ct->ct_softc; - mtx_lock(&softc->lock); - for (i = 0; i < CTL_MAX_LUNS; i++) { - if (ct->ct_luns[i] != lun_id) - continue; - ct->ct_luns[i] = UINT32_MAX; - break; - } - mtx_unlock(&softc->lock); return (0); } Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend_iscsi.h Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.h Thu Feb 19 14:31:16 2015 (r279002) @@ -38,7 +38,6 @@ struct cfiscsi_target { TAILQ_ENTRY(cfiscsi_target) ct_next; - uint32_t ct_luns[CTL_MAX_LUNS]; struct cfiscsi_softc *ct_softc; volatile u_int ct_refcount; char ct_name[CTL_ISCSI_NAME_LEN]; Modified: stable/10/sys/cam/ctl/ctl_ioctl.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_ioctl.h Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_ioctl.h Thu Feb 19 14:31:16 2015 (r279002) @@ -805,6 +805,12 @@ struct ctl_iscsi { /* passed to userland */ }; +struct ctl_lun_map { + uint32_t port; + uint32_t plun; + uint32_t lun; +}; + #define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io) #define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry) #define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry) @@ -832,6 +838,7 @@ struct ctl_iscsi { #define CTL_ISCSI _IOWR(CTL_MINOR, 0x25, struct ctl_iscsi) #define CTL_PORT_REQ _IOWR(CTL_MINOR, 0x26, struct ctl_req) #define CTL_PORT_LIST _IOWR(CTL_MINOR, 0x27, struct ctl_lun_list) +#define CTL_LUN_MAP _IOW(CTL_MINOR, 0x28, struct ctl_lun_map) #endif /* _CTL_IOCTL_H_ */ Modified: stable/10/sys/cam/ctl/ctl_private.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_private.h Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_private.h Thu Feb 19 14:31:16 2015 (r279002) @@ -492,6 +492,13 @@ extern const struct ctl_cmd_entry ctl_cm uint32_t ctl_get_initindex(struct ctl_nexus *nexus); uint32_t ctl_get_resindex(struct ctl_nexus *nexus); uint32_t ctl_port_idx(int port_num); +int ctl_lun_map_init(struct ctl_port *port); +int ctl_lun_map_deinit(struct ctl_port *port); +int ctl_lun_map_set(struct ctl_port *port, uint32_t plun, uint32_t glun); +int ctl_lun_map_unset(struct ctl_port *port, uint32_t plun); +int ctl_lun_map_unsetg(struct ctl_port *port, uint32_t glun); +uint32_t ctl_lun_map_from_port(struct ctl_port *port, uint32_t plun); +uint32_t ctl_lun_map_to_port(struct ctl_port *port, uint32_t glun); int ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name, uint32_t total_ctl_io, void **npool); void ctl_pool_free(struct ctl_io_pool *pool); Modified: stable/10/sys/cam/ctl/ctl_tpc_local.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_tpc_local.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/sys/cam/ctl/ctl_tpc_local.c Thu Feb 19 14:31:16 2015 (r279002) @@ -314,48 +314,30 @@ tpcl_resolve(struct ctl_softc *softc, in struct scsi_ec_cscd_id *cscdid; struct ctl_port *port; struct ctl_lun *lun; - uint64_t lunid = UINT64_MAX, l; - int i; + uint64_t lunid = UINT64_MAX; if (cscd->type_code != EC_CSCD_ID) return (lunid); cscdid = (struct scsi_ec_cscd_id *)cscd; mtx_lock(&softc->ctl_lock); - if (init_port >= 0) { + if (init_port >= 0) port = softc->ctl_ports[ctl_port_idx(init_port)]; - if (port == NULL || port->lun_map == NULL) - init_port = -1; - } - if (init_port < 0) { - STAILQ_FOREACH(lun, &softc->lun_list, links) { - if (lun->lun_devid == NULL) - continue; - if (scsi_devid_match(lun->lun_devid->data, - lun->lun_devid->len, &cscdid->codeset, - cscdid->length + 4) == 0) { - lunid = lun->lun; - if (ss && lun->be_lun) - *ss = lun->be_lun->blocksize; - break; - } - } - } else { - for (i = 0; i < CTL_MAX_LUNS; i++) { - l = port->lun_map(port->targ_lun_arg, i); - if (l >= CTL_MAX_LUNS) - continue; - lun = softc->ctl_luns[l]; - if (lun == NULL || lun->lun_devid == NULL) - continue; - if (scsi_devid_match(lun->lun_devid->data, - lun->lun_devid->len, &cscdid->codeset, - cscdid->length + 4) == 0) { - lunid = lun->lun; - if (ss && lun->be_lun) - *ss = lun->be_lun->blocksize; - break; - } + else + port = NULL; + STAILQ_FOREACH(lun, &softc->lun_list, links) { + if (port != NULL && + ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS) + continue; + if (lun->lun_devid == NULL) + continue; + if (scsi_devid_match(lun->lun_devid->data, + lun->lun_devid->len, &cscdid->codeset, + cscdid->length + 4) == 0) { + lunid = lun->lun; + if (ss && lun->be_lun) + *ss = lun->be_lun->blocksize; + break; } } mtx_unlock(&softc->ctl_lock); Modified: stable/10/usr.sbin/ctladm/ctladm.8 ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.8 Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/usr.sbin/ctladm/ctladm.8 Thu Feb 19 14:31:16 2015 (r279002) @@ -34,7 +34,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd December 17, 2014 +.Dd February 1, 2015 .Dt CTLADM 8 .Os .Sh NAME @@ -196,11 +196,17 @@ .Ic portlist .Op Fl f Ar frontend .Op Fl i +.Op Fl l .Op Fl p Ar targ_port .Op Fl q .Op Fl v .Op Fl x .Nm +.Ic lunmap +.Aq Fl p Ar targ_port +.Op Fl l Ar pLUN +.Op Fl L Ar cLUN +.Nm .Ic dumpooa .Nm .Ic dumpstructs @@ -782,7 +788,9 @@ List CTL frontend ports. .It Fl f Ar frontend Specify the frontend type. .It Fl i -Report target and connected initiators addresses +Report target and connected initiators addresses. +.It Fl l +Report LUN mapping. .It Fl p Ar targ_port Specify the frontend port number. .It Fl q @@ -792,6 +800,31 @@ Enable verbose output (report all port o .It Fl x Output the port list in XML format. .El +.It Ic lunmap +Change LUN mapping for specified port. +If both +.Ar pLUN +and +.Ar cLUN +are specified -- LUN will be mapped. +If +.Ar pLUN +is specified, but +.Ar cLUN +is not -- LUN will be unmapped. +If neither +.Ar pLUN +nor +.Ar cLUN +are specified -- LUN mapping will be disabled, exposing all CTL LUNs. +.Bl -tag -width 12n +.It Fl p Ar targ_port +Specify the frontend port number. +.It Fl l Ar pLUN +LUN number visible by specified port. +.It Fl L Ar cLUN +CTL LUN number. +.El .It Ic dumpooa Dump the OOA (Order Of Arrival) queue for each LUN registered with CTL. .It Ic dumpstructs Modified: stable/10/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/usr.sbin/ctladm/ctladm.c Thu Feb 19 14:31:16 2015 (r279002) @@ -121,7 +121,8 @@ typedef enum { CTLADM_CMD_MODIFY, CTLADM_CMD_ISLIST, CTLADM_CMD_ISLOGOUT, - CTLADM_CMD_ISTERMINATE + CTLADM_CMD_ISTERMINATE, + CTLADM_CMD_LUNMAP } ctladm_cmdfunction; typedef enum { @@ -188,10 +189,11 @@ static struct ctladm_opts option_table[] {"islogout", CTLADM_CMD_ISLOGOUT, CTLADM_ARG_NONE, "ac:i:p:"}, {"isterminate", CTLADM_CMD_ISTERMINATE, CTLADM_ARG_NONE, "ac:i:p:"}, {"lunlist", CTLADM_CMD_LUNLIST, CTLADM_ARG_NONE, NULL}, + {"lunmap", CTLADM_CMD_LUNMAP, CTLADM_ARG_NONE, "p:l:L:"}, {"modesense", CTLADM_CMD_MODESENSE, CTLADM_ARG_NEED_TL, "P:S:dlm:c:"}, {"modify", CTLADM_CMD_MODIFY, CTLADM_ARG_NONE, "b:l:s:"}, {"port", CTLADM_CMD_PORT, CTLADM_ARG_NONE, "lo:p:qt:w:W:x"}, - {"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:ip:qvx"}, + {"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:ilp:qvx"}, {"prin", CTLADM_CMD_PRES_IN, CTLADM_ARG_NEED_TL, "a:"}, {"prout", CTLADM_CMD_PRES_OUT, CTLADM_ARG_NEED_TL, "a:k:r:s:"}, {"read", CTLADM_CMD_READ, CTLADM_ARG_NEED_TL, rw_opts}, @@ -4106,8 +4108,9 @@ struct cctl_port { char *frontend_type; char *name; int pp, vp; - char *target, *port; + char *target, *port, *lun_map; STAILQ_HEAD(,cctl_lun_nv) init_list; + STAILQ_HEAD(,cctl_lun_nv) lun_list; STAILQ_HEAD(,cctl_lun_nv) attr_list; STAILQ_ENTRY(cctl_port) links; }; @@ -4161,6 +4164,7 @@ cctl_start_pelement(void *user_data, con portlist->cur_port = cur_port; STAILQ_INIT(&cur_port->init_list); + STAILQ_INIT(&cur_port->lun_list); STAILQ_INIT(&cur_port->attr_list); cur_port->port_id = portlist->cur_id; STAILQ_INSERT_TAIL(&portlist->port_list, cur_port, links); @@ -4220,6 +4224,9 @@ cctl_end_pelement(void *user_data, const } else if (strcmp(name, "port") == 0) { cur_port->port = str; str = NULL; + } else if (strcmp(name, "lun_map") == 0) { + cur_port->lun_map = str; + str = NULL; } else if (strcmp(name, "targ_port") == 0) { portlist->cur_port = NULL; } else if (strcmp(name, "ctlportlist") == 0) { @@ -4232,7 +4239,8 @@ cctl_end_pelement(void *user_data, const err(1, "%s: can't allocate %zd bytes for nv pair", __func__, sizeof(*nv)); - if (strcmp(name, "initiator") == 0) + if (strcmp(name, "initiator") == 0 || + strcmp(name, "lun") == 0) asprintf(&nv->name, "%ju", portlist->cur_id); else nv->name = strdup(name); @@ -4244,6 +4252,8 @@ cctl_end_pelement(void *user_data, const str = NULL; if (strcmp(name, "initiator") == 0) STAILQ_INSERT_TAIL(&cur_port->init_list, nv, links); + else if (strcmp(name, "lun") == 0) + STAILQ_INSERT_TAIL(&cur_port->lun_list, nv, links); else STAILQ_INSERT_TAIL(&cur_port->attr_list, nv, links); } @@ -4274,7 +4284,7 @@ cctl_portlist(int fd, int argc, char **a int retval, c; char *frontend = NULL; uint64_t portarg = UINT64_MAX; - int verbose = 0, init = 0, quiet = 0; + int verbose = 0, init = 0, lun = 0, quiet = 0; retval = 0; port_len = 4096; @@ -4290,6 +4300,9 @@ cctl_portlist(int fd, int argc, char **a case 'i': init++; break; + case 'l': + lun++; + break; case 'p': portarg = strtoll(optarg, NULL, 0); break; @@ -4381,6 +4394,17 @@ retry: } } + if (lun || verbose) { + if (port->lun_map) { + STAILQ_FOREACH(nv, &port->lun_list, links) + printf(" LUN %s: %s\n", + nv->name, nv->value); + if (STAILQ_EMPTY(&port->lun_list)) + printf(" No LUNs mapped\n"); + } else + printf(" All LUNs mapped\n"); + } + if (verbose) { STAILQ_FOREACH(nv, &port->attr_list, links) { printf(" %s=%s\n", nv->name, nv->value); @@ -4393,6 +4417,41 @@ bailout: return (retval); } +static int +cctl_lunmap(int fd, int argc, char **argv, char *combinedopt) +{ + struct ctl_lun_map lm; + int retval = 0, c; + + retval = 0; + lm.port = UINT32_MAX; + lm.plun = UINT32_MAX; + lm.lun = UINT32_MAX; + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch (c) { + case 'p': + lm.port = strtoll(optarg, NULL, 0); + break; + case 'l': + lm.plun = strtoll(optarg, NULL, 0); + break; + case 'L': + lm.lun = strtoll(optarg, NULL, 0); + break; + default: + break; + } + } + + if (ioctl(fd, CTL_LUN_MAP, &lm) == -1) { + warn("%s: error issuing CTL_LUN_MAP ioctl", __func__); + retval = 1; + } + + return (retval); +} + void usage(int error) { @@ -4430,6 +4489,7 @@ usage(int error) " ctladm hardstop\n" " ctladm hardstart\n" " ctladm lunlist\n" +" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n" " ctladm bbrread [dev_id] <-l lba> <-d datalen>\n" " ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n" " [-t secs]\n" @@ -4529,10 +4589,15 @@ usage(int error) "portlist options:\n" "-f fronetnd : specify frontend type\n" "-i : report target and initiators addresses\n" +"-l : report LUN mapping\n" "-p targ_port : specify target port number\n" "-q : omit header in list output\n" "-v : verbose output (report all port options)\n" "-x : output port list in XML format\n" +"lunmap options:\n" +"-p targ_port : specify target port number\n" +"-L pLUN : specify port-visible LUN\n" +"-L cLUN : specify CTL LUN\n" "bbrread options:\n" "-l lba : starting LBA\n" "-d datalen : length, in bytes, to read\n", @@ -4760,6 +4825,9 @@ main(int argc, char **argv) case CTLADM_CMD_PORTLIST: retval = cctl_portlist(fd, argc, argv, combinedopt); break; + case CTLADM_CMD_LUNMAP: + retval = cctl_lunmap(fd, argc, argv, combinedopt); + break; case CTLADM_CMD_READCAPACITY: retval = cctl_read_capacity(fd, target, lun, initid, retries, argc, argv, combinedopt); Modified: stable/10/usr.sbin/ctld/ctl.conf.5 ============================================================================== --- stable/10/usr.sbin/ctld/ctl.conf.5 Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/usr.sbin/ctld/ctl.conf.5 Thu Feb 19 14:31:16 2015 (r279002) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 24, 2014 +.Dd February 1, 2015 .Dt CTL.CONF 5 .Os .Sh NAME @@ -60,9 +60,14 @@ file is: .Dl ... } +.No lun Ar name No { +.Dl path Ar path +} + .No target Ar name { .Dl auth-group Ar name .Dl portal-group Ar name +.Dl lun Ar number Ar name .Dl lun Ar number No { .Dl path Ar path .Dl } @@ -95,6 +100,10 @@ Create a configuration context, defining a new portal-group, which can then be assigned to any number of targets. +.It Ic lun Ar name +Create a +.Sy lun +configuration context, defining a LUN to be exported by some target(s). .It Ic target Ar name Create a .Sy target @@ -312,6 +321,10 @@ IPv4 or IPv6 address to redirect initiat When configured, all initiators attempting to connect to this target will get redirected using "Target moved temporarily" login response. Redirection happens after successful authentication. +.It Ic lun Ar number Ar name +Export previously defined +.Sy lun +by the parent target. .It Ic lun Ar number Create a .Sy lun @@ -386,21 +399,21 @@ target iqn.2012-06.com.example:target0 { } } +lun example_1 { + path /dev/zvol/tank/example_1 +} + target iqn.2012-06.com.example:target1 { chap chapuser chapsecret - lun 0 { - path /dev/zvol/tank/example_1 - } + lun 0 example_1 } target iqn.2012-06.com.example:target2 { auth-group ag0 portal-group pg0 - lun 0 { - path /dev/zvol/tank/example2_0 - } + lun 0 example_1 lun 1 { - path /dev/zvol/tank/example2_1 + path /dev/zvol/tank/example_2 option foo bar } } Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:28:47 2015 (r279001) +++ stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:31:16 2015 (r279002) @@ -87,6 +87,7 @@ conf_new(void) conf = calloc(1, sizeof(*conf)); if (conf == NULL) log_err(1, "calloc"); + TAILQ_INIT(&conf->conf_luns); TAILQ_INIT(&conf->conf_targets); TAILQ_INIT(&conf->conf_auth_groups); TAILQ_INIT(&conf->conf_portal_groups); @@ -104,6 +105,7 @@ conf_new(void) void conf_delete(struct conf *conf) { + struct lun *lun, *ltmp; struct target *targ, *tmp; struct auth_group *ag, *cagtmp; struct portal_group *pg, *cpgtmp; @@ -111,6 +113,8 @@ conf_delete(struct conf *conf) assert(conf->conf_pidfh == NULL); + TAILQ_FOREACH_SAFE(lun, &conf->conf_luns, l_next, ltmp) + lun_delete(lun); TAILQ_FOREACH_SAFE(targ, &conf->conf_targets, t_next, tmp) target_delete(targ); TAILQ_FOREACH_SAFE(ag, &conf->conf_auth_groups, ag_next, cagtmp) @@ -1146,7 +1150,6 @@ target_new(struct conf *conf, const char for (i = 0; i < len; i++) targ->t_name[i] = tolower(targ->t_name[i]); - TAILQ_INIT(&targ->t_luns); targ->t_conf = conf; TAILQ_INSERT_TAIL(&conf->conf_targets, targ, t_next); @@ -1156,12 +1159,9 @@ target_new(struct conf *conf, const char void target_delete(struct target *targ) { - struct lun *lun, *tmp; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:33:48 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CE350919; Thu, 19 Feb 2015 14:33:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B7928D52; Thu, 19 Feb 2015 14:33:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEXm1O004205; Thu, 19 Feb 2015 14:33:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEXlvZ004198; Thu, 19 Feb 2015 14:33:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191433.t1JEXlvZ004198@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:33:47 +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: r279003 - in stable/10: sys/cam/ctl usr.sbin/ctladm usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:33:49 -0000 Author: mav Date: Thu Feb 19 14:33:46 2015 New Revision: 279003 URL: https://svnweb.freebsd.org/changeset/base/279003 Log: MFC r278161: Bring some more order into iSCSI portal group tags support. While ctld(8) still does not allow multiple portal groups per target to be configured, kernel should now be able to handle it. Sponsored by: iXsystems, Inc. Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c stable/10/sys/cam/ctl/ctl_frontend_iscsi.h stable/10/usr.sbin/ctladm/ctladm.c stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/ctld/kernel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c Thu Feb 19 14:33:46 2015 (r279003) @@ -168,9 +168,10 @@ static void cfiscsi_pdu_handle_data_out( static void cfiscsi_pdu_handle_logout_request(struct icl_pdu *request); static void cfiscsi_session_terminate(struct cfiscsi_session *cs); static struct cfiscsi_target *cfiscsi_target_find(struct cfiscsi_softc - *softc, const char *name); + *softc, const char *name, uint16_t tag); static struct cfiscsi_target *cfiscsi_target_find_or_create( - struct cfiscsi_softc *softc, const char *name, const char *alias); + struct cfiscsi_softc *softc, const char *name, const char *alias, + uint16_t tag); static void cfiscsi_target_release(struct cfiscsi_target *ct); static void cfiscsi_session_delete(struct cfiscsi_session *cs); @@ -1437,7 +1438,8 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi * cihp->initiator_name, cihp->initiator_addr, cihp->target_name); - ct = cfiscsi_target_find(softc, cihp->target_name); + ct = cfiscsi_target_find(softc, cihp->target_name, + cihp->portal_group_tag); if (ct == NULL) { ci->status = CTL_ISCSI_ERROR; snprintf(ci->error_str, sizeof(ci->error_str), @@ -1487,7 +1489,6 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi * * PDU from the Login Phase received from the initiator. Thus, * the -1 below. */ - cs->cs_portal_group_tag = cihp->portal_group_tag; cs->cs_cmdsn = cihp->cmdsn; cs->cs_statsn = cihp->statsn; cs->cs_max_data_segment_length = cihp->max_recv_data_segment_length; @@ -1532,7 +1533,6 @@ restart: TAILQ_FOREACH(cs2, &softc->sessions, cs_next) { if (cs2 != cs && cs2->cs_tasks_aborted == false && cs->cs_target == cs2->cs_target && - cs->cs_portal_group_tag == cs2->cs_portal_group_tag && strcmp(cs->cs_initiator_id, cs2->cs_initiator_id) == 0) { cfiscsi_session_terminate(cs2); mtx_unlock(&softc->lock); @@ -1617,6 +1617,7 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci) "%s" "%s" "%s" + "%u" "%s" "%s" "%zd" @@ -1626,6 +1627,7 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci) cs->cs_id, cs->cs_initiator_name, cs->cs_initiator_addr, cs->cs_initiator_alias, cs->cs_target->ct_name, cs->cs_target->ct_alias, + cs->cs_target->ct_tag, cs->cs_conn->ic_header_crc32c ? "CRC32C" : "None", cs->cs_conn->ic_data_crc32c ? "CRC32C" : "None", cs->cs_max_data_segment_length, @@ -1983,23 +1985,25 @@ cfiscsi_ioctl_port_create(struct ctl_req { struct cfiscsi_target *ct; struct ctl_port *port; - const char *target, *alias, *tag; + const char *target, *alias, *tags; struct scsi_vpd_id_descriptor *desc; ctl_options_t opts; int retval, len, idlen; + uint16_t tag; ctl_init_opts(&opts, req->num_args, req->kern_args); target = ctl_get_opt(&opts, "cfiscsi_target"); alias = ctl_get_opt(&opts, "cfiscsi_target_alias"); - tag = ctl_get_opt(&opts, "cfiscsi_portal_group_tag"); - if (target == NULL || tag == NULL) { + tags = ctl_get_opt(&opts, "cfiscsi_portal_group_tag"); + if (target == NULL || tags == NULL) { req->status = CTL_LUN_ERROR; snprintf(req->error_str, sizeof(req->error_str), "Missing required argument"); ctl_free_opts(&opts); return; } - ct = cfiscsi_target_find_or_create(&cfiscsi_softc, target, alias); + tag = strtol(tags, (char **)NULL, 10); + ct = cfiscsi_target_find_or_create(&cfiscsi_softc, target, alias, tag); if (ct == NULL) { req->status = CTL_LUN_ERROR; snprintf(req->error_str, sizeof(req->error_str), @@ -2024,7 +2028,7 @@ cfiscsi_ioctl_port_create(struct ctl_req /* XXX KDM what should the real number be here? */ port->num_requested_ctl_io = 4096; port->port_name = "iscsi"; - port->physical_port = strtoul(tag, NULL, 0); + port->physical_port = tag; port->virtual_port = ct->ct_target_id; port->port_online = cfiscsi_online; port->port_offline = cfiscsi_offline; @@ -2056,8 +2060,7 @@ cfiscsi_ioctl_port_create(struct ctl_req desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT | SVPD_ID_TYPE_SCSI_NAME; desc->length = idlen; - snprintf(desc->identifier, idlen, "%s,t,0x%4.4x", - target, port->physical_port); + snprintf(desc->identifier, idlen, "%s,t,0x%4.4x", target, tag); /* Generate Target ID. */ idlen = strlen(target) + 1; @@ -2095,19 +2098,22 @@ static void cfiscsi_ioctl_port_remove(struct ctl_req *req) { struct cfiscsi_target *ct; - const char *target; + const char *target, *tags; ctl_options_t opts; + uint16_t tag; ctl_init_opts(&opts, req->num_args, req->kern_args); target = ctl_get_opt(&opts, "cfiscsi_target"); - if (target == NULL) { + tags = ctl_get_opt(&opts, "cfiscsi_portal_group_tag"); + if (target == NULL || tags == NULL) { ctl_free_opts(&opts); req->status = CTL_LUN_ERROR; snprintf(req->error_str, sizeof(req->error_str), "Missing required argument"); return; } - ct = cfiscsi_target_find(&cfiscsi_softc, target); + tag = strtol(tags, (char **)NULL, 10); + ct = cfiscsi_target_find(&cfiscsi_softc, target, tag); if (ct == NULL) { ctl_free_opts(&opts); req->status = CTL_LUN_ERROR; @@ -2128,6 +2134,7 @@ cfiscsi_ioctl_port_remove(struct ctl_req ctl_port_offline(&ct->ct_port); cfiscsi_target_release(ct); cfiscsi_target_release(ct); + req->status = CTL_LUN_OK; } static int @@ -2236,13 +2243,14 @@ cfiscsi_target_release(struct cfiscsi_ta } static struct cfiscsi_target * -cfiscsi_target_find(struct cfiscsi_softc *softc, const char *name) +cfiscsi_target_find(struct cfiscsi_softc *softc, const char *name, uint16_t tag) { struct cfiscsi_target *ct; mtx_lock(&softc->lock); TAILQ_FOREACH(ct, &softc->targets, ct_next) { - if (strcmp(name, ct->ct_name) != 0 || + if (ct->ct_tag != tag || + strcmp(name, ct->ct_name) != 0 || ct->ct_state != CFISCSI_TARGET_STATE_ACTIVE) continue; cfiscsi_target_hold(ct); @@ -2256,7 +2264,7 @@ cfiscsi_target_find(struct cfiscsi_softc static struct cfiscsi_target * cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name, - const char *alias) + const char *alias, uint16_t tag) { struct cfiscsi_target *ct, *newct; @@ -2267,7 +2275,8 @@ cfiscsi_target_find_or_create(struct cfi mtx_lock(&softc->lock); TAILQ_FOREACH(ct, &softc->targets, ct_next) { - if (strcmp(name, ct->ct_name) != 0 || + if (ct->ct_tag != tag || + strcmp(name, ct->ct_name) != 0 || ct->ct_state == CFISCSI_TARGET_STATE_INVALID) continue; cfiscsi_target_hold(ct); @@ -2279,6 +2288,7 @@ cfiscsi_target_find_or_create(struct cfi strlcpy(newct->ct_name, name, sizeof(newct->ct_name)); if (alias != NULL) strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias)); + newct->ct_tag = tag; refcount_init(&newct->ct_refcount, 1); newct->ct_softc = softc; if (TAILQ_EMPTY(&softc->targets)) Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_frontend_iscsi.h Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.h Thu Feb 19 14:33:46 2015 (r279003) @@ -42,6 +42,7 @@ struct cfiscsi_target { volatile u_int ct_refcount; char ct_name[CTL_ISCSI_NAME_LEN]; char ct_alias[CTL_ISCSI_ALIAS_LEN]; + uint16_t ct_tag; int ct_state; int ct_online; int ct_target_id; @@ -79,7 +80,6 @@ struct cfiscsi_session { struct cfiscsi_target *cs_target; struct callout cs_callout; int cs_timeout; - int cs_portal_group_tag; struct cv cs_maintenance_cv; bool cs_terminating; bool cs_tasks_aborted; Modified: stable/10/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.c Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/usr.sbin/ctladm/ctladm.c Thu Feb 19 14:33:46 2015 (r279003) @@ -3542,6 +3542,7 @@ cctl_islist_end_element(void *user_data, } else if (strcmp(name, "target_alias") == 0) { cur_conn->target_alias = str; str = NULL; + } else if (strcmp(name, "target_portal_group_tag") == 0) { } else if (strcmp(name, "header_digest") == 0) { cur_conn->header_digest = str; str = NULL; Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:33:46 2015 (r279003) @@ -59,6 +59,7 @@ static volatile bool sigterm_received = static volatile bool sigalrm_received = false; static int nchildren = 0; +static uint16_t last_portal_group_tag = 0; static void usage(void) @@ -609,8 +610,7 @@ portal_group_new(struct conf *conf, cons pg->pg_name = checked_strdup(name); TAILQ_INIT(&pg->pg_portals); pg->pg_conf = conf; - conf->conf_last_portal_group_tag++; - pg->pg_tag = conf->conf_last_portal_group_tag; + pg->pg_tag = 0; /* Assigned later in conf_apply(). */ TAILQ_INSERT_TAIL(&conf->conf_portal_groups, pg, pg_next); return (pg); @@ -1655,6 +1655,17 @@ conf_apply(struct conf *oldconf, struct } } + /* + * Go through the new portal groups, assigning tags or preserving old. + */ + TAILQ_FOREACH(newpg, &newconf->conf_portal_groups, pg_next) { + oldpg = portal_group_find(oldconf, newpg->pg_name); + if (oldpg != NULL) + newpg->pg_tag = oldpg->pg_tag; + else + newpg->pg_tag = ++last_portal_group_tag; + } + /* Deregister on removed iSNS servers. */ TAILQ_FOREACH(oldns, &oldconf->conf_isns, i_next) { TAILQ_FOREACH(newns, &newconf->conf_isns, i_next) { @@ -2372,7 +2383,7 @@ main(int argc, char **argv) log_debugx("exiting on signal; " "reloading empty configuration"); - log_debugx("disabling CTL iSCSI port " + log_debugx("removing CTL iSCSI ports " "and terminating all connections"); oldconf = newconf; Modified: stable/10/usr.sbin/ctld/ctld.h ============================================================================== --- stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:33:46 2015 (r279003) @@ -180,7 +180,6 @@ struct conf { int conf_timeout; int conf_maxproc; - uint16_t conf_last_portal_group_tag; #ifdef ICL_KERNEL_PROXY int conf_portal_id; #endif Modified: stable/10/usr.sbin/ctld/kernel.c ============================================================================== --- stable/10/usr.sbin/ctld/kernel.c Thu Feb 19 14:31:16 2015 (r279002) +++ stable/10/usr.sbin/ctld/kernel.c Thu Feb 19 14:33:46 2015 (r279003) @@ -913,12 +913,8 @@ kernel_port_remove(struct target *targ) req.num_args = 2; req.args = malloc(req.num_args * sizeof(*req.args)); str_arg(&req.args[0], "cfiscsi_target", targ->t_name); - if (targ->t_portal_group) { - snprintf(tagstr, sizeof(tagstr), "%d", - targ->t_portal_group->pg_tag); - str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr); - } else - req.num_args--; + snprintf(tagstr, sizeof(tagstr), "%d", targ->t_portal_group->pg_tag); + str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr); error = ioctl(ctl_fd, CTL_PORT_REQ, &req); free(req.args); From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:36:05 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 34B01A64; Thu, 19 Feb 2015 14:36:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 15A8FD68; Thu, 19 Feb 2015 14:36:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEa4IJ004588; Thu, 19 Feb 2015 14:36:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEa4ox004579; Thu, 19 Feb 2015 14:36:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191436.t1JEa4ox004579@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:36:04 +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: r279004 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:36:05 -0000 Author: mav Date: Thu Feb 19 14:36:03 2015 New Revision: 279004 URL: https://svnweb.freebsd.org/changeset/base/279004 Log: MFC r278625: Make XCOPY and WUT commands respect physical block size/offset. This change by 2-3 times improves performance of misaligned XCOPY and WUT commands by avoiding unneeded read-modify-write cycles inside ZFS. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c stable/10/sys/cam/ctl/ctl_tpc.c stable/10/sys/cam/ctl/ctl_tpc.h stable/10/sys/cam/ctl/ctl_tpc_local.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 14:33:46 2015 (r279003) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 14:36:03 2015 (r279004) @@ -1190,7 +1190,8 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b struct ctl_be_block_io *beio; struct ctl_be_block_softc *softc; struct ctl_lba_len_flags *lbalen; - uint64_t len_left, lba, pb, pbo, adj; + uint64_t len_left, lba; + uint32_t pb, pbo, adj; int i, seglen; uint8_t *buf, *end; @@ -1244,8 +1245,11 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b DPRINTF("WRITE SAME at LBA %jx len %u\n", (uintmax_t)lbalen->lba, lbalen->len); - pb = (uint64_t)be_lun->blocksize << be_lun->pblockexp; - pbo = pb - (uint64_t)be_lun->blocksize * be_lun->pblockoff; + pb = be_lun->blocksize << be_lun->pblockexp; + if (be_lun->pblockoff > 0) + pbo = pb - be_lun->blocksize * be_lun->pblockoff; + else + pbo = 0; len_left = (uint64_t)lbalen->len * be_lun->blocksize; for (i = 0, lba = 0; i < CTLBLK_MAX_SEGS && len_left > 0; i++) { Modified: stable/10/sys/cam/ctl/ctl_tpc.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_tpc.c Thu Feb 19 14:33:46 2015 (r279003) +++ stable/10/sys/cam/ctl/ctl_tpc.c Thu Feb 19 14:36:03 2015 (r279004) @@ -785,18 +785,25 @@ ctl_copy_operation_abort(struct ctl_scsi } static uint64_t -tpc_resolve(struct tpc_list *list, uint16_t idx, uint32_t *ss) +tpc_resolve(struct tpc_list *list, uint16_t idx, uint32_t *ss, + uint32_t *pb, uint32_t *pbo) { if (idx == 0xffff) { if (ss && list->lun->be_lun) *ss = list->lun->be_lun->blocksize; + if (pb && list->lun->be_lun) + *pb = list->lun->be_lun->blocksize << + list->lun->be_lun->pblockexp; + if (pbo && list->lun->be_lun) + *pbo = list->lun->be_lun->blocksize * + list->lun->be_lun->pblockoff; return (list->lun->lun); } if (idx >= list->ncscd) return (UINT64_MAX); return (tpcl_resolve(list->lun->ctl_softc, - list->init_port, &list->cscd[idx], ss)); + list->init_port, &list->cscd[idx], ss, pb, pbo)); } static int @@ -809,7 +816,7 @@ tpc_process_b2b(struct tpc_list *list) uint64_t sl, dl; off_t srclba, dstlba, numbytes, donebytes, roundbytes; int numlba; - uint32_t srcblock, dstblock; + uint32_t srcblock, dstblock, pb, pbo, adj; if (list->stage == 1) { while ((tior = TAILQ_FIRST(&list->allio)) != NULL) { @@ -834,14 +841,16 @@ tpc_process_b2b(struct tpc_list *list) TAILQ_INIT(&list->allio); seg = (struct scsi_ec_segment_b2b *)list->seg[list->curseg]; - sl = tpc_resolve(list, scsi_2btoul(seg->src_cscd), &srcblock); - dl = tpc_resolve(list, scsi_2btoul(seg->dst_cscd), &dstblock); + sl = tpc_resolve(list, scsi_2btoul(seg->src_cscd), &srcblock, NULL, NULL); + dl = tpc_resolve(list, scsi_2btoul(seg->dst_cscd), &dstblock, &pb, &pbo); if (sl >= CTL_MAX_LUNS || dl >= CTL_MAX_LUNS) { ctl_set_sense(list->ctsio, /*current_error*/ 1, /*sense_key*/ SSD_KEY_COPY_ABORTED, /*asc*/ 0x08, /*ascq*/ 0x04, SSD_ELEM_NONE); return (CTL_RETVAL_ERROR); } + if (pbo > 0) + pbo = pb - pbo; sdstp = &list->cscd[scsi_2btoul(seg->src_cscd)].dtsp; if (scsi_3btoul(sdstp->block_length) != 0) srcblock = scsi_3btoul(sdstp->block_length); @@ -878,7 +887,16 @@ tpc_process_b2b(struct tpc_list *list) prun = &run; list->tbdio = 1; while (donebytes < numbytes) { - roundbytes = MIN(numbytes - donebytes, TPC_MAX_IO_SIZE); + roundbytes = numbytes - donebytes; + if (roundbytes > TPC_MAX_IO_SIZE) { + roundbytes = TPC_MAX_IO_SIZE; + roundbytes -= roundbytes % dstblock; + if (pb > dstblock) { + adj = (dstlba * dstblock + roundbytes - pbo) % pb; + if (roundbytes > adj) + roundbytes -= adj; + } + } tior = malloc(sizeof(*tior), M_CTL, M_WAITOK | M_ZERO); TAILQ_INIT(&tior->run); @@ -891,7 +909,7 @@ tpc_process_b2b(struct tpc_list *list) /*read_op*/ 1, /*byte2*/ 0, /*minimum_cdb_size*/ 0, - /*lba*/ srclba + donebytes / srcblock, + /*lba*/ srclba, /*num_blocks*/ roundbytes / srcblock, /*tag_type*/ CTL_TAG_SIMPLE, /*control*/ 0); @@ -910,7 +928,7 @@ tpc_process_b2b(struct tpc_list *list) /*read_op*/ 0, /*byte2*/ 0, /*minimum_cdb_size*/ 0, - /*lba*/ dstlba + donebytes / dstblock, + /*lba*/ dstlba, /*num_blocks*/ roundbytes / dstblock, /*tag_type*/ CTL_TAG_SIMPLE, /*control*/ 0); @@ -922,6 +940,8 @@ tpc_process_b2b(struct tpc_list *list) TAILQ_INSERT_TAIL(prun, tior, rlinks); prun = &tior->run; donebytes += roundbytes; + srclba += roundbytes / srcblock; + dstlba += roundbytes / dstblock; } while ((tior = TAILQ_FIRST(&run)) != NULL) { @@ -961,7 +981,7 @@ tpc_process_verify(struct tpc_list *list TAILQ_INIT(&list->allio); seg = (struct scsi_ec_segment_verify *)list->seg[list->curseg]; - sl = tpc_resolve(list, scsi_2btoul(seg->src_cscd), NULL); + sl = tpc_resolve(list, scsi_2btoul(seg->src_cscd), NULL, NULL, NULL); if (sl >= CTL_MAX_LUNS) { ctl_set_sense(list->ctsio, /*current_error*/ 1, /*sense_key*/ SSD_KEY_COPY_ABORTED, @@ -1019,7 +1039,7 @@ tpc_process_register_key(struct tpc_list TAILQ_INIT(&list->allio); seg = (struct scsi_ec_segment_register_key *)list->seg[list->curseg]; - dl = tpc_resolve(list, scsi_2btoul(seg->dst_cscd), NULL); + dl = tpc_resolve(list, scsi_2btoul(seg->dst_cscd), NULL, NULL, NULL); if (dl >= CTL_MAX_LUNS) { ctl_set_sense(list->ctsio, /*current_error*/ 1, /*sense_key*/ SSD_KEY_COPY_ABORTED, @@ -1090,7 +1110,7 @@ tpc_process_wut(struct tpc_list *list) int drange, srange; off_t doffset, soffset; off_t srclba, dstlba, numbytes, donebytes, roundbytes; - uint32_t srcblock, dstblock; + uint32_t srcblock, dstblock, pb, pbo, adj; if (list->stage > 0) { /* Cleanup after previous rounds. */ @@ -1118,6 +1138,11 @@ tpc_process_wut(struct tpc_list *list) &drange, &doffset) != 0) return (CTL_RETVAL_COMPLETE); dstblock = list->lun->be_lun->blocksize; + pb = dstblock << list->lun->be_lun->pblockexp; + if (list->lun->be_lun->pblockoff > 0) + pbo = pb - dstblock * list->lun->be_lun->pblockoff; + else + pbo = 0; /* Check where we are on source ranges list. */ srcblock = list->token->blocksize; @@ -1131,12 +1156,20 @@ tpc_process_wut(struct tpc_list *list) } srclba = scsi_8btou64(list->token->range[srange].lba) + soffset; - numbytes = srcblock * omin(TPC_MAX_IOCHUNK_SIZE / srcblock, - (scsi_4btoul(list->token->range[srange].length) - soffset)); dstlba = scsi_8btou64(list->range[drange].lba) + doffset; - numbytes = omin(numbytes, - dstblock * omin(TPC_MAX_IOCHUNK_SIZE / dstblock, - (scsi_4btoul(list->range[drange].length) - doffset))); + numbytes = srcblock * + (scsi_4btoul(list->token->range[srange].length) - soffset); + numbytes = omin(numbytes, dstblock * + (scsi_4btoul(list->range[drange].length) - doffset)); + if (numbytes > TPC_MAX_IOCHUNK_SIZE) { + numbytes = TPC_MAX_IOCHUNK_SIZE; + numbytes -= numbytes % dstblock; + if (pb > dstblock) { + adj = (dstlba * dstblock + numbytes - pbo) % pb; + if (numbytes > adj) + numbytes -= adj; + } + } if (numbytes % srcblock != 0 || numbytes % dstblock != 0) { ctl_set_sense(list->ctsio, /*current_error*/ 1, @@ -1157,7 +1190,16 @@ tpc_process_wut(struct tpc_list *list) list->tbdio = 1; TAILQ_INIT(&list->allio); while (donebytes < numbytes) { - roundbytes = MIN(numbytes - donebytes, TPC_MAX_IO_SIZE); + roundbytes = numbytes - donebytes; + if (roundbytes > TPC_MAX_IO_SIZE) { + roundbytes = TPC_MAX_IO_SIZE; + roundbytes -= roundbytes % dstblock; + if (pb > dstblock) { + adj = (dstlba * dstblock + roundbytes - pbo) % pb; + if (roundbytes > adj) + roundbytes -= adj; + } + } tior = malloc(sizeof(*tior), M_CTL, M_WAITOK | M_ZERO); TAILQ_INIT(&tior->run); @@ -1170,7 +1212,7 @@ tpc_process_wut(struct tpc_list *list) /*read_op*/ 1, /*byte2*/ 0, /*minimum_cdb_size*/ 0, - /*lba*/ srclba + donebytes / srcblock, + /*lba*/ srclba, /*num_blocks*/ roundbytes / srcblock, /*tag_type*/ CTL_TAG_SIMPLE, /*control*/ 0); @@ -1189,7 +1231,7 @@ tpc_process_wut(struct tpc_list *list) /*read_op*/ 0, /*byte2*/ 0, /*minimum_cdb_size*/ 0, - /*lba*/ dstlba + donebytes / dstblock, + /*lba*/ dstlba, /*num_blocks*/ roundbytes / dstblock, /*tag_type*/ CTL_TAG_SIMPLE, /*control*/ 0); @@ -1201,6 +1243,8 @@ tpc_process_wut(struct tpc_list *list) TAILQ_INSERT_TAIL(prun, tior, rlinks); prun = &tior->run; donebytes += roundbytes; + srclba += roundbytes / srcblock; + dstlba += roundbytes / dstblock; } while ((tior = TAILQ_FIRST(&run)) != NULL) { Modified: stable/10/sys/cam/ctl/ctl_tpc.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_tpc.h Thu Feb 19 14:33:46 2015 (r279003) +++ stable/10/sys/cam/ctl/ctl_tpc.h Thu Feb 19 14:36:03 2015 (r279004) @@ -32,7 +32,7 @@ void tpc_done(union ctl_io *io); uint64_t tpcl_resolve(struct ctl_softc *softc, int init_port, - struct scsi_ec_cscd *cscd, uint32_t *ss); + struct scsi_ec_cscd *cscd, uint32_t *ss, uint32_t *ps, uint32_t *pso); union ctl_io * tpcl_alloc_io(void); int tpcl_queue(union ctl_io *io, uint64_t lun); Modified: stable/10/sys/cam/ctl/ctl_tpc_local.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_tpc_local.c Thu Feb 19 14:33:46 2015 (r279003) +++ stable/10/sys/cam/ctl/ctl_tpc_local.c Thu Feb 19 14:36:03 2015 (r279004) @@ -309,7 +309,7 @@ tpcl_done(union ctl_io *io) uint64_t tpcl_resolve(struct ctl_softc *softc, int init_port, - struct scsi_ec_cscd *cscd, uint32_t *ss) + struct scsi_ec_cscd *cscd, uint32_t *ss, uint32_t *ps, uint32_t *pso) { struct scsi_ec_cscd_id *cscdid; struct ctl_port *port; @@ -337,6 +337,12 @@ tpcl_resolve(struct ctl_softc *softc, in lunid = lun->lun; if (ss && lun->be_lun) *ss = lun->be_lun->blocksize; + if (ps && lun->be_lun) + *ps = lun->be_lun->blocksize << + lun->be_lun->pblockexp; + if (pso && lun->be_lun) + *pso = lun->be_lun->blocksize * + lun->be_lun->pblockoff; break; } } From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:40:51 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CD3D7C5D; Thu, 19 Feb 2015 14:40:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B7D76E26; Thu, 19 Feb 2015 14:40:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEepdt005850; Thu, 19 Feb 2015 14:40:51 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEeosp005847; Thu, 19 Feb 2015 14:40:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191440.t1JEeosp005847@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:40:50 +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: r279005 - in stable/10/sys: cam/ctl sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:40:51 -0000 Author: mav Date: Thu Feb 19 14:40:50 2015 New Revision: 279005 URL: https://svnweb.freebsd.org/changeset/base/279005 Log: MFC r278672: Teach CTL to ask GEOM devices about BIO_DELETE support. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c stable/10/sys/cam/ctl/ctl_backend_ramdisk.c stable/10/sys/sys/disk.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 14:36:03 2015 (r279004) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 14:40:50 2015 (r279005) @@ -1877,7 +1877,7 @@ ctl_be_block_open_dev(struct ctl_be_bloc struct cdev *dev; struct cdevsw *devsw; char *value; - int error, atomic, maxio; + int error, atomic, maxio, unmap; off_t ps, pss, po, pos, us, uss, uo, uos; params = &be_lun->params; @@ -1902,7 +1902,6 @@ ctl_be_block_open_dev(struct ctl_be_bloc maxio = CTLBLK_MAX_IO_SIZE; } be_lun->lun_flush = ctl_be_block_flush_dev; - be_lun->unmap = ctl_be_block_unmap_dev; be_lun->getattr = ctl_be_block_getattr_dev; error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED); @@ -2033,6 +2032,24 @@ ctl_be_block_open_dev(struct ctl_be_bloc be_lun->atomicblock = atomic / be_lun->blocksize; be_lun->opttxferlen = maxio / be_lun->blocksize; + + if (be_lun->dispatch == ctl_be_block_dispatch_zvol) { + unmap = 1; + } else { + struct diocgattr_arg arg; + + strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); + arg.len = sizeof(arg.value.i); + error = devsw->d_ioctl(dev, DIOCGATTR, + (caddr_t)&arg, FREAD, curthread); + unmap = (error == 0) ? arg.value.i : 0; + } + value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); + if (value != NULL) + unmap = (strcmp(value, "on") == 0); + if (unmap) + be_lun->unmap = ctl_be_block_unmap_dev; + return (0); } @@ -2185,7 +2202,7 @@ ctl_be_block_create(struct ctl_be_block_ char num_thread_str[16]; char tmpstr[32]; char *value; - int retval, num_threads, unmap; + int retval, num_threads; int tmp_num_threads; params = &req->reqdata.create; @@ -2278,16 +2295,12 @@ ctl_be_block_create(struct ctl_be_block_ } num_threads = tmp_num_threads; } - unmap = (be_lun->dispatch == ctl_be_block_dispatch_zvol); - value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); - if (value != NULL) - unmap = (strcmp(value, "on") == 0); be_lun->flags = CTL_BE_BLOCK_LUN_UNCONFIGURED; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; if (be_lun->vn == NULL) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_OFFLINE; - if (unmap) + if (be_lun->unmap != NULL) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; if (be_lun->dispatch != ctl_be_block_dispatch_dev) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_SERSEQ_READ; @@ -2671,6 +2684,8 @@ ctl_be_block_modify(struct ctl_be_block_ * XXX: Note that this field is being updated without locking, * which might cause problems on 32-bit architectures. */ + if (be_lun->unmap != NULL) + be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ? 0 : (be_lun->size_blocks - 1); be_lun->ctl_be_lun.blocksize = be_lun->blocksize; Modified: stable/10/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Thu Feb 19 14:36:03 2015 (r279004) +++ stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Thu Feb 19 14:40:50 2015 (r279005) @@ -588,10 +588,10 @@ ctl_backend_ramdisk_create(struct ctl_be be_lun->softc = softc; - unmap = 0; + unmap = 1; value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); if (value != NULL && strcmp(value, "on") == 0) - unmap = 1; + unmap = (strcmp(value, "on") == 0); be_lun->flags = CTL_BE_RAMDISK_LUN_UNCONFIGURED; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; Modified: stable/10/sys/sys/disk.h ============================================================================== --- stable/10/sys/sys/disk.h Thu Feb 19 14:36:03 2015 (r279004) +++ stable/10/sys/sys/disk.h Thu Feb 19 14:40:50 2015 (r279005) @@ -131,6 +131,7 @@ struct diocgattr_arg { union { char str[DISK_IDENT_SIZE]; off_t off; + int i; } value; }; #define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg) From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 14:52:04 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DDDBC42A; Thu, 19 Feb 2015 14:52:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 C757FF56; Thu, 19 Feb 2015 14:52:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JEq3ef013975; Thu, 19 Feb 2015 14:52:03 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JEq1w7013965; Thu, 19 Feb 2015 14:52:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502191452.t1JEq1w7013965@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Feb 2015 14:52:01 +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: r279006 - stable/10/usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:52:04 -0000 Author: mav Date: Thu Feb 19 14:52:01 2015 New Revision: 279006 URL: https://svnweb.freebsd.org/changeset/base/279006 Log: MFC r278322: Add support for multiple portal groups per target. This change allows multiple "portal-group" options to be specified per target. Each of them may include new optional auth-group name parameter to override per-target auth parameters for specific portal group. Kernel side support was added earlier at r278161. Sponsored by: iXsystems, Inc. Modified: stable/10/usr.sbin/ctld/ctl.conf.5 stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/ctld/discovery.c stable/10/usr.sbin/ctld/kernel.c stable/10/usr.sbin/ctld/login.c stable/10/usr.sbin/ctld/parse.y Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctl.conf.5 ============================================================================== --- stable/10/usr.sbin/ctld/ctl.conf.5 Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/ctl.conf.5 Thu Feb 19 14:52:01 2015 (r279006) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2015 +.Dd February 6, 2015 .Dt CTL.CONF 5 .Os .Sh NAME @@ -66,7 +66,7 @@ file is: .No target Ar name { .Dl auth-group Ar name -.Dl portal-group Ar name +.Dl portal-group Ar name Op Ar agname .Dl lun Ar number Ar name .Dl lun Ar number No { .Dl path Ar path @@ -310,12 +310,15 @@ This clause is mutually exclusive with .Sy auth-group ; one cannot use both in a single target. -.It Ic portal-group Ar name +.It Ic portal-group Ar name Op Ar agname Assign a previously defined portal group to the target. The default portal group is .Qq Ar default , which makes the target available on TCP port 3260 on all configured IPv4 and IPv6 addresses. +Optional second argument specifies auth group name for connections +to this specific portal group. +If second argument is not specified, target auth group is used. .It Ic redirect Aq Ar address IPv4 or IPv6 address to redirect initiators to. When configured, all initiators attempting to connect to this target Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/ctld.c Thu Feb 19 14:52:01 2015 (r279006) @@ -91,6 +91,7 @@ conf_new(void) TAILQ_INIT(&conf->conf_luns); TAILQ_INIT(&conf->conf_targets); TAILQ_INIT(&conf->conf_auth_groups); + TAILQ_INIT(&conf->conf_ports); TAILQ_INIT(&conf->conf_portal_groups); TAILQ_INIT(&conf->conf_isns); @@ -124,6 +125,7 @@ conf_delete(struct conf *conf) portal_group_delete(pg); TAILQ_FOREACH_SAFE(is, &conf->conf_isns, i_next, istmp) isns_delete(is); + assert(TAILQ_EMPTY(&conf->conf_ports)); free(conf->conf_pidfile_path); free(conf); } @@ -609,6 +611,7 @@ portal_group_new(struct conf *conf, cons log_err(1, "calloc"); pg->pg_name = checked_strdup(name); TAILQ_INIT(&pg->pg_portals); + TAILQ_INIT(&pg->pg_ports); pg->pg_conf = conf; pg->pg_tag = 0; /* Assigned later in conf_apply(). */ TAILQ_INSERT_TAIL(&conf->conf_portal_groups, pg, pg_next); @@ -620,7 +623,10 @@ void portal_group_delete(struct portal_group *pg) { struct portal *portal, *tmp; + struct port *port, *tport; + TAILQ_FOREACH_SAFE(port, &pg->pg_ports, p_pgs, tport) + port_delete(port); TAILQ_REMOVE(&pg->pg_conf->conf_portal_groups, pg, pg_next); TAILQ_FOREACH_SAFE(portal, &pg->pg_portals, p_next, tmp) @@ -784,6 +790,7 @@ isns_do_register(struct isns *isns, int struct target *target; struct portal *portal; struct portal_group *pg; + struct port *port; struct isns_req *req; int res = 0; uint32_t error; @@ -807,11 +814,14 @@ isns_do_register(struct isns *isns, int isns_req_add_32(req, 33, 1); /* 1 -- Target*/ if (target->t_alias != NULL) isns_req_add_str(req, 34, target->t_alias); - pg = target->t_portal_group; - isns_req_add_32(req, 51, pg->pg_tag); - TAILQ_FOREACH(portal, &pg->pg_portals, p_next) { - isns_req_add_addr(req, 49, portal->p_ai); - isns_req_add_port(req, 50, portal->p_ai); + TAILQ_FOREACH(port, &target->t_ports, p_ts) { + if ((pg = port->p_portal_group) == NULL) + continue; + isns_req_add_32(req, 51, pg->pg_tag); + TAILQ_FOREACH(portal, &pg->pg_portals, p_next) { + isns_req_add_addr(req, 49, portal->p_ai); + isns_req_add_port(req, 50, portal->p_ai); + } } } res = isns_req_send(s, req); @@ -1123,6 +1133,68 @@ valid_iscsi_name(const char *name) return (true); } +struct port * +port_new(struct conf *conf, struct target *target, struct portal_group *pg) +{ + struct port *port; + + port = calloc(1, sizeof(*port)); + if (port == NULL) + log_err(1, "calloc"); + asprintf(&port->p_name, "%s-%s", pg->pg_name, target->t_name); + if (port_find(conf, port->p_name) != NULL) { + log_warnx("duplicate port \"%s\"", port->p_name); + free(port); + return (NULL); + } + port->p_conf = conf; + TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); + TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); + port->p_target = target; + TAILQ_INSERT_TAIL(&pg->pg_ports, port, p_pgs); + port->p_portal_group = pg; + return (port); +} + +struct port * +port_find(const struct conf *conf, const char *name) +{ + struct port *port; + + TAILQ_FOREACH(port, &conf->conf_ports, p_next) { + if (strcasecmp(port->p_name, name) == 0) + return (port); + } + + return (NULL); +} + +struct port * +port_find_in_pg(const struct portal_group *pg, const char *target) +{ + struct port *port; + + TAILQ_FOREACH(port, &pg->pg_ports, p_pgs) { + if (strcasecmp(port->p_target->t_name, target) == 0) + return (port); + } + + return (NULL); +} + +void +port_delete(struct port *port) +{ + + if (port->p_portal_group) + TAILQ_REMOVE(&port->p_portal_group->pg_ports, port, p_pgs); + if (port->p_target) + TAILQ_REMOVE(&port->p_target->t_ports, port, p_ts); + TAILQ_REMOVE(&port->p_conf->conf_ports, port, p_next); + free(port->p_name); + free(port); +} + struct target * target_new(struct conf *conf, const char *name) { @@ -1151,6 +1223,7 @@ target_new(struct conf *conf, const char targ->t_name[i] = tolower(targ->t_name[i]); targ->t_conf = conf; + TAILQ_INIT(&targ->t_ports); TAILQ_INSERT_TAIL(&conf->conf_targets, targ, t_next); return (targ); @@ -1159,7 +1232,10 @@ target_new(struct conf *conf, const char void target_delete(struct target *targ) { + struct port *port, *tport; + TAILQ_FOREACH_SAFE(port, &targ->t_ports, p_ts, tport) + port_delete(port); TAILQ_REMOVE(&targ->t_conf->conf_targets, targ, t_next); free(targ->t_name); @@ -1196,13 +1272,6 @@ target_set_redirection(struct target *ta return (0); } -void -target_set_ctl_port(struct target *target, uint32_t value) -{ - - target->t_ctl_port = value; -} - struct lun * lun_new(struct conf *conf, const char *name) { @@ -1508,6 +1577,7 @@ conf_verify(struct conf *conf) { struct auth_group *ag; struct portal_group *pg; + struct port *port; struct target *targ; struct lun *lun; bool found; @@ -1527,10 +1597,10 @@ conf_verify(struct conf *conf) "default"); assert(targ->t_auth_group != NULL); } - if (targ->t_portal_group == NULL) { - targ->t_portal_group = portal_group_find(conf, - "default"); - assert(targ->t_portal_group != NULL); + if (TAILQ_EMPTY(&targ->t_ports)) { + pg = portal_group_find(conf, "default"); + assert(pg != NULL); + port_new(conf, targ, pg); } found = false; for (i = 0; i < MAX_LUNS; i++) { @@ -1558,20 +1628,14 @@ conf_verify(struct conf *conf) if (pg->pg_discovery_filter == PG_FILTER_UNKNOWN) pg->pg_discovery_filter = PG_FILTER_NONE; - TAILQ_FOREACH(targ, &conf->conf_targets, t_next) { - if (targ->t_portal_group == pg) - break; - } - if (pg->pg_redirection != NULL) { - if (targ != NULL) { + if (!TAILQ_EMPTY(&pg->pg_ports)) { + if (pg->pg_redirection != NULL) { log_debugx("portal-group \"%s\" assigned " - "to target \"%s\", but configured " + "to target, but configured " "for redirection", - pg->pg_name, targ->t_name); + pg->pg_name); } pg->pg_unassigned = false; - } else if (targ != NULL) { - pg->pg_unassigned = false; } else { if (strcmp(pg->pg_name, "default") != 0) log_warnx("portal-group \"%s\" not assigned " @@ -1592,6 +1656,12 @@ conf_verify(struct conf *conf) break; } } + TAILQ_FOREACH(port, &conf->conf_ports, p_next) { + if (port->p_auth_group == ag) { + found = true; + break; + } + } TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) { if (pg->pg_discovery_auth_group == ag) { found = true; @@ -1613,10 +1683,10 @@ conf_verify(struct conf *conf) static int conf_apply(struct conf *oldconf, struct conf *newconf) { - struct target *oldtarg, *newtarg, *tmptarg; struct lun *oldlun, *newlun, *tmplun; struct portal_group *oldpg, *newpg; struct portal *oldp, *newp; + struct port *oldport, *newport, *tmpport; struct isns *oldns, *newns; pid_t otherpid; int changed, cumulated_error = 0, error, sockbuf; @@ -1684,17 +1754,17 @@ conf_apply(struct conf *oldconf, struct * really happen, so leave it as it is for now. */ /* - * First, remove any targets present in the old configuration + * First, remove any ports present in the old configuration * and missing in the new one. */ - TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) { - newtarg = target_find(newconf, oldtarg->t_name); - if (newtarg != NULL) + TAILQ_FOREACH_SAFE(oldport, &oldconf->conf_ports, p_next, tmpport) { + newport = port_find(newconf, oldport->p_name); + if (newport != NULL) continue; - error = kernel_port_remove(oldtarg); + error = kernel_port_remove(oldport); if (error != 0) { - log_warnx("failed to remove target %s", - oldtarg->t_name); + log_warnx("failed to remove port %s", + oldport->p_name); /* * XXX: Uncomment after fixing the root cause. * @@ -1809,21 +1879,21 @@ conf_apply(struct conf *oldconf, struct } /* - * Now add new targets or modify existing ones. + * Now add new ports or modify existing ones. */ - TAILQ_FOREACH(newtarg, &newconf->conf_targets, t_next) { - oldtarg = target_find(oldconf, newtarg->t_name); + TAILQ_FOREACH(newport, &newconf->conf_ports, p_next) { + oldport = port_find(oldconf, newport->p_name); - if (oldtarg == NULL) - error = kernel_port_add(newtarg); - else { - target_set_ctl_port(newtarg, oldtarg->t_ctl_port); - error = kernel_port_update(newtarg); + if (oldport == NULL) { + error = kernel_port_add(newport); + } else { + newport->p_ctl_port = oldport->p_ctl_port; + error = kernel_port_update(newport); } if (error != 0) { - log_warnx("failed to %s target %s", - (oldtarg == NULL) ? "add" : "update", - newtarg->t_name); + log_warnx("failed to %s port %s", + (oldport == NULL) ? "add" : "update", + newport->p_name); /* * XXX: Uncomment after fixing the root cause. * Modified: stable/10/usr.sbin/ctld/ctld.h ============================================================================== --- stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/ctld.h Thu Feb 19 14:52:01 2015 (r279006) @@ -119,11 +119,25 @@ struct portal_group { int pg_discovery_filter; bool pg_unassigned; TAILQ_HEAD(, portal) pg_portals; + TAILQ_HEAD(, port) pg_ports; char *pg_redirection; uint16_t pg_tag; }; +struct port { + TAILQ_ENTRY(port) p_next; + TAILQ_ENTRY(port) p_pgs; + TAILQ_ENTRY(port) p_ts; + struct conf *p_conf; + char *p_name; + struct auth_group *p_auth_group; + struct portal_group *p_portal_group; + struct target *p_target; + + uint32_t p_ctl_port; +}; + struct lun_option { TAILQ_ENTRY(lun_option) lo_next; struct lun *lo_lun; @@ -152,12 +166,10 @@ struct target { struct conf *t_conf; struct lun *t_luns[MAX_LUNS]; struct auth_group *t_auth_group; - struct portal_group *t_portal_group; + TAILQ_HEAD(, port) t_ports; char *t_name; char *t_alias; char *t_redirection; - - uint32_t t_ctl_port; }; struct isns { @@ -172,6 +184,7 @@ struct conf { TAILQ_HEAD(, lun) conf_luns; TAILQ_HEAD(, target) conf_targets; TAILQ_HEAD(, auth_group) conf_auth_groups; + TAILQ_HEAD(, port) conf_ports; TAILQ_HEAD(, portal_group) conf_portal_groups; TAILQ_HEAD(, isns) conf_isns; int conf_isns_period; @@ -199,6 +212,7 @@ struct conf { struct connection { struct portal *conn_portal; + struct port *conn_port; struct target *conn_target; int conn_socket; int conn_session_type; @@ -317,14 +331,19 @@ void isns_register(struct isns *isns, void isns_check(struct isns *isns); void isns_deregister(struct isns *isns); +struct port *port_new(struct conf *conf, struct target *target, + struct portal_group *pg); +struct port *port_find(const struct conf *conf, const char *name); +struct port *port_find_in_pg(const struct portal_group *pg, + const char *target); +void port_delete(struct port *port); + struct target *target_new(struct conf *conf, const char *name); void target_delete(struct target *target); struct target *target_find(struct conf *conf, const char *name); int target_set_redirection(struct target *target, const char *addr); -void target_set_ctl_port(struct target *target, - uint32_t value); struct lun *lun_new(struct conf *conf, const char *name); void lun_delete(struct lun *lun); @@ -351,9 +370,9 @@ int kernel_lun_add(struct lun *lun); int kernel_lun_resize(struct lun *lun); int kernel_lun_remove(struct lun *lun); void kernel_handoff(struct connection *conn); -int kernel_port_add(struct target *targ); -int kernel_port_update(struct target *targ); -int kernel_port_remove(struct target *targ); +int kernel_port_add(struct port *port); +int kernel_port_update(struct port *port); +int kernel_port_remove(struct port *port); void kernel_capsicate(void); #ifdef ICL_KERNEL_PROXY Modified: stable/10/usr.sbin/ctld/discovery.c ============================================================================== --- stable/10/usr.sbin/ctld/discovery.c Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/discovery.c Thu Feb 19 14:52:01 2015 (r279006) @@ -162,6 +162,7 @@ logout_new_response(struct pdu *request) static void discovery_add_target(struct keys *response_keys, const struct target *targ) { + struct port *port; struct portal *portal; char *buf; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; @@ -169,7 +170,10 @@ discovery_add_target(struct keys *respon int ret; keys_add(response_keys, "TargetName", targ->t_name); - TAILQ_FOREACH(portal, &targ->t_portal_group->pg_portals, p_next) { + TAILQ_FOREACH(port, &targ->t_ports, p_ts) { + if (port->p_portal_group == NULL) + continue; + TAILQ_FOREACH(portal, &port->p_portal_group->pg_portals, p_next) { ai = portal->p_ai; ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), @@ -183,13 +187,13 @@ discovery_add_target(struct keys *respon if (strcmp(hbuf, "0.0.0.0") == 0) continue; ret = asprintf(&buf, "%s:%s,%d", hbuf, sbuf, - targ->t_portal_group->pg_tag); + port->p_portal_group->pg_tag); break; case AF_INET6: if (strcmp(hbuf, "::") == 0) continue; ret = asprintf(&buf, "[%s]:%s,%d", hbuf, sbuf, - targ->t_portal_group->pg_tag); + port->p_portal_group->pg_tag); break; default: continue; @@ -198,19 +202,24 @@ discovery_add_target(struct keys *respon log_err(1, "asprintf"); keys_add(response_keys, "TargetAddress", buf); free(buf); + } } } static bool discovery_target_filtered_out(const struct connection *conn, - const struct target *targ) + const struct port *port) { const struct auth_group *ag; const struct portal_group *pg; + const struct target *targ; const struct auth *auth; int error; - ag = targ->t_auth_group; + targ = port->p_target; + ag = port->p_auth_group; + if (ag == NULL) + ag = targ->t_auth_group; pg = conn->conn_portal->p_portal_group; assert(pg->pg_discovery_auth_group != PG_FILTER_UNKNOWN); @@ -265,8 +274,8 @@ discovery(struct connection *conn) { struct pdu *request, *response; struct keys *request_keys, *response_keys; + const struct port *port; const struct portal_group *pg; - const struct target *targ; const char *send_targets; pg = conn->conn_portal->p_portal_group; @@ -284,29 +293,23 @@ discovery(struct connection *conn) response_keys = keys_new(); if (strcmp(send_targets, "All") == 0) { - TAILQ_FOREACH(targ, &pg->pg_conf->conf_targets, t_next) { - if (targ->t_portal_group != pg) { - log_debugx("not returning target \"%s\"; " - "belongs to a different portal group", - targ->t_name); - continue; - } - if (discovery_target_filtered_out(conn, targ)) { + TAILQ_FOREACH(port, &pg->pg_ports, p_pgs) { + if (discovery_target_filtered_out(conn, port)) { /* Ignore this target. */ continue; } - discovery_add_target(response_keys, targ); + discovery_add_target(response_keys, port->p_target); } } else { - targ = target_find(pg->pg_conf, send_targets); - if (targ == NULL) { + port = port_find_in_pg(pg, send_targets); + if (port == NULL) { log_debugx("initiator requested information on unknown " "target \"%s\"; returning nothing", send_targets); } else { - if (discovery_target_filtered_out(conn, targ)) { + if (discovery_target_filtered_out(conn, port)) { /* Ignore this target. */ } else { - discovery_add_target(response_keys, targ); + discovery_add_target(response_keys, port->p_target); } } } Modified: stable/10/usr.sbin/ctld/kernel.c ============================================================================== --- stable/10/usr.sbin/ctld/kernel.c Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/kernel.c Thu Feb 19 14:52:01 2015 (r279006) @@ -121,9 +121,10 @@ struct cctl_lun { struct cctl_port { uint32_t port_id; - int cfiscsi_status; + int cfiscsi_state; char *cfiscsi_target; uint16_t cfiscsi_portal_group_tag; + char *ctld_portal_group_name; STAILQ_HEAD(,cctl_lun_nv) attr_list; STAILQ_ENTRY(cctl_port) links; }; @@ -332,10 +333,13 @@ cctl_end_pelement(void *user_data, const if (strcmp(name, "cfiscsi_target") == 0) { cur_port->cfiscsi_target = str; str = NULL; - } else if (strcmp(name, "cfiscsi_status") == 0) { - cur_port->cfiscsi_status = strtoul(str, NULL, 0); + } else if (strcmp(name, "cfiscsi_state") == 0) { + cur_port->cfiscsi_state = strtoul(str, NULL, 0); } else if (strcmp(name, "cfiscsi_portal_group_tag") == 0) { cur_port->cfiscsi_portal_group_tag = strtoul(str, NULL, 0); + } else if (strcmp(name, "ctld_portal_group_name") == 0) { + cur_port->ctld_portal_group_name = str; + str = NULL; } else if (strcmp(name, "targ_port") == 0) { devlist->cur_port = NULL; } else if (strcmp(name, "ctlportlist") == 0) { @@ -373,6 +377,8 @@ conf_new_from_kernel(void) { struct conf *conf = NULL; struct target *targ; + struct portal_group *pg; + struct port *cp; struct lun *cl; struct lun_option *lo; struct ctl_lun_list list; @@ -496,9 +502,9 @@ retry_port: "ignoring", (uintmax_t)port->port_id); continue; } - if (port->cfiscsi_status != 1) { + if (port->cfiscsi_state != 1) { log_debugx("CTL port %ju is not active (%d); ignoring", - (uintmax_t)port->port_id, port->cfiscsi_status); + (uintmax_t)port->port_id, port->cfiscsi_state); continue; } @@ -514,6 +520,28 @@ retry_port: continue; } } + + if (port->ctld_portal_group_name == NULL) + continue; + pg = portal_group_find(conf, port->ctld_portal_group_name); + if (pg == NULL) { +#if 0 + log_debugx("found new kernel portal group %s for CTL port %ld", + port->ctld_portal_group_name, port->port_id); +#endif + pg = portal_group_new(conf, port->ctld_portal_group_name); + if (pg == NULL) { + log_warnx("portal_group_new failed"); + continue; + } + } + pg->pg_tag = port->cfiscsi_portal_group_tag; + cp = port_new(conf, targ, pg); + if (cp == NULL) { + log_warnx("port_new failed"); + continue; + } + cp->p_ctl_port = port->port_id; } STAILQ_FOREACH(lun, &devlist.lun_list, links) { @@ -804,32 +832,34 @@ kernel_handoff(struct connection *conn) } int -kernel_port_add(struct target *targ) +kernel_port_add(struct port *port) { struct ctl_port_entry entry; struct ctl_req req; struct ctl_lun_map lm; + struct target *targ = port->p_target; + struct portal_group *pg = port->p_portal_group; char tagstr[16]; - int error, i; + int error, i, n; /* Create iSCSI port. */ bzero(&req, sizeof(req)); strlcpy(req.driver, "iscsi", sizeof(req.driver)); req.reqtype = CTL_REQ_CREATE; - req.num_args = 4; req.args = malloc(req.num_args * sizeof(*req.args)); - req.args[0].namelen = sizeof("port_id"); - req.args[0].name = __DECONST(char *, "port_id"); - req.args[0].vallen = sizeof(targ->t_ctl_port); - req.args[0].value = &targ->t_ctl_port; - req.args[0].flags = CTL_BEARG_WR; - str_arg(&req.args[1], "cfiscsi_target", targ->t_name); - snprintf(tagstr, sizeof(tagstr), "%d", targ->t_portal_group->pg_tag); - str_arg(&req.args[2], "cfiscsi_portal_group_tag", tagstr); + n = 0; + req.args[n].namelen = sizeof("port_id"); + req.args[n].name = __DECONST(char *, "port_id"); + req.args[n].vallen = sizeof(port->p_ctl_port); + req.args[n].value = &port->p_ctl_port; + req.args[n++].flags = CTL_BEARG_WR; + str_arg(&req.args[n++], "cfiscsi_target", targ->t_name); + snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); + str_arg(&req.args[n++], "cfiscsi_portal_group_tag", tagstr); if (targ->t_alias) - str_arg(&req.args[3], "cfiscsi_target_alias", targ->t_alias); - else - req.num_args--; + str_arg(&req.args[n++], "cfiscsi_target_alias", targ->t_alias); + str_arg(&req.args[n++], "ctld_portal_group_name", pg->pg_name); + req.num_args = n; error = ioctl(ctl_fd, CTL_PORT_REQ, &req); free(req.args); if (error != 0) { @@ -848,7 +878,7 @@ kernel_port_add(struct target *targ) } /* Explicitly enable mapping to block any access except allowed. */ - lm.port = targ->t_ctl_port; + lm.port = port->p_ctl_port; lm.plun = UINT32_MAX; lm.lun = 0; error = ioctl(ctl_fd, CTL_LUN_MAP, &lm); @@ -859,7 +889,7 @@ kernel_port_add(struct target *targ) for (i = 0; i < MAX_LUNS; i++) { if (targ->t_luns[i] == NULL) continue; - lm.port = targ->t_ctl_port; + lm.port = port->p_ctl_port; lm.plun = i; lm.lun = targ->t_luns[i]->l_ctl_lun; error = ioctl(ctl_fd, CTL_LUN_MAP, &lm); @@ -869,7 +899,7 @@ kernel_port_add(struct target *targ) /* Enable port */ bzero(&entry, sizeof(entry)); - entry.targ_port = targ->t_ctl_port; + entry.targ_port = port->p_ctl_port; error = ioctl(ctl_fd, CTL_ENABLE_PORT, &entry); if (error != 0) { log_warn("CTL_ENABLE_PORT ioctl failed"); @@ -880,14 +910,15 @@ kernel_port_add(struct target *targ) } int -kernel_port_update(struct target *targ) +kernel_port_update(struct port *port) { struct ctl_lun_map lm; + struct target *targ = port->p_target; int error, i; /* Map configured LUNs and unmap others */ for (i = 0; i < MAX_LUNS; i++) { - lm.port = targ->t_ctl_port; + lm.port = port->p_ctl_port; lm.plun = i; if (targ->t_luns[i] == NULL) lm.lun = UINT32_MAX; @@ -901,10 +932,12 @@ kernel_port_update(struct target *targ) } int -kernel_port_remove(struct target *targ) +kernel_port_remove(struct port *port) { struct ctl_req req; char tagstr[16]; + struct target *targ = port->p_target; + struct portal_group *pg = port->p_portal_group; int error; bzero(&req, sizeof(req)); @@ -913,7 +946,7 @@ kernel_port_remove(struct target *targ) req.num_args = 2; req.args = malloc(req.num_args * sizeof(*req.args)); str_arg(&req.args[0], "cfiscsi_target", targ->t_name); - snprintf(tagstr, sizeof(tagstr), "%d", targ->t_portal_group->pg_tag); + snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr); error = ioctl(ctl_fd, CTL_PORT_REQ, &req); Modified: stable/10/usr.sbin/ctld/login.c ============================================================================== --- stable/10/usr.sbin/ctld/login.c Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/login.c Thu Feb 19 14:52:01 2015 (r279006) @@ -827,19 +827,22 @@ login(struct connection *conn) log_errx(1, "received Login PDU without TargetName"); } - conn->conn_target = target_find(pg->pg_conf, target_name); - if (conn->conn_target == NULL) { + conn->conn_port = port_find_in_pg(pg, target_name); + if (conn->conn_port == NULL) { login_send_error(request, 0x02, 0x03); log_errx(1, "requested target \"%s\" not found", target_name); } + conn->conn_target = conn->conn_port->p_target; } /* * At this point we know what kind of authentication we need. */ if (conn->conn_session_type == CONN_SESSION_TYPE_NORMAL) { - ag = conn->conn_target->t_auth_group; + ag = conn->conn_port->p_auth_group; + if (ag == NULL) + ag = conn->conn_target->t_auth_group; if (ag->ag_name != NULL) { log_debugx("initiator requests to connect " "to target \"%s\"; auth-group \"%s\"", Modified: stable/10/usr.sbin/ctld/parse.y ============================================================================== --- stable/10/usr.sbin/ctld/parse.y Thu Feb 19 14:40:50 2015 (r279005) +++ stable/10/usr.sbin/ctld/parse.y Thu Feb 19 14:52:01 2015 (r279006) @@ -652,21 +652,58 @@ target_initiator_portal: INITIATOR_PORTA } ; -target_portal_group: PORTAL_GROUP STR +target_portal_group: PORTAL_GROUP STR STR { - if (target->t_portal_group != NULL) { - log_warnx("portal-group for target \"%s\" " - "specified more than once", target->t_name); + struct portal_group *tpg; + struct auth_group *tag; + struct port *tp; + + tpg = portal_group_find(conf, $2); + if (tpg == NULL) { + log_warnx("unknown portal-group \"%s\" for target " + "\"%s\"", $2, target->t_name); free($2); + free($3); return (1); } - target->t_portal_group = portal_group_find(conf, $2); - if (target->t_portal_group == NULL) { + tag = auth_group_find(conf, $3); + if (tag == NULL) { + log_warnx("unknown auth-group \"%s\" for target " + "\"%s\"", $3, target->t_name); + free($2); + free($3); + return (1); + } + tp = port_new(conf, target, tpg); + if (tp == NULL) { + log_warnx("can't link portal-group \"%s\" to target " + "\"%s\"", $2, target->t_name); + free($2); + return (1); + } + tp->p_auth_group = tag; + free($2); + free($3); + } + | PORTAL_GROUP STR + { + struct portal_group *tpg; + struct port *tp; + + tpg = portal_group_find(conf, $2); + if (tpg == NULL) { log_warnx("unknown portal-group \"%s\" for target " "\"%s\"", $2, target->t_name); free($2); return (1); } + tp = port_new(conf, target, tpg); + if (tp == NULL) { + log_warnx("can't link portal-group \"%s\" to target " + "\"%s\"", $2, target->t_name); + free($2); + return (1); + } free($2); } ; From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 16:17:45 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D0484A29; Thu, 19 Feb 2015 16:17:45 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 A0BF0ACA; Thu, 19 Feb 2015 16:17:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JGHjAs052320; Thu, 19 Feb 2015 16:17:45 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JGHj61052319; Thu, 19 Feb 2015 16:17:45 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502191617.t1JGHj61052319@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 19 Feb 2015 16:17:45 +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: r279008 - stable/10/lib/libc/gen X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 16:17:45 -0000 Author: pfg Date: Thu Feb 19 16:17:44 2015 New Revision: 279008 URL: https://svnweb.freebsd.org/changeset/base/279008 Log: MFC r278300, r278314: getdiskbyname(): plug resource leak Variable cq going out of scope leaks the storage it points to. CID: 270511 Phabric: D1775 Reviewed by: imp Obtained from: NetBSD (CVS rev. 1.34) Modified: stable/10/lib/libc/gen/disklabel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/disklabel.c ============================================================================== --- stable/10/lib/libc/gen/disklabel.c Thu Feb 19 15:41:23 2015 (r279007) +++ stable/10/lib/libc/gen/disklabel.c Thu Feb 19 16:17:44 2015 (r279008) @@ -85,10 +85,13 @@ getdiskbyname(const char *name) cq++, cp++; *cq = '\0'; - if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (cq && strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; + if (cgetstr(buf, "ty", &cq) > 0) { + if (strcmp(cq, "removable") == 0) + dp->d_flags |= D_REMOVABLE; + else if (cq && strcmp(cq, "simulated") == 0) + dp->d_flags |= D_RAMDISK; + free(cq); + } if (cgetcap(buf, "sf", ':') != NULL) dp->d_flags |= D_BADSECT; @@ -100,9 +103,10 @@ getdiskbyname(const char *name) getnumdflt(dp->d_nsectors, "ns", 0); getnumdflt(dp->d_ncylinders, "nc", 0); - if (cgetstr(buf, "dt", &cq) > 0) + if (cgetstr(buf, "dt", &cq) > 0) { dp->d_type = gettype(cq, dktypenames); - else + free(cq); + } else getnumdflt(dp->d_type, "dt", 0); getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks); getnumdflt(dp->d_secperunit, "su", dp->d_secpercyl * dp->d_ncylinders); @@ -140,8 +144,11 @@ getdiskbyname(const char *name) pp->p_frag = 8; } getnumdflt(pp->p_fstype, ptype, 0); - if (pp->p_fstype == 0 && cgetstr(buf, ptype, &cq) > 0) - pp->p_fstype = gettype(cq, fstypenames); + if (pp->p_fstype == 0) + if (cgetstr(buf, ptype, &cq) >= 0) { + pp->p_fstype = gettype(cq, fstypenames); + free(cq); + } max = p; } } From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 16:24:28 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D971DDFC; Thu, 19 Feb 2015 16:24:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 C3DA2C05; Thu, 19 Feb 2015 16:24:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JGOSsO056778; Thu, 19 Feb 2015 16:24:28 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JGOSr7056777; Thu, 19 Feb 2015 16:24:28 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502191624.t1JGOSr7056777@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 19 Feb 2015 16:24:28 +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: r279010 - stable/10/lib/libc/stdlib X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 16:24:29 -0000 Author: pfg Date: Thu Feb 19 16:24:27 2015 New Revision: 279010 URL: https://svnweb.freebsd.org/changeset/base/279010 Log: MFC r278301, r278315: tdelete(3): don't delete the node we are about to return. CID: 272528 Obtained from: NetBSD (CVS rev. 1.4) Modified: stable/10/lib/libc/stdlib/tdelete.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/stdlib/tdelete.c ============================================================================== --- stable/10/lib/libc/stdlib/tdelete.c Thu Feb 19 16:19:00 2015 (r279009) +++ stable/10/lib/libc/stdlib/tdelete.c Thu Feb 19 16:24:27 2015 (r279010) @@ -14,7 +14,7 @@ #include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); +__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $"); #endif /* LIBC_SCCS and not lint */ #endif __FBSDID("$FreeBSD$"); @@ -25,9 +25,9 @@ __FBSDID("$FreeBSD$"); /* - * delete node with given key + * find a node with given key * - * vkey: key to be deleted + * vkey: key to be found * vrootp: address of the root of the tree * compar: function to carry out node comparisons */ @@ -65,7 +65,8 @@ tdelete(const void * __restrict vkey, vo q->rlink = (*rootp)->rlink; } } - free(*rootp); /* D4: Free node */ + if (p != *rootp) + free(*rootp); /* D4: Free node */ *rootp = q; /* link parent to new node */ return p; } From owner-svn-src-stable-10@FreeBSD.ORG Thu Feb 19 17:42:13 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9E787ACA; Thu, 19 Feb 2015 17:42:13 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 88CA97AD; Thu, 19 Feb 2015 17:42:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JHgDnZ094188; Thu, 19 Feb 2015 17:42:13 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JHgDQt094187; Thu, 19 Feb 2015 17:42:13 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201502191742.t1JHgDQt094187@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 19 Feb 2015 17:42:13 +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: r279014 - stable/10/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 17:42:13 -0000 Author: hselasky Date: Thu Feb 19 17:42:12 2015 New Revision: 279014 URL: https://svnweb.freebsd.org/changeset/base/279014 Log: MFC r278856: The "frag_info" pointer is already pointing to an array index. Don't index twice. Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/drivers/net/mlx4/en_rx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/drivers/net/mlx4/en_rx.c ============================================================================== --- stable/10/sys/ofed/drivers/net/mlx4/en_rx.c Thu Feb 19 17:03:13 2015 (r279013) +++ stable/10/sys/ofed/drivers/net/mlx4/en_rx.c Thu Feb 19 17:42:12 2015 (r279014) @@ -492,7 +492,7 @@ static int mlx4_en_complete_rx_desc(stru if (nr) mb->m_next = mb_list[nr]; mb = mb_list[nr]; - mb->m_len = frag_info[nr].frag_size; + mb->m_len = frag_info->frag_size; dma = be64_to_cpu(rx_desc->data[nr].addr); /* Allocate a replacement page */ From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 09:25:14 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6951F47; Fri, 20 Feb 2015 09:25:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 A1262CC0; Fri, 20 Feb 2015 09:25:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1K9PEAJ052094; Fri, 20 Feb 2015 09:25:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1K9PE89052092; Fri, 20 Feb 2015 09:25:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502200925.t1K9PE89052092@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 20 Feb 2015 09:25:14 +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: r279049 - stable/10/lib/libc/include X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 09:25:14 -0000 Author: kib Date: Fri Feb 20 09:25:13 2015 New Revision: 279049 URL: https://svnweb.freebsd.org/changeset/base/279049 Log: MFC r278889: Restore the extern qualifier on __cleanup. Modified: stable/10/lib/libc/include/libc_private.h Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/include/libc_private.h ============================================================================== --- stable/10/lib/libc/include/libc_private.h Fri Feb 20 07:57:59 2015 (r279048) +++ stable/10/lib/libc/include/libc_private.h Fri Feb 20 09:25:13 2015 (r279049) @@ -271,7 +271,7 @@ void _malloc_first_thread(void); /* * Function to clean up streams, called from abort() and exit(). */ -void (*__cleanup)(void) __hidden; +extern void (*__cleanup)(void) __hidden; /* * Get kern.osreldate to detect ABI revisions. Explicitly From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 11:52:47 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A466D82; Fri, 20 Feb 2015 11:52:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 44E75DF5; Fri, 20 Feb 2015 11:52:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KBqlP5021847; Fri, 20 Feb 2015 11:52:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KBqlan021846; Fri, 20 Feb 2015 11:52:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502201152.t1KBqlan021846@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Feb 2015 11:52:47 +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: r279052 - stable/10/lib/libnetgraph X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 11:52:47 -0000 Author: mav Date: Fri Feb 20 11:52:46 2015 New Revision: 279052 URL: https://svnweb.freebsd.org/changeset/base/279052 Log: MFC r278311: Some NetGraph debug polishing. Submitted by: Dmitry Luhtionov Modified: stable/10/lib/libnetgraph/debug.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libnetgraph/debug.c ============================================================================== --- stable/10/lib/libnetgraph/debug.c Fri Feb 20 11:23:41 2015 (r279051) +++ stable/10/lib/libnetgraph/debug.c Fri Feb 20 11:52:46 2015 (r279052) @@ -62,13 +62,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -82,15 +85,20 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include +#include #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -130,13 +138,16 @@ static const struct ng_cookie cookies[] COOKIE(ATMLLC), COOKIE(BPF), COOKIE(BRIDGE), + COOKIE(CAR), COOKIE(CISCO), + COOKIE(DEFLATE), COOKIE(DEVICE), COOKIE(ECHO), COOKIE(EIFACE), COOKIE(ETF), COOKIE(ETHER), COOKIE(FEC), + COOKIE(ETHER_ECHO), COOKIE(FRAMERELAY), COOKIE(GIF), COOKIE(GIF_DEMUX), @@ -151,15 +162,20 @@ static const struct ng_cookie cookies[] COOKIE(LMI), COOKIE(MPPC), COOKIE(NAT), + COOKIE(NETFLOW), COOKIE(ONE2MANY), + COOKIE(PATCH), + COOKIE(PIPE), COOKIE(PPP), COOKIE(PPPOE), COOKIE(PPTPGRE), + COOKIE(PRED1), COOKIE(RFC1490), COOKIE(SOCKET), COOKIE(SOURCE), COOKIE(SPLIT), COOKIE(SPPP), + COOKIE(TAG), COOKIE(TCPMSS), COOKIE(TEE), COOKIE(TTY), @@ -183,9 +199,8 @@ NgSetDebug(int level) { int old = _gNgDebugLevel; - if (level < 0) - level = old; - _gNgDebugLevel = level; + if (level >= 0) + _gNgDebugLevel = level; return (old); } @@ -227,10 +242,10 @@ _NgDebugMsg(const struct ng_mesg *msg, c /* Display header stuff */ NGLOGX("NG_MESG :"); NGLOGX(" vers %d", msg->header.version); - NGLOGX(" arglen %d", msg->header.arglen); - NGLOGX(" flags %ld", msg->header.flags); - NGLOGX(" token %lu", (u_long)msg->header.token); - NGLOGX(" cookie %s (%d)", + NGLOGX(" arglen %u", msg->header.arglen); + NGLOGX(" flags %x", msg->header.flags); + NGLOGX(" token %u", msg->header.token); + NGLOGX(" cookie %s (%u)", NgCookie(msg->header.typecookie), msg->header.typecookie); /* At lower debugging levels, skip ASCII translation */ From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 17:09:52 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4C26535F; Fri, 20 Feb 2015 17:09:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 3514F9D3; Fri, 20 Feb 2015 17:09:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KH9qb8070625; Fri, 20 Feb 2015 17:09:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KH9o5o070617; Fri, 20 Feb 2015 17:09:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502201709.t1KH9o5o070617@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Feb 2015 17:09:50 +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: r279055 - stable/10/usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 17:09:52 -0000 Author: mav Date: Fri Feb 20 17:09:49 2015 New Revision: 279055 URL: https://svnweb.freebsd.org/changeset/base/279055 Log: MFC r278354: Teach ctld(8) to control non-iSCSI CTL ports. This change introduces new target option "port", that assigns current target to specified CTL port. On config application ctld(8) will apply LUN mapping according to target configuration to specified port and bring the port up. On shutdown cltd(8) will remove the mapping and put the port down. This change allows to configure both iSCSI and FibreChannel targets in the same configuration file in alike way. Kernel side support was added earlier at r278037. Relnotes: yes Sponsored by: iXsystems, Inc. Modified: stable/10/usr.sbin/ctld/ctl.conf.5 stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/ctld/kernel.c stable/10/usr.sbin/ctld/parse.y stable/10/usr.sbin/ctld/token.l Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctl.conf.5 ============================================================================== --- stable/10/usr.sbin/ctld/ctl.conf.5 Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/ctl.conf.5 Fri Feb 20 17:09:49 2015 (r279055) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 6, 2015 +.Dd February 7, 2015 .Dt CTL.CONF 5 .Os .Sh NAME @@ -67,6 +67,7 @@ file is: .No target Ar name { .Dl auth-group Ar name .Dl portal-group Ar name Op Ar agname +.Dl port Ar name .Dl lun Ar number Ar name .Dl lun Ar number No { .Dl path Ar path @@ -319,6 +320,10 @@ on TCP port 3260 on all configured IPv4 Optional second argument specifies auth group name for connections to this specific portal group. If second argument is not specified, target auth group is used. +.It Ic port Ar name +Assign specified CTL port (such as "isp0") to the target. +On startup ctld configures LUN mapping and enables all assigned ports. +Each port can be assigned to only one target. .It Ic redirect Aq Ar address IPv4 or IPv6 address to redirect initiators to. When configured, all initiators attempting to connect to this target Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/ctld.c Fri Feb 20 17:09:49 2015 (r279055) @@ -93,6 +93,7 @@ conf_new(void) TAILQ_INIT(&conf->conf_auth_groups); TAILQ_INIT(&conf->conf_ports); TAILQ_INIT(&conf->conf_portal_groups); + TAILQ_INIT(&conf->conf_pports); TAILQ_INIT(&conf->conf_isns); conf->conf_isns_period = 900; @@ -111,6 +112,7 @@ conf_delete(struct conf *conf) struct target *targ, *tmp; struct auth_group *ag, *cagtmp; struct portal_group *pg, *cpgtmp; + struct pport *pp, *pptmp; struct isns *is, *istmp; assert(conf->conf_pidfh == NULL); @@ -123,6 +125,8 @@ conf_delete(struct conf *conf) auth_group_delete(ag); TAILQ_FOREACH_SAFE(pg, &conf->conf_portal_groups, pg_next, cpgtmp) portal_group_delete(pg); + TAILQ_FOREACH_SAFE(pp, &conf->conf_pports, pp_next, pptmp) + pport_delete(pp); TAILQ_FOREACH_SAFE(is, &conf->conf_isns, i_next, istmp) isns_delete(is); assert(TAILQ_EMPTY(&conf->conf_ports)); @@ -1133,21 +1137,72 @@ valid_iscsi_name(const char *name) return (true); } +struct pport * +pport_new(struct conf *conf, const char *name, uint32_t ctl_port) +{ + struct pport *pp; + + pp = calloc(1, sizeof(*pp)); + if (pp == NULL) + log_err(1, "calloc"); + pp->pp_conf = conf; + pp->pp_name = checked_strdup(name); + pp->pp_ctl_port = ctl_port; + TAILQ_INIT(&pp->pp_ports); + TAILQ_INSERT_TAIL(&conf->conf_pports, pp, pp_next); + return (pp); +} + +struct pport * +pport_find(const struct conf *conf, const char *name) +{ + struct pport *pp; + + TAILQ_FOREACH(pp, &conf->conf_pports, pp_next) { + if (strcasecmp(pp->pp_name, name) == 0) + return (pp); + } + return (NULL); +} + +struct pport * +pport_copy(struct pport *pp, struct conf *conf) +{ + struct pport *ppnew; + + ppnew = pport_new(conf, pp->pp_name, pp->pp_ctl_port); + return (ppnew); +} + +void +pport_delete(struct pport *pp) +{ + struct port *port, *tport; + + TAILQ_FOREACH_SAFE(port, &pp->pp_ports, p_ts, tport) + port_delete(port); + TAILQ_REMOVE(&pp->pp_conf->conf_pports, pp, pp_next); + free(pp->pp_name); + free(pp); +} + struct port * port_new(struct conf *conf, struct target *target, struct portal_group *pg) { struct port *port; + char *name; + asprintf(&name, "%s-%s", pg->pg_name, target->t_name); + if (port_find(conf, name) != NULL) { + log_warnx("duplicate port \"%s\"", name); + free(name); + return (NULL); + } port = calloc(1, sizeof(*port)); if (port == NULL) log_err(1, "calloc"); - asprintf(&port->p_name, "%s-%s", pg->pg_name, target->t_name); - if (port_find(conf, port->p_name) != NULL) { - log_warnx("duplicate port \"%s\"", port->p_name); - free(port); - return (NULL); - } port->p_conf = conf; + port->p_name = name; TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); port->p_target = target; @@ -1157,6 +1212,31 @@ port_new(struct conf *conf, struct targe } struct port * +port_new_pp(struct conf *conf, struct target *target, struct pport *pp) +{ + struct port *port; + char *name; + + asprintf(&name, "%s-%s", pp->pp_name, target->t_name); + if (port_find(conf, name) != NULL) { + log_warnx("duplicate port \"%s\"", name); + free(name); + return (NULL); + } + port = calloc(1, sizeof(*port)); + if (port == NULL) + log_err(1, "calloc"); + port->p_conf = conf; + port->p_name = name; + TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); + TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); + port->p_target = target; + TAILQ_INSERT_TAIL(&pp->pp_ports, port, p_pps); + port->p_pport = pp; + return (port); +} + +struct port * port_find(const struct conf *conf, const char *name) { struct port *port; @@ -1188,6 +1268,8 @@ port_delete(struct port *port) if (port->p_portal_group) TAILQ_REMOVE(&port->p_portal_group->pg_ports, port, p_pgs); + if (port->p_pport) + TAILQ_REMOVE(&port->p_pport->pp_ports, port, p_pps); if (port->p_target) TAILQ_REMOVE(&port->p_target->t_ports, port, p_ts); TAILQ_REMOVE(&port->p_conf->conf_ports, port, p_next); @@ -1761,6 +1843,7 @@ conf_apply(struct conf *oldconf, struct newport = port_find(newconf, oldport->p_name); if (newport != NULL) continue; + log_debugx("removing port \"%s\"", oldport->p_name); error = kernel_port_remove(oldport); if (error != 0) { log_warnx("failed to remove port %s", @@ -1885,8 +1968,10 @@ conf_apply(struct conf *oldconf, struct oldport = port_find(oldconf, newport->p_name); if (oldport == NULL) { + log_debugx("adding port \"%s\"", newport->p_name); error = kernel_port_add(newport); } else { + log_debugx("updating port \"%s\"", newport->p_name); newport->p_ctl_port = oldport->p_ctl_port; error = kernel_port_update(newport); } @@ -2398,7 +2483,7 @@ main(int argc, char **argv) kernel_init(); oldconf = conf_new_from_kernel(); - newconf = conf_new_from_file(config_path); + newconf = conf_new_from_file(config_path, oldconf); if (newconf == NULL) log_errx(1, "configuration error; exiting"); if (debug > 0) { @@ -2433,7 +2518,7 @@ main(int argc, char **argv) if (sighup_received) { sighup_received = false; log_debugx("received SIGHUP, reloading configuration"); - tmpconf = conf_new_from_file(config_path); + tmpconf = conf_new_from_file(config_path, newconf); if (tmpconf == NULL) { log_warnx("configuration error, " "continuing with old configuration"); Modified: stable/10/usr.sbin/ctld/ctld.h ============================================================================== --- stable/10/usr.sbin/ctld/ctld.h Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/ctld.h Fri Feb 20 17:09:49 2015 (r279055) @@ -125,14 +125,25 @@ struct portal_group { uint16_t pg_tag; }; +struct pport { + TAILQ_ENTRY(pport) pp_next; + TAILQ_HEAD(, port) pp_ports; + struct conf *pp_conf; + char *pp_name; + + uint32_t pp_ctl_port; +}; + struct port { TAILQ_ENTRY(port) p_next; TAILQ_ENTRY(port) p_pgs; + TAILQ_ENTRY(port) p_pps; TAILQ_ENTRY(port) p_ts; struct conf *p_conf; char *p_name; struct auth_group *p_auth_group; struct portal_group *p_portal_group; + struct pport *p_pport; struct target *p_target; uint32_t p_ctl_port; @@ -186,6 +197,7 @@ struct conf { TAILQ_HEAD(, auth_group) conf_auth_groups; TAILQ_HEAD(, port) conf_ports; TAILQ_HEAD(, portal_group) conf_portal_groups; + TAILQ_HEAD(, pport) conf_pports; TAILQ_HEAD(, isns) conf_isns; int conf_isns_period; int conf_isns_timeout; @@ -278,7 +290,7 @@ char *rchap_get_response(struct rchap void rchap_delete(struct rchap *rchap); struct conf *conf_new(void); -struct conf *conf_new_from_file(const char *path); +struct conf *conf_new_from_file(const char *path, struct conf *old); struct conf *conf_new_from_kernel(void); void conf_delete(struct conf *conf); int conf_verify(struct conf *conf); @@ -331,8 +343,16 @@ void isns_register(struct isns *isns, void isns_check(struct isns *isns); void isns_deregister(struct isns *isns); +struct pport *pport_new(struct conf *conf, const char *name, + uint32_t ctl_port); +struct pport *pport_find(const struct conf *conf, const char *name); +struct pport *pport_copy(struct pport *pport, struct conf *conf); +void pport_delete(struct pport *pport); + struct port *port_new(struct conf *conf, struct target *target, struct portal_group *pg); +struct port *port_new_pp(struct conf *conf, struct target *target, + struct pport *pp); struct port *port_find(const struct conf *conf, const char *name); struct port *port_find_in_pg(const struct portal_group *pg, const char *target); Modified: stable/10/usr.sbin/ctld/kernel.c ============================================================================== --- stable/10/usr.sbin/ctld/kernel.c Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/kernel.c Fri Feb 20 17:09:49 2015 (r279055) @@ -121,6 +121,7 @@ struct cctl_lun { struct cctl_port { uint32_t port_id; + char *port_name; int cfiscsi_state; char *cfiscsi_target; uint16_t cfiscsi_portal_group_tag; @@ -330,7 +331,10 @@ cctl_end_pelement(void *user_data, const devlist->cur_sb[devlist->level] = NULL; devlist->level--; - if (strcmp(name, "cfiscsi_target") == 0) { + if (strcmp(name, "port_name") == 0) { + cur_port->port_name = str; + str = NULL; + } else if (strcmp(name, "cfiscsi_target") == 0) { cur_port->cfiscsi_target = str; str = NULL; } else if (strcmp(name, "cfiscsi_state") == 0) { @@ -378,6 +382,7 @@ conf_new_from_kernel(void) struct conf *conf = NULL; struct target *targ; struct portal_group *pg; + struct pport *pp; struct port *cp; struct lun *cl; struct lun_option *lo; @@ -498,8 +503,20 @@ retry_port: STAILQ_FOREACH(port, &devlist.port_list, links) { if (port->cfiscsi_target == NULL) { - log_debugx("CTL port %ju wasn't managed by ctld; " - "ignoring", (uintmax_t)port->port_id); + log_debugx("CTL port %u \"%s\" wasn't managed by ctld; ", + port->port_id, port->port_name); + pp = pport_find(conf, port->port_name); + if (pp == NULL) { +#if 0 + log_debugx("found new kernel port %u \"%s\"", + port->port_id, port->port_name); +#endif + pp = pport_new(conf, port->port_name, port->port_id); + if (pp == NULL) { + log_warnx("pport_new failed"); + continue; + } + } continue; } if (port->cfiscsi_state != 1) { @@ -843,39 +860,42 @@ kernel_port_add(struct port *port) int error, i, n; /* Create iSCSI port. */ - bzero(&req, sizeof(req)); - strlcpy(req.driver, "iscsi", sizeof(req.driver)); - req.reqtype = CTL_REQ_CREATE; - req.args = malloc(req.num_args * sizeof(*req.args)); - n = 0; - req.args[n].namelen = sizeof("port_id"); - req.args[n].name = __DECONST(char *, "port_id"); - req.args[n].vallen = sizeof(port->p_ctl_port); - req.args[n].value = &port->p_ctl_port; - req.args[n++].flags = CTL_BEARG_WR; - str_arg(&req.args[n++], "cfiscsi_target", targ->t_name); - snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); - str_arg(&req.args[n++], "cfiscsi_portal_group_tag", tagstr); - if (targ->t_alias) - str_arg(&req.args[n++], "cfiscsi_target_alias", targ->t_alias); - str_arg(&req.args[n++], "ctld_portal_group_name", pg->pg_name); - req.num_args = n; - error = ioctl(ctl_fd, CTL_PORT_REQ, &req); - free(req.args); - if (error != 0) { - log_warn("error issuing CTL_PORT_REQ ioctl"); - return (1); - } - if (req.status == CTL_LUN_ERROR) { - log_warnx("error returned from port creation request: %s", - req.error_str); - return (1); - } - if (req.status != CTL_LUN_OK) { - log_warnx("unknown port creation request status %d", - req.status); - return (1); - } + if (port->p_portal_group) { + bzero(&req, sizeof(req)); + strlcpy(req.driver, "iscsi", sizeof(req.driver)); + req.reqtype = CTL_REQ_CREATE; + req.args = malloc(req.num_args * sizeof(*req.args)); + n = 0; + req.args[n].namelen = sizeof("port_id"); + req.args[n].name = __DECONST(char *, "port_id"); + req.args[n].vallen = sizeof(port->p_ctl_port); + req.args[n].value = &port->p_ctl_port; + req.args[n++].flags = CTL_BEARG_WR; + str_arg(&req.args[n++], "cfiscsi_target", targ->t_name); + snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); + str_arg(&req.args[n++], "cfiscsi_portal_group_tag", tagstr); + if (targ->t_alias) + str_arg(&req.args[n++], "cfiscsi_target_alias", targ->t_alias); + str_arg(&req.args[n++], "ctld_portal_group_name", pg->pg_name); + req.num_args = n; + error = ioctl(ctl_fd, CTL_PORT_REQ, &req); + free(req.args); + if (error != 0) { + log_warn("error issuing CTL_PORT_REQ ioctl"); + return (1); + } + if (req.status == CTL_LUN_ERROR) { + log_warnx("error returned from port creation request: %s", + req.error_str); + return (1); + } + if (req.status != CTL_LUN_OK) { + log_warnx("unknown port creation request status %d", + req.status); + return (1); + } + } else if (port->p_pport) + port->p_ctl_port = port->p_pport->pp_ctl_port; /* Explicitly enable mapping to block any access except allowed. */ lm.port = port->p_ctl_port; @@ -934,40 +954,58 @@ kernel_port_update(struct port *port) int kernel_port_remove(struct port *port) { + struct ctl_port_entry entry; + struct ctl_lun_map lm; struct ctl_req req; char tagstr[16]; struct target *targ = port->p_target; struct portal_group *pg = port->p_portal_group; int error; - bzero(&req, sizeof(req)); - strlcpy(req.driver, "iscsi", sizeof(req.driver)); - req.reqtype = CTL_REQ_REMOVE; - req.num_args = 2; - req.args = malloc(req.num_args * sizeof(*req.args)); - str_arg(&req.args[0], "cfiscsi_target", targ->t_name); - snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); - str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr); - - error = ioctl(ctl_fd, CTL_PORT_REQ, &req); - free(req.args); + /* Disable port */ + bzero(&entry, sizeof(entry)); + entry.targ_port = port->p_ctl_port; + error = ioctl(ctl_fd, CTL_DISABLE_PORT, &entry); if (error != 0) { - log_warn("error issuing CTL_PORT_REQ ioctl"); - return (1); - } - - if (req.status == CTL_LUN_ERROR) { - log_warnx("error returned from port removal request: %s", - req.error_str); - return (1); + log_warn("CTL_DISABLE_PORT ioctl failed"); + return (-1); } - if (req.status != CTL_LUN_OK) { - log_warnx("unknown port removal request status %d", - req.status); - return (1); + /* Remove iSCSI port. */ + if (port->p_portal_group) { + bzero(&req, sizeof(req)); + strlcpy(req.driver, "iscsi", sizeof(req.driver)); + req.reqtype = CTL_REQ_REMOVE; + req.num_args = 2; + req.args = malloc(req.num_args * sizeof(*req.args)); + str_arg(&req.args[0], "cfiscsi_target", targ->t_name); + snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); + str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr); + error = ioctl(ctl_fd, CTL_PORT_REQ, &req); + free(req.args); + if (error != 0) { + log_warn("error issuing CTL_PORT_REQ ioctl"); + return (1); + } + if (req.status == CTL_LUN_ERROR) { + log_warnx("error returned from port removal request: %s", + req.error_str); + return (1); + } + if (req.status != CTL_LUN_OK) { + log_warnx("unknown port removal request status %d", + req.status); + return (1); + } + } else { + /* Disable LUN mapping. */ + lm.port = port->p_ctl_port; + lm.plun = UINT32_MAX; + lm.lun = UINT32_MAX; + error = ioctl(ctl_fd, CTL_LUN_MAP, &lm); + if (error != 0) + log_warn("CTL_LUN_MAP ioctl failed"); } - return (0); } Modified: stable/10/usr.sbin/ctld/parse.y ============================================================================== --- stable/10/usr.sbin/ctld/parse.y Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/parse.y Fri Feb 20 17:09:49 2015 (r279055) @@ -61,7 +61,7 @@ extern void yyrestart(FILE *); %token CLOSING_BRACKET DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP DISCOVERY_FILTER %token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT %token LISTEN LISTEN_ISER LUN MAXPROC OPENING_BRACKET OPTION -%token PATH PIDFILE PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR +%token PATH PIDFILE PORT PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR %token TARGET TIMEOUT %union @@ -465,6 +465,8 @@ target_entry: | target_portal_group | + target_port + | target_redirect | target_lun @@ -708,6 +710,36 @@ target_portal_group: PORTAL_GROUP STR ST } ; +target_port: PORT STR + { + struct pport *pp; + struct port *tp; + + pp = pport_find(conf, $2); + if (pp == NULL) { + log_warnx("unknown port \"%s\" for target \"%s\"", + $2, target->t_name); + free($2); + return (1); + } + if (!TAILQ_EMPTY(&pp->pp_ports)) { + log_warnx("can't link port \"%s\" to target \"%s\", " + "port already linked to some target", + $2, target->t_name); + free($2); + return (1); + } + tp = port_new_pp(conf, target, pp); + if (tp == NULL) { + log_warnx("can't link port \"%s\" to target \"%s\"", + $2, target->t_name); + free($2); + return (1); + } + free($2); + } + ; + target_redirect: REDIRECT STR { int error; @@ -937,16 +969,20 @@ check_perms(const char *path) } struct conf * -conf_new_from_file(const char *path) +conf_new_from_file(const char *path, struct conf *oldconf) { struct auth_group *ag; struct portal_group *pg; + struct pport *pp; int error; log_debugx("obtaining configuration from %s", path); conf = conf_new(); + TAILQ_FOREACH(pp, &oldconf->conf_pports, pp_next) + pport_copy(pp, conf); + ag = auth_group_new(conf, "default"); assert(ag != NULL); Modified: stable/10/usr.sbin/ctld/token.l ============================================================================== --- stable/10/usr.sbin/ctld/token.l Fri Feb 20 13:50:50 2015 (r279054) +++ stable/10/usr.sbin/ctld/token.l Fri Feb 20 17:09:49 2015 (r279055) @@ -71,6 +71,7 @@ pidfile { return PIDFILE; } isns-server { return ISNS_SERVER; } isns-period { return ISNS_PERIOD; } isns-timeout { return ISNS_TIMEOUT; } +port { return PORT; } portal-group { return PORTAL_GROUP; } redirect { return REDIRECT; } serial { return SERIAL; } From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 17:10:47 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2982C4A9; Fri, 20 Feb 2015 17:10:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 13765A7B; Fri, 20 Feb 2015 17:10:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KHAkU3071346; Fri, 20 Feb 2015 17:10:46 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KHAkFY071345; Fri, 20 Feb 2015 17:10:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201502201710.t1KHAkFY071345@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Feb 2015 17:10:46 +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: r279056 - stable/10/usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 17:10:47 -0000 Author: mav Date: Fri Feb 20 17:10:46 2015 New Revision: 279056 URL: https://svnweb.freebsd.org/changeset/base/279056 Log: MFC r278594: Add missing asprintf() status checks. Modified: stable/10/usr.sbin/ctld/ctld.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Fri Feb 20 17:09:49 2015 (r279055) +++ stable/10/usr.sbin/ctld/ctld.c Fri Feb 20 17:10:46 2015 (r279056) @@ -1191,8 +1191,11 @@ port_new(struct conf *conf, struct targe { struct port *port; char *name; + int ret; - asprintf(&name, "%s-%s", pg->pg_name, target->t_name); + ret = asprintf(&name, "%s-%s", pg->pg_name, target->t_name); + if (ret <= 0) + log_err(1, "asprintf"); if (port_find(conf, name) != NULL) { log_warnx("duplicate port \"%s\"", name); free(name); @@ -1216,8 +1219,11 @@ port_new_pp(struct conf *conf, struct ta { struct port *port; char *name; + int ret; - asprintf(&name, "%s-%s", pp->pp_name, target->t_name); + ret = asprintf(&name, "%s-%s", pp->pp_name, target->t_name); + if (ret <= 0) + log_err(1, "asprintf"); if (port_find(conf, name) != NULL) { log_warnx("duplicate port \"%s\"", name); free(name); From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 18:06:34 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D7502357; Fri, 20 Feb 2015 18:06:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 BB5EDEE; Fri, 20 Feb 2015 18:06:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KI6YJ9000250; Fri, 20 Feb 2015 18:06:34 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KI6YMI000249; Fri, 20 Feb 2015 18:06:34 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502201806.t1KI6YMI000249@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 20 Feb 2015 18:06:34 +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: r279070 - stable/10/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 18:06:35 -0000 Author: gjb Date: Fri Feb 20 18:06:33 2015 New Revision: 279070 URL: https://svnweb.freebsd.org/changeset/base/279070 Log: Document r278982, pmc callchain depths increased. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 18:06:11 2015 (r279069) +++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 18:06:33 2015 (r279070) @@ -246,6 +246,11 @@ Throttling via ACPI and P4TCC via &man.device.hints.5; have been turned off by default. + + The + &man.hwpmc.4; default and maximum callchain depths have been + increased. The default has been increased from 16 to 32, and + the maximum increased from 32 to 128. From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 20:02:48 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2714FAC2; Fri, 20 Feb 2015 20:02:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 ECBAAFC6; Fri, 20 Feb 2015 20:02:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KK2lsU058041; Fri, 20 Feb 2015 20:02:47 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KK2lVq058040; Fri, 20 Feb 2015 20:02:47 GMT (envelope-from rpaulo@FreeBSD.org) Message-Id: <201502202002.t1KK2lVq058040@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rpaulo set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo Date: Fri, 20 Feb 2015 20:02:47 +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: r279082 - stable/10/lib/libproc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 20:02:48 -0000 Author: rpaulo Date: Fri Feb 20 20:02:47 2015 New Revision: 279082 URL: https://svnweb.freebsd.org/changeset/base/279082 Log: MFC r278658: Teach libproc how to find debugging symbols in /usr/lib/debug. Modified: stable/10/lib/libproc/proc_sym.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libproc/proc_sym.c ============================================================================== --- stable/10/lib/libproc/proc_sym.c Fri Feb 20 19:48:24 2015 (r279081) +++ stable/10/lib/libproc/proc_sym.c Fri Feb 20 20:02:47 2015 (r279082) @@ -71,6 +71,21 @@ fail: strlcpy(buf, symbol, len); } +static int +find_dbg_obj(const char *path) +{ + int fd; + char dbg_path[PATH_MAX]; + + snprintf(dbg_path, sizeof(dbg_path), + "/usr/lib/debug/%s.debug", path); + fd = open(dbg_path, O_RDONLY); + if (fd > 0) + return (fd); + else + return (open(path, O_RDONLY)); +} + static void proc_rdl2prmap(rd_loadobj_t *rdl, prmap_t *map) { @@ -247,7 +262,7 @@ proc_addr2sym(struct proc_handle *p, uin if ((map = proc_addr2map(p, addr)) == NULL) return (-1); - if ((fd = open(map->pr_mapname, O_RDONLY, 0)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } @@ -428,7 +443,7 @@ proc_name2sym(struct proc_handle *p, con DPRINTFX("ERROR: couldn't find object %s", object); goto err0; } - if ((fd = open(map->pr_mapname, O_RDONLY, 0)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } @@ -525,7 +540,7 @@ proc_iter_symbyaddr(struct proc_handle * if ((map = proc_name2map(p, object)) == NULL) return (-1); - if ((fd = open(map->pr_mapname, O_RDONLY)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 20:30:00 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 001FA75B; Fri, 20 Feb 2015 20:29:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 DF9952FB; Fri, 20 Feb 2015 20:29:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KKTxIk070944; Fri, 20 Feb 2015 20:29:59 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KKTxHf070943; Fri, 20 Feb 2015 20:29:59 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502202029.t1KKTxHf070943@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 20 Feb 2015 20:29:59 +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: r279085 - stable/10/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 20:30:00 -0000 Author: gjb Date: Fri Feb 20 20:29:59 2015 New Revision: 279085 URL: https://svnweb.freebsd.org/changeset/base/279085 Log: Document r277434, fstyp(8) addition. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:27:53 2015 (r279084) +++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:29:59 2015 (r279085) @@ -178,6 +178,10 @@ The &man.elfdump.1; utility has been updated to support capability mode provided by &man.capsicum.4;. + + The + &man.fstyp.8; utility has been added, which is used to + determine the filesystem on a specified device. From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 20:30:02 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BE71283D; Fri, 20 Feb 2015 20:30:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 AA39B2FD; Fri, 20 Feb 2015 20:30:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KKU234071093; Fri, 20 Feb 2015 20:30:02 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KKU230071092; Fri, 20 Feb 2015 20:30:02 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502202030.t1KKU230071092@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 20 Feb 2015 20:30:02 +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: r279086 - stable/10/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 20:30:02 -0000 Author: gjb Date: Fri Feb 20 20:30:01 2015 New Revision: 279086 URL: https://svnweb.freebsd.org/changeset/base/279086 Log: Document r277583, arc_meta_limit exposed via kstats. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:29:59 2015 (r279085) +++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:30:01 2015 (r279086) @@ -334,6 +334,14 @@ A new tunable, vfs.zfs.spa_slop_shift, has been added, which controls how much space is reserved by default. + + The arc_meta_limit + statistics are now visible through the + kstat &man.sysctl.8;. As a result of this + change, the vfs.zfs.arc_meta_used + &man.sysctl.8; has been removed, and replaced with the + kstat.zfs.misc.arcstats.arc_meta_used + &man.sysctl.8;. From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 20:30:05 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 605BE99B; Fri, 20 Feb 2015 20:30:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 4994E2FF; Fri, 20 Feb 2015 20:30:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KKU5p3071159; Fri, 20 Feb 2015 20:30:05 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KKU5da071158; Fri, 20 Feb 2015 20:30:05 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502202030.t1KKU5da071158@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 20 Feb 2015 20:30:05 +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: r279087 - stable/10/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 20:30:05 -0000 Author: gjb Date: Fri Feb 20 20:30:04 2015 New Revision: 279087 URL: https://svnweb.freebsd.org/changeset/base/279087 Log: Add 'Generic Storage' section. Document r279002, r279055: ctld(8) update to control non-iSCSI CTL ports CTL LUN mapping rewrite Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:30:01 2015 (r279086) +++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:30:04 2015 (r279087) @@ -316,6 +316,18 @@ This section covers changes and additions to file systems and other storage subsystems, both local and networked. + + General Storage + The + &man.ctl.4; LUN mapping has been rewritten, + replacing iSCSI-specific mapping mechanisms + with a new mechanism that works for any port. + + The + &man.ctld.8; utility has been updated to allow controlling + non-iSCSI &man.ctl.4; ports. + + Networked Storage From owner-svn-src-stable-10@FreeBSD.ORG Fri Feb 20 20:33:44 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 67EF1B80; Fri, 20 Feb 2015 20:33:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 535EA3E7; Fri, 20 Feb 2015 20:33:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1KKXiSm075094; Fri, 20 Feb 2015 20:33:44 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1KKXi65075093; Fri, 20 Feb 2015 20:33:44 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201502202033.t1KKXi65075093@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Fri, 20 Feb 2015 20:33:44 +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: r279088 - stable/10/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 20:33:44 -0000 Author: gjb Date: Fri Feb 20 20:33:43 2015 New Revision: 279088 URL: https://svnweb.freebsd.org/changeset/base/279088 Log: Update commented last revision. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:30:04 2015 (r279087) +++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Feb 20 20:33:43 2015 (r279088) @@ -22,7 +22,7 @@ $FreeBSD$ - + 2015