Date: Tue, 17 Dec 2019 00:13:30 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355834 - head/sys/cam Message-ID: <201912170013.xBH0DUPA090566@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Tue Dec 17 00:13:30 2019 New Revision: 355834 URL: https://svnweb.freebsd.org/changeset/base/355834 Log: Eliminate the TRIM_ACTIVE flag. Rather than a trim active flag, have a counter that can be used to have a absolute limit on the number of trims in flight independent of any I/O limiting factors. Sponsored by: Netflix Modified: head/sys/cam/cam_iosched.c Modified: head/sys/cam/cam_iosched.c ============================================================================== --- head/sys/cam/cam_iosched.c Tue Dec 17 00:13:26 2019 (r355833) +++ head/sys/cam/cam_iosched.c Tue Dec 17 00:13:30 2019 (r355834) @@ -281,6 +281,8 @@ struct cam_iosched_softc { int trim_ticks; /* Max ticks to hold trims */ int last_trim_tick; /* Last 'tick' time ld a trim */ int queued_trims; /* Number of trims in the queue */ + int max_trims; /* Maximum number of trims pending at once */ + int pend_trims; /* Number of pending trims now */ #ifdef CAM_IOSCHED_DYNAMIC int read_bias; /* Read bias setting */ int current_read_bias; /* Current read bias state */ @@ -707,11 +709,6 @@ cam_iosched_cl_maybe_steer(struct control_loop *clp) } #endif -/* - * Trim or similar currently pending completion. Should only be set for - * those drivers wishing only one Trim active at a time. - */ -#define CAM_IOSCHED_FLAG_TRIM_ACTIVE (1ul << 0) /* Callout active, and needs to be torn down */ #define CAM_IOSCHED_FLAG_CALLOUT_ACTIVE (1ul << 1) @@ -784,8 +781,7 @@ cam_iosched_has_more_trim(struct cam_iosched_softc *is return false; } - /* NB: Should perhaps have a max trim active independent of I/O limiters */ - return !(isc->flags & CAM_IOSCHED_FLAG_TRIM_ACTIVE) && bp != NULL; + return isc->pend_trims <= isc->max_trims && bp != NULL; } #define cam_iosched_sort_queue(isc) ((isc)->sort_io_queue >= 0 ? \ @@ -1109,6 +1105,7 @@ cam_iosched_init(struct cam_iosched_softc **iscp, stru (*iscp)->sort_io_queue = -1; bioq_init(&(*iscp)->bio_queue); bioq_init(&(*iscp)->trim_queue); + (*iscp)->max_trims = 1; #ifdef CAM_IOSCHED_DYNAMIC if (do_dynamic_iosched) { bioq_init(&(*iscp)->write_queue); @@ -1609,7 +1606,7 @@ void cam_iosched_trim_done(struct cam_iosched_softc *isc) { - isc->flags &= ~CAM_IOSCHED_FLAG_TRIM_ACTIVE; + isc->pend_trims--; } /* @@ -1677,7 +1674,7 @@ void cam_iosched_submit_trim(struct cam_iosched_softc *isc) { - isc->flags |= CAM_IOSCHED_FLAG_TRIM_ACTIVE; + isc->pend_trims++; } /* @@ -1922,8 +1919,8 @@ DB_SHOW_COMMAND(iosched, cam_iosched_db_show) db_printf("Trim Q len %d\n", biolen(&isc->trim_queue)); db_printf("read_bias: %d\n", isc->read_bias); db_printf("current_read_bias: %d\n", isc->current_read_bias); - db_printf("Trim active? %s\n", - (isc->flags & CAM_IOSCHED_FLAG_TRIM_ACTIVE) ? "yes" : "no"); + db_printf("Trims active %d\n", isc->pend_trim); + db_printf("Max trims active %d\n", isc->max_trim); } #endif #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912170013.xBH0DUPA090566>