* Compute the number of items that will fit in a slab. If hdr is true, the * item count may be limited to provide space in the slab for an inline slab * header. Otherwise, all slab space will be provided for item storage. */
| 2015 | * header. Otherwise, all slab space will be provided for item storage. |
| 2016 | */ |
| 2017 | static u_int |
| 2018 | slab_ipers_hdr(u_int size, u_int rsize, u_int slabsize, bool hdr) |
| 2019 | { |
| 2020 | u_int ipers; |
| 2021 | u_int padpi; |
| 2022 | |
| 2023 | /* The padding between items is not needed after the last item. */ |
| 2024 | padpi = rsize - size; |
| 2025 | |
| 2026 | if (hdr) { |
| 2027 | /* |
| 2028 | * Start with the maximum item count and remove items until |
| 2029 | * the slab header first alongside the allocatable memory. |
| 2030 | */ |
| 2031 | for (ipers = MIN(SLAB_MAX_SETSIZE, |
| 2032 | (slabsize + padpi - slab_sizeof(1)) / rsize); |
| 2033 | ipers > 0 && |
| 2034 | ipers * rsize - padpi + slab_sizeof(ipers) > slabsize; |
| 2035 | ipers--) |
| 2036 | continue; |
| 2037 | } else { |
| 2038 | ipers = MIN((slabsize + padpi) / rsize, SLAB_MAX_SETSIZE); |
| 2039 | } |
| 2040 | |
| 2041 | return (ipers); |
| 2042 | } |
| 2043 | |
| 2044 | struct keg_layout_result { |
| 2045 | u_int format; |
no test coverage detected