Date: Tue, 03 Sep 2019 14:07:38 -0000 From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346511 - head/sys/cam/scsi Message-ID: <201904220108.x3M18FgG009809@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Apr 22 01:08:14 2019 New Revision: 346511 URL: https://svnweb.freebsd.org/changeset/base/346511 Log: 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. MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.h head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Mon Apr 22 00:49:13 2019 (r346510) +++ head/sys/cam/scsi/scsi_all.h Mon Apr 22 01:08:14 2019 (r346511) @@ -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: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Mon Apr 22 00:49:13 2019 (r346510) +++ head/sys/cam/scsi/scsi_da.c Mon Apr 22 01:08:14 2019 (r346511) @@ -344,6 +344,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; @@ -2292,7 +2293,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), @@ -2303,6 +2304,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, @@ -4649,7 +4659,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")); @@ -4731,11 +4741,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; @@ -5983,9 +5999,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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904220108.x3M18FgG009809>