FreeBSD/sys/cam/cam_iosched.c
/*
 * Allocate the iosched structure. This also insulates callers from knowing
 * sizeof struct cam_iosched_softc.
 */
Allocate the iosched structure. This also insulates callers from knowing
sizeof struct cam_iosched_softc.
Allocate the iosched structure . This also insulates callers from knowing sizeof struct cam_iosched_softc .
int
cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph)
{
	*iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO);
	if (*iscp == NULL)
		return ENOMEM;
#ifdef CAM_IOSCHED_DYNAMIC
	if (iosched_debug)
		printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp);
#endif
	(*iscp)->sort_io_queue = -1;
	bioq_init(&(*iscp)->bio_queue);
	bioq_init(&(*iscp)->trim_queue);
#ifdef CAM_IOSCHED_DYNAMIC
	if (do_dynamic_iosched) {
		bioq_init(&(*iscp)->write_queue);
		(*iscp)->read_bias = 100;
		(*iscp)->current_read_bias = 100;
		(*iscp)->quanta = 200;
		cam_iosched_iop_stats_init(*iscp, &(*iscp)->read_stats);
		cam_iosched_iop_stats_init(*iscp, &(*iscp)->write_stats);
		cam_iosched_iop_stats_init(*iscp, &(*iscp)->trim_stats);
		(*iscp)->trim_stats.max = 1;	
		(*iscp)->last_time = sbinuptime();
		callout_init_mtx(&(*iscp)->ticker, cam_periph_mtx(periph), 0);
		(*iscp)->periph = periph;
		cam_iosched_cl_init(&(*iscp)->cl, *iscp);
		callout_reset(&(*iscp)->ticker, hz / (*iscp)->quanta - 1, cam_iosched_ticker, *iscp);
		(*iscp)->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
	}
#endif
	return 0;
}
int cam_iosched_init ( struct cam_iosched_softc * * iscp , struct cam_periph * periph ) { * iscp = malloc ( sizeof ( * * iscp ) , M_CAMSCHED , M_NOWAIT | M_ZERO ) ; if ( * iscp == NULL ) return ENOMEM ; #ifdef CAM_IOSCHED_DYNAMIC if ( iosched_debug ) printf ( " \n " , * iscp ) ; #endif ( * iscp ) -> sort_io_queue = -1 ; bioq_init ( & ( * iscp ) -> bio_queue ) ; bioq_init ( & ( * iscp ) -> trim_queue ) ; #ifdef CAM_IOSCHED_DYNAMIC if ( do_dynamic_iosched ) { bioq_init ( & ( * iscp ) -> write_queue ) ; ( * iscp ) -> read_bias = 100 ; ( * iscp ) -> current_read_bias = 100 ; ( * iscp ) -> quanta = 200 ; cam_iosched_iop_stats_init ( * iscp , & ( * iscp ) -> read_stats ) ; cam_iosched_iop_stats_init ( * iscp , & ( * iscp ) -> write_stats ) ; cam_iosched_iop_stats_init ( * iscp , & ( * iscp ) -> trim_stats ) ; ( * iscp ) -> trim_stats . max = 1 ; ( * iscp ) -> last_time = sbinuptime ( ) ; callout_init_mtx ( & ( * iscp ) -> ticker , cam_periph_mtx ( periph ) , 0 ) ; ( * iscp ) -> periph = periph ; cam_iosched_cl_init ( & ( * iscp ) -> cl , * iscp ) ; callout_reset ( & ( * iscp ) -> ticker , hz / ( * iscp ) -> quanta - 1 , cam_iosched_ticker , * iscp ) ; ( * iscp ) -> flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE ; } #endif return 0 ; }
Allocate the iosched structure.
Allocate the iosched structure .
/* Trims are special: one at a time for now */