Changeset ca7fa5b in mainline


Ignore:
Timestamp:
2025-04-02T18:24:11Z (6 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
800d188
Parents:
bbcd06e
Message:

hr: use <inttypes.h> macro specifiers

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hrctl/hrctl.c

    rbbcd06e rca7fa5b  
    289289                                    str_error(rc));
    290290                        } else {
    291                                 printf("hrctl: auto assembled %lu volumes\n",
     291                                printf("hrctl: auto assembled %zu volumes\n",
    292292                                    cnt);
    293293                        }
     
    431431                        printf("hrctl: auto assemble rc: %s\n", str_error(rc));
    432432                } else {
    433                         printf("hrctl: auto assembled %lu volumes\n",
     433                        printf("hrctl: auto assembled %zu volumes\n",
    434434                            assembled_cnt);
    435435                }
  • uspace/lib/device/src/hr.c

    rbbcd06e rca7fa5b  
    195195        printf("--- vol %zu ---\n", index);
    196196
    197         printf("svc_id: %lu\n", vol_info->svc_id);
     197        printf("svc_id: %" PRIun "\n", vol_info->svc_id);
    198198
    199199        rc = loc_service_get_name(vol_info->svc_id, &devname);
     
    211211        if (vol_info->level == HR_LVL_0 || vol_info->level == HR_LVL_4) {
    212212                if (vol_info->strip_size / 1024 < 1)
    213                         printf("strip size in bytes: %u\n",
     213                        printf("strip size in bytes: %" PRIu32 "\n",
    214214                            vol_info->strip_size);
    215215                else
    216                         printf("strip size: %uK\n",
     216                        printf("strip size: %" PRIu32 "K\n",
    217217                            vol_info->strip_size / 1024);
    218218        }
    219         printf("size in bytes: %luMiB\n",
     219        printf("size in bytes: %" PRIu64 "MiB\n",
    220220            vol_info->nblocks * vol_info->bsize / 1024 / 1024);
    221         printf("size in blocks: %lu\n", vol_info->nblocks);
     221        printf("size in blocks: %" PRIu64 "\n", vol_info->nblocks);
    222222        printf("block size: %zu\n", vol_info->bsize);
    223223
  • uspace/srv/bd/hr/io.c

    rbbcd06e rca7fa5b  
    3737#include <errno.h>
    3838#include <hr.h>
     39#include <inttypes.h>
    3940#include <stdio.h>
    4041#include <str_error.h>
     
    5152        errno_t rc;
    5253
    53         HR_DEBUG("WORKER on extent: %lu, ba: %lu, cnt: %lu\n",
    54             io->extent, io->ba, io->cnt);
     54        const char *debug_type_str = NULL;
     55        switch (io->type) {
     56        case HR_BD_SYNC:
     57                debug_type_str = "SYNC";
     58                break;
     59        case HR_BD_READ:
     60                debug_type_str = "READ";
     61                break;
     62        case HR_BD_WRITE:
     63                debug_type_str = "WRITE";
     64                break;
     65        }
     66
     67        HR_DEBUG("%s WORKER (%p) on extent: %zu, ba: %" PRIu64 ", "
     68            "cnt: %" PRIu64 "\n",
     69            debug_type_str, io, io->extent, io->ba, io->cnt);
    5570
    5671        switch (io->type) {
     
    7388        }
    7489
     90        HR_DEBUG("WORKER (%p) rc: %s\n", io, str_error(rc));
     91
    7592        /*
    7693         * We don't have to invalidate extents who got ENOMEM
     
    8299                io->state_callback(io->vol, io->extent, rc);
    83100
    84         HR_DEBUG("WORKER rc: %s\n", str_error(rc));
    85 
    86101        return rc;
    87102}
  • uspace/srv/bd/hr/raid1.c

    rbbcd06e rca7fa5b  
    3838#include <errno.h>
    3939#include <hr.h>
     40#include <inttypes.h>
    4041#include <io/log.h>
    4142#include <ipc/hr.h>
     
    522523        }
    523524
    524         HR_DEBUG("hr_raid1_rebuild(): rebuild finished on \"%s\" (%lu), "
    525             "extent no. %lu\n", vol->devname, vol->svc_id, rebuild_idx);
     525        HR_DEBUG("hr_raid1_rebuild(): rebuild finished on \"%s\" (%" PRIun "), "
     526            "extent no. %zu\n", vol->devname, vol->svc_id, rebuild_idx);
    526527
    527528        fibril_rwlock_write_lock(&vol->states_lock);
     
    616617        hr_extent_t *rebuild_ext = &vol->extents[bad];
    617618
    618         HR_DEBUG("hr_raid1_rebuild(): starting REBUILD on extent no. %lu (%lu)"
    619             "\n", bad, rebuild_ext->svc_id);
     619        HR_DEBUG("hr_raid1_rebuild(): starting REBUILD on extent no. %zu "
     620            "(%"  PRIun  ")\n", bad, rebuild_ext->svc_id);
    620621
    621622        atomic_store_explicit(&vol->rebuild_blk, 0, memory_order_relaxed);
     
    687688                if (i + 1 >= vol->extent_no) {
    688689                        if (rc != ENOMEM) {
    689                                 HR_ERROR("rebuild on \"%s\" (%lu), failed due "
    690                                     "to too many failed extents\n",
     690                                HR_ERROR("rebuild on \"%s\" (%" PRIun "), "
     691                                    "failed due to too many failed extents\n",
    691692                                    vol->devname, vol->svc_id);
    692693                        }
     
    694695                        /* for now we have to invalidate the rebuild extent */
    695696                        if (rc == ENOMEM) {
    696                                 HR_ERROR("rebuild on \"%s\" (%lu), failed due "
    697                                     "to too many failed reads, because of not "
    698                                     "enough memory\n",
     697                                HR_ERROR("rebuild on \"%s\" (%" PRIun "), "
     698                                    "failed due to too many failed reads, "
     699                                    "because of not enough memory\n",
    699700                                    vol->devname, vol->svc_id);
    700701                                hr_raid1_ext_state_callback(vol, rebuild_idx,
     
    718719                hr_raid1_ext_state_callback(vol, rebuild_idx, rc);
    719720
    720                 HR_ERROR("rebuild on \"%s\" (%lu), failed due to "
    721                     "the rebuilt extent no. %lu WRITE (rc: %s)\n",
     721                HR_ERROR("rebuild on \"%s\" (%" PRIun "), failed due to "
     722                    "the rebuilt extent no. %zu WRITE (rc: %s)\n",
    722723                    vol->devname, vol->svc_id, rebuild_idx, str_error(rc));
    723724
  • uspace/srv/bd/hr/raid5.c

    rbbcd06e rca7fa5b  
    3939#include <errno.h>
    4040#include <hr.h>
     41#include <inttypes.h>
    4142#include <io/log.h>
    4243#include <ipc/hr.h>
     
    770771        hr_extent_t *rebuild_ext = &vol->extents[bad];
    771772
    772         HR_DEBUG("hr_raid5_rebuild(): starting rebuild on (%lu)\n",
     773        HR_DEBUG("hr_raid5_rebuild(): starting rebuild on (%" PRIun ")\n",
    773774            rebuild_ext->svc_id);
    774775
     
    804805                        if (rc != EOK) {
    805806                                hr_raid5_handle_extent_error(vol, i, rc);
    806                                 HR_ERROR("rebuild on \"%s\" (%lu), failed due "
    807                                     "to a failed ONLINE extent, number %lu\n",
     807                                HR_ERROR("rebuild on \"%s\" (%" PRIun "), "
     808                                    "failed due to a failed ONLINE extent, "
     809                                    "number %zu\n",
    808810                                    vol->devname, vol->svc_id, i);
    809811                                goto end;
     
    819821                if (rc != EOK) {
    820822                        hr_raid5_handle_extent_error(vol, bad, rc);
    821                         HR_ERROR("rebuild on \"%s\" (%lu), failed due to "
    822                             "the rebuilt extent number %lu failing\n",
     823                        HR_ERROR("rebuild on \"%s\" (%" PRIun "), failed due to "
     824                            "the rebuilt extent number %zu failing\n",
    823825                            vol->devname, vol->svc_id, bad);
    824826                        goto end;
     
    838840        }
    839841
    840         HR_DEBUG("hr_raid5_rebuild(): rebuild finished on \"%s\" (%lu), "
    841             "extent number %lu\n", vol->devname, vol->svc_id, hotspare_idx);
     842        HR_DEBUG("hr_raid5_rebuild(): rebuild finished on \"%s\" (%" PRIun "), "
     843            "extent number %zu\n", vol->devname, vol->svc_id, hotspare_idx);
    842844
    843845        hr_update_ext_status(vol, bad, HR_EXT_ONLINE);
  • uspace/srv/bd/hr/superblock.c

    rbbcd06e rca7fa5b  
    3737#include <byteorder.h>
    3838#include <errno.h>
     39#include <inttypes.h>
    3940#include <io/log.h>
    4041#include <loc.h>
     
    291292        }
    292293        printf("\n");
    293         printf("\tnblocks: %lu\n", metadata->nblocks);
    294         printf("\tdata_blkno: %lu\n", metadata->data_blkno);
    295         printf("\ttruncated_blkno: %lu\n", metadata->truncated_blkno);
    296         printf("\tdata_offset: %lu\n", metadata->data_offset);
    297         printf("\tcounter: %lu\n", metadata->counter);
    298         printf("\tversion: %u\n", metadata->version);
    299         printf("\textent_no: %u\n", metadata->extent_no);
    300         printf("\tindex: %u\n", metadata->index);
    301         printf("\tlevel: %u\n", metadata->level);
    302         printf("\tlayout: %u\n", metadata->layout);
    303         printf("\tstrip_size: %u\n", metadata->strip_size);
    304         printf("\tbsize: %u\n", metadata->bsize);
     294        printf("\tnblocks: %" PRIu64 "\n", metadata->nblocks);
     295        printf("\tdata_blkno: %" PRIu64 "\n", metadata->data_blkno);
     296        printf("\ttruncated_blkno: %" PRIu64 "\n", metadata->truncated_blkno);
     297        printf("\tdata_offset: %" PRIu64 "\n", metadata->data_offset);
     298        printf("\tcounter: %" PRIu64 "\n", metadata->counter);
     299        printf("\tversion: %" PRIu32 "\n", metadata->version);
     300        printf("\textent_no: %" PRIu32 "\n", metadata->extent_no);
     301        printf("\tindex: %" PRIu32 "\n", metadata->index);
     302        printf("\tlevel: %" PRIu32 "\n", metadata->level);
     303        printf("\tlayout: %" PRIu32 "\n", metadata->layout);
     304        printf("\tstrip_size: %" PRIu32 "\n", metadata->strip_size);
     305        printf("\tbsize: %" PRIu32 "\n", metadata->bsize);
    305306        printf("\tdevname: %s\n", metadata->devname);
    306307}
  • uspace/srv/bd/hr/util.c

    rbbcd06e rca7fa5b  
    3939#include <fibril_synch.h>
    4040#include <hr.h>
     41#include <inttypes.h>
    4142#include <io/log.h>
    4243#include <loc.h>
     
    234235
    235236        errno_t rc;
    236         size_t i, blkno, bsize;
     237        uint64_t blkno;
     238        size_t i, bsize;
    237239        size_t last_bsize = 0;
    238240
     
    244246                }
    245247
    246                 HR_DEBUG("%s(): block_init() on (%lu)\n", __func__, svc_id);
     248                HR_DEBUG("%s(): block_init() on (%" PRIun ")\n", __func__,
     249                    svc_id);
    247250                rc = block_init(svc_id);
    248251                if (rc != EOK) {
    249                         HR_DEBUG("%s(): initing (%lu) failed, aborting\n",
     252                        HR_DEBUG("%s(): initing (%" PRIun ") failed, aborting\n",
    250253                            __func__, svc_id);
    251254                        goto error;
     
    298301        for (i = 0; i < vol->extent_no; i++) {
    299302                if (vol->extents[i].svc_id != 0) {
    300                         HR_DEBUG("hr_fini_devs(): block_fini() on (%lu)\n",
     303                        HR_DEBUG("hr_fini_devs(): block_fini() on (%" PRIun ")\n",
    301304                            vol->extents[i].svc_id);
    302305                        block_fini(vol->extents[i].svc_id);
     
    306309        for (i = 0; i < vol->hotspare_no; i++) {
    307310                if (vol->hotspares[i].svc_id != 0) {
    308                         HR_DEBUG("hr_fini_devs(): block_fini() on (%lu)\n",
     311                        HR_DEBUG("hr_fini_devs(): block_fini() on (%" PRIun ")\n",
    309312                            vol->hotspares[i].svc_id);
    310313                        block_fini(vol->hotspares[i].svc_id);
     
    370373}
    371374
    372 void hr_update_ext_status(hr_volume_t *vol, size_t extent, hr_ext_status_t s)
     375void hr_update_ext_status(hr_volume_t *vol, size_t ext_idx, hr_ext_status_t s)
    373376{
    374377        if (vol->level != HR_LVL_0)
     
    377380        assert(fibril_rwlock_is_write_locked(&vol->states_lock));
    378381
    379         assert(extent < vol->extent_no);
    380 
    381         hr_ext_status_t old = vol->extents[extent].status;
    382         HR_WARN("\"%s\": changing extent %lu state: %s -> %s\n",
    383             vol->devname, extent, hr_get_ext_status_msg(old),
     382        assert(ext_idx < vol->extent_no);
     383
     384        hr_ext_status_t old = vol->extents[ext_idx].status;
     385        HR_WARN("\"%s\": changing extent %zu state: %s -> %s\n",
     386            vol->devname, ext_idx, hr_get_ext_status_msg(old),
    384387            hr_get_ext_status_msg(s));
    385         vol->extents[extent].status = s;
    386 }
    387 
    388 void hr_update_hotspare_status(hr_volume_t *vol, size_t hs, hr_ext_status_t s)
     388        vol->extents[ext_idx].status = s;
     389}
     390
     391void hr_update_hotspare_status(hr_volume_t *vol, size_t hs_idx,
     392    hr_ext_status_t s)
    389393{
    390394        assert(fibril_mutex_is_locked(&vol->hotspare_lock));
    391395
    392         assert(hs < vol->hotspare_no);
    393 
    394         hr_ext_status_t old = vol->hotspares[hs].status;
    395         HR_WARN("\"%s\": changing hotspare %lu state: %s -> %s\n",
    396             vol->devname, hs, hr_get_ext_status_msg(old),
     396        assert(hs_idx < vol->hotspare_no);
     397
     398        hr_ext_status_t old = vol->hotspares[hs_idx].status;
     399        HR_WARN("\"%s\": changing hotspare %zu state: %s -> %s\n",
     400            vol->devname, hs_idx, hr_get_ext_status_msg(old),
    397401            hr_get_ext_status_msg(s));
    398         vol->hotspares[hs].status = s;
     402        vol->hotspares[hs_idx].status = s;
    399403}
    400404
     
    408412}
    409413
    410 void hr_update_ext_svc_id(hr_volume_t *vol, size_t extent, service_id_t new)
     414void hr_update_ext_svc_id(hr_volume_t *vol, size_t ext_idx, service_id_t new)
    411415{
    412416        if (vol->level != HR_LVL_0)
    413417                assert(fibril_rwlock_is_write_locked(&vol->extents_lock));
    414418
    415         assert(extent < vol->extent_no);
    416 
    417         service_id_t old = vol->extents[extent].svc_id;
    418         HR_WARN("\"%s\": changing extent no. %lu svc_id: (%lu) -> (%lu)\n",
    419             vol->devname, extent, old, new);
    420         vol->extents[extent].svc_id = new;
    421 }
    422 
    423 void hr_update_hotspare_svc_id(hr_volume_t *vol, size_t hs, service_id_t new)
     419        assert(ext_idx < vol->extent_no);
     420
     421        service_id_t old = vol->extents[ext_idx].svc_id;
     422        HR_WARN("\"%s\": changing extent no. %zu svc_id: (%" PRIun ") -> "
     423            "(%" PRIun ")\n", vol->devname, ext_idx, old, new);
     424        vol->extents[ext_idx].svc_id = new;
     425}
     426
     427void hr_update_hotspare_svc_id(hr_volume_t *vol, size_t hs_idx,
     428    service_id_t new)
    424429{
    425430        assert(fibril_mutex_is_locked(&vol->hotspare_lock));
    426431
    427         assert(hs < vol->hotspare_no);
    428 
    429         service_id_t old = vol->hotspares[hs].svc_id;
    430         HR_WARN("\"%s\": changing hotspare no. %lu svc_id: (%lu) -> (%lu)\n",
    431             vol->devname, hs, old, new);
    432         vol->hotspares[hs].svc_id = new;
     432        assert(hs_idx < vol->hotspare_no);
     433
     434        service_id_t old = vol->hotspares[hs_idx].svc_id;
     435        HR_WARN("\"%s\": changing hotspare no. %zu svc_id: (%" PRIun ") -> "
     436            "(%" PRIun ")\n", vol->devname, hs_idx, old, new);
     437        vol->hotspares[hs_idx].svc_id = new;
    433438}
    434439
     
    805810                vol->extents[iter->md->index].svc_id = iter->svc_id;
    806811
    807                 size_t blkno;
     812                uint64_t blkno;
    808813                rc = block_get_nblocks(iter->svc_id, &blkno);
    809814                if (rc != EOK)
     
    10491054                goto error;
    10501055
    1051         size_t hs_blkno;
     1056        uint64_t hs_blkno;
    10521057        rc = block_get_nblocks(hotspare, &hs_blkno);
    10531058        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.