From owner-svn-src-projects@freebsd.org Sat Jul 27 02:23:09 2019 Return-Path: Delivered-To: svn-src-projects@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 72036AEB14 for ; Sat, 27 Jul 2019 02:23:09 +0000 (UTC) (envelope-from rmacklem@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 5E22E8CDD7; Sat, 27 Jul 2019 02:23:09 +0000 (UTC) (envelope-from rmacklem@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 372CF207D2; Sat, 27 Jul 2019 02:23:09 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6R2N99n037717; Sat, 27 Jul 2019 02:23:09 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6R2N58c037697; Sat, 27 Jul 2019 02:23:05 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201907270223.x6R2N58c037697@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 27 Jul 2019 02:23:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r350368 - in projects/nfsv42/sys: amd64/amd64 arm64/arm64 cam/ata cam/ctl cam/scsi dev/nvme dev/virtio/mmio dev/virtio/pci i386/i386 net riscv/riscv sys ufs/ufs X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/nfsv42/sys: amd64/amd64 arm64/arm64 cam/ata cam/ctl cam/scsi dev/nvme dev/virtio/mmio dev/virtio/pci i386/i386 net riscv/riscv sys ufs/ufs X-SVN-Commit-Revision: 350368 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5E22E8CDD7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.942,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2019 02:23:09 -0000 Author: rmacklem Date: Sat Jul 27 02:23:05 2019 New Revision: 350368 URL: https://svnweb.freebsd.org/changeset/base/350368 Log: Merge in an up to date kernel from head. Modified: projects/nfsv42/sys/amd64/amd64/pmap.c projects/nfsv42/sys/arm64/arm64/pmap.c projects/nfsv42/sys/cam/ata/ata_all.c projects/nfsv42/sys/cam/ctl/ctl.c projects/nfsv42/sys/cam/ctl/ctl.h projects/nfsv42/sys/cam/ctl/ctl_private.h projects/nfsv42/sys/cam/scsi/scsi_all.c projects/nfsv42/sys/cam/scsi/scsi_all.h projects/nfsv42/sys/dev/nvme/nvme_ctrlr.c projects/nfsv42/sys/dev/virtio/mmio/virtio_mmio.c projects/nfsv42/sys/dev/virtio/pci/virtio_pci.c projects/nfsv42/sys/i386/i386/pmap.c projects/nfsv42/sys/net/if_tap.h projects/nfsv42/sys/net/if_tun.h projects/nfsv42/sys/net/if_tuntap.c projects/nfsv42/sys/riscv/riscv/pmap.c projects/nfsv42/sys/sys/ata.h projects/nfsv42/sys/ufs/ufs/ufs_vnops.c Directory Properties: projects/nfsv42/sys/ (props changed) Modified: projects/nfsv42/sys/amd64/amd64/pmap.c ============================================================================== --- projects/nfsv42/sys/amd64/amd64/pmap.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/amd64/amd64/pmap.c Sat Jul 27 02:23:05 2019 (r350368) @@ -7574,7 +7574,7 @@ pmap_clear_modify(vm_page_t m) pmap_t pmap; pv_entry_t next_pv, pv; pd_entry_t oldpde, *pde; - pt_entry_t oldpte, *pte, PG_M, PG_RW, PG_V; + pt_entry_t *pte, PG_M, PG_RW; struct rwlock *lock; vm_offset_t va; int md_gen, pvh_gen; @@ -7610,33 +7610,23 @@ restart: } } PG_M = pmap_modified_bit(pmap); - PG_V = pmap_valid_bit(pmap); PG_RW = pmap_rw_bit(pmap); va = pv->pv_va; pde = pmap_pde(pmap, va); oldpde = *pde; - if ((oldpde & PG_RW) != 0) { - if (pmap_demote_pde_locked(pmap, pde, va, &lock)) { - if ((oldpde & PG_W) == 0) { - /* - * Write protect the mapping to a - * single page so that a subsequent - * write access may repromote. - */ - va += VM_PAGE_TO_PHYS(m) - (oldpde & - PG_PS_FRAME); - pte = pmap_pde_to_pte(pde, va); - oldpte = *pte; - if ((oldpte & PG_V) != 0) { - while (!atomic_cmpset_long(pte, - oldpte, - oldpte & ~(PG_M | PG_RW))) - oldpte = *pte; - vm_page_dirty(m); - pmap_invalidate_page(pmap, va); - } - } - } + /* If oldpde has PG_RW set, then it also has PG_M set. */ + if ((oldpde & PG_RW) != 0 && + pmap_demote_pde_locked(pmap, pde, va, &lock) && + (oldpde & PG_W) == 0) { + /* + * Write protect the mapping to a single page so that + * a subsequent write access may repromote. + */ + va += VM_PAGE_TO_PHYS(m) - (oldpde & PG_PS_FRAME); + pte = pmap_pde_to_pte(pde, va); + atomic_clear_long(pte, PG_M | PG_RW); + vm_page_dirty(m); + pmap_invalidate_page(pmap, va); } PMAP_UNLOCK(pmap); } Modified: projects/nfsv42/sys/arm64/arm64/pmap.c ============================================================================== --- projects/nfsv42/sys/arm64/arm64/pmap.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/arm64/arm64/pmap.c Sat Jul 27 02:23:05 2019 (r350368) @@ -2499,7 +2499,7 @@ pmap_remove_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_ /* * pmap_remove_l3: do the things to unmap a page in a process */ -static int __unused +static int pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va, pd_entry_t l2e, struct spglist *free, struct rwlock **lockp) { @@ -4839,6 +4839,110 @@ out: void pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int advice) { + struct rwlock *lock; + vm_offset_t va, va_next; + vm_page_t m; + pd_entry_t *l0, *l1, *l2, oldl2; + pt_entry_t *l3, oldl3; + + if (advice != MADV_DONTNEED && advice != MADV_FREE) + return; + + PMAP_LOCK(pmap); + for (; sva < eva; sva = va_next) { + l0 = pmap_l0(pmap, sva); + if (pmap_load(l0) == 0) { + va_next = (sva + L0_SIZE) & ~L0_OFFSET; + if (va_next < sva) + va_next = eva; + continue; + } + l1 = pmap_l0_to_l1(l0, sva); + if (pmap_load(l1) == 0) { + va_next = (sva + L1_SIZE) & ~L1_OFFSET; + if (va_next < sva) + va_next = eva; + continue; + } + va_next = (sva + L2_SIZE) & ~L2_OFFSET; + if (va_next < sva) + va_next = eva; + l2 = pmap_l1_to_l2(l1, sva); + oldl2 = pmap_load(l2); + if (oldl2 == 0) + continue; + if ((oldl2 & ATTR_DESCR_MASK) == L2_BLOCK) { + if ((oldl2 & ATTR_SW_MANAGED) == 0) + continue; + lock = NULL; + if (!pmap_demote_l2_locked(pmap, l2, sva, &lock)) { + if (lock != NULL) + rw_wunlock(lock); + + /* + * The 2MB page mapping was destroyed. + */ + continue; + } + + /* + * Unless the page mappings are wired, remove the + * mapping to a single page so that a subsequent + * access may repromote. Since the underlying page + * table page is fully populated, this removal never + * frees a page table page. + */ + if ((oldl2 & ATTR_SW_WIRED) == 0) { + l3 = pmap_l2_to_l3(l2, sva); + KASSERT(pmap_load(l3) != 0, + ("pmap_advise: invalid PTE")); + pmap_remove_l3(pmap, l3, sva, pmap_load(l2), + NULL, &lock); + } + if (lock != NULL) + rw_wunlock(lock); + } + KASSERT((pmap_load(l2) & ATTR_DESCR_MASK) == L2_TABLE, + ("pmap_advise: invalid L2 entry after demotion")); + if (va_next > eva) + va_next = eva; + va = va_next; + for (l3 = pmap_l2_to_l3(l2, sva); sva != va_next; l3++, + sva += L3_SIZE) { + oldl3 = pmap_load(l3); + if ((oldl3 & (ATTR_SW_MANAGED | ATTR_DESCR_MASK)) != + (ATTR_SW_MANAGED | L3_PAGE)) + goto maybe_invlrng; + else if (pmap_pte_dirty(oldl3)) { + if (advice == MADV_DONTNEED) { + /* + * Future calls to pmap_is_modified() + * can be avoided by making the page + * dirty now. + */ + m = PHYS_TO_VM_PAGE(oldl3 & ~ATTR_MASK); + vm_page_dirty(m); + } + while (!atomic_fcmpset_long(l3, &oldl3, + (oldl3 & ~ATTR_AF) | ATTR_AP(ATTR_AP_RO))) + cpu_spinwait(); + } else if ((oldl3 & ATTR_AF) != 0) + pmap_clear_bits(l3, ATTR_AF); + else + goto maybe_invlrng; + if (va == va_next) + va = sva; + continue; +maybe_invlrng: + if (va != va_next) { + pmap_invalidate_range(pmap, va, sva); + va = va_next; + } + } + if (va != va_next) + pmap_invalidate_range(pmap, va, sva); + } + PMAP_UNLOCK(pmap); } /* @@ -4889,28 +4993,22 @@ restart: va = pv->pv_va; l2 = pmap_l2(pmap, va); oldl2 = pmap_load(l2); - if ((oldl2 & ATTR_SW_DBM) != 0) { - if (pmap_demote_l2_locked(pmap, l2, va, &lock)) { - if ((oldl2 & ATTR_SW_WIRED) == 0) { - /* - * Write protect the mapping to a - * single page so that a subsequent - * write access may repromote. - */ - va += VM_PAGE_TO_PHYS(m) - - (oldl2 & ~ATTR_MASK); - l3 = pmap_l2_to_l3(l2, va); - oldl3 = pmap_load(l3); - if (pmap_l3_valid(oldl3)) { - while (!atomic_fcmpset_long(l3, - &oldl3, (oldl3 & ~ATTR_SW_DBM) | - ATTR_AP(ATTR_AP_RO))) - cpu_spinwait(); - vm_page_dirty(m); - pmap_invalidate_page(pmap, va); - } - } - } + /* If oldl2 has ATTR_SW_DBM set, then it is also dirty. */ + if ((oldl2 & ATTR_SW_DBM) != 0 && + pmap_demote_l2_locked(pmap, l2, va, &lock) && + (oldl2 & ATTR_SW_WIRED) == 0) { + /* + * Write protect the mapping to a single page so that + * a subsequent write access may repromote. + */ + va += VM_PAGE_TO_PHYS(m) - (oldl2 & ~ATTR_MASK); + l3 = pmap_l2_to_l3(l2, va); + oldl3 = pmap_load(l3); + while (!atomic_fcmpset_long(l3, &oldl3, + (oldl3 & ~ATTR_SW_DBM) | ATTR_AP(ATTR_AP_RO))) + cpu_spinwait(); + vm_page_dirty(m); + pmap_invalidate_page(pmap, va); } PMAP_UNLOCK(pmap); } Modified: projects/nfsv42/sys/cam/ata/ata_all.c ============================================================================== --- projects/nfsv42/sys/cam/ata/ata_all.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/ata/ata_all.c Sat Jul 27 02:23:05 2019 (r350368) @@ -215,7 +215,16 @@ ata_op_string(struct ata_cmd *cmd) return ("SMART"); case 0xb1: return ("DEVICE CONFIGURATION"); case 0xb2: return ("SET_SECTOR_CONFIGURATION_EXT"); - case 0xb4: return ("SANITIZE_DEVICE"); + case 0xb4: + switch(cmd->features) { + case 0x00: return ("SANITIZE_STATUS_EXT"); + case 0x11: return ("CRYPTO_SCRAMBLE_EXT"); + case 0x12: return ("BLOCK_ERASE_EXT"); + case 0x14: return ("OVERWRITE_EXT"); + case 0x20: return ("SANITIZE_FREEZE_LOCK_EXT"); + case 0x40: return ("SANITIZE_ANTIFREEZE_LOCK_EXT"); + } + return ("SANITIZE_DEVICE"); case 0xc0: return ("CFA_ERASE"); case 0xc4: return ("READ_MUL"); case 0xc5: return ("WRITE_MUL"); Modified: projects/nfsv42/sys/cam/ctl/ctl.c ============================================================================== --- projects/nfsv42/sys/cam/ctl/ctl.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/ctl/ctl.c Sat Jul 27 02:23:05 2019 (r350368) @@ -448,10 +448,11 @@ SYSCTL_INT(_kern_cam_ctl, OID_AUTO, max_ports, CTLFLAG /* * Supported pages (0x00), Serial number (0x80), Device ID (0x83), * Extended INQUIRY Data (0x86), Mode Page Policy (0x87), - * SCSI Ports (0x88), Third-party Copy (0x8F), Block limits (0xB0), - * Block Device Characteristics (0xB1) and Logical Block Provisioning (0xB2) + * SCSI Ports (0x88), Third-party Copy (0x8F), SCSI Feature Sets (0x92), + * Block limits (0xB0), Block Device Characteristics (0xB1) and + * Logical Block Provisioning (0xB2) */ -#define SCSI_EVPD_NUM_SUPPORTED_PAGES 10 +#define SCSI_EVPD_NUM_SUPPORTED_PAGES 11 static void ctl_isc_event_handler(ctl_ha_channel chanel, ctl_ha_event event, int param); @@ -489,6 +490,7 @@ static int ctl_inquiry_evpd_eid(struct ctl_scsiio *cts static int ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len); +static int ctl_inquiry_evpd_sfs(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len); @@ -4448,12 +4450,14 @@ ctl_init_log_page_index(struct ctl_lun *lun) lun->log_pages.index[0].page_len = j; lun->log_pages.index[1].page_data = &lun->log_pages.subpages_page[0]; lun->log_pages.index[1].page_len = k * 2; - lun->log_pages.index[2].page_data = &lun->log_pages.lbp_page[0]; - lun->log_pages.index[2].page_len = 12*CTL_NUM_LBP_PARAMS; - lun->log_pages.index[3].page_data = (uint8_t *)&lun->log_pages.stat_page; - lun->log_pages.index[3].page_len = sizeof(lun->log_pages.stat_page); - lun->log_pages.index[4].page_data = (uint8_t *)&lun->log_pages.ie_page; - lun->log_pages.index[4].page_len = sizeof(lun->log_pages.ie_page); + lun->log_pages.index[2].page_data = (uint8_t *)&lun->log_pages.temp_page; + lun->log_pages.index[2].page_len = sizeof(lun->log_pages.temp_page); + lun->log_pages.index[3].page_data = &lun->log_pages.lbp_page[0]; + lun->log_pages.index[3].page_len = 12*CTL_NUM_LBP_PARAMS; + lun->log_pages.index[4].page_data = (uint8_t *)&lun->log_pages.stat_page; + lun->log_pages.index[4].page_len = sizeof(lun->log_pages.stat_page); + lun->log_pages.index[5].page_data = (uint8_t *)&lun->log_pages.ie_page; + lun->log_pages.index[5].page_len = sizeof(lun->log_pages.ie_page); return (CTL_RETVAL_COMPLETE); } @@ -6361,13 +6365,12 @@ int ctl_mode_sense(struct ctl_scsiio *ctsio) { struct ctl_lun *lun = CTL_LUN(ctsio); - int pc, page_code, dbd, subpage; - int alloc_len, page_len, header_len, total_len; - struct scsi_mode_block_descr *block_desc; + int pc, page_code, llba, subpage; + int alloc_len, page_len, header_len, bd_len, total_len; + void *block_desc; struct ctl_page_index *page_index; - dbd = 0; - block_desc = NULL; + llba = 0; CTL_DEBUG_PRINT(("ctl_mode_sense\n")); @@ -6379,9 +6382,10 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) header_len = sizeof(struct scsi_mode_hdr_6); if (cdb->byte2 & SMS_DBD) - dbd = 1; + bd_len = 0; else - header_len += sizeof(struct scsi_mode_block_descr); + bd_len = sizeof(struct scsi_mode_block_descr); + header_len += bd_len; pc = (cdb->page & SMS_PAGE_CTRL_MASK) >> 6; page_code = cdb->page & SMS_PAGE_CODE; @@ -6395,11 +6399,18 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) cdb = (struct scsi_mode_sense_10 *)ctsio->cdb; header_len = sizeof(struct scsi_mode_hdr_10); + if (cdb->byte2 & SMS_DBD) { + bd_len = 0; + } else if (lun->be_lun->lun_type == T_DIRECT) { + if (cdb->byte2 & SMS10_LLBAA) { + llba = 1; + bd_len = sizeof(struct scsi_mode_block_descr_dlong); + } else + bd_len = sizeof(struct scsi_mode_block_descr_dshort); + } else + bd_len = sizeof(struct scsi_mode_block_descr); + header_len += bd_len; - if (cdb->byte2 & SMS_DBD) - dbd = 1; - else - header_len += sizeof(struct scsi_mode_block_descr); pc = (cdb->page & SMS_PAGE_CTRL_MASK) >> 6; page_code = cdb->page & SMS_PAGE_CODE; subpage = cdb->subpage; @@ -6532,12 +6543,8 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) (lun->MODE_CTRL.eca_and_aen & SCP_SWP) != 0) header->dev_specific |= 0x80; /* WP */ } - if (dbd) - header->block_descr_len = 0; - else - header->block_descr_len = - sizeof(struct scsi_mode_block_descr); - block_desc = (struct scsi_mode_block_descr *)&header[1]; + header->block_descr_len = bd_len; + block_desc = &header[1]; break; } case MODE_SENSE_10: { @@ -6554,12 +6561,10 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) (lun->MODE_CTRL.eca_and_aen & SCP_SWP) != 0) header->dev_specific |= 0x80; /* WP */ } - if (dbd) - scsi_ulto2b(0, header->block_descr_len); - else - scsi_ulto2b(sizeof(struct scsi_mode_block_descr), - header->block_descr_len); - block_desc = (struct scsi_mode_block_descr *)&header[1]; + if (llba) + header->flags |= SMH_LONGLBA; + scsi_ulto2b(bd_len, header->block_descr_len); + block_desc = &header[1]; break; } default: @@ -6570,12 +6575,27 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) * If we've got a disk, use its blocksize in the block * descriptor. Otherwise, just set it to 0. */ - if (dbd == 0) { - if (lun->be_lun->lun_type == T_DIRECT) - scsi_ulto3b(lun->be_lun->blocksize, - block_desc->block_len); - else - scsi_ulto3b(0, block_desc->block_len); + if (bd_len > 0) { + if (lun->be_lun->lun_type == T_DIRECT) { + if (llba) { + struct scsi_mode_block_descr_dlong *bd = block_desc; + if (lun->be_lun->maxlba != 0) + scsi_u64to8b(lun->be_lun->maxlba + 1, + bd->num_blocks); + scsi_ulto4b(lun->be_lun->blocksize, + bd->block_len); + } else { + struct scsi_mode_block_descr_dshort *bd = block_desc; + if (lun->be_lun->maxlba != 0) + scsi_ulto4b(MIN(lun->be_lun->maxlba+1, + UINT32_MAX), bd->num_blocks); + scsi_ulto3b(lun->be_lun->blocksize, + bd->block_len); + } + } else { + struct scsi_mode_block_descr *bd = block_desc; + scsi_ulto3b(0, bd->block_len); + } } switch (page_code) { @@ -6677,6 +6697,40 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) } int +ctl_temp_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc) +{ + struct ctl_lun *lun = CTL_LUN(ctsio); + struct scsi_log_temperature *data; + const char *value; + + data = (struct scsi_log_temperature *)page_index->page_data; + + scsi_ulto2b(SLP_TEMPERATURE, data->hdr.param_code); + data->hdr.param_control = SLP_LBIN; + data->hdr.param_len = sizeof(struct scsi_log_temperature) - + sizeof(struct scsi_log_param_header); + if ((value = dnvlist_get_string(lun->be_lun->options, "temperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; + data++; + + scsi_ulto2b(SLP_REFTEMPERATURE, data->hdr.param_code); + data->hdr.param_control = SLP_LBIN; + data->hdr.param_len = sizeof(struct scsi_log_temperature) - + sizeof(struct scsi_log_param_header); + if ((value = dnvlist_get_string(lun->be_lun->options, "reftemperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; + return (0); +} + +int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc) @@ -6800,6 +6854,7 @@ ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, { struct ctl_lun *lun = CTL_LUN(ctsio); struct scsi_log_informational_exceptions *data; + const char *value; data = (struct scsi_log_informational_exceptions *)page_index->page_data; @@ -6809,7 +6864,11 @@ ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, sizeof(struct scsi_log_param_header); data->ie_asc = lun->ie_asc; data->ie_ascq = lun->ie_ascq; - data->temperature = 0xff; + if ((value = dnvlist_get_string(lun->be_lun->options, "temperature", + NULL)) != NULL) + data->temperature = strtol(value, NULL, 0); + else + data->temperature = 0xff; return (0); } @@ -9318,6 +9377,8 @@ ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, i pages->page_list[p++] = SVPD_SCSI_PORTS; /* Third-party Copy */ pages->page_list[p++] = SVPD_SCSI_TPC; + /* SCSI Feature Sets */ + pages->page_list[p++] = SVPD_SCSI_SFS; if (lun != NULL && lun->be_lun->lun_type == T_DIRECT) { /* Block limits */ pages->page_list[p++] = SVPD_BLOCK_LIMITS; @@ -9699,6 +9760,58 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, } static int +ctl_inquiry_evpd_sfs(struct ctl_scsiio *ctsio, int alloc_len) +{ + struct ctl_lun *lun = CTL_LUN(ctsio); + struct scsi_vpd_sfs *sfs_ptr; + int sfs_page_size, n; + + sfs_page_size = sizeof(*sfs_ptr) + 5 * 2; + ctsio->kern_data_ptr = malloc(sfs_page_size, M_CTL, M_WAITOK | M_ZERO); + sfs_ptr = (struct scsi_vpd_sfs *)ctsio->kern_data_ptr; + ctsio->kern_sg_entries = 0; + ctsio->kern_rel_offset = 0; + ctsio->kern_sg_entries = 0; + ctsio->kern_data_len = min(sfs_page_size, alloc_len); + ctsio->kern_total_len = ctsio->kern_data_len; + + /* + * The control device is always connected. The disk device, on the + * other hand, may not be online all the time. Need to change this + * to figure out whether the disk device is actually online or not. + */ + if (lun != NULL) + sfs_ptr->device = (SID_QUAL_LU_CONNECTED << 5) | + lun->be_lun->lun_type; + else + sfs_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; + + sfs_ptr->page_code = SVPD_SCSI_SFS; + n = 0; + /* Discovery 2016 */ + scsi_ulto2b(0x0001, &sfs_ptr->codes[2 * n++]); + if (lun != NULL && lun->be_lun->lun_type == T_DIRECT) { + /* SBC Base 2016 */ + scsi_ulto2b(0x0101, &sfs_ptr->codes[2 * n++]); + /* SBC Base 2010 */ + scsi_ulto2b(0x0102, &sfs_ptr->codes[2 * n++]); + if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { + /* Basic Provisioning 2016 */ + scsi_ulto2b(0x0103, &sfs_ptr->codes[2 * n++]); + } + /* Drive Maintenance 2016 */ + //scsi_ulto2b(0x0104, &sfs_ptr->codes[2 * n++]); + } + scsi_ulto2b(4 + 2 * n, sfs_ptr->page_length); + + ctl_set_success(ctsio); + ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; + ctsio->be_move_done = ctl_config_move_done; + ctl_datamove((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); +} + +static int ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) { struct ctl_lun *lun = CTL_LUN(ctsio); @@ -9811,7 +9924,7 @@ ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int all else i = 0; bdc_ptr->wab_wac_ff = (i & 0x0f); - bdc_ptr->flags = SVPD_FUAB | SVPD_VBULS; + bdc_ptr->flags = SVPD_RBWZ | SVPD_FUAB | SVPD_VBULS; ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; @@ -9903,6 +10016,9 @@ ctl_inquiry_evpd(struct ctl_scsiio *ctsio) break; case SVPD_SCSI_TPC: retval = ctl_inquiry_evpd_tpc(ctsio, alloc_len); + break; + case SVPD_SCSI_SFS: + retval = ctl_inquiry_evpd_sfs(ctsio, alloc_len); break; case SVPD_BLOCK_LIMITS: if (lun == NULL || lun->be_lun->lun_type != T_DIRECT) Modified: projects/nfsv42/sys/cam/ctl/ctl.h ============================================================================== --- projects/nfsv42/sys/cam/ctl/ctl.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/ctl/ctl.h Sat Jul 27 02:23:05 2019 (r350368) @@ -158,6 +158,9 @@ int ctl_default_page_handler(struct ctl_scsiio *ctsio, int ctl_ie_page_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, uint8_t *page_ptr); +int ctl_temp_log_sense_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, + int pc); int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, int pc); Modified: projects/nfsv42/sys/cam/ctl/ctl_private.h ============================================================================== --- projects/nfsv42/sys/cam/ctl/ctl_private.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/ctl/ctl_private.h Sat Jul 27 02:23:05 2019 (r350368) @@ -331,6 +331,8 @@ static const struct ctl_page_index log_page_index_temp CTL_PAGE_FLAG_ALL, NULL, NULL}, {SLS_SUPPORTED_PAGES_PAGE, SLS_SUPPORTED_SUBPAGES_SUBPAGE, 0, NULL, CTL_PAGE_FLAG_ALL, NULL, NULL}, + {SLS_TEMPERATURE, 0, 0, NULL, + CTL_PAGE_FLAG_DIRECT, ctl_temp_log_sense_handler, NULL}, {SLS_LOGICAL_BLOCK_PROVISIONING, 0, 0, NULL, CTL_PAGE_FLAG_DIRECT, ctl_lbp_log_sense_handler, NULL}, {SLS_STAT_AND_PERF, 0, 0, NULL, @@ -351,6 +353,7 @@ struct ctl_log_pages { struct scsi_log_idle_time it; struct scsi_log_time_interval ti; } stat_page; + struct scsi_log_temperature temp_page[2]; struct scsi_log_informational_exceptions ie_page; struct ctl_page_index index[CTL_NUM_LOG_PAGES]; }; Modified: projects/nfsv42/sys/cam/scsi/scsi_all.c ============================================================================== --- projects/nfsv42/sys/cam/scsi/scsi_all.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/scsi/scsi_all.c Sat Jul 27 02:23:05 2019 (r350368) @@ -379,7 +379,7 @@ static struct op_table_entry scsi_op_codes[] = { { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" }, /* 41 O WRITE SAME(10) */ { 0x41, D, "WRITE SAME(10)" }, - /* 42 O UNMAP */ + /* 42 O UNMAP */ { 0x42, D, "UNMAP" }, /* 42 O READ SUB-CHANNEL */ { 0x42, R, "READ SUB-CHANNEL" }, @@ -394,7 +394,8 @@ static struct op_table_entry scsi_op_codes[] = { { 0x46, R, "GET CONFIGURATION" }, /* 47 O PLAY AUDIO MSF */ { 0x47, R, "PLAY AUDIO MSF" }, - /* 48 */ + /* 48 O SANITIZE */ + { 0x48, D, "SANITIZE" }, /* 49 */ /* 4A M GET EVENT STATUS NOTIFICATION */ { 0x4A, R, "GET EVENT STATUS NOTIFICATION" }, @@ -1162,7 +1163,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x04, 0x1A, SS_RDEF, /* XXX TBD */ "Logical unit not ready, START/STOP UNIT command in progress") }, /* D B */ - { SST(0x04, 0x1B, SS_RDEF, /* XXX TBD */ + { SST(0x04, 0x1B, SS_WAIT | EBUSY, "Logical unit not ready, sanitize in progress") }, /* DT MAEB */ { SST(0x04, 0x1C, SS_START | SSQ_DECREMENT_COUNT | ENXIO, @@ -1453,7 +1454,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x11, 0x14, SS_RDEF, /* XXX TBD */ "Read error - LBA marked bad by application client") }, /* D */ - { SST(0x11, 0x15, SS_RDEF, /* XXX TBD */ + { SST(0x11, 0x15, SS_FATAL | EIO, "Write after sanitize required") }, /* D W O BK */ { SST(0x12, 0x00, SS_RDEF, @@ -2064,7 +2065,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x31, 0x02, SS_RDEF, /* XXX TBD */ "Zoned formatting failed due to spare linking") }, /* D B */ - { SST(0x31, 0x03, SS_RDEF, /* XXX TBD */ + { SST(0x31, 0x03, SS_FATAL | EIO, "SANITIZE command failed") }, /* D W O BK */ { SST(0x32, 0x00, SS_RDEF, Modified: projects/nfsv42/sys/cam/scsi/scsi_all.h ============================================================================== --- projects/nfsv42/sys/cam/scsi/scsi_all.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/cam/scsi/scsi_all.h Sat Jul 27 02:23:05 2019 (r350368) @@ -264,7 +264,9 @@ struct scsi_mode_hdr_10 u_int8_t datalen[2]; u_int8_t medium_type; u_int8_t dev_specific; - u_int8_t reserved[2]; + u_int8_t flags; +#define SMH_LONGLBA 0x01 + u_int8_t reserved; u_int8_t block_descr_len[2]; }; @@ -276,6 +278,20 @@ struct scsi_mode_block_descr u_int8_t block_len[3]; }; +struct scsi_mode_block_descr_dshort +{ + u_int8_t num_blocks[4]; + u_int8_t reserved; + u_int8_t block_len[3]; +}; + +struct scsi_mode_block_descr_dlong +{ + u_int8_t num_blocks[8]; + u_int8_t reserved[4]; + u_int8_t block_len[4]; +}; + struct scsi_per_res_in { u_int8_t opcode; @@ -568,6 +584,7 @@ struct scsi_log_sense #define SLS_ERROR_NONMEDIUM_PAGE 0x06 #define SLS_ERROR_LASTN_PAGE 0x07 #define SLS_LOGICAL_BLOCK_PROVISIONING 0x0c +#define SLS_TEMPERATURE 0x0d #define SLS_SELF_TEST_PAGE 0x10 #define SLS_SOLID_STATE_MEDIA 0x11 #define SLS_STAT_AND_PERF 0x19 @@ -683,6 +700,14 @@ struct scsi_log_informational_exceptions { uint8_t temperature; }; +struct scsi_log_temperature { + struct scsi_log_param_header hdr; +#define SLP_TEMPERATURE 0x0000 +#define SLP_REFTEMPERATURE 0x0001 + uint8_t reserved; + uint8_t temperature; +}; + struct scsi_control_page { u_int8_t page_code; u_int8_t page_length; @@ -2763,6 +2788,19 @@ struct scsi_vpd_tpc }; /* + * SCSI Feature Sets VPD Page + */ +struct scsi_vpd_sfs +{ + uint8_t device; + uint8_t page_code; +#define SVPD_SCSI_SFS 0x92 + uint8_t page_length[2]; + uint8_t reserved[4]; + uint8_t codes[]; +}; + +/* * Block Device Characteristics VPD Page based on * T10/1799-D Revision 31 */ @@ -2803,11 +2841,15 @@ struct scsi_vpd_block_device_characteristics uint8_t flags; #define SVPD_VBULS 0x01 #define SVPD_FUAB 0x02 +#define SVPD_BOCS 0x04 +#define SVPD_RBWZ 0x08 #define SVPD_ZBC_NR 0x00 /* Not Reported */ #define SVPD_HAW_ZBC 0x10 /* Host Aware */ #define SVPD_DM_ZBC 0x20 /* Drive Managed */ #define SVPD_ZBC_MASK 0x30 /* Zoned mask */ - uint8_t reserved[55]; + uint8_t reserved[3]; + uint8_t depopulation_time[4]; + uint8_t reserved2[48]; }; #define SBDC_IS_PRESENT(bdc, length, field) \ Modified: projects/nfsv42/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- projects/nfsv42/sys/dev/nvme/nvme_ctrlr.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/dev/nvme/nvme_ctrlr.c Sat Jul 27 02:23:05 2019 (r350368) @@ -1227,7 +1227,7 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de struct make_dev_args md_args; uint32_t cap_lo; uint32_t cap_hi; - uint8_t to; + uint32_t to; uint8_t dstrd; uint8_t mpsmin; int status, timeout_period; Modified: projects/nfsv42/sys/dev/virtio/mmio/virtio_mmio.c ============================================================================== --- projects/nfsv42/sys/dev/virtio/mmio/virtio_mmio.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/dev/virtio/mmio/virtio_mmio.c Sat Jul 27 02:23:05 2019 (r350368) @@ -440,7 +440,7 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int n size = vtmmio_read_config_4(sc, VIRTIO_MMIO_QUEUE_NUM_MAX); error = virtqueue_alloc(dev, idx, size, - VIRTIO_MMIO_VRING_ALIGN, 0xFFFFFFFFUL, info, &vq); + VIRTIO_MMIO_VRING_ALIGN, ~(vm_paddr_t)0, info, &vq); if (error) { device_printf(dev, "cannot allocate virtqueue %d: %d\n", Modified: projects/nfsv42/sys/dev/virtio/pci/virtio_pci.c ============================================================================== --- projects/nfsv42/sys/dev/virtio/pci/virtio_pci.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/dev/virtio/pci/virtio_pci.c Sat Jul 27 02:23:05 2019 (r350368) @@ -505,7 +505,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nv size = vtpci_read_config_2(sc, VIRTIO_PCI_QUEUE_NUM); error = virtqueue_alloc(dev, idx, size, VIRTIO_PCI_VRING_ALIGN, - 0xFFFFFFFFUL, info, &vq); + ~(vm_paddr_t)0, info, &vq); if (error) { device_printf(dev, "cannot allocate virtqueue %d: %d\n", idx, error); Modified: projects/nfsv42/sys/i386/i386/pmap.c ============================================================================== --- projects/nfsv42/sys/i386/i386/pmap.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/i386/i386/pmap.c Sat Jul 27 02:23:05 2019 (r350368) @@ -5280,7 +5280,7 @@ __CONCAT(PMTYPE, clear_modify)(vm_page_t m) pv_entry_t next_pv, pv; pmap_t pmap; pd_entry_t oldpde, *pde; - pt_entry_t oldpte, *pte; + pt_entry_t *pte; vm_offset_t va; KASSERT((m->oflags & VPO_UNMANAGED) == 0, @@ -5307,34 +5307,24 @@ __CONCAT(PMTYPE, clear_modify)(vm_page_t m) PMAP_LOCK(pmap); pde = pmap_pde(pmap, va); oldpde = *pde; - if ((oldpde & PG_RW) != 0) { - if (pmap_demote_pde(pmap, pde, va)) { - if ((oldpde & PG_W) == 0) { - /* - * Write protect the mapping to a - * single page so that a subsequent - * write access may repromote. - */ - va += VM_PAGE_TO_PHYS(m) - (oldpde & - PG_PS_FRAME); - pte = pmap_pte_quick(pmap, va); - oldpte = *pte; - if ((oldpte & PG_V) != 0) { - /* - * Regardless of whether a pte is 32 or 64 bits - * in size, PG_RW and PG_M are among the least - * significant 32 bits. - */ - while (!atomic_cmpset_int((u_int *)pte, - oldpte, - oldpte & ~(PG_M | PG_RW))) - oldpte = *pte; - vm_page_dirty(m); - pmap_invalidate_page_int(pmap, - va); - } - } - } + /* If oldpde has PG_RW set, then it also has PG_M set. */ + if ((oldpde & PG_RW) != 0 && + pmap_demote_pde(pmap, pde, va) && + (oldpde & PG_W) == 0) { + /* + * Write protect the mapping to a single page so that + * a subsequent write access may repromote. + */ + va += VM_PAGE_TO_PHYS(m) - (oldpde & PG_PS_FRAME); + pte = pmap_pte_quick(pmap, va); + /* + * Regardless of whether a pte is 32 or 64 bits + * in size, PG_RW and PG_M are among the least + * significant 32 bits. + */ + atomic_clear_int((u_int *)pte, PG_M | PG_RW); + vm_page_dirty(m); + pmap_invalidate_page_int(pmap, va); } PMAP_UNLOCK(pmap); } Modified: projects/nfsv42/sys/net/if_tap.h ============================================================================== --- projects/nfsv42/sys/net/if_tap.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/net/if_tap.h Sat Jul 27 02:23:05 2019 (r350368) @@ -55,7 +55,7 @@ #define TAPGDEBUG TUNGDEBUG #define TAPSIFINFO TUNSIFINFO #define TAPGIFINFO TUNGIFINFO -#define TAPGIFNAME _IOR('t', 93, struct ifreq) +#define TAPGIFNAME TUNGIFNAME /* VMware ioctl's */ #define VMIO_SIOCSIFFLAGS _IOWINT('V', 0) Modified: projects/nfsv42/sys/net/if_tun.h ============================================================================== --- projects/nfsv42/sys/net/if_tun.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/net/if_tun.h Sat Jul 27 02:23:05 2019 (r350368) @@ -40,6 +40,7 @@ struct tuninfo { #define TUNSIFINFO _IOW('t', 91, struct tuninfo) #define TUNGIFINFO _IOR('t', 92, struct tuninfo) #define TUNSLMODE _IOW('t', 93, int) +#define TUNGIFNAME _IOR('t', 93, struct ifreq) #define TUNSIFMODE _IOW('t', 94, int) #define TUNSIFPID _IO('t', 95) #define TUNSIFHEAD _IOW('t', 96, int) Modified: projects/nfsv42/sys/net/if_tuntap.c ============================================================================== --- projects/nfsv42/sys/net/if_tuntap.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/net/if_tuntap.c Sat Jul 27 02:23:05 2019 (r350368) @@ -1235,12 +1235,6 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i if (l2tun) { /* tap specific ioctls */ switch(cmd) { - case TAPGIFNAME: - ifrp = (struct ifreq *)data; - strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname, - IFNAMSIZ); - - return (0); /* VMware/VMnet port ioctl's */ #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ defined(COMPAT_FREEBSD4) @@ -1337,6 +1331,11 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i } switch (cmd) { + case TUNGIFNAME: + ifrp = (struct ifreq *)data; + strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname, IFNAMSIZ); + + return (0); case TUNSIFINFO: tunp = (struct tuninfo *)data; if (TUN2IFP(tp)->if_type != tunp->type) Modified: projects/nfsv42/sys/riscv/riscv/pmap.c ============================================================================== --- projects/nfsv42/sys/riscv/riscv/pmap.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/riscv/riscv/pmap.c Sat Jul 27 02:23:05 2019 (r350368) @@ -4105,7 +4105,7 @@ pmap_clear_modify(vm_page_t m) pmap_t pmap; pv_entry_t next_pv, pv; pd_entry_t *l2, oldl2; - pt_entry_t *l3, oldl3; + pt_entry_t *l3; vm_offset_t va; int md_gen, pvh_gen; @@ -4143,28 +4143,19 @@ restart: va = pv->pv_va; l2 = pmap_l2(pmap, va); oldl2 = pmap_load(l2); - if ((oldl2 & PTE_W) != 0) { - if (pmap_demote_l2_locked(pmap, l2, va, &lock)) { - if ((oldl2 & PTE_SW_WIRED) == 0) { - /* - * Write protect the mapping to a - * single page so that a subsequent - * write access may repromote. - */ - va += VM_PAGE_TO_PHYS(m) - - PTE_TO_PHYS(oldl2); - l3 = pmap_l2_to_l3(l2, va); - oldl3 = pmap_load(l3); - if ((oldl3 & PTE_V) != 0) { - while (!atomic_fcmpset_long(l3, - &oldl3, oldl3 & ~(PTE_D | - PTE_W))) - cpu_spinwait(); - vm_page_dirty(m); - pmap_invalidate_page(pmap, va); - } - } - } + /* If oldl2 has PTE_W set, then it also has PTE_D set. */ + if ((oldl2 & PTE_W) != 0 && + pmap_demote_l2_locked(pmap, l2, va, &lock) && + (oldl2 & PTE_SW_WIRED) == 0) { + /* + * Write protect the mapping to a single page so that + * a subsequent write access may repromote. + */ + va += VM_PAGE_TO_PHYS(m) - PTE_TO_PHYS(oldl2); + l3 = pmap_l2_to_l3(l2, va); + pmap_clear_bits(l3, PTE_D | PTE_W); + vm_page_dirty(m); + pmap_invalidate_page(pmap, va); } PMAP_UNLOCK(pmap); } Modified: projects/nfsv42/sys/sys/ata.h ============================================================================== --- projects/nfsv42/sys/sys/ata.h Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/sys/ata.h Sat Jul 27 02:23:05 2019 (r350368) @@ -97,6 +97,8 @@ struct ata_params { #define ATA_SUPPORT_OVERWRITE_EXT 0x4000 #define ATA_SUPPORT_CRYPTO_SCRAMBLE_EXT 0x2000 #define ATA_SUPPORT_SANITIZE 0x1000 +#define ATA_SUPPORT_SANITIZE_ALLOWED 0x0800 +#define ATA_SUPPORT_ANTIFREEZE_LOCK_EXT 0x0400 #define ATA_MULTI_VALID 0x0100 /*060*/ u_int16_t lba_size_1; @@ -454,6 +456,7 @@ struct ata_params { #define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ #define ATA_SERVICE 0xa2 /* service command */ #define ATA_SMART_CMD 0xb0 /* SMART command */ +#define ATA_SANITIZE 0xb4 /* sanitize device */ #define ATA_CFA_ERASE 0xc0 /* CFA erase */ #define ATA_READ_MUL 0xc4 /* read multi */ #define ATA_WRITE_MUL 0xc5 /* write multi */ Modified: projects/nfsv42/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- projects/nfsv42/sys/ufs/ufs/ufs_vnops.c Sat Jul 27 01:52:34 2019 (r350367) +++ projects/nfsv42/sys/ufs/ufs/ufs_vnops.c Sat Jul 27 02:23:05 2019 (r350368) @@ -2702,11 +2702,18 @@ static int ufs_ioctl(struct vop_ioctl_args *ap) { struct vnode *vp; + int error; vp = ap->a_vp; switch (ap->a_command) { case FIOSEEKDATA: - return (ufs_bmap_seekdata(vp, (off_t *)ap->a_data)); + error = vn_lock(vp, LK_SHARED); + if (error == 0) { + error = ufs_bmap_seekdata(vp, (off_t *)ap->a_data); + VOP_UNLOCK(vp, 0); + } else + error = EBADF; + return (error); case FIOSEEKHOLE: return (vn_bmap_seekhole(vp, ap->a_command, (off_t *)ap->a_data, ap->a_cred));