| 148 | } |
| 149 | |
| 150 | int |
| 151 | khelp_init_osd(uint32_t classes, struct osd *hosd) |
| 152 | { |
| 153 | struct helper *h; |
| 154 | void *hdata; |
| 155 | int error; |
| 156 | |
| 157 | KASSERT(hosd != NULL, ("struct osd not initialised!")); |
| 158 | |
| 159 | error = 0; |
| 160 | |
| 161 | KHELP_LIST_RLOCK(); |
| 162 | TAILQ_FOREACH(h, &helpers, h_next) { |
| 163 | /* If helper is correct class and needs to store OSD... */ |
| 164 | if (h->h_classes & classes && h->h_flags & HELPER_NEEDS_OSD) { |
| 165 | hdata = uma_zalloc(h->h_zone, M_NOWAIT); |
| 166 | if (hdata == NULL) { |
| 167 | error = ENOMEM; |
| 168 | break; |
| 169 | } |
| 170 | osd_set(OSD_KHELP, hosd, h->h_id, hdata); |
| 171 | refcount_acquire(&h->h_refcount); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (error) { |
| 176 | /* Delete OSD that was assigned prior to the error. */ |
| 177 | TAILQ_FOREACH(h, &helpers, h_next) { |
| 178 | if (h->h_classes & classes) |
| 179 | khelp_remove_osd(h, hosd); |
| 180 | } |
| 181 | } |
| 182 | KHELP_LIST_RUNLOCK(); |
| 183 | |
| 184 | return (error); |
| 185 | } |
| 186 | |
| 187 | int |
| 188 | khelp_destroy_osd(struct osd *hosd) |
no test coverage detected