cam_iosched.h (721fc9d8ec8347cdc7ac9f1aefb44dff3eeb2220) cam_iosched.h (e4c9cba71ff03f0aa6daa924437208b29cffeb40)
1/*-
2 * CAM IO Scheduler Interface
3 *
4 * Copyright (c) 2015 Netflix, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 27 unchanged lines hidden (view full) ---

36
37/* Forward declare all structs to keep interface thin */
38struct cam_iosched_softc;
39struct sysctl_ctx_list;
40struct sysctl_oid;
41union ccb;
42struct bio;
43
1/*-
2 * CAM IO Scheduler Interface
3 *
4 * Copyright (c) 2015 Netflix, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 27 unchanged lines hidden (view full) ---

36
37/* Forward declare all structs to keep interface thin */
38struct cam_iosched_softc;
39struct sysctl_ctx_list;
40struct sysctl_oid;
41union ccb;
42struct bio;
43
44/*
45 * For 64-bit platforms, we know that uintptr_t is the same size as sbintime_t
46 * so we can store values in it. For 32-bit systems, however, uintptr_t is only
47 * 32-bits, so it won't fit. For those systems, store 24 bits of fraction and 8
48 * bits of seconds. This allows us to measure an interval of up to ~256s, which
49 * is ~200x what our current uses require. Provide some convenience functions to
50 * get the time, subtract two times and convert back to sbintime_t in a safe way
51 * that can be centralized.
52 */
53#ifdef __LP64__
54#define CAM_IOSCHED_TIME_SHIFT 0
55#else
56#define CAM_IOSCHED_TIME_SHIFT 8
57#endif
58static inline uintptr_t
59cam_iosched_now(void)
60{
61
62 /* Cast here is to avoid right shifting a signed value */
63 return (uintptr_t)((uint64_t)sbinuptime() >> CAM_IOSCHED_TIME_SHIFT);
64}
65
66static inline uintptr_t
67cam_iosched_delta_t(uintptr_t then)
68{
69
70 /* Since the types are identical, wrapping works correctly */
71 return (cam_iosched_now() - then);
72}
73
74static inline sbintime_t
75cam_iosched_sbintime_t(uintptr_t delta)
76{
77
78 /* Cast here is to widen the type so the left shift doesn't lose precision */
79 return (sbintime_t)((uint64_t)delta << CAM_IOSCHED_TIME_SHIFT);
80}
81
44int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph);
45void cam_iosched_fini(struct cam_iosched_softc *);
46void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);
47struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc);
48struct bio *cam_iosched_get_trim(struct cam_iosched_softc *isc);
49struct bio *cam_iosched_next_bio(struct cam_iosched_softc *isc);
50void cam_iosched_queue_work(struct cam_iosched_softc *isc, struct bio *bp);
51void cam_iosched_flush(struct cam_iosched_softc *isc, struct devstat *stp, int err);

--- 13 unchanged lines hidden ---
82int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph);
83void cam_iosched_fini(struct cam_iosched_softc *);
84void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);
85struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc);
86struct bio *cam_iosched_get_trim(struct cam_iosched_softc *isc);
87struct bio *cam_iosched_next_bio(struct cam_iosched_softc *isc);
88void cam_iosched_queue_work(struct cam_iosched_softc *isc, struct bio *bp);
89void cam_iosched_flush(struct cam_iosched_softc *isc, struct devstat *stp, int err);

--- 13 unchanged lines hidden ---