git: b1bd7fed589f - main - nda: Move ndasetgeom
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Mar 2026 18:01:13 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=b1bd7fed589fb5381fa2595f1f08e74895868941
commit b1bd7fed589fb5381fa2595f1f08e74895868941
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-03-03 17:59:22 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-03-03 17:59:22 +0000
nda: Move ndasetgeom
Move ndasetgeom up in the file. We'll need it here for future
commits. Also, preserve the UNMAPPED_BIO flag since we can't observe
enough data from this routine to set it directly.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D55519
---
sys/cam/nvme/nvme_da.c | 57 +++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 833738cfcb98..9646b792e9a9 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -285,6 +285,39 @@ nda_nvme_rw_bio(struct nda_softc *softc, struct ccb_nvmeio *nvmeio,
nvme_ns_rw_cmd(&nvmeio->cmd, rwcmd, softc->nsid, lba, count);
}
+static void
+ndasetgeom(struct nda_softc *softc, struct cam_periph *periph)
+{
+ struct disk *disk = softc->disk;
+ const struct nvme_namespace_data *nsd;
+ const struct nvme_controller_data *cd;
+ uint8_t flbas_fmt, lbads, vwc_present;
+ u_int flags;
+
+ nsd = nvme_get_identify_ns(periph);
+ cd = nvme_get_identify_cntrl(periph);
+
+ /*
+ * Preserve flags we can't infer that were set before. UNMAPPED comes
+ * from the PIM, so won't change after we set it the first
+ * time. Subsequent times, we have to preserve it.
+ */
+ flags = disk->d_flags & DISKFLAG_UNMAPPED_BIO; /* Need to preserve */
+
+ flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsd->flbas);
+ lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, nsd->lbaf[flbas_fmt]);
+ disk->d_sectorsize = 1 << lbads;
+ disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze);
+ disk->d_delmaxsize = disk->d_mediasize;
+ disk->d_flags = DISKFLAG_DIRECT_COMPLETION;
+ if (nvme_ctrlr_has_dataset_mgmt(cd))
+ disk->d_flags |= DISKFLAG_CANDELETE;
+ vwc_present = NVMEV(NVME_CTRLR_DATA_VWC_PRESENT, cd->vwc);
+ if (vwc_present)
+ disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
+ disk->d_flags |= flags;
+}
+
static int
ndaopen(struct disk *dp)
{
@@ -644,30 +677,6 @@ ndacleanup(struct cam_periph *periph)
cam_periph_lock(periph);
}
-static void
-ndasetgeom(struct nda_softc *softc, struct cam_periph *periph)
-{
- struct disk *disk = softc->disk;
- const struct nvme_namespace_data *nsd;
- const struct nvme_controller_data *cd;
- uint8_t flbas_fmt, lbads, vwc_present;
-
- nsd = nvme_get_identify_ns(periph);
- cd = nvme_get_identify_cntrl(periph);
-
- flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsd->flbas);
- lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, nsd->lbaf[flbas_fmt]);
- disk->d_sectorsize = 1 << lbads;
- disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze);
- disk->d_delmaxsize = disk->d_mediasize;
- disk->d_flags = DISKFLAG_DIRECT_COMPLETION;
- if (nvme_ctrlr_has_dataset_mgmt(cd))
- disk->d_flags |= DISKFLAG_CANDELETE;
- vwc_present = NVMEV(NVME_CTRLR_DATA_VWC_PRESENT, cd->vwc);
- if (vwc_present)
- disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
-}
-
static void
ndaasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
{