Changeset aa9bad8 in mainline for uspace/srv/bd/hr/metadata/foreign


Ignore:
Timestamp:
2025-06-27T22:21:05Z (4 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
2de7c1f
Parents:
78433bb
git-author:
Miroslav Cimerman <mc@…> (2025-06-27 22:14:37)
git-committer:
Miroslav Cimerman <mc@…> (2025-06-27 22:21:05)
Message:

hr: let each format implement own probe

This will allow metadata to have superblocks in
different locations accross versions.

This also greatly reduces the format handling interface,
because now, functions used by the probing done
publicly in superblock.c are now used just
inside specific metadata format code.

Location:
uspace/srv/bd/hr/metadata/foreign
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/metadata/foreign/geom/hr_g_mirror.c

    r78433bb raa9bad8  
    5454#include "g_mirror.h"
    5555
     56/* not exposed */
    5657static void *meta_gmirror_alloc_struct(void);
     58/* static void meta_gmirror_encode(void *, void *); */
     59static errno_t meta_gmirror_decode(const void *, void *);
     60static errno_t meta_gmirror_get_block(service_id_t, void **);
     61/* static errno_t meta_gmirror_write_block(service_id_t, const void *); */
     62static bool meta_gmirror_has_valid_magic(const void *);
     63
     64static errno_t meta_gmirror_probe(service_id_t, void **);
    5765static errno_t meta_gmirror_init_vol2meta(hr_volume_t *);
    5866static errno_t meta_gmirror_init_meta2vol(const list_t *, hr_volume_t *);
    59 static void meta_gmirror_encode(void *, void *);
    60 static errno_t meta_gmirror_decode(const void *, void *);
    61 static errno_t meta_gmirror_get_block(service_id_t, void **);
    62 static errno_t meta_gmirror_write_block(service_id_t, const void *);
    63 static bool meta_gmirror_has_valid_magic(const void *);
    6467static bool meta_gmirror_compare_uuids(const void *, const void *);
    6568static void meta_gmirror_inc_counter(hr_volume_t *);
     
    7578
    7679hr_superblock_ops_t metadata_gmirror_ops = {
    77         .alloc_struct = meta_gmirror_alloc_struct,
     80        .probe = meta_gmirror_probe,
    7881        .init_vol2meta = meta_gmirror_init_vol2meta,
    7982        .init_meta2vol = meta_gmirror_init_meta2vol,
    80         .encode = meta_gmirror_encode,
    81         .decode = meta_gmirror_decode,
    82         .get_block = meta_gmirror_get_block,
    83         .write_block = meta_gmirror_write_block,
    84         .has_valid_magic = meta_gmirror_has_valid_magic,
    8583        .compare_uuids = meta_gmirror_compare_uuids,
    8684        .inc_counter = meta_gmirror_inc_counter,
     
    9694};
    9795
    98 static void *meta_gmirror_alloc_struct(void)
    99 {
    100         return calloc(1, sizeof(struct g_mirror_metadata));
     96static errno_t meta_gmirror_probe(service_id_t svc_id, void **rmd)
     97{
     98        errno_t rc;
     99        void *meta_block;
     100
     101        void *metadata_struct = meta_gmirror_alloc_struct();
     102        if (metadata_struct == NULL)
     103                return ENOMEM;
     104
     105        rc = meta_gmirror_get_block(svc_id, &meta_block);
     106        if (rc != EOK)
     107                goto error;
     108
     109        rc = meta_gmirror_decode(meta_block, metadata_struct);
     110
     111        free(meta_block);
     112
     113        if (rc != EOK)
     114                goto error;
     115
     116        if (!meta_gmirror_has_valid_magic(metadata_struct)) {
     117                rc = ENOFS;
     118                goto error;
     119        }
     120
     121        *rmd = metadata_struct;
     122        return EOK;
     123
     124error:
     125        free(metadata_struct);
     126        return ENOFS;
    101127}
    102128
     
    177203}
    178204
     205static bool meta_gmirror_compare_uuids(const void *m1_v, const void *m2_v)
     206{
     207        const struct g_mirror_metadata *m1 = m1_v;
     208        const struct g_mirror_metadata *m2 = m2_v;
     209        if (m1->md_mid == m2->md_mid)
     210                return true;
     211
     212        return false;
     213}
     214
     215static void meta_gmirror_inc_counter(hr_volume_t *vol)
     216{
     217        fibril_mutex_lock(&vol->md_lock);
     218
     219        struct g_mirror_metadata *md = vol->in_mem_md;
     220
     221        /* XXX: probably md_genid and not md_syncid is incremented */
     222        md->md_genid++;
     223
     224        fibril_mutex_unlock(&vol->md_lock);
     225}
     226
     227static errno_t meta_gmirror_save(hr_volume_t *vol, bool with_state_callback)
     228{
     229        HR_DEBUG("%s()", __func__);
     230
     231        (void)vol;
     232        (void)with_state_callback;
     233
     234        /*
     235         * cannot support right now, because would need to store the
     236         * metadata for all disks, because of hardcoded provider names and
     237         * more importantly, disk unique ids
     238         */
     239
     240        return ENOTSUP;
     241}
     242
     243static errno_t meta_gmirror_save_ext(hr_volume_t *vol, size_t ext_idx,
     244    bool with_state_callback)
     245{
     246        HR_DEBUG("%s()", __func__);
     247
     248        return ENOTSUP;
     249}
     250
     251static const char *meta_gmirror_get_devname(const void *md_v)
     252{
     253        const struct g_mirror_metadata *md = md_v;
     254
     255        return md->md_name;
     256}
     257
     258static hr_level_t meta_gmirror_get_level(const void *md_v)
     259{
     260        (void)md_v;
     261
     262        return HR_LVL_1;
     263}
     264
     265static uint64_t meta_gmirror_get_data_offset(void)
     266{
     267        return 0;
     268}
     269
     270static size_t meta_gmirror_get_size(void)
     271{
     272        return 1;
     273}
     274
     275static uint8_t meta_gmirror_get_flags(void)
     276{
     277        uint8_t flags = 0;
     278
     279        return flags;
     280}
     281
     282static hr_metadata_type_t meta_gmirror_get_type(void)
     283{
     284        return  HR_METADATA_GEOM_MIRROR;
     285}
     286
     287static void meta_gmirror_dump(const void *md_v)
     288{
     289        HR_DEBUG("%s()", __func__);
     290
     291        mirror_metadata_dump(md_v);
     292}
     293
     294static void *meta_gmirror_alloc_struct(void)
     295{
     296        return calloc(1, sizeof(struct g_mirror_metadata));
     297}
     298
     299#if 0
    179300static void meta_gmirror_encode(void *md_v, void *block)
    180301{
     
    183304        mirror_metadata_encode(md_v, block);
    184305}
     306#endif
    185307
    186308static errno_t meta_gmirror_decode(const void *block, void *md_v)
     
    237359}
    238360
     361#if 0
    239362static errno_t meta_gmirror_write_block(service_id_t dev, const void *block)
    240363{
     
    263386        return rc;
    264387}
     388#endif
    265389
    266390static bool meta_gmirror_has_valid_magic(const void *md_v)
     
    276400}
    277401
    278 static bool meta_gmirror_compare_uuids(const void *m1_v, const void *m2_v)
    279 {
    280         const struct g_mirror_metadata *m1 = m1_v;
    281         const struct g_mirror_metadata *m2 = m2_v;
    282         if (m1->md_mid == m2->md_mid)
    283                 return true;
    284 
    285         return false;
    286 }
    287 
    288 static void meta_gmirror_inc_counter(hr_volume_t *vol)
    289 {
    290         fibril_mutex_lock(&vol->md_lock);
    291 
    292         struct g_mirror_metadata *md = vol->in_mem_md;
    293 
    294         /* XXX: probably md_genid and not md_syncid is incremented */
    295         md->md_genid++;
    296 
    297         fibril_mutex_unlock(&vol->md_lock);
    298 }
    299 
    300 static errno_t meta_gmirror_save(hr_volume_t *vol, bool with_state_callback)
    301 {
    302         HR_DEBUG("%s()", __func__);
    303 
    304         (void)vol;
    305         (void)with_state_callback;
    306 
    307         /*
    308          * cannot support right now, because would need to store the
    309          * metadata for all disks, because of hardcoded provider names and
    310          * more importantly, disk unique ids
    311          */
    312 
    313         return ENOTSUP;
    314 }
    315 
    316 static errno_t meta_gmirror_save_ext(hr_volume_t *vol, size_t ext_idx,
    317     bool with_state_callback)
    318 {
    319         HR_DEBUG("%s()", __func__);
    320 
    321         return ENOTSUP;
    322 }
    323 
    324 static const char *meta_gmirror_get_devname(const void *md_v)
    325 {
    326         const struct g_mirror_metadata *md = md_v;
    327 
    328         return md->md_name;
    329 }
    330 
    331 static hr_level_t meta_gmirror_get_level(const void *md_v)
    332 {
    333         (void)md_v;
    334 
    335         return HR_LVL_1;
    336 }
    337 
    338 static uint64_t meta_gmirror_get_data_offset(void)
    339 {
    340         return 0;
    341 }
    342 
    343 static size_t meta_gmirror_get_size(void)
    344 {
    345         return 1;
    346 }
    347 
    348 static uint8_t meta_gmirror_get_flags(void)
    349 {
    350         uint8_t flags = 0;
    351 
    352         return flags;
    353 }
    354 
    355 static hr_metadata_type_t meta_gmirror_get_type(void)
    356 {
    357         return  HR_METADATA_GEOM_MIRROR;
    358 }
    359 
    360 static void meta_gmirror_dump(const void *md_v)
    361 {
    362         HR_DEBUG("%s()", __func__);
    363 
    364         mirror_metadata_dump(md_v);
    365 }
    366 
    367402/** @}
    368403 */
  • uspace/srv/bd/hr/metadata/foreign/geom/hr_g_stripe.c

    r78433bb raa9bad8  
    5454#include "g_stripe.h"
    5555
     56/* not exposed */
    5657static void *meta_gstripe_alloc_struct(void);
     58/* static void meta_gstripe_encode(void *, void *); */
     59static errno_t meta_gstripe_decode(const void *, void *);
     60static errno_t meta_gstripe_get_block(service_id_t, void **);
     61/* static errno_t meta_gstripe_write_block(service_id_t, const void *); */
     62static bool meta_gstripe_has_valid_magic(const void *);
     63
     64static errno_t meta_gstripe_probe(service_id_t, void **);
    5765static errno_t meta_gstripe_init_vol2meta(hr_volume_t *);
    5866static errno_t meta_gstripe_init_meta2vol(const list_t *, hr_volume_t *);
    59 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 *);
    6467static bool meta_gstripe_compare_uuids(const void *, const void *);
    6568static void meta_gstripe_inc_counter(hr_volume_t *);
     
    7578
    7679hr_superblock_ops_t metadata_gstripe_ops = {
    77         .alloc_struct = meta_gstripe_alloc_struct,
     80        .probe = meta_gstripe_probe,
    7881        .init_vol2meta = meta_gstripe_init_vol2meta,
    7982        .init_meta2vol = meta_gstripe_init_meta2vol,
    80         .encode = meta_gstripe_encode,
    81         .decode = meta_gstripe_decode,
    82         .get_block = meta_gstripe_get_block,
    83         .write_block = meta_gstripe_write_block,
    84         .has_valid_magic = meta_gstripe_has_valid_magic,
    8583        .compare_uuids = meta_gstripe_compare_uuids,
    8684        .inc_counter = meta_gstripe_inc_counter,
     
    9694};
    9795
    98 static void *meta_gstripe_alloc_struct(void)
    99 {
    100         return calloc(1, sizeof(struct g_stripe_metadata));
     96static errno_t meta_gstripe_probe(service_id_t svc_id, void **rmd)
     97{
     98        errno_t rc;
     99        void *meta_block;
     100
     101        void *metadata_struct = meta_gstripe_alloc_struct();
     102        if (metadata_struct == NULL)
     103                return ENOMEM;
     104
     105        rc = meta_gstripe_get_block(svc_id, &meta_block);
     106        if (rc != EOK)
     107                goto error;
     108
     109        rc = meta_gstripe_decode(meta_block, metadata_struct);
     110
     111        free(meta_block);
     112
     113        if (rc != EOK)
     114                goto error;
     115
     116        if (!meta_gstripe_has_valid_magic(metadata_struct)) {
     117                rc = ENOFS;
     118                goto error;
     119        }
     120
     121        *rmd = metadata_struct;
     122        return EOK;
     123
     124error:
     125        free(metadata_struct);
     126        return ENOFS;
    101127}
    102128
     
    178204}
    179205
     206static bool meta_gstripe_compare_uuids(const void *md1_v, const void *md2_v)
     207{
     208        const struct g_stripe_metadata *md1 = md1_v;
     209        const struct g_stripe_metadata *md2 = md2_v;
     210        if (md1->md_id == md2->md_id)
     211                return true;
     212
     213        return false;
     214}
     215
     216static void meta_gstripe_inc_counter(hr_volume_t *vol)
     217{
     218        (void)vol;
     219}
     220
     221static errno_t meta_gstripe_save(hr_volume_t *vol, bool with_state_callback)
     222{
     223        HR_DEBUG("%s()", __func__);
     224
     225        return ENOTSUP;
     226}
     227
     228static errno_t meta_gstripe_save_ext(hr_volume_t *vol, size_t ext_idx,
     229    bool with_state_callback)
     230{
     231        HR_DEBUG("%s()", __func__);
     232
     233        return ENOTSUP;
     234}
     235
     236static const char *meta_gstripe_get_devname(const void *md_v)
     237{
     238        const struct g_stripe_metadata *md = md_v;
     239
     240        return md->md_name;
     241}
     242
     243static hr_level_t meta_gstripe_get_level(const void *md_v)
     244{
     245        (void)md_v;
     246
     247        return HR_LVL_0;
     248}
     249
     250static uint64_t meta_gstripe_get_data_offset(void)
     251{
     252        return 0;
     253}
     254
     255static size_t meta_gstripe_get_size(void)
     256{
     257        return 1;
     258}
     259
     260static uint8_t meta_gstripe_get_flags(void)
     261{
     262        uint8_t flags = 0;
     263
     264        return flags;
     265}
     266
     267static hr_metadata_type_t meta_gstripe_get_type(void)
     268{
     269        return HR_METADATA_GEOM_STRIPE;
     270}
     271
     272static void meta_gstripe_dump(const void *md_v)
     273{
     274        HR_DEBUG("%s()", __func__);
     275
     276        const struct g_stripe_metadata *md = md_v;
     277
     278        printf("     magic: %s\n", md->md_magic);
     279        printf("   version: %u\n", (u_int)md->md_version);
     280        printf("      name: %s\n", md->md_name);
     281        printf("        id: %u\n", (u_int)md->md_id);
     282        printf("        no: %u\n", (u_int)md->md_no);
     283        printf("       all: %u\n", (u_int)md->md_all);
     284        printf("stripesize: %u\n", (u_int)md->md_stripesize);
     285        printf(" mediasize: %jd\n", (intmax_t)md->md_provsize);
     286}
     287
     288static void *meta_gstripe_alloc_struct(void)
     289{
     290        return calloc(1, sizeof(struct g_stripe_metadata));
     291}
     292
     293#if 0
    180294static void meta_gstripe_encode(void *md_v, void *block)
    181295{
     
    184298        stripe_metadata_encode(md_v, block);
    185299}
     300#endif
    186301
    187302static errno_t meta_gstripe_decode(const void *block, void *md_v)
     
    239354}
    240355
     356#if 0
    241357static errno_t meta_gstripe_write_block(service_id_t dev, const void *block)
    242358{
     
    265381        return rc;
    266382}
     383#endif
    267384
    268385static bool meta_gstripe_has_valid_magic(const void *md_v)
     
    278395}
    279396
    280 static bool meta_gstripe_compare_uuids(const void *md1_v, const void *md2_v)
    281 {
    282         const struct g_stripe_metadata *md1 = md1_v;
    283         const struct g_stripe_metadata *md2 = md2_v;
    284         if (md1->md_id == md2->md_id)
    285                 return true;
    286 
    287         return false;
    288 }
    289 
    290 static void meta_gstripe_inc_counter(hr_volume_t *vol)
    291 {
    292         (void)vol;
    293 }
    294 
    295 static errno_t meta_gstripe_save(hr_volume_t *vol, bool with_state_callback)
    296 {
    297         HR_DEBUG("%s()", __func__);
    298 
    299         return ENOTSUP;
    300 }
    301 
    302 static errno_t meta_gstripe_save_ext(hr_volume_t *vol, size_t ext_idx,
    303     bool with_state_callback)
    304 {
    305         HR_DEBUG("%s()", __func__);
    306 
    307         return ENOTSUP;
    308 }
    309 
    310 static const char *meta_gstripe_get_devname(const void *md_v)
    311 {
    312         const struct g_stripe_metadata *md = md_v;
    313 
    314         return md->md_name;
    315 }
    316 
    317 static hr_level_t meta_gstripe_get_level(const void *md_v)
    318 {
    319         (void)md_v;
    320 
    321         return HR_LVL_0;
    322 }
    323 
    324 static uint64_t meta_gstripe_get_data_offset(void)
    325 {
    326         return 0;
    327 }
    328 
    329 static size_t meta_gstripe_get_size(void)
    330 {
    331         return 1;
    332 }
    333 
    334 static uint8_t meta_gstripe_get_flags(void)
    335 {
    336         uint8_t flags = 0;
    337 
    338         return flags;
    339 }
    340 
    341 static hr_metadata_type_t meta_gstripe_get_type(void)
    342 {
    343         return  HR_METADATA_GEOM_STRIPE;
    344 }
    345 
    346 static void meta_gstripe_dump(const void *md_v)
    347 {
    348         HR_DEBUG("%s()", __func__);
    349 
    350         const struct g_stripe_metadata *md = md_v;
    351 
    352         printf("     magic: %s\n", md->md_magic);
    353         printf("   version: %u\n", (u_int)md->md_version);
    354         printf("      name: %s\n", md->md_name);
    355         printf("        id: %u\n", (u_int)md->md_id);
    356         printf("        no: %u\n", (u_int)md->md_no);
    357         printf("       all: %u\n", (u_int)md->md_all);
    358         printf("stripesize: %u\n", (u_int)md->md_stripesize);
    359         printf(" mediasize: %jd\n", (intmax_t)md->md_provsize);
    360 }
    361 
    362397/** @}
    363398 */
  • uspace/srv/bd/hr/metadata/foreign/softraid/hr_softraid.c

    r78433bb raa9bad8  
    5454#include "softraidvar.h"
    5555
     56/* not exposed */
    5657static void *meta_softraid_alloc_struct(void);
     58/* static void meta_softraid_encode(void *, void *); */
     59static errno_t meta_softraid_decode(const void *, void *);
     60static errno_t meta_softraid_get_block(service_id_t, void **);
     61/* static errno_t meta_softraid_write_block(service_id_t, const void *); */
     62static bool meta_softraid_has_valid_magic(const void *);
     63
     64static errno_t meta_softraid_probe(service_id_t, void **);
    5765static errno_t meta_softraid_init_vol2meta(hr_volume_t *);
    5866static errno_t meta_softraid_init_meta2vol(const list_t *, hr_volume_t *);
    59 static void meta_softraid_encode(void *, void *);
    60 static errno_t meta_softraid_decode(const void *, void *);
    61 static errno_t meta_softraid_get_block(service_id_t, void **);
    62 static errno_t meta_softraid_write_block(service_id_t, const void *);
    63 static bool meta_softraid_has_valid_magic(const void *);
    6467static bool meta_softraid_compare_uuids(const void *, const void *);
    6568static void meta_softraid_inc_counter(hr_volume_t *);
     
    7578
    7679hr_superblock_ops_t metadata_softraid_ops = {
    77         .alloc_struct = meta_softraid_alloc_struct,
     80        .probe = meta_softraid_probe,
    7881        .init_vol2meta = meta_softraid_init_vol2meta,
    7982        .init_meta2vol = meta_softraid_init_meta2vol,
    80         .encode = meta_softraid_encode,
    81         .decode = meta_softraid_decode,
    82         .get_block = meta_softraid_get_block,
    83         .write_block = meta_softraid_write_block,
    84         .has_valid_magic = meta_softraid_has_valid_magic,
    8583        .compare_uuids = meta_softraid_compare_uuids,
    8684        .inc_counter = meta_softraid_inc_counter,
     
    9694};
    9795
    98 static void *meta_softraid_alloc_struct(void)
    99 {
    100         return calloc(1, SR_META_SIZE * DEV_BSIZE);
     96static errno_t meta_softraid_probe(service_id_t svc_id, void **rmd)
     97{
     98        errno_t rc;
     99        void *meta_block;
     100
     101        void *metadata_struct = meta_softraid_alloc_struct();
     102        if (metadata_struct == NULL)
     103                return ENOMEM;
     104
     105        rc = meta_softraid_get_block(svc_id, &meta_block);
     106        if (rc != EOK)
     107                goto error;
     108
     109        rc = meta_softraid_decode(meta_block, metadata_struct);
     110
     111        free(meta_block);
     112
     113        if (rc != EOK)
     114                goto error;
     115
     116        if (!meta_softraid_has_valid_magic(metadata_struct)) {
     117                rc = ENOFS;
     118                goto error;
     119        }
     120
     121        *rmd = metadata_struct;
     122        return EOK;
     123
     124error:
     125        free(metadata_struct);
     126        return ENOFS;
    101127}
    102128
     
    181207}
    182208
     209static bool meta_softraid_compare_uuids(const void *m1_v, const void *m2_v)
     210{
     211        const struct sr_metadata *m1 = m1_v;
     212        const struct sr_metadata *m2 = m2_v;
     213        if (memcmp(&m1->ssdi.ssd_uuid, &m2->ssdi.ssd_uuid,
     214            SR_UUID_MAX) == 0)
     215                return true;
     216
     217        return false;
     218}
     219
     220static void meta_softraid_inc_counter(hr_volume_t *vol)
     221{
     222        fibril_mutex_lock(&vol->md_lock);
     223
     224        struct sr_metadata *md = vol->in_mem_md;
     225
     226        md->ssd_ondisk++;
     227
     228        fibril_mutex_unlock(&vol->md_lock);
     229}
     230
     231static errno_t meta_softraid_save(hr_volume_t *vol, bool with_state_callback)
     232{
     233        HR_DEBUG("%s()", __func__);
     234
     235        return ENOTSUP;
     236}
     237
     238static errno_t meta_softraid_save_ext(hr_volume_t *vol, size_t ext_idx,
     239    bool with_state_callback)
     240{
     241        HR_DEBUG("%s()", __func__);
     242
     243        return ENOTSUP;
     244}
     245
     246static const char *meta_softraid_get_devname(const void *md_v)
     247{
     248        const struct sr_metadata *md = md_v;
     249
     250        return md->ssd_devname;
     251}
     252
     253static hr_level_t meta_softraid_get_level(const void *md_v)
     254{
     255        const struct sr_metadata *md = md_v;
     256
     257        switch (md->ssdi.ssd_level) {
     258        case 0:
     259                return HR_LVL_0;
     260        case 1:
     261                return HR_LVL_1;
     262        case 5:
     263                return HR_LVL_5;
     264        default:
     265                return HR_LVL_UNKNOWN;
     266        }
     267}
     268
     269static uint64_t meta_softraid_get_data_offset(void)
     270{
     271        return SR_DATA_OFFSET;
     272}
     273
     274static size_t meta_softraid_get_size(void)
     275{
     276        return SR_META_SIZE;
     277}
     278
     279static uint8_t meta_softraid_get_flags(void)
     280{
     281        uint8_t flags = 0;
     282
     283        return flags;
     284}
     285
     286static hr_metadata_type_t meta_softraid_get_type(void)
     287{
     288        return HR_METADATA_SOFTRAID;
     289}
     290
     291static void meta_softraid_dump(const void *md_v)
     292{
     293        HR_DEBUG("%s()", __func__);
     294
     295        const struct sr_metadata *md = md_v;
     296
     297        sr_meta_print(md);
     298}
     299
     300static void *meta_softraid_alloc_struct(void)
     301{
     302        return calloc(1, SR_META_SIZE * DEV_BSIZE);
     303}
     304
     305#if 0
    183306static void meta_softraid_encode(void *md_v, void *block)
    184307{
     
    188311        (void)block;
    189312}
     313#endif
    190314
    191315static errno_t meta_softraid_decode(const void *block, void *md_v)
     
    372496}
    373497
     498#if 0
    374499static errno_t meta_softraid_write_block(service_id_t dev, const void *block)
    375500{
     
    398523        return rc;
    399524}
     525#endif
    400526
    401527static bool meta_softraid_has_valid_magic(const void *md_v)
     
    411537}
    412538
    413 static bool meta_softraid_compare_uuids(const void *m1_v, const void *m2_v)
    414 {
    415         const struct sr_metadata *m1 = m1_v;
    416         const struct sr_metadata *m2 = m2_v;
    417         if (memcmp(&m1->ssdi.ssd_uuid, &m2->ssdi.ssd_uuid,
    418             SR_UUID_MAX) == 0)
    419                 return true;
    420 
    421         return false;
    422 }
    423 
    424 static void meta_softraid_inc_counter(hr_volume_t *vol)
    425 {
    426         fibril_mutex_lock(&vol->md_lock);
    427 
    428         struct sr_metadata *md = vol->in_mem_md;
    429 
    430         md->ssd_ondisk++;
    431 
    432         fibril_mutex_unlock(&vol->md_lock);
    433 }
    434 
    435 static errno_t meta_softraid_save(hr_volume_t *vol, bool with_state_callback)
    436 {
    437         HR_DEBUG("%s()", __func__);
    438 
    439         return ENOTSUP;
    440 }
    441 
    442 static errno_t meta_softraid_save_ext(hr_volume_t *vol, size_t ext_idx,
    443     bool with_state_callback)
    444 {
    445         HR_DEBUG("%s()", __func__);
    446 
    447         return ENOTSUP;
    448 }
    449 
    450 static const char *meta_softraid_get_devname(const void *md_v)
    451 {
    452         const struct sr_metadata *md = md_v;
    453 
    454         return md->ssd_devname;
    455 }
    456 
    457 static hr_level_t meta_softraid_get_level(const void *md_v)
    458 {
    459         const struct sr_metadata *md = md_v;
    460 
    461         switch (md->ssdi.ssd_level) {
    462         case 0:
    463                 return HR_LVL_0;
    464         case 1:
    465                 return HR_LVL_1;
    466         case 5:
    467                 return HR_LVL_5;
    468         default:
    469                 return HR_LVL_UNKNOWN;
    470         }
    471 }
    472 
    473 static uint64_t meta_softraid_get_data_offset(void)
    474 {
    475         return SR_DATA_OFFSET;
    476 }
    477 
    478 static size_t meta_softraid_get_size(void)
    479 {
    480         return SR_META_SIZE;
    481 }
    482 
    483 static uint8_t meta_softraid_get_flags(void)
    484 {
    485         uint8_t flags = 0;
    486 
    487         return flags;
    488 }
    489 
    490 static hr_metadata_type_t meta_softraid_get_type(void)
    491 {
    492         return HR_METADATA_SOFTRAID;
    493 }
    494 
    495 static void meta_softraid_dump(const void *md_v)
    496 {
    497         HR_DEBUG("%s()", __func__);
    498 
    499         const struct sr_metadata *md = md_v;
    500 
    501         sr_meta_print(md);
    502 }
    503 
    504539/** @}
    505540 */
Note: See TracChangeset for help on using the changeset viewer.