Changeset 8b51009 in mainline for uspace/srv/bd/hr/superblock.h


Ignore:
Timestamp:
2025-03-28T23:37:16Z (3 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
0437dd5
Parents:
7bfe468
git-author:
Miroslav Cimerman <mc@…> (2025-03-28 23:25:57)
git-committer:
Miroslav Cimerman <mc@…> (2025-03-28 23:37:16)
Message:

hr: auto assembly, refactor

Added automatic assembly (with hrctl -A). All disks or their partitions
are scanned for HelenRAID metadata and assembly is attempted.

Main volume list is now locked with RW lock. The volume list
manipulation functions are moved into util.c.

hr_{create,destroy}_vol_struct() are implemented for better reusability
and modularity.

Volume destroy/stop (hrctl -D) now returns EBUSY if someone has still
the volume open()-ed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/superblock.h

    r7bfe468 r8b51009  
    11/*
    2  * Copyright (c) 2024 Miroslav Cimerman
     2 * Copyright (c) 2025 Miroslav Cimerman
    33 * All rights reserved.
    44 *
     
    3939#include "var.h"
    4040
    41 #define HR_META_SIZE 1  /* in blocks */
    42 #define HR_META_OFF 7   /* in blocks */
    43 #define HR_DATA_OFF (HR_META_SIZE + HR_META_OFF)
     41#define HR_META_SIZE            1       /* in blocks */
     42#define HR_META_OFF             7       /* in blocks */
     43#define HR_DATA_OFF             (HR_META_OFF + HR_META_SIZE)
    4444
    45 #define HR_MAGIC 0x4420492041205248LLU
    46 #define HR_UUID_LEN 16
     45#define HR_MAGIC_STR            "HelenRAID"
     46#define HR_MAGIC_SIZE           16
     47#define HR_UUID_LEN             16
     48/* #define HR_METADATA_VERSION 0 */
    4749
    48 typedef struct hr_metadata {
    49         uint64_t magic;
    50         uint32_t version;       /* unused XXX */
    51         uint32_t extent_no;
     50typedef struct hr_metadata hr_metadata_t;
     51typedef struct hr_volume hr_volume_t;
    5252
    53         uint32_t index;         /* index of disk in array */
    54         uint32_t level;
    55         uint32_t layout;
    56         uint32_t strip_size;
     53struct hr_metadata {
     54        char            magic[HR_MAGIC_SIZE];
    5755
    58         uint64_t nblocks;       /* all blocks */
    59         uint64_t data_blkno;    /* usable blocks */
     56        uint8_t         uuid[HR_UUID_LEN];
    6057
    61         uint64_t data_offset;   /* block where data starts */
     58        /* TODO: change to blkno */
     59        uint64_t        nblocks;                /* all blocks */
     60        uint64_t        data_blkno;             /* usable blocks */
    6261
    63         uint64_t counter; /* unused */
     62        uint64_t        truncated_blkno;        /* usable blocks */
     63        uint64_t        data_offset;
    6464
    65         uint8_t uuid[HR_UUID_LEN];
     65        uint64_t        counter;                /* yet unused */
     66        uint32_t        version;                /* yet unused */
     67        uint32_t        extent_no;
    6668
    67         char devname[HR_DEVNAME_LEN];
    68 } hr_metadata_t;
     69        uint32_t        index;                  /* index of extent in volume */
     70        uint32_t        level;
     71        uint32_t        layout;
     72        uint32_t        strip_size;
    6973
    70 extern errno_t hr_write_meta_to_vol(hr_volume_t *);
    71 extern errno_t hr_write_meta_to_ext(hr_volume_t *, size_t);
    72 extern errno_t hr_fill_vol_from_meta(hr_volume_t *);
     74        uint32_t        bsize;
     75
     76        char            devname[HR_DEVNAME_LEN];
     77};
     78
     79extern errno_t  hr_write_meta_to_vol(hr_volume_t *);
     80extern errno_t  hr_write_meta_to_ext(hr_volume_t *, size_t);
     81extern errno_t  hr_fill_vol_from_meta(hr_volume_t *);
     82extern errno_t  hr_get_metadata_block(service_id_t, void **);
     83extern void     hr_decode_metadata_from_block(void *, hr_metadata_t *);
     84extern void     hr_metadata_dump(hr_metadata_t *);
     85extern bool     hr_valid_md_magic(hr_metadata_t *);
    7386
    7487#endif
Note: See TracChangeset for help on using the changeset viewer.