From owner-svn-src-stable-12@freebsd.org Wed May 8 15:20:18 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42726158A033; Wed, 8 May 2019 15:20:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE48B778E5; Wed, 8 May 2019 15:20:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8ECD07930; Wed, 8 May 2019 15:20:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x48FKHPL097166; Wed, 8 May 2019 15:20:17 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x48FKHs8097163; Wed, 8 May 2019 15:20:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201905081520.x48FKHs8097163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 8 May 2019 15:20:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347336 - stable/12/sys/cam/scsi X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/scsi X-SVN-Commit-Revision: 347336 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DE48B778E5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 15:20:18 -0000 Author: mav Date: Wed May 8 15:20:16 2019 New Revision: 347336 URL: https://svnweb.freebsd.org/changeset/base/347336 Log: MFC r346511: Report DIF protection type the disk is formatted with. Some disks formatted with protection report errors if written without protection used. This should help to diagnose the problem. Modified: stable/12/sys/cam/scsi/scsi_all.h stable/12/sys/cam/scsi/scsi_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/12/sys/cam/scsi/scsi_all.h Wed May 8 15:17:45 2019 (r347335) +++ stable/12/sys/cam/scsi/scsi_all.h Wed May 8 15:20:16 2019 (r347336) @@ -2931,6 +2931,7 @@ struct scsi_read_capacity_data_long uint8_t length[4]; #define SRC16_PROT_EN 0x01 #define SRC16_P_TYPE 0x0e +#define SRC16_P_TYPE_SHIFT 1 #define SRC16_PTYPE_1 0x00 #define SRC16_PTYPE_2 0x02 #define SRC16_PTYPE_3 0x04 Modified: stable/12/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/12/sys/cam/scsi/scsi_da.c Wed May 8 15:17:45 2019 (r347335) +++ stable/12/sys/cam/scsi/scsi_da.c Wed May 8 15:20:16 2019 (r347336) @@ -339,6 +339,7 @@ struct da_softc { da_delete_func_t *delete_func; int unmappedio; int rotating; + int p_type; struct disk_params params; struct disk *disk; union ccb saved_ccb; @@ -2262,7 +2263,7 @@ dasysctlinit(void *context, int pending) CTLFLAG_RD, &softc->unmappedio, 0, - "Unmapped I/O leaf"); + "Unmapped I/O support"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), @@ -2273,6 +2274,15 @@ dasysctlinit(void *context, int pending) 0, "Rotating media"); + SYSCTL_ADD_INT(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, + "p_type", + CTLFLAG_RD, + &softc->p_type, + 0, + "DIF protection type"); + #ifdef CAM_TEST_FAILURE SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "invalidate", CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, @@ -4613,7 +4623,7 @@ dadone_proberc(struct cam_periph *periph, union ccb *d da_ccb_state state; char *announce_buf; u_int32_t priority; - int lbp; + int lbp, n; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_proberc\n")); @@ -4695,11 +4705,17 @@ dadone_proberc(struct cam_periph *periph, union ccb *d rcaplong, sizeof(*rcaplong)); lbp = (lalba & SRC16_LBPME_A); dp = &softc->params; - snprintf(announce_buf, DA_ANNOUNCETMP_SZ, - "%juMB (%ju %u byte sectors)", + n = snprintf(announce_buf, DA_ANNOUNCETMP_SZ, + "%juMB (%ju %u byte sectors", ((uintmax_t)dp->secsize * dp->sectors) / (1024 * 1024), (uintmax_t)dp->sectors, dp->secsize); + if (softc->p_type != 0) { + n += snprintf(announce_buf + n, + DA_ANNOUNCETMP_SZ - n, + ", DIF type %d", softc->p_type); + } + snprintf(announce_buf + n, DA_ANNOUNCETMP_SZ - n, ")"); } } else { int error; @@ -5948,9 +5964,15 @@ dasetgeom(struct cam_periph *periph, uint32_t block_le lbppbe = rcaplong->prot_lbppbe & SRC16_LBPPBE; lalba = scsi_2btoul(rcaplong->lalba_lbp); lalba &= SRC16_LALBA_A; + if (rcaplong->prot & SRC16_PROT_EN) + softc->p_type = ((rcaplong->prot & SRC16_P_TYPE) >> + SRC16_P_TYPE_SHIFT) + 1; + else + softc->p_type = 0; } else { lbppbe = 0; lalba = 0; + softc->p_type = 0; } if (lbppbe > 0) {