Changeset 80c760e in mainline


Ignore:
Timestamp:
2025-04-21T12:34:02Z (4 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
75262d2f
Parents:
18c3658
Message:

hr: remove truncated_blkno calculation from raid*.c

Calculate the initial truncated_blkno in hr_init_extents_from_cfg,
allowing the removal of hr_extent_t.blkno.

Also fixes double block_fini() on failed volume creation in
hr_util_try_assemble().

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/device/include/hr.h

    r18c3658 r80c760e  
    9999        service_id_t    svc_id;
    100100        hr_ext_status_t status;
    101         uint64_t        blkno;
    102101} hr_extent_t;
    103102
  • uspace/srv/bd/hr/metadata/foreign/geom/mirror.c

    r18c3658 r80c760e  
    155155
    156156                vol->extents[index].svc_id = iter->svc_id;
    157 
    158                 uint64_t blkno;
    159                 rc = block_get_nblocks(iter->svc_id, &blkno);
    160                 if (rc != EOK)
    161                         goto error;
    162 
    163                 vol->extents[index].blkno = blkno;
     157                iter->fini = false;
    164158
    165159                if (iter_meta->md_genid == max_counter_val)
  • uspace/srv/bd/hr/metadata/native.c

    r18c3658 r80c760e  
    139139        HR_DEBUG("%s()", __func__);
    140140
    141         errno_t rc = EOK;
    142 
    143141        hr_metadata_t *main_meta = NULL;
    144142        size_t max_counter_val = 0;
     
    169167
    170168                vol->extents[iter_meta->index].svc_id = iter->svc_id;
    171 
    172                 uint64_t blkno;
    173                 rc = block_get_nblocks(iter->svc_id, &blkno);
    174                 if (rc != EOK)
    175                         goto error;
    176 
    177                 vol->extents[iter_meta->index].blkno = blkno;
     169                iter->fini = false;
    178170
    179171                if (iter_meta->counter == max_counter_val)
     
    188180        }
    189181
    190 error:
    191         return rc;
     182        return EOK;
    192183}
    193184
  • uspace/srv/bd/hr/raid0.c

    r18c3658 r80c760e  
    117117        assert(vol->level == HR_LVL_0);
    118118
    119         uint64_t truncated_blkno = vol->extents[0].blkno;
    120         for (size_t i = 1; i < vol->extent_no; i++) {
    121                 if (vol->extents[i].blkno < truncated_blkno)
    122                         truncated_blkno = vol->extents[i].blkno;
    123         }
    124 
    125         uint64_t total_blkno = truncated_blkno * vol->extent_no;
    126 
    127         vol->truncated_blkno = truncated_blkno;
     119        uint64_t total_blkno = vol->truncated_blkno * vol->extent_no;
     120
    128121        vol->data_offset = vol->meta_ops->get_data_offset();
    129122
  • uspace/srv/bd/hr/raid1.c

    r18c3658 r80c760e  
    133133        assert(vol->level == HR_LVL_1);
    134134
    135         uint64_t truncated_blkno = vol->extents[0].blkno;
    136         for (size_t i = 1; i < vol->extent_no; i++) {
    137                 if (vol->extents[i].blkno < truncated_blkno)
    138                         truncated_blkno = vol->extents[i].blkno;
    139         }
    140 
    141         vol->truncated_blkno = truncated_blkno;
    142135        vol->data_offset = vol->meta_ops->get_data_offset();
    143         vol->data_blkno = truncated_blkno - vol->meta_ops->get_size();
     136        vol->data_blkno = vol->truncated_blkno - vol->meta_ops->get_size();
    144137        vol->strip_size = 0;
    145138
  • uspace/srv/bd/hr/raid5.c

    r18c3658 r80c760e  
    131131        assert(vol->level == HR_LVL_5 || vol->level == HR_LVL_4);
    132132
    133         uint64_t truncated_blkno = vol->extents[0].blkno;
    134         for (size_t i = 1; i < vol->extent_no; i++) {
    135                 if (vol->extents[i].blkno < truncated_blkno)
    136                         truncated_blkno = vol->extents[i].blkno;
    137         }
    138 
    139         uint64_t total_blkno = truncated_blkno * vol->extent_no;
    140 
    141         vol->truncated_blkno = truncated_blkno;
     133        uint64_t total_blkno = vol->truncated_blkno * vol->extent_no;
     134
    142135        vol->data_offset = vol->meta_ops->get_data_offset();
    143136
     
    145138        /* count md blocks */
    146139        vol->data_blkno -= vol->meta_ops->get_size() * vol->extent_no;
    147         vol->data_blkno -= truncated_blkno; /* count parity */
     140        vol->data_blkno -= vol->truncated_blkno; /* count parity */
    148141
    149142        vol->strip_size = HR_STRIP_SIZE;
  • uspace/srv/bd/hr/util.c

    r18c3658 r80c760e  
    234234
    235235        errno_t rc;
    236         uint64_t blkno;
     236        uint64_t blkno, smallest_blkno = ~0ULL;
    237237        size_t i, bsize;
    238238        size_t last_bsize = 0;
     
    269269
    270270                vol->extents[i].svc_id = svc_id;
    271                 vol->extents[i].blkno = blkno;
    272271                vol->extents[i].status = HR_EXT_ONLINE;
    273272
     273                if (blkno < smallest_blkno)
     274                        smallest_blkno = blkno;
    274275                last_bsize = bsize;
    275276        }
     
    277278        vol->bsize = last_bsize;
    278279        vol->extent_no = cfg->dev_no;
     280        vol->truncated_blkno = smallest_blkno;
    279281
    280282        for (i = 0; i < HR_MAX_HOTSPARES; i++)
     
    728730
    729731                iter->inited = true;
     732                iter->fini = true;
    730733        }
    731734
     
    738741
    739742        list_foreach(*list, link, struct dev_list_member, iter) {
    740                 if (iter->inited) {
     743                if (iter->inited && iter->fini) {
    741744                        block_fini(iter->svc_id);
    742745                        iter->inited = false;
     746                        iter->fini = false;
    743747                }
    744748        }
     
    983987                        asm_cnt++;
    984988                        break;
    985                 case EEXIST:
    986                         /*
    987                          * A race is detected this way, because we don't want
    988                          * to hold the hr_volumes list lock for a long time,
    989                          * for all assembly attempts. XXX: discuss...
    990                          */
     989                case ENOMEM:
     990                        goto error;
     991                default:
    991992                        rc = EOK;
    992                         break;
    993                 default:
    994                         block_fini_dev_list(&matching_svcs_list);
    995                         free_svc_id_list(&matching_svcs_list);
    996                         goto error;
    997                 }
    998 
     993                }
     994                block_fini_dev_list(&matching_svcs_list);
    999995                free_svc_id_list(&matching_svcs_list);
    1000996        }
  • uspace/srv/bd/hr/util.h

    r18c3658 r80c760e  
    5151        bool             inited;
    5252        bool             md_present;
     53        bool             fini;
    5354};
    5455
Note: See TracChangeset for help on using the changeset viewer.