git: 31412fda9fa7 - stable/15 - nvme: Refactor geom setting to function.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 19 Nov 2025 04:13:23 UTC
The branch stable/15 has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=31412fda9fa71d85a19604151d662ac65c301c2a
commit 31412fda9fa71d85a19604151d662ac65c301c2a
Author: Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2025-11-18 15:24:23 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-11-19 04:10:53 +0000
nvme: Refactor geom setting to function.
Refactor setting of geometry for the disk to its own function. No
functional changes.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33032
(cherry picked from commit dffd882d12d2a71aca464f48209ec9ae6f393b15)
---
sys/cam/nvme/nvme_da.c | 47 +++++++++++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 1c0d5e8381d8..330f4ca66e1e 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -643,6 +643,35 @@ 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;
+ struct ccb_pathinq cpi;
+ 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;
+ if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
+ disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
+ softc->unmappedio = 1;
+ }
+}
+
static void
ndaasync(void *callback_arg, uint32_t code,
struct cam_path *path, void *arg)
@@ -846,7 +875,6 @@ ndaregister(struct cam_periph *periph, void *arg)
const struct nvme_namespace_data *nsd;
const struct nvme_controller_data *cd;
char announce_buf[80];
- uint8_t flbas_fmt, lbads, vwc_present;
u_int maxio;
int quirks;
@@ -903,21 +931,8 @@ ndaregister(struct cam_periph *periph, void *arg)
else if (maxio > maxphys)
maxio = maxphys; /* for safety */
disk->d_maxsize = maxio;
- 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;
- if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
- disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
- softc->unmappedio = 1;
- }
+ ndasetgeom(softc, periph);
+
/*
* d_ident and d_descr are both far bigger than the length of either
* the serial or model number strings.