The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d3795c1d72f042c86efebdaa9ae790f64ef79f47

commit d3795c1d72f042c86efebdaa9ae790f64ef79f47
Author:     Warner Losh <[email protected]>
AuthorDate: 2024-07-20 19:58:04 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2024-07-20 19:59:18 +0000

    cam/iosched: Use better malloc idiom
    
    Allocate to a simple poiter, use that everywhere, then return it at the
    end. The code looks cleaner.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D46043
---
 sys/cam/cam_iosched.c | 46 ++++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c
index 4f4a2b2cde55..15e98b7cb39d 100644
--- a/sys/cam/cam_iosched.c
+++ b/sys/cam/cam_iosched.c
@@ -1160,37 +1160,39 @@ int
 cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph,
     const struct disk *dp, cam_iosched_schedule_t schedfnc)
 {
+       struct cam_iosched_softc *isc;
 
-       *iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO);
-       if (*iscp == NULL)
+       isc = malloc(sizeof(*isc), M_CAMSCHED, M_NOWAIT | M_ZERO);
+       if (isc == NULL)
                return ENOMEM;
-       (*iscp)->disk = dp;
-       (*iscp)->schedfnc = schedfnc;
+       isc->disk = dp;
+       isc->schedfnc = schedfnc;
 #ifdef CAM_IOSCHED_DYNAMIC
        if (iosched_debug)
-               printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp);
+               printf("CAM IOSCHEDULER Allocating entry at %p\n", isc);
 #endif
-       (*iscp)->sort_io_queue = -1;
-       bioq_init(&(*iscp)->bio_queue);
-       bioq_init(&(*iscp)->trim_queue);
+       isc->sort_io_queue = -1;
+       bioq_init(&isc->bio_queue);
+       bioq_init(&isc->trim_queue);
 #ifdef CAM_IOSCHED_DYNAMIC
        if (do_dynamic_iosched) {
-               bioq_init(&(*iscp)->write_queue);
-               (*iscp)->read_bias = default_read_bias;
-               (*iscp)->current_read_bias = 0;
-               (*iscp)->quanta = min(hz, 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;    /* Trims are special: one at a 
time for now */
-               (*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, 
cam_iosched_ticker, *iscp);
-               (*iscp)->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
+               bioq_init(&isc->write_queue);
+               isc->read_bias = default_read_bias;
+               isc->current_read_bias = 0;
+               isc->quanta = min(hz, 200);
+               cam_iosched_iop_stats_init(isc, &isc->read_stats);
+               cam_iosched_iop_stats_init(isc, &isc->write_stats);
+               cam_iosched_iop_stats_init(isc, &isc->trim_stats);
+               isc->trim_stats.max = 1;        /* Trims are special: one at a 
time for now */
+               isc->last_time = sbinuptime();
+               callout_init_mtx(&isc->ticker, cam_periph_mtx(periph), 0);
+               isc->periph = periph;
+               cam_iosched_cl_init(&isc->cl, isc);
+               callout_reset(&isc->ticker, hz / isc->quanta, 
cam_iosched_ticker, isc);
+               isc->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
        }
 #endif
+       *iscp = isc;
 
        return 0;
 }

Reply via email to