Changeset cf28ffd3 in mainline


Ignore:
Timestamp:
2024-10-28T22:19:45Z (8 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
1cfa162
Parents:
d84773a
Message:

hr: add option to silently fail an extent

Location:
uspace
Files:
4 edited

Legend:

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

    rd84773a rcf28ffd3  
    5959    "  -s, --status              display status of active arrays\n"
    6060    "  -T, --stop                stop an active array\n"
     61    "  -F, --fail-extent         fail an extent, use with -T and set it before\n"
    6162    "  -c, --create=NAME         create new array\n"
    6263    "  -a, --assemble=NAME       assemble an existing array\n"
     
    8889        { "assemble-file", required_argument, 0, 'A' },
    8990        { "stop", required_argument, 0, 'T' },
     91        { "fail-extent", required_argument, 0, 'F' },
    9092        { 0, 0, 0, 0 }
    9193};
     
    220222        int retval, c;
    221223        bool create, assemble;
     224        long fail_extent = -1;
    222225        hr_t *hr;
    223226        hr_config_t *cfg;
     
    241244
    242245        while (c != -1) {
    243                 c = getopt_long(argc, argv, "hsC:c:A:a:l:0145Ln:T:",
     246                c = getopt_long(argc, argv, "hsC:c:A:a:l:0145Ln:T:F:",
    244247                    long_options, NULL);
    245248                switch (c) {
     
    286289                        break;
    287290                case 'T':
    288                         rc = hr_stop(optarg);
     291                        rc = hr_stop(optarg, fail_extent);
    289292                        free(cfg);
    290293                        if (rc != EOK) {
     
    295298                        }
    296299                        return 0;
     300                case 'F':
     301                        fail_extent = strtol(optarg, NULL, 10);
     302                        break;
    297303                case 'l':
    298304                        if (cfg->level != HR_LVL_UNKNOWN)
  • uspace/lib/device/include/hr.h

    rd84773a rcf28ffd3  
    9797
    9898extern errno_t hr_create(hr_t *, hr_config_t *, bool);
    99 extern errno_t hr_stop(const char *);
     99extern errno_t hr_stop(const char *, long);
    100100extern errno_t hr_print_status(void);
    101101
  • uspace/lib/device/src/hr.c

    rd84773a rcf28ffd3  
    169169}
    170170
    171 errno_t hr_stop(const char *devname)
     171errno_t hr_stop(const char *devname, long extent)
    172172{
    173173        hr_t *hr;
     
    189189                goto error;
    190190        }
    191         rc = async_req_1_0(exch, HR_STOP, svc_id);
     191        rc = async_req_2_0(exch, HR_STOP, svc_id, extent);
    192192        async_exchange_end(exch);
    193193
  • uspace/srv/bd/hr/hr.c

    rd84773a rcf28ffd3  
    255255        log_msg(LOG_DEFAULT, LVL_NOTE, "hr_stop_srv()");
    256256
    257         errno_t rc;
     257        errno_t rc = EOK;
    258258        service_id_t svc_id;
     259        long fail_extent;
    259260        hr_volume_t *vol;
    260261
    261262        svc_id = ipc_get_arg1(icall);
     263        fail_extent = (long) ipc_get_arg2(icall);
    262264
    263265        vol = hr_get_volume(svc_id);
     
    267269        }
    268270
    269         rc = hr_remove_volume(svc_id);
    270         if (rc != EOK) {
    271                 async_answer_0(icall, rc);
    272                 return;
    273         }
    274 
    275         rc = loc_service_unregister(hr_srv, svc_id);
    276 
     271        if (fail_extent == -1) {
     272                rc = hr_remove_volume(svc_id);
     273                if (rc != EOK) {
     274                        async_answer_0(icall, rc);
     275                        return;
     276                }
     277                rc = loc_service_unregister(hr_srv, svc_id);
     278        } else {
     279                /* fibril safe for now */
     280                fibril_mutex_lock(&vol->lock);
     281                hr_update_ext_status(vol, fail_extent, HR_EXT_FAILED);
     282                fibril_mutex_unlock(&vol->lock);
     283        }
    277284        async_answer_0(icall, rc);
    278285}
Note: See TracChangeset for help on using the changeset viewer.