Changeset d85ee06 in mainline
- Timestamp:
- 2025-04-22T11:13:11Z (4 weeks ago)
- Children:
- dd76b46
- Parents:
- a056759
- git-author:
- Miroslav Cimerman <mc@…> (2025-04-22 11:09:10)
- git-committer:
- Miroslav Cimerman <mc@…> (2025-04-22 11:13:11)
- Location:
- uspace/srv/bd/hr
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/meson.build
ra056759 rd85ee06 32 32 'hr.c', 33 33 'io.c', 34 'metadata/foreign/geom/ mirror.c',35 'metadata/foreign/geom/ stripe.c',34 'metadata/foreign/geom/hr_g_mirror.c', 35 'metadata/foreign/geom/hr_g_stripe.c', 36 36 'metadata/native.c', 37 37 'raid0.c', -
uspace/srv/bd/hr/metadata/foreign/geom/hr_g_mirror.c
ra056759 rd85ee06 103 103 (void)vol; 104 104 (void)md_v; 105 105 106 return ENOTSUP; 106 107 } … … 113 114 114 115 struct g_mirror_metadata *main_meta = NULL; 115 size_t max_counter_val = 0;116 uint64_t max_counter_val = 0; 116 117 117 118 list_foreach(*list, link, struct dev_list_member, iter) { … … 157 158 iter->fini = false; 158 159 160 /* for now no md_sync_offset handling for saved REBUILD */ 159 161 if (iter_meta->md_genid == max_counter_val) 160 162 vol->extents[index].status = HR_EXT_ONLINE; … … 291 293 } 292 294 293 /*294 * XXX: finish this fcn documentation295 *296 * Returns ENOMEM else EOK297 */298 295 static errno_t meta_gmirror_save(hr_volume_t *vol, bool with_state_callback) 299 296 { 300 297 HR_DEBUG("%s()", __func__); 301 298 302 errno_t rc = EOK; 303 304 void *md_block = calloc(1, vol->bsize); 305 if (md_block == NULL) 306 return ENOMEM; 307 308 struct g_mirror_metadata *md = vol->in_mem_md; 309 310 fibril_rwlock_read_lock(&vol->extents_lock); 311 312 fibril_mutex_lock(&vol->md_lock); 313 314 for (size_t i = 0; i < vol->extent_no; i++) { 315 hr_extent_t *ext = &vol->extents[i]; 316 317 fibril_rwlock_read_lock(&vol->states_lock); 318 319 /* TODO: special case for REBUILD */ 320 if (ext->status != HR_EXT_ONLINE) 321 continue; 322 323 fibril_rwlock_read_unlock(&vol->states_lock); 324 325 md->md_priority = i; 326 meta_gmirror_encode(md, md_block); 327 rc = meta_gmirror_write_block(ext->svc_id, md_block); 328 if (with_state_callback && rc != EOK) 329 vol->state_callback(vol, i, rc); 330 } 331 332 fibril_mutex_unlock(&vol->md_lock); 333 334 fibril_rwlock_read_unlock(&vol->extents_lock); 335 336 if (with_state_callback) 337 vol->hr_ops.status_event(vol); 338 339 free(md_block); 299 (void)vol; 300 (void)with_state_callback; 301 302 /* 303 * cannot support right now, because would need to store the 304 * metadata for all disks, because of hardcoded provider names and 305 * most importantly, disk unique ids 306 */ 307 308 /* silent */ 340 309 return EOK; 310 /* return ENOTSUP; */ 341 311 } 342 312 -
uspace/srv/bd/hr/metadata/foreign/geom/hr_g_stripe.c
ra056759 rd85ee06 53 53 #include "g_stripe.h" 54 54 55 static void *meta_ stripe_alloc_struct(void);56 static errno_t meta_ stripe_init_vol2meta(const hr_volume_t *, void *);57 static errno_t meta_ stripe_init_meta2vol(const list_t *,55 static void *meta_gstripe_alloc_struct(void); 56 static errno_t meta_gstripe_init_vol2meta(const hr_volume_t *, void *); 57 static errno_t meta_gstripe_init_meta2vol(const list_t *, 58 58 hr_volume_t *); 59 static void meta_ stripe_encode(void *, void *);60 static errno_t meta_ stripe_decode(const void *, void *);61 static errno_t meta_ stripe_get_block(service_id_t, void **);62 static errno_t meta_ stripe_write_block(service_id_t, const void *);63 static bool meta_ stripe_has_valid_magic(const void *);64 static bool meta_ stripe_compare_uuids(const void *, const void *);65 static void meta_ stripe_inc_counter(void *);66 static errno_t meta_ stripe_save(hr_volume_t *, bool);67 static const char *meta_ stripe_get_devname(const void *);68 static hr_level_t meta_ stripe_get_level(const void *);69 static uint64_t meta_ stripe_get_data_offset(void);70 static size_t meta_ stripe_get_size(void);71 static uint8_t meta_ stripe_get_flags(void);72 static hr_metadata_type_t meta_ stripe_get_type(void);73 static void meta_ stripe_dump(const void *);74 75 hr_superblock_ops_t metadata_ stripe_ops = {76 .alloc_struct = meta_ stripe_alloc_struct,77 .init_vol2meta = meta_ stripe_init_vol2meta,78 .init_meta2vol = meta_ stripe_init_meta2vol,79 .encode = meta_ stripe_encode,80 .decode = meta_ stripe_decode,81 .get_block = meta_ stripe_get_block,82 .write_block = meta_ stripe_write_block,83 .has_valid_magic = meta_ stripe_has_valid_magic,84 .compare_uuids = meta_ stripe_compare_uuids,85 .inc_counter = meta_ stripe_inc_counter,86 .save = meta_ stripe_save,87 .get_devname = meta_ stripe_get_devname,88 .get_level = meta_ stripe_get_level,89 .get_data_offset = meta_ stripe_get_data_offset,90 .get_size = meta_ stripe_get_size,91 .get_flags = meta_ stripe_get_flags,92 .get_type = meta_ stripe_get_type,93 .dump = meta_ stripe_dump59 static void meta_gstripe_encode(void *, void *); 60 static errno_t meta_gstripe_decode(const void *, void *); 61 static errno_t meta_gstripe_get_block(service_id_t, void **); 62 static errno_t meta_gstripe_write_block(service_id_t, const void *); 63 static bool meta_gstripe_has_valid_magic(const void *); 64 static bool meta_gstripe_compare_uuids(const void *, const void *); 65 static void meta_gstripe_inc_counter(void *); 66 static errno_t meta_gstripe_save(hr_volume_t *, bool); 67 static const char *meta_gstripe_get_devname(const void *); 68 static hr_level_t meta_gstripe_get_level(const void *); 69 static uint64_t meta_gstripe_get_data_offset(void); 70 static size_t meta_gstripe_get_size(void); 71 static uint8_t meta_gstripe_get_flags(void); 72 static hr_metadata_type_t meta_gstripe_get_type(void); 73 static void meta_gstripe_dump(const void *); 74 75 hr_superblock_ops_t metadata_gstripe_ops = { 76 .alloc_struct = meta_gstripe_alloc_struct, 77 .init_vol2meta = meta_gstripe_init_vol2meta, 78 .init_meta2vol = meta_gstripe_init_meta2vol, 79 .encode = meta_gstripe_encode, 80 .decode = meta_gstripe_decode, 81 .get_block = meta_gstripe_get_block, 82 .write_block = meta_gstripe_write_block, 83 .has_valid_magic = meta_gstripe_has_valid_magic, 84 .compare_uuids = meta_gstripe_compare_uuids, 85 .inc_counter = meta_gstripe_inc_counter, 86 .save = meta_gstripe_save, 87 .get_devname = meta_gstripe_get_devname, 88 .get_level = meta_gstripe_get_level, 89 .get_data_offset = meta_gstripe_get_data_offset, 90 .get_size = meta_gstripe_get_size, 91 .get_flags = meta_gstripe_get_flags, 92 .get_type = meta_gstripe_get_type, 93 .dump = meta_gstripe_dump 94 94 }; 95 95 96 static void *meta_ stripe_alloc_struct(void)96 static void *meta_gstripe_alloc_struct(void) 97 97 { 98 98 return calloc(1, sizeof(struct g_stripe_metadata)); 99 99 } 100 100 101 static errno_t meta_ stripe_init_vol2meta(const hr_volume_t *vol, void *md_v)101 static errno_t meta_gstripe_init_vol2meta(const hr_volume_t *vol, void *md_v) 102 102 { 103 103 (void)vol; … … 106 106 } 107 107 108 static errno_t meta_ stripe_init_meta2vol(const list_t *list, hr_volume_t *vol)108 static errno_t meta_gstripe_init_meta2vol(const list_t *list, hr_volume_t *vol) 109 109 { 110 110 HR_DEBUG("%s()", __func__); … … 128 128 struct g_stripe_metadata *iter_meta = iter->md; 129 129 130 meta_ stripe_dump(iter_meta);130 meta_gstripe_dump(iter_meta); 131 131 132 132 if (iter_meta->md_provsize < smallest_provider_size) { … … 179 179 } 180 180 181 static void meta_ stripe_encode(void *md_v, void *block)181 static void meta_gstripe_encode(void *md_v, void *block) 182 182 { 183 183 HR_DEBUG("%s()", __func__); … … 186 186 } 187 187 188 static errno_t meta_ stripe_decode(const void *block, void *md_v)188 static errno_t meta_gstripe_decode(const void *block, void *md_v) 189 189 { 190 190 HR_DEBUG("%s()", __func__); … … 195 195 } 196 196 197 static errno_t meta_ stripe_get_block(service_id_t dev, void **rblock)197 static errno_t meta_gstripe_get_block(service_id_t dev, void **rblock) 198 198 { 199 199 HR_DEBUG("%s()", __func__); … … 240 240 } 241 241 242 static errno_t meta_ stripe_write_block(service_id_t dev, const void *block)242 static errno_t meta_gstripe_write_block(service_id_t dev, const void *block) 243 243 { 244 244 HR_DEBUG("%s()", __func__); … … 267 267 } 268 268 269 static bool meta_ stripe_has_valid_magic(const void *md_v)269 static bool meta_gstripe_has_valid_magic(const void *md_v) 270 270 { 271 271 HR_DEBUG("%s()", __func__); … … 279 279 } 280 280 281 static bool meta_ stripe_compare_uuids(const void *md1_v, const void *md2_v)281 static bool meta_gstripe_compare_uuids(const void *md1_v, const void *md2_v) 282 282 { 283 283 const struct g_stripe_metadata *md1 = md1_v; … … 289 289 } 290 290 291 static void meta_ stripe_inc_counter(void *md_v)291 static void meta_gstripe_inc_counter(void *md_v) 292 292 { 293 293 (void)md_v; 294 294 } 295 295 296 static errno_t meta_ stripe_save(hr_volume_t *vol, bool with_state_callback)296 static errno_t meta_gstripe_save(hr_volume_t *vol, bool with_state_callback) 297 297 { 298 298 HR_DEBUG("%s()", __func__); … … 301 301 } 302 302 303 static const char *meta_ stripe_get_devname(const void *md_v)303 static const char *meta_gstripe_get_devname(const void *md_v) 304 304 { 305 305 const struct g_stripe_metadata *md = md_v; … … 308 308 } 309 309 310 static hr_level_t meta_ stripe_get_level(const void *md_v)310 static hr_level_t meta_gstripe_get_level(const void *md_v) 311 311 { 312 312 (void)md_v; … … 315 315 } 316 316 317 static uint64_t meta_ stripe_get_data_offset(void)317 static uint64_t meta_gstripe_get_data_offset(void) 318 318 { 319 319 return 0; 320 320 } 321 321 322 static size_t meta_ stripe_get_size(void)322 static size_t meta_gstripe_get_size(void) 323 323 { 324 324 return 1; 325 325 } 326 326 327 static uint8_t meta_ stripe_get_flags(void)327 static uint8_t meta_gstripe_get_flags(void) 328 328 { 329 329 uint8_t flags = 0; … … 332 332 } 333 333 334 static hr_metadata_type_t meta_ stripe_get_type(void)334 static hr_metadata_type_t meta_gstripe_get_type(void) 335 335 { 336 336 return HR_METADATA_GEOM_STRIPE; 337 337 } 338 338 339 static void meta_ stripe_dump(const void *md_v)339 static void meta_gstripe_dump(const void *md_v) 340 340 { 341 341 HR_DEBUG("%s()", __func__); -
uspace/srv/bd/hr/superblock.c
ra056759 rd85ee06 52 52 #include "metadata/foreign/geom/g_mirror.h" 53 53 #include "metadata/foreign/geom/g_stripe.h" 54 #include "metadata/foreign/softraid/softraidvar.h" 55 54 56 #include "metadata/native.h" 55 57 56 58 extern hr_superblock_ops_t metadata_native_ops; 57 59 extern hr_superblock_ops_t metadata_gmirror_ops; 58 extern hr_superblock_ops_t metadata_ stripe_ops;60 extern hr_superblock_ops_t metadata_gstripe_ops; 59 61 60 62 static hr_superblock_ops_t *hr_superblock_ops_all[] = { 61 63 [HR_METADATA_NATIVE] = &metadata_native_ops, 62 64 [HR_METADATA_GEOM_MIRROR] = &metadata_gmirror_ops, 63 [HR_METADATA_GEOM_STRIPE] = &metadata_ stripe_ops65 [HR_METADATA_GEOM_STRIPE] = &metadata_gstripe_ops 64 66 }; 65 67
Note:
See TracChangeset
for help on using the changeset viewer.