Changeset 5d96f427 in mainline
- Timestamp:
- 2024-11-15T16:44:25Z (6 months ago)
- Children:
- 733564a
- Parents:
- bd51105
- git-author:
- Miroslav Cimerman <mc@…> (2024-11-15 16:08:11)
- git-committer:
- Miroslav Cimerman <mc@…> (2024-11-15 16:44:25)
- Location:
- uspace/srv/bd/hr
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/hr.c
rbd51105 r5d96f427 62 62 static hr_volume_t *hr_get_volume(service_id_t svc_id) 63 63 { 64 log_msg(LOG_DEFAULT, LVL_DEBUG, "hr_get_volume(): (%" PRIun ")", 65 svc_id); 64 DPRINTF("hr_get_volume(): (%" PRIun ")\n", svc_id); 66 65 67 66 fibril_mutex_lock(&hr_volumes_lock); … … 79 78 static errno_t hr_remove_volume(service_id_t svc_id) 80 79 { 81 log_msg(LOG_DEFAULT, LVL_DEBUG, "hr_remove_volume(): (%" PRIun ")", 82 svc_id); 80 DPRINTF("hr_remove_volume(): (%" PRIun ")\n", svc_id); 83 81 84 82 fibril_mutex_lock(&hr_volumes_lock); … … 99 97 static void hr_create_srv(ipc_call_t *icall, bool assemble) 100 98 { 101 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_create_srv()");99 DPRINTF("hr_create_srv()\n"); 102 100 103 101 errno_t rc; … … 141 139 for (i = 0; i < cfg->dev_no; i++) { 142 140 if (cfg->devs[i] == 0) { 141 ERR_PRINTF("missing device provided for array " 142 "creation, aborting"); 143 143 free(cfg); 144 144 async_answer_0(icall, EINVAL); … … 205 205 break; 206 206 default: 207 log_msg(LOG_DEFAULT, LVL_ERROR, 208 "level %d not implemented yet", new_volume->level); 207 ERR_PRINTF("unkown level: %d, aborting\n", new_volume->level); 209 208 rc = EINVAL; 210 209 goto error; … … 232 231 233 232 if (assemble) { 234 log_msg(LOG_DEFAULT, LVL_NOTE, 235 "assembled volume \"%s\" (%" PRIun ")", 233 DPRINTF("assembled volume \"%s\" (%" PRIun ")\n", 236 234 new_volume->devname, new_volume->svc_id); 237 235 } else { 238 log_msg(LOG_DEFAULT, LVL_NOTE, 239 "created volume \"%s\" (%" PRIun ")", 236 DPRINTF("created volume \"%s\" (%" PRIun ")\n", 240 237 new_volume->devname, new_volume->svc_id); 241 238 } … … 253 250 static void hr_stop_srv(ipc_call_t *icall) 254 251 { 255 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_stop_srv()");252 DPRINTF("hr_stop_srv()\n"); 256 253 257 254 errno_t rc = EOK; … … 287 284 static void hr_print_status_srv(ipc_call_t *icall) 288 285 { 289 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_status_srv()");286 DPRINTF("hr_status_srv()\n"); 290 287 291 288 errno_t rc; … … 351 348 static void hr_ctl_conn(ipc_call_t *icall, void *arg) 352 349 { 353 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_ctl_conn()");350 DPRINTF("hr_ctl_conn()\n"); 354 351 355 352 async_accept_0(icall); … … 386 383 static void hr_client_conn(ipc_call_t *icall, void *arg) 387 384 { 388 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_client_conn()");385 DPRINTF("hr_client_conn()\n"); 389 386 390 387 hr_volume_t *vol; … … 395 392 hr_ctl_conn(icall, arg); 396 393 } else { 397 log_msg(LOG_DEFAULT, LVL_NOTE, "bd_conn()");394 DPRINTF("bd_conn()\n"); 398 395 vol = hr_get_volume(svc_id); 399 396 if (vol == NULL) … … 422 419 rc = loc_server_register(NAME, &hr_srv); 423 420 if (rc != EOK) { 424 log_msg(LOG_DEFAULT, LVL_ERROR, 425 "failed registering server: %s", str_error(rc)); 421 ERR_PRINTF("failed registering server: %s", str_error(rc)); 426 422 return EEXIST; 427 423 } … … 429 425 rc = loc_service_register(hr_srv, SERVICE_NAME_HR, &ctl_sid); 430 426 if (rc != EOK) { 431 log_msg(LOG_DEFAULT, LVL_ERROR, 432 "failed registering service: %s", str_error(rc)); 427 ERR_PRINTF("failed registering service: %s", str_error(rc)); 433 428 return EEXIST; 434 429 } -
uspace/srv/bd/hr/raid0.c
rbd51105 r5d96f427 89 89 for (size_t i = 0; i < vol->dev_no; i++) { 90 90 if (vol->extents[i].status != HR_EXT_ONLINE) { 91 log_msg(LOG_DEFAULT, LVL_ERROR, 92 "RAID 0 needs all extents to be ONLINE, marking " 93 "\"%s\" (%lu) as FAULTY", 91 ERR_PRINTF("RAID 0 needs all extents to be ONLINE, " 92 "marking \"%s\" (%lu) as FAULTY", 94 93 vol->devname, vol->svc_id); 95 94 vol->status = HR_VOL_FAULTY; … … 104 103 static errno_t hr_raid0_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 105 104 { 106 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_open()");105 DPRINTF("hr_bd_open()\n"); 107 106 return EOK; 108 107 } … … 110 109 static errno_t hr_raid0_bd_close(bd_srv_t *bd) 111 110 { 112 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_close()");111 DPRINTF("hr_bd_close()\n"); 113 112 return EOK; 114 113 } … … 246 245 247 246 if (new_volume->dev_no < 2) { 248 log_msg(LOG_DEFAULT, LVL_ERROR, 249 "RAID 0 array needs at least 2 devices"); 247 ERR_PRINTF("RAID 0 array needs at least 2 devices"); 250 248 return EINVAL; 251 249 } -
uspace/srv/bd/hr/raid1.c
rbd51105 r5d96f427 95 95 if (healthy == 0) { 96 96 if (old_state != HR_VOL_FAULTY) { 97 log_msg(LOG_DEFAULT, LVL_ERROR, 98 "RAID 1 needs at least 1 extent to be ONLINE, " 99 "marking \"%s\" (%lu) as FAULTY", 97 ERR_PRINTF("RAID 1 needs at least 1 extent to be" 98 "ONLINE, marking \"%s\" (%lu) volume as FAULTY", 100 99 vol->devname, vol->svc_id); 101 100 vol->status = HR_VOL_FAULTY; … … 104 103 } else if (healthy < vol->dev_no) { 105 104 if (old_state != HR_VOL_DEGRADED) { 106 log_msg(LOG_DEFAULT, LVL_ERROR, 107 "RAID 1 array \"%s\" (%lu) has some inactive " 108 "extents, marking as DEGRADED", 105 ERR_PRINTF("RAID 1 array \"%s\" (%lu) has some " 106 "inactive extent(s), marking volume as DEGRADED", 109 107 vol->devname, vol->svc_id); 110 108 vol->status = HR_VOL_DEGRADED; … … 113 111 } else { 114 112 if (old_state != HR_VOL_ONLINE) { 115 log_msg(LOG_DEFAULT, LVL_ERROR, 116 "RAID 1 array \"%s\" (%lu) has all extents active, " 117 "marking as ONLINE", 113 DPRINTF("RAID 1 array \"%s\" (%lu) has all extents " 114 "active, marking volume as ONLINE", 118 115 vol->devname, vol->svc_id); 119 116 vol->status = HR_VOL_ONLINE; … … 125 122 static errno_t hr_raid1_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 126 123 { 127 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_open()");124 DPRINTF("hr_bd_open()\n"); 128 125 return EOK; 129 126 } … … 131 128 static errno_t hr_raid1_bd_close(bd_srv_t *bd) 132 129 { 133 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_close()");130 DPRINTF("hr_bd_close()\n"); 134 131 return EOK; 135 132 } … … 260 257 261 258 if (new_volume->dev_no < 2) { 262 log_msg(LOG_DEFAULT, LVL_ERROR, 263 "RAID 1 array needs at least 2 devices"); 259 ERR_PRINTF("RAID 1 array needs at least 2 devices\n"); 264 260 return EINVAL; 265 261 } -
uspace/srv/bd/hr/raid4.c
rbd51105 r5d96f427 109 109 case 0: 110 110 if (old_state != HR_VOL_ONLINE) { 111 log_msg(LOG_DEFAULT, LVL_ERROR, 112 "RAID 4 has all extents online, " 111 DPRINTF("RAID 4 has all extents online, " 113 112 "marking \"%s\" (%lu) as ONLINE", 114 113 vol->devname, vol->svc_id); … … 118 117 case 1: 119 118 if (old_state != HR_VOL_DEGRADED) { 120 log_msg(LOG_DEFAULT, LVL_ERROR, 121 "RAID 4 array \"%s\" (%lu) has 1 extent inactive, " 122 "marking as DEGRADED", 119 ERR_PRINTF("RAID 4 array \"%s\" (%lu) has 1 extent " 120 "inactive, marking as DEGRADED", 123 121 vol->devname, vol->svc_id); 124 122 vol->status = HR_VOL_DEGRADED; … … 127 125 default: 128 126 if (old_state != HR_VOL_FAULTY) { 129 log_msg(LOG_DEFAULT, LVL_ERROR, 130 "RAID 4 array \"%s\" (%lu) has more than one 1 " 131 "extent inactive, marking as FAULTY", 127 ERR_PRINTF("RAID 4 array \"%s\" (%lu) has more " 128 "than one 1 extent inactive, marking as FAULTY", 132 129 vol->devname, vol->svc_id); 133 130 vol->status = HR_VOL_FAULTY; … … 324 321 static errno_t hr_raid4_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 325 322 { 326 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_open()");323 DPRINTF("hr_bd_open()\n"); 327 324 return EOK; 328 325 } … … 330 327 static errno_t hr_raid4_bd_close(bd_srv_t *bd) 331 328 { 332 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_close()");329 DPRINTF("hr_bd_close()\n"); 333 330 return EOK; 334 331 } … … 495 492 496 493 if (new_volume->dev_no < 3) { 497 log_msg(LOG_DEFAULT, LVL_ERROR, 498 "RAID 4 array needs at least 3 devices"); 494 ERR_PRINTF("RAID 4 array needs at least 3 devices"); 499 495 return EINVAL; 500 496 } -
uspace/srv/bd/hr/raid5.c
rbd51105 r5d96f427 109 109 case 0: 110 110 if (old_state != HR_VOL_ONLINE) { 111 log_msg(LOG_DEFAULT, LVL_ERROR, 112 "RAID 5 has all extents online, " 111 DPRINTF("RAID 5 has all extents online, " 113 112 "marking \"%s\" (%lu) as ONLINE", 114 113 vol->devname, vol->svc_id); … … 118 117 case 1: 119 118 if (old_state != HR_VOL_DEGRADED) { 120 log_msg(LOG_DEFAULT, LVL_ERROR, 121 "RAID 5 array \"%s\" (%lu) has 1 extent inactive, " 122 "marking as DEGRADED", 119 ERR_PRINTF("RAID 5 array \"%s\" (%lu) has 1 extent " 120 "inactive, marking as DEGRADED", 123 121 vol->devname, vol->svc_id); 124 122 vol->status = HR_VOL_DEGRADED; … … 127 125 default: 128 126 if (old_state != HR_VOL_FAULTY) { 129 log_msg(LOG_DEFAULT, LVL_ERROR, 130 "RAID 5 array \"%s\" (%lu) has more than one 1 " 131 "extent inactive, marking as FAULTY", 127 ERR_PRINTF("RAID 5 array \"%s\" (%lu) has more " 128 "than one 1 extent inactive, marking as FAULTY", 132 129 vol->devname, vol->svc_id); 133 130 vol->status = HR_VOL_FAULTY; … … 324 321 static errno_t hr_raid5_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 325 322 { 326 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_open()");323 DPRINTF("hr_bd_open()\n"); 327 324 return EOK; 328 325 } … … 330 327 static errno_t hr_raid5_bd_close(bd_srv_t *bd) 331 328 { 332 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_bd_close()");329 DPRINTF("hr_bd_close()\n"); 333 330 return EOK; 334 331 } … … 504 501 505 502 if (new_volume->dev_no < 3) { 506 log_msg(LOG_DEFAULT, LVL_ERROR, 507 "RAID 5 array needs at least 3 devices"); 503 ERR_PRINTF("RAID 5 array needs at least 3 devices"); 508 504 return EINVAL; 509 505 } -
uspace/srv/bd/hr/superblock.c
rbd51105 r5d96f427 54 54 errno_t hr_write_meta_to_vol(hr_volume_t *vol) 55 55 { 56 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_write_meta_to_vol()");56 DPRINTF("hr_write_meta_to_vol()\n"); 57 57 58 58 errno_t rc; … … 71 71 72 72 if (vol->nblocks < meta_blkno) { 73 log_msg(LOG_DEFAULT, LVL_ERROR, 74 "not enough blocks to write metadata"); 73 ERR_PRINTF("not enough blocks to write metadat\n"); 75 74 rc = EINVAL; 76 75 goto error; 77 76 } else if (vol->nblocks == meta_blkno) { 78 log_msg(LOG_DEFAULT, LVL_ERROR,79 " there would be zero data blocks after writingmetadata, aborting");77 ERR_PRINTF("there would be zero data blocks after writing " 78 "metadata, aborting"); 80 79 rc = EINVAL; 81 80 goto error; … … 115 114 { 116 115 if (uint64_t_le2host(md->magic) != HR_MAGIC) { 117 printf("invalid magic\n");116 ERR_PRINTF("invalid magic\n"); 118 117 return EINVAL; 119 118 } … … 123 122 errno_t hr_fill_vol_from_meta(hr_volume_t *vol) 124 123 { 125 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_get_vol_from_meta()");124 DPRINTF("hr_get_vol_from_meta()\n"); 126 125 127 126 errno_t rc; … … 171 170 172 171 if (vol->dev_no != uint32_t_le2host(metadata->extent_no)) { 173 log_msg(LOG_DEFAULT, LVL_ERROR,174 " number of divices in array differ: specified %zu,metadata states %u",172 ERR_PRINTF("number of divices in array differ: specified %zu, " 173 "metadata states %u", 175 174 vol->dev_no, uint32_t_le2host(metadata->extent_no)); 176 175 rc = EINVAL; … … 185 184 186 185 if (str_cmp(metadata->devname, vol->devname) != 0) { 187 log_msg(LOG_DEFAULT, LVL_ NOTE,188 "devname on metadata (%s) and config (%s) differ, using config",189 metadata->devname, vol->devname);186 log_msg(LOG_DEFAULT, LVL_WARN, 187 "devname on metadata (%s) and config (%s) differ, " 188 "using config", metadata->devname, vol->devname); 190 189 } 191 190 end: -
uspace/srv/bd/hr/util.c
rbd51105 r5d96f427 50 50 errno_t hr_init_devs(hr_volume_t *vol) 51 51 { 52 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_init_devs()");52 DPRINTF("hr_init_devs()\n"); 53 53 54 54 errno_t rc; 55 55 size_t i; 56 57 for (i = 0; i < vol->dev_no; i++) { 58 if (vol->extents[i].svc_id == 0) { 59 vol->extents[i].status = HR_EXT_MISSING; 60 continue; 61 } 62 rc = block_init(vol->extents[i].svc_id); 63 vol->extents[i].status = HR_EXT_ONLINE; 64 log_msg(LOG_DEFAULT, LVL_DEBUG, 65 "hr_init_devs(): initing (%" PRIun ")", 66 vol->extents[i].svc_id); 56 hr_extent_t *extent; 57 58 for (i = 0; i < vol->dev_no; i++) { 59 extent = &vol->extents[i]; 60 if (extent->svc_id == 0) { 61 extent->status = HR_EXT_MISSING; 62 continue; 63 } 64 65 DPRINTF("hr_init_devs(): block_init() on (%lu)\n", 66 extent->svc_id); 67 rc = block_init(extent->svc_id); 68 extent->status = HR_EXT_ONLINE; 69 67 70 if (rc != EOK) { 68 log_msg(LOG_DEFAULT, LVL_ERROR, 69 "hr_init_devs(): initing (%" PRIun ") failed, aborting", 71 ERR_PRINTF("hr_init_devs(): initing (%lu) failed, " 72 "aborting\n", extent->svc_id); 73 break; 74 } 75 } 76 77 return rc; 78 } 79 80 void hr_fini_devs(hr_volume_t *vol) 81 { 82 DPRINTF("hr_fini_devs()\n"); 83 84 size_t i; 85 86 for (i = 0; i < vol->dev_no; i++) { 87 if (vol->extents[i].status != HR_EXT_MISSING) { 88 DPRINTF("hr_fini_devs(): block_fini() on (%lu)\n", 70 89 vol->extents[i].svc_id); 71 break;72 }73 }74 75 return rc;76 }77 78 void hr_fini_devs(hr_volume_t *vol)79 {80 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_fini_devs()");81 82 size_t i;83 84 for (i = 0; i < vol->dev_no; i++)85 if (vol->extents[i].status != HR_EXT_MISSING)86 90 block_fini(vol->extents[i].svc_id); 87 } 88 89 errno_t hr_register_volume(hr_volume_t *new_volume) 90 { 91 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_register_volume()"); 91 } 92 } 93 } 94 95 errno_t hr_register_volume(hr_volume_t *vol) 96 { 97 DPRINTF("hr_register_volume()\n"); 92 98 93 99 errno_t rc; … … 95 101 category_id_t cat_id; 96 102 char *fullname = NULL; 97 98 if (asprintf(&fullname, "devices/%s", new_volume->devname) < 0) 103 char *devname = vol->devname; 104 105 if (asprintf(&fullname, "devices/%s", devname) < 0) 99 106 return ENOMEM; 100 107 101 108 rc = loc_service_register(hr_srv, fullname, &new_id); 102 109 if (rc != EOK) { 103 log_msg(LOG_DEFAULT, LVL_ERROR, 104 "unable to register device \"%s\": %s\n", 105 new_volume->devname, str_error(rc)); 110 ERR_PRINTF("unable to register device \"%s\": %s\n", 111 fullname, str_error(rc)); 106 112 goto error; 107 113 } … … 109 115 rc = loc_category_get_id("raid", &cat_id, IPC_FLAG_BLOCKING); 110 116 if (rc != EOK) { 111 log_msg(LOG_DEFAULT, LVL_ERROR,112 "failed resolving category \"raid\": %s\n",str_error(rc));117 ERR_PRINTF("failed resolving category \"raid\": %s\n", 118 str_error(rc)); 113 119 goto error; 114 120 } … … 116 122 rc = loc_service_add_to_cat(hr_srv, new_id, cat_id); 117 123 if (rc != EOK) { 118 log_msg(LOG_DEFAULT, LVL_ERROR, 119 "failed adding \"%s\" to category \"raid\": %s\n", 120 new_volume->devname, str_error(rc)); 124 ERR_PRINTF("failed adding \"%s\" to category \"raid\": %s\n", 125 fullname, str_error(rc)); 121 126 goto error; 122 127 } 123 128 124 new_volume->svc_id = new_id;129 vol->svc_id = new_id; 125 130 126 131 error: … … 131 136 errno_t hr_check_devs(hr_volume_t *vol, uint64_t *rblkno, size_t *rbsize) 132 137 { 133 log_msg(LOG_DEFAULT, LVL_NOTE, "hr_check_devs()");138 DPRINTF("hr_check_devs()\n"); 134 139 135 140 errno_t rc; … … 139 144 uint64_t last_nblocks = 0; 140 145 uint64_t total_blocks = 0; 141 142 for (i = 0; i < vol->dev_no; i++) { 143 if (vol->extents[i].status == HR_EXT_MISSING) 144 continue; 145 rc = block_get_nblocks(vol->extents[i].svc_id, &nblocks); 146 hr_extent_t *extent; 147 148 for (i = 0; i < vol->dev_no; i++) { 149 extent = &vol->extents[i]; 150 if (extent->status == HR_EXT_MISSING) 151 continue; 152 rc = block_get_nblocks(extent->svc_id, &nblocks); 146 153 if (rc != EOK) 147 154 goto error; 148 155 if (last_nblocks != 0 && nblocks != last_nblocks) { 149 log_msg(LOG_DEFAULT, LVL_ERROR, 150 "number of blocks differs"); 156 ERR_PRINTF("number of blocks differs\n"); 151 157 rc = EINVAL; 152 158 goto error; 153 159 } 160 154 161 total_blocks += nblocks; 155 162 last_nblocks = nblocks; … … 157 164 158 165 for (i = 0; i < vol->dev_no; i++) { 159 if (vol->extents[i].status == HR_EXT_MISSING) 160 continue; 161 rc = block_get_bsize(vol->extents[i].svc_id, &bsize); 166 extent = &vol->extents[i]; 167 if (extent->status == HR_EXT_MISSING) 168 continue; 169 rc = block_get_bsize(extent->svc_id, &bsize); 162 170 if (rc != EOK) 163 171 goto error; 164 172 if (last_bsize != 0 && bsize != last_bsize) { 165 log_msg(LOG_DEFAULT, LVL_ERROR, "block sizes differ");173 ERR_PRINTF("block sizes differ\n"); 166 174 rc = EINVAL; 167 175 goto error; 168 176 } 177 169 178 last_bsize = bsize; 170 179 } 171 180 172 181 if ((bsize % 512) != 0) { 173 log_msg(LOG_DEFAULT, LVL_ERROR, 174 "block size not multiple of 512"); 182 ERR_PRINTF("block size not multiple of 512\n"); 175 183 return EINVAL; 176 184 }
Note:
See TracChangeset
for help on using the changeset viewer.