Author: imp Date: Thu Feb 13 01:23:44 2020 New Revision: 357849 URL: https://svnweb.freebsd.org/changeset/base/357849
Log: Convert rotating and unmapped_io to a DA flag Rotating and unmapped_io are really da flags. Convert them to a flag so it will be reported with the other flags for the device. Deprecate the .rotating and .unmapped_io sysctls in FreeBSD 14 and remove the softc ints. Differential Revision: https://reviews.freebsd.org/D23417 Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Thu Feb 13 01:23:32 2020 (r357848) +++ head/sys/cam/scsi/scsi_da.c Thu Feb 13 01:23:44 2020 (r357849) @@ -106,6 +106,7 @@ typedef enum { DA_FLAG_NEW_PACK = 0x000002, DA_FLAG_PACK_LOCKED = 0x000004, DA_FLAG_PACK_REMOVABLE = 0x000008, + DA_FLAG_ROTATING = 0x000010, DA_FLAG_NEED_OTAG = 0x000020, DA_FLAG_WAS_OTAG = 0x000040, DA_FLAG_RETRY_UA = 0x000080, @@ -120,7 +121,8 @@ typedef enum { DA_FLAG_CAN_ATA_IDLOG = 0x010000, DA_FLAG_CAN_ATA_SUPCAP = 0x020000, DA_FLAG_CAN_ATA_ZONE = 0x040000, - DA_FLAG_TUR_PENDING = 0x080000 + DA_FLAG_TUR_PENDING = 0x080000, + DA_FLAG_UNMAPPEDIO = 0x100000 } da_flags; #define DA_FLAG_STRING \ "\020" \ @@ -128,7 +130,7 @@ typedef enum { "\002NEW_PACK" \ "\003PACK_LOCKED" \ "\004PACK_REMOVABLE" \ - "\005UNUSED" \ + "\005ROTATING" \ "\006NEED_OTAG" \ "\007WAS_OTAG" \ "\010RETRY_UA" \ @@ -143,7 +145,8 @@ typedef enum { "\021CAN_ATA_IDLOG" \ "\022CAN_ATA_SUPACP" \ "\023CAN_ATA_ZONE" \ - "\024TUR_PENDING" + "\024TUR_PENDING" \ + "\025UNMAPPEDIO" typedef enum { DA_Q_NONE = 0x00, @@ -367,8 +370,6 @@ struct da_softc { da_delete_methods delete_method_pref; da_delete_methods delete_method; da_delete_func_t *delete_func; - int unmappedio; - int rotating; int p_type; struct disk_params params; struct disk *disk; @@ -1464,6 +1465,7 @@ static void dasysctlinit(void *context, int pending); static int dasysctlsofttimeout(SYSCTL_HANDLER_ARGS); static int dacmdsizesysctl(SYSCTL_HANDLER_ARGS); static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS); +static int dabitsysctl(SYSCTL_HANDLER_ARGS); static int daflagssysctl(SYSCTL_HANDLER_ARGS); static int dazonemodesysctl(SYSCTL_HANDLER_ARGS); static int dazonesupsysctl(SYSCTL_HANDLER_ARGS); @@ -2315,24 +2317,6 @@ dasysctlinit(void *context, int pending) SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, - "unmapped_io", - CTLFLAG_RD, - &softc->unmappedio, - 0, - "Unmapped I/O support"); - - SYSCTL_ADD_INT(&softc->sysctl_ctx, - SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, - "rotating", - CTLFLAG_RD, - &softc->rotating, - 0, - "Rotating media"); - - SYSCTL_ADD_INT(&softc->sysctl_ctx, - SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, "p_type", CTLFLAG_RD, &softc->p_type, @@ -2343,6 +2327,14 @@ dasysctlinit(void *context, int pending) OID_AUTO, "flags", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, daflagssysctl, "A", "Flags for drive"); + SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, "rotating", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + &softc->flags, DA_FLAG_ROTATING, dabitsysctl, "I", + "Rotating media *DEPRECATED* gone in FreeBSD 14"); + SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, "unmapped_io", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + &softc->flags, DA_FLAG_UNMAPPEDIO, dabitsysctl, "I", + "Unmapped I/O support *DEPRECATED* gone in FreeBSD 14"); #ifdef CAM_TEST_FAILURE SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), @@ -2619,6 +2611,21 @@ dadeletemethodchoose(struct da_softc *softc, da_delete } static int +dabitsysctl(SYSCTL_HANDLER_ARGS) +{ + int flags = (intptr_t)arg1; + int test = arg2; + int tmpout, error; + + tmpout = !!(flags & test); + error = SYSCTL_OUT(req, &tmpout, sizeof(tmpout)); + if (error || !req->newptr) + return (error); + + return (EPERM); +} + +static int daflagssysctl(SYSCTL_HANDLER_ARGS) { struct sbuf sbuf; @@ -2775,7 +2782,7 @@ daregister(struct cam_periph *periph, void *arg) softc->unmap_gran_align = 0; softc->ws_max_blks = WS16_MAX_BLKS; softc->trim_max_ranges = ATA_TRIM_MAX_RANGES; - softc->rotating = 1; + softc->flags |= DA_FLAG_ROTATING; periph->softc = softc; @@ -2908,7 +2915,7 @@ daregister(struct cam_periph *periph, void *arg) if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; if ((cpi.hba_misc & PIM_UNMAPPED) != 0) { - softc->unmappedio = 1; + softc->flags |= DA_FLAG_UNMAPPEDIO; softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO; } cam_strvis(softc->disk->d_descr, cgd->inq_data.vendor, @@ -5188,7 +5195,7 @@ dadone_probebdc(struct cam_periph *periph, union ccb * SVPD_BDC_RATE_NON_ROTATING) { cam_iosched_set_sort_queue( softc->cam_iosched, 0); - softc->rotating = 0; + softc->flags &= ~DA_FLAG_ROTATING; } if (softc->disk->d_rotation_rate != old_rate) { disk_attr_changed(softc->disk, @@ -5298,7 +5305,7 @@ dadone_probeata(struct cam_periph *periph, union ccb * softc->disk->d_rotation_rate = ata_params->media_rotation_rate; if (softc->disk->d_rotation_rate == ATA_RATE_NON_ROTATING) { cam_iosched_set_sort_queue(softc->cam_iosched, 0); - softc->rotating = 0; + softc->flags &= ~DA_FLAG_ROTATING; } if (softc->disk->d_rotation_rate != old_rate) { disk_attr_changed(softc->disk, _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"