From nobody Sat Jul 20 02:59:08 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WQrq06ms3z5QxxB; Sat, 20 Jul 2024 02:59:08 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WQrq04tM4z433R; Sat, 20 Jul 2024 02:59:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721444348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dAOj9u/em+KgLrWBYgADkmtxXnNti42poIBJVy0qwNw=; b=Okt8SzR/o4LcDLBAyvBWugYTYbBN+yDBmFWDKCxD3/tvZhk7CmICjYRMLBImgc44XxYDs0 e9ddsahCBUOt5x03NZ50tS5+tdO9oxL/iyMzR1v5uaADw8/gBxicsFylaPd56WkCEStRXT lUfDC/kUwW8RMv7htqarXjmIagdL1lDrySvkULYqSHbScdd2GC8gY1Q+/JAgmOZcHt2DcF YG/dES/d2RuCvnmxMm6GLnu8WohPZUy+OI/VhkL9B/KZPkqzUJAQjaASrOQfe5jFOlQu63 fQFu29R/2AMD5von+L8uLRkrCSl9LAWxGKhUsQOLKznyvK9IQv+d2c6rbYI57Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721444348; a=rsa-sha256; cv=none; b=GQ6OlT6dHcxQG7eYOOfNWxnGkOEs6tkx2o6D+Jayd9I3fyIzuh/LEFdHT4pw39LKD833OX Uc1zqnvU3y7xzFKVFHtAX/cj31O5kG6Q7smEUlrAMJ1Lgj2/denk9YxFZ/aRQRflUpCO7O gqJt6w3NPGhCbjtB5ybRL/xSYGzTJEBBXIwCnSHlj4BVurnZBwsqMhueAFK0gklUubZ5Bt u5hTl4uPyFFdc5mCuyLaoflETy66b/FEJlDXqHTO2po6csanAaorUTthctDBZn9w0+tg7m wQso4YjH5Um8dy2rbIbupBANsfeyVZKjWVu1mEv8Y5PFgHVmEOC9PuIzHeO9Pw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721444348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dAOj9u/em+KgLrWBYgADkmtxXnNti42poIBJVy0qwNw=; b=cnJJ4MIoiZnPKHpuJFJPkNQi14h5yaqwQDAgiRBN4irZIrdzEzr3pcGId9SOGv7wdWjmyI DY8EBtjqH+enDS/TH3IEz+j8yKk6ueDAYhaj16gI4DKmRqUmc2O3um2UbJ6kJve+tI4P4v Xj7sesRj5CBnde/h9OMKgOAxZ+Azq+6guoTaynXsp2tEMzhMoxyBRiQa9dJAYZV/hPHhHL +qwBHB05AnKCo8iqNd704J6/V1fDn/6Tf6qabN5MSapUy4Wjdc/QlBstztvTfnGXFXmaZt suSIrDiuW1G8XdZL9jE/qbD/+HUClJVuXzqBoUtrE/6Gs10dLxfocRdlSOQRMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WQrq04VDlzySD; Sat, 20 Jul 2024 02:59:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46K2x8Xk024507; Sat, 20 Jul 2024 02:59:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46K2x8sA024504; Sat, 20 Jul 2024 02:59:08 GMT (envelope-from git) Date: Sat, 20 Jul 2024 02:59:08 GMT Message-Id: <202407200259.46K2x8sA024504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 6f1dd6071a91 - main - cam/iosched: Pass in the disk when initializing List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6f1dd6071a9171b8d1472ba36f6045a7a10b622a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=6f1dd6071a9171b8d1472ba36f6045a7a10b622a commit 6f1dd6071a9171b8d1472ba36f6045a7a10b622a Author: Warner Losh AuthorDate: 2024-07-20 02:53:01 +0000 Commit: Warner Losh CommitDate: 2024-07-20 02:53:37 +0000 cam/iosched: Pass in the disk when initializing The disk is nice to have at times, especially when you need the sector size. At present, the only plans for this are related to logging. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D46035 --- sys/cam/ata/ata_da.c | 19 ++++++++++--------- sys/cam/cam_iosched.c | 5 ++++- sys/cam/cam_iosched.h | 3 ++- sys/cam/nvme/nvme_da.c | 17 +++++++++-------- sys/cam/scsi/scsi_da.c | 16 ++++++++-------- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 6e008cfc8d22..2c1183b74c1d 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1834,13 +1834,6 @@ adaregister(struct cam_periph *periph, void *arg) announce_buf = softc->announce_temp; bzero(announce_buf, ADA_ANNOUNCETMP_SZ); - if (cam_iosched_init(&softc->cam_iosched, periph) != 0) { - printf("adaregister: Unable to probe new device. " - "Unable to allocate iosched memory\n"); - free(softc, M_DEVBUF); - return(CAM_REQ_CMP_ERR); - } - periph->softc = softc; xpt_path_inq(&softc->cpi, periph->path); @@ -1901,8 +1894,6 @@ adaregister(struct cam_periph *periph, void *arg) } else { softc->flags |= ADA_FLAG_ROTATING; } - cam_iosched_set_sort_queue(softc->cam_iosched, - (softc->flags & ADA_FLAG_ROTATING) ? -1 : 0); softc->disk = disk_alloc(); adasetgeom(softc, cgd); softc->disk->d_devstat = devstat_new_entry(periph->periph_name, @@ -1921,6 +1912,16 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_name = "ada"; softc->disk->d_drv1 = periph; softc->disk->d_unit = periph->unit_number; + + if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk) != 0) { + printf("adaregister: Unable to probe new device. " + "Unable to allocate iosched memory\n"); + free(softc, M_DEVBUF); + return(CAM_REQ_CMP_ERR); + } + cam_iosched_set_sort_queue(softc->cam_iosched, + (softc->flags & ADA_FLAG_ROTATING) ? -1 : 0); + cam_periph_lock(periph); dp = &softc->params; diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index 330d5ea22b61..cfefc8098d18 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -314,6 +314,7 @@ struct control_loop { struct cam_iosched_softc { struct bio_queue_head bio_queue; struct bio_queue_head trim_queue; + const struct disk *disk; /* scheduler flags < 16, user flags >= 16 */ uint32_t flags; int sort_io_queue; @@ -1153,12 +1154,14 @@ cam_iosched_cl_sysctl_fini(struct control_loop *clp) * sizeof struct cam_iosched_softc. */ int -cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph) +cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph, + const struct disk *dp) { *iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO); if (*iscp == NULL) return ENOMEM; + (*iscp)->disk = dp; #ifdef CAM_IOSCHED_DYNAMIC if (iosched_debug) printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp); diff --git a/sys/cam/cam_iosched.h b/sys/cam/cam_iosched.h index c8e4341f5095..e1019c531579 100644 --- a/sys/cam/cam_iosched.h +++ b/sys/cam/cam_iosched.h @@ -80,7 +80,8 @@ cam_iosched_sbintime_t(uintptr_t delta) typedef void (*cam_iosched_latfcn_t)(void *, sbintime_t, struct bio *); -int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph); +int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph, + const struct disk *dp); void cam_iosched_fini(struct cam_iosched_softc *); void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *); struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc); diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 41c552e2780a..1a93ea71ba77 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -862,13 +862,6 @@ ndaregister(struct cam_periph *periph, void *arg) return(CAM_REQ_CMP_ERR); } - if (cam_iosched_init(&softc->cam_iosched, periph) != 0) { - printf("ndaregister: Unable to probe new device. " - "Unable to allocate iosched memory\n"); - free(softc, M_DEVBUF); - return(CAM_REQ_CMP_ERR); - } - /* ident_data parsing */ periph->softc = softc; @@ -891,7 +884,6 @@ ndaregister(struct cam_periph *periph, void *arg) quirks = softc->quirks; TUNABLE_INT_FETCH(announce_buf, &quirks); softc->quirks = quirks; - cam_iosched_set_sort_queue(softc->cam_iosched, 0); softc->disk = disk = disk_alloc(); disk->d_rotation_rate = DISK_RR_NON_ROTATING; disk->d_open = ndaopen; @@ -953,6 +945,15 @@ ndaregister(struct cam_periph *periph, void *arg) DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT | XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_DISK); + + if (cam_iosched_init(&softc->cam_iosched, periph, disk) != 0) { + printf("ndaregister: Unable to probe new device. " + "Unable to allocate iosched memory\n"); + free(softc, M_DEVBUF); + return(CAM_REQ_CMP_ERR); + } + cam_iosched_set_sort_queue(softc->cam_iosched, 0); + /* * Add alias for older nvd drives to ease transition. */ diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 59745231bca5..4ecf8c35aca2 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2804,13 +2804,6 @@ daregister(struct cam_periph *periph, void *arg) return(CAM_REQ_CMP_ERR); } - if (cam_iosched_init(&softc->cam_iosched, periph) != 0) { - printf("daregister: Unable to probe new device. " - "Unable to allocate iosched memory\n"); - free(softc, M_DEVBUF); - return(CAM_REQ_CMP_ERR); - } - LIST_INIT(&softc->pending_ccbs); softc->state = DA_STATE_PROBE_WP; bioq_init(&softc->delete_run_queue); @@ -2979,7 +2972,13 @@ daregister(struct cam_periph *periph, void *arg) 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); - cam_periph_lock(periph); + + if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk) != 0) { + printf("daregister: Unable to probe new device. " + "Unable to allocate iosched memory\n"); + free(softc, M_DEVBUF); + return(CAM_REQ_CMP_ERR); + } /* * Add async callbacks for events of interest. @@ -2988,6 +2987,7 @@ daregister(struct cam_periph *periph, void *arg) * fine without them and the only alternative * would be to not attach the device on failure. */ + cam_periph_lock(periph); xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE | AC_ADVINFO_CHANGED | AC_SCSI_AEN | AC_UNIT_ATTENTION | AC_INQ_CHANGED, daasync, periph, periph->path);