Changeset 78433bb in mainline


Ignore:
Timestamp:
2025-06-27T21:02:40Z (4 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
aa9bad8
Parents:
c69cbef
git-author:
Miroslav Cimerman <mc@…> (2025-06-27 21:01:51)
git-committer:
Miroslav Cimerman <mc@…> (2025-06-27 21:02:40)
Message:

hr: allocate in-memory metadata in format code

This will allow some formats to store in-memory
copy of metadata for each extent.

Location:
uspace/srv/bd/hr
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/hr.c

    rc69cbef r78433bb  
    147147                goto error;
    148148
    149         rc = vol->meta_ops->init_vol2meta(vol, vol->in_mem_md);
     149        rc = vol->meta_ops->init_vol2meta(vol);
    150150        if (rc != EOK)
    151151                goto error;
  • uspace/srv/bd/hr/metadata/foreign/geom/hr_g_mirror.c

    rc69cbef r78433bb  
    5555
    5656static void *meta_gmirror_alloc_struct(void);
    57 static errno_t meta_gmirror_init_vol2meta(const hr_volume_t *, void *);
     57static errno_t meta_gmirror_init_vol2meta(hr_volume_t *);
    5858static errno_t meta_gmirror_init_meta2vol(const list_t *, hr_volume_t *);
    5959static void meta_gmirror_encode(void *, void *);
     
    101101}
    102102
    103 static errno_t meta_gmirror_init_vol2meta(const hr_volume_t *vol, void *md_v)
     103static errno_t meta_gmirror_init_vol2meta(hr_volume_t *vol)
    104104{
    105105        (void)vol;
    106         (void)md_v;
    107106
    108107        return ENOTSUP;
  • uspace/srv/bd/hr/metadata/foreign/geom/hr_g_stripe.c

    rc69cbef r78433bb  
    5555
    5656static void *meta_gstripe_alloc_struct(void);
    57 static errno_t meta_gstripe_init_vol2meta(const hr_volume_t *, void *);
     57static errno_t meta_gstripe_init_vol2meta(hr_volume_t *);
    5858static errno_t meta_gstripe_init_meta2vol(const list_t *, hr_volume_t *);
    5959static void meta_gstripe_encode(void *, void *);
     
    101101}
    102102
    103 static errno_t meta_gstripe_init_vol2meta(const hr_volume_t *vol, void *md_v)
     103static errno_t meta_gstripe_init_vol2meta(hr_volume_t *vol)
    104104{
    105105        (void)vol;
    106         (void)md_v;
    107106        return ENOTSUP;
    108107}
  • uspace/srv/bd/hr/metadata/foreign/softraid/hr_softraid.c

    rc69cbef r78433bb  
    5555
    5656static void *meta_softraid_alloc_struct(void);
    57 static errno_t meta_softraid_init_vol2meta(const hr_volume_t *, void *);
     57static errno_t meta_softraid_init_vol2meta(hr_volume_t *);
    5858static errno_t meta_softraid_init_meta2vol(const list_t *, hr_volume_t *);
    5959static void meta_softraid_encode(void *, void *);
     
    101101}
    102102
    103 static errno_t meta_softraid_init_vol2meta(const hr_volume_t *vol, void *md_v)
     103static errno_t meta_softraid_init_vol2meta(hr_volume_t *vol)
    104104{
    105105        (void)vol;
    106         (void)md_v;
     106
    107107        return ENOTSUP;
    108108}
  • uspace/srv/bd/hr/metadata/native.c

    rc69cbef r78433bb  
    5555
    5656static void *meta_native_alloc_struct(void);
    57 static errno_t meta_native_init_vol2meta(const hr_volume_t *, void *);
     57static errno_t meta_native_init_vol2meta(hr_volume_t *);
    5858static errno_t meta_native_init_meta2vol(const list_t *, hr_volume_t *);
    5959static void meta_native_encode(void *, void *);
     
    103103}
    104104
    105 static errno_t meta_native_init_vol2meta(const hr_volume_t *vol, void *md_v)
    106 {
    107         HR_DEBUG("%s()", __func__);
    108 
    109         hr_metadata_t *md = md_v;
     105static errno_t meta_native_init_vol2meta(hr_volume_t *vol)
     106{
     107        HR_DEBUG("%s()", __func__);
     108
     109        hr_metadata_t *md = calloc(1, sizeof(*md));
     110        if (md == NULL)
     111                return ENOMEM;
    110112
    111113        str_cpy(md->magic, HR_NATIVE_MAGIC_SIZE, HR_NATIVE_MAGIC_STR);
     
    132134        md->bsize = vol->bsize;
    133135        memcpy(md->devname, vol->devname, HR_DEVNAME_LEN);
     136
     137        vol->in_mem_md = md;
    134138
    135139        return EOK;
     
    163167        /* already set */
    164168        /* memcpy(vol->devname, main_meta->devname, HR_DEVNAME_LEN); */
     169
     170        vol->in_mem_md = calloc(1, sizeof(hr_metadata_t));
     171        if (vol->in_mem_md == NULL)
     172                return ENOMEM;
    165173        memcpy(vol->in_mem_md, main_meta, sizeof(hr_metadata_t));
    166174
  • uspace/srv/bd/hr/superblock.h

    rc69cbef r78433bb  
    4545typedef struct hr_superblock_ops {
    4646        void *(*alloc_struct)(void);
    47         errno_t (*init_vol2meta)(const hr_volume_t *, void *);
     47        errno_t (*init_vol2meta)(hr_volume_t *);
    4848        errno_t (*init_meta2vol)(const list_t *, hr_volume_t *);
    4949        void (*encode)(void *, void *);
  • uspace/srv/bd/hr/util.c

    rc69cbef r78433bb  
    159159        }
    160160
    161         vol->in_mem_md = vol->meta_ops->alloc_struct();
    162         if (vol->in_mem_md == NULL) {
    163                 free(vol->fge);
    164                 rc = ENOMEM;
    165                 goto error;
    166         }
    167 
    168161        vol->state = HR_VOL_NONE;
    169162
Note: See TracChangeset for help on using the changeset viewer.