From owner-svn-src-head@freebsd.org Sat Nov 9 17:30:22 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24BB81AF531; Sat, 9 Nov 2019 17:30:22 +0000 (UTC) (envelope-from trasz@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 479PKp077Kz3yLY; Sat, 9 Nov 2019 17:30:22 +0000 (UTC) (envelope-from trasz@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 DB9CD1A0A8; Sat, 9 Nov 2019 17:30:21 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA9HULPO091889; Sat, 9 Nov 2019 17:30:21 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA9HUKGn091881; Sat, 9 Nov 2019 17:30:20 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201911091730.xA9HUKGn091881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 9 Nov 2019 17:30:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354571 - in head: sys/cam/ata sys/cam/mmc sys/cam/nvme sys/cam/scsi sys/geom usr.sbin/diskinfo X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: in head: sys/cam/ata sys/cam/mmc sys/cam/nvme sys/cam/scsi sys/geom usr.sbin/diskinfo X-SVN-Commit-Revision: 354571 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Nov 2019 17:30:22 -0000 Author: trasz Date: Sat Nov 9 17:30:19 2019 New Revision: 354571 URL: https://svnweb.freebsd.org/changeset/base/354571 Log: Add GEOM attribute to report physical device name, and report it via 'diskinfo -v'. This avoids the need to track it down via CAM, and should also work for disks that don't use CAM. And since it's inherited thru the GEOM hierarchy, in most cases one doesn't need to walk the GEOM graph either, eg you can use it on a partition instead of disk itself. Reviewed by: allanjude, imp Sponsored by: Klara Inc Differential Revision: https://reviews.freebsd.org/D22249 Modified: head/sys/cam/ata/ata_da.c head/sys/cam/mmc/mmc_da.c head/sys/cam/nvme/nvme_da.c head/sys/cam/scsi/scsi_cd.c head/sys/cam/scsi/scsi_da.c head/sys/geom/geom_disk.c head/sys/geom/geom_disk.h head/usr.sbin/diskinfo/diskinfo.c Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/cam/ata/ata_da.c Sat Nov 9 17:30:19 2019 (r354571) @@ -3420,6 +3420,8 @@ adasetgeom(struct ada_softc *softc, struct ccb_getdev softc->disk->d_fwheads = softc->params.heads; ata_disk_firmware_geom_adjust(softc->disk); softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate; + snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), + "%s%d", softc->cpi.dev_name, softc->cpi.unit_number); } static void Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/cam/mmc/mmc_da.c Sat Nov 9 17:30:19 2019 (r354571) @@ -1532,6 +1532,8 @@ sdda_add_part(struct cam_periph *periph, u_int type, c part->disk->d_hba_device = cpi.hba_device; part->disk->d_hba_subvendor = cpi.hba_subvendor; part->disk->d_hba_subdevice = cpi.hba_subdevice; + snprintf(part->disk->d_attachment, sizeof(part->disk->d_attachment), + "%s%d", cpi.dev_name, cpi.unit_number); part->disk->d_sectorsize = mmc_get_sector_size(periph); part->disk->d_mediasize = media_size; Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/cam/nvme/nvme_da.c Sat Nov 9 17:30:19 2019 (r354571) @@ -815,6 +815,8 @@ ndaregister(struct cam_periph *periph, void *arg) disk->d_hba_device = cpi.hba_device; disk->d_hba_subvendor = cpi.hba_subvendor; disk->d_hba_subdevice = cpi.hba_subdevice; + snprintf(disk->d_attachment, sizeof(disk->d_attachment), + "%s%d", cpi.dev_name, cpi.unit_number); disk->d_stripesize = disk->d_sectorsize; disk->d_stripeoffset = 0; disk->d_devstat = devstat_new_entry(periph->periph_name, Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/cam/scsi/scsi_cd.c Sat Nov 9 17:30:19 2019 (r354571) @@ -702,6 +702,8 @@ cdregister(struct cam_periph *periph, void *arg) softc->disk->d_hba_device = cpi.hba_device; softc->disk->d_hba_subvendor = cpi.hba_subvendor; softc->disk->d_hba_subdevice = cpi.hba_subdevice; + snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), + "%s%d", cpi.dev_name, cpi.unit_number); /* * Acquire a reference to the periph before we register with GEOM. Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/cam/scsi/scsi_da.c Sat Nov 9 17:30:19 2019 (r354571) @@ -2875,6 +2875,8 @@ daregister(struct cam_periph *periph, void *arg) softc->disk->d_hba_device = cpi.hba_device; softc->disk->d_hba_subvendor = cpi.hba_subvendor; softc->disk->d_hba_subdevice = cpi.hba_subdevice; + snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), + "%s%d", cpi.dev_name, cpi.unit_number); /* * Acquire a reference to the periph before we register with GEOM. Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/geom/geom_disk.c Sat Nov 9 17:30:19 2019 (r354571) @@ -528,7 +528,10 @@ g_disk_start(struct bio *bp) else if (g_handleattr_uint16_t(bp, "GEOM::rotation_rate", dp->d_rotation_rate)) break; - else + else if (g_handleattr_str(bp, "GEOM::attachment", + dp->d_attachment)) + break; + else error = ENOIOCTL; break; case BIO_FLUSH: Modified: head/sys/geom/geom_disk.h ============================================================================== --- head/sys/geom/geom_disk.h Sat Nov 9 17:08:27 2019 (r354570) +++ head/sys/geom/geom_disk.h Sat Nov 9 17:30:19 2019 (r354571) @@ -118,6 +118,7 @@ struct disk { uint16_t d_hba_subvendor; uint16_t d_hba_subdevice; uint16_t d_rotation_rate; + char d_attachment[DISK_IDENT_SIZE]; /* Fields private to the driver */ void *d_drv1; Modified: head/usr.sbin/diskinfo/diskinfo.c ============================================================================== --- head/usr.sbin/diskinfo/diskinfo.c Sat Nov 9 17:08:27 2019 (r354570) +++ head/usr.sbin/diskinfo/diskinfo.c Sat Nov 9 17:30:19 2019 (r354571) @@ -251,6 +251,10 @@ main(int argc, char **argv) printf("\t%-12s\t# Disk descr.\n", arg.value.str); if (ioctl(fd, DIOCGIDENT, ident) == 0) printf("\t%-12s\t# Disk ident.\n", ident); + strlcpy(arg.name, "GEOM::attachment", sizeof(arg.name)); + arg.len = sizeof(arg.value.str); + if (ioctl(fd, DIOCGATTR, &arg) == 0) + printf("\t%-12s\t# Attachment\n", arg.value.str); if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) printf("\t%-12s\t# Physical path\n", physpath); printf("\t%-12s\t# TRIM/UNMAP support\n",