aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2026-03-03 17:59:22 +0000
committerWarner Losh <imp@FreeBSD.org>2026-03-03 17:59:22 +0000
commitb1bd7fed589fb5381fa2595f1f08e74895868941 (patch)
tree6d849ddd7aaa726256e831b8f108061c24d98d64
parent3212aa86ac87fcd3b483d3f1668dcb26a3ab84b0 (diff)
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
-rw-r--r--sys/cam/nvme/nvme_da.c57
1 files 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)
{
@@ -645,30 +678,6 @@ ndacleanup(struct cam_periph *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)
{
struct cam_periph *periph = callback_arg;