Changeset 4224ef7 in mainline


Ignore:
Timestamp:
2019-08-06T18:18:37Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
e55741e
Parents:
dd5c623
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-11 16:50:40)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 18:18:37)
Message:

sysman: Add VFS FS server autostart

  • VFS autostart instrumentation removes explicit dependency on FS servers.
  • Compositor service properly named, it's now resolved as implicit dependency.

Conflicts:

boot/Makefile.common
uspace/lib/gui/window.c
uspace/srv/locsrv/locsrv.c
uspace/srv/vfs/vfs.c
uspace/srv/vfs/vfs_ops.c

Location:
uspace
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/cfg/sysman/barber.svc

    rdd5c623 r4224ef7  
    11[Unit]
    2 ; explicit dependency on compositor,
    3 ; until exposee to unit name map in locsrv is defined
    4 After = compositor.svc
    52After = rootfs.mnt
    63
  • uspace/cfg/sysman/locfs.mnt

    rdd5c623 r4224ef7  
    1 [Unit]
    2 ; explicit, VFS not instrumented for autostart
    3 After = locfs.svc
    4 
    51[Mount]
    62What =
  • uspace/cfg/sysman/rootfs.mnt

    rdd5c623 r4224ef7  
    1 [Unit]
    2 ; explicit, VFS not instrumented for autostart
    3 After = fat.svc
    4 
    51[Mount]
    62What = devices/\hw\pci0\00:01.0\ata-c1\d0
  • uspace/cfg/sysman/vlaunch.svc

    rdd5c623 r4224ef7  
    11[Unit]
    2 ; explicit dependency on compositor,
    3 ; until exposee to unit name map in locsrv is defined
    4 After = compositor.svc
    52; explicit because of executable path
    63After = rootfs.mnt
     
    85After = locfs.mnt
    96
    10 ; unclear status of vlaunch as service (more relevant to user session)
     7; unclear status of vlaunch as a service (more relevant to user session)
    118[Service]
    129ExecStart = /root/app/vlaunch comp:0/winreg
  • uspace/lib/gui/window.c

    rdd5c623 r4224ef7  
    616616        win->surface = NULL;
    617617
     618        unsigned int ipc_flags = IPC_FLAG_AUTOSTART;
    618619        service_id_t reg_dsid;
    619         errno_t rc = loc_service_get_id(winreg, &reg_dsid, 0);
     620        errno_t rc = loc_service_get_id(winreg, &reg_dsid, ipc_flags);
    620621        if (rc != EOK) {
    621622                free(win);
     
    624625
    625626        async_sess_t *reg_sess =
    626             loc_service_connect(reg_dsid, INTERFACE_COMPOSITOR, 0);
     627            loc_service_connect(reg_dsid, INTERFACE_COMPOSITOR, ipc_flags);
     628
    627629        if (reg_sess == NULL) {
    628630                free(win);
     
    639641        }
    640642
    641         win->osess = loc_service_connect(out_dsid, INTERFACE_COMPOSITOR, 0);
     643
     644        win->osess = loc_service_connect(out_dsid, INTERFACE_COMPOSITOR, ipc_flags);
     645
    642646        if (win->osess == NULL) {
    643647                free(win);
     
    645649        }
    646650
    647         win->isess = loc_service_connect(in_dsid, INTERFACE_COMPOSITOR, 0);
     651        win->isess = loc_service_connect(in_dsid, INTERFACE_COMPOSITOR, ipc_flags);
     652
    648653        if (win->isess == NULL) {
    649654                async_hangup(win->osess);
  • uspace/lib/sysman/src/ctl.c

    rdd5c623 r4224ef7  
    3333#include <sysman/sysman.h>
    3434
     35/*
     36 * TODO
     37 * Non-blocking favor of this API is effectively incomplete as it doesn't
     38 * provide means how to obtain result of the start operation.
     39 * Probably devise individual API for brokers that could exploit the fact that
     40 * broker knows when appropriate exposee is created and the request succeeded.
     41 * Still though, it's necessary to centralize timeout into sysman.
     42 */
    3543int sysman_unit_start(const char *unit_name, int flags)
    3644{
  • uspace/srv/locsrv/locsrv.c

    rdd5c623 r4224ef7  
    339339        char *service_name = NULL;
    340340
     341        /*
     342         * All services in 'device' namespace are considered to be drivers and
     343         * devman is thus requested to start. Otherwise name of unit is made
     344         * from fully qualified name of service (namespace separator is changed
     345         * for usage in unit name.
     346         */
    341347        if (str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) {
    342348                asprintf(&service_name, "%s", SERVICE_NAME_DEVMAN);
     
    359365        }
    360366
    361         //printf("%s(%s) before\n", __func__, unit_name);//DEBUG
    362367        int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING);
    363         //printf("%s(%s) after %i\n", __func__, unit_name, rc);//DEBUG
    364368        free(unit_name);
    365369        free(service_name);
     
    811815         */
    812816        if (svc == NULL) {
    813                 //printf("%s: service '%s/%s' not found\n", NAME, ns_name, name);//DEBUG
    814                 if (flags & (IPC_FLAG_AUTOSTART | IPC_FLAG_BLOCKING)) {
    815                         /* TODO:
    816                          * consider non-blocking service start, return
    817                          * some dummy id and block only after connection
    818                          * request (actually makes more sense as those who asks
    819                          * for ID might be someone else than those connecting)
    820                          */
    821                         if (!start_requested && (flags & IPC_FLAG_AUTOSTART)) {
    822                                 rc = loc_service_request_start(ns_name, name);
    823                                 if (rc != EOK) {
    824                                         goto finish;
    825                                 }
    826                                 start_requested = true;
     817                /* TODO:
     818                 * consider non-blocking service start, return
     819                 * some dummy id and block only after connection
     820                 * request (actually makes more sense as those who asks
     821                 * for ID might be someone else than those connecting)
     822                 * Note:
     823                 * service_list_mutex is released as we don't need to keep it
     824                 * while waiting for start request to finish.
     825                 */
     826                if ((flags & IPC_FLAG_AUTOSTART) && !start_requested) {
     827                        fibril_mutex_unlock(&services_list_mutex);
     828                        rc = loc_service_request_start(ns_name, name);
     829                        fibril_mutex_lock(&services_list_mutex);
     830                        start_requested = true;
     831
     832                        if (rc != EOK) {
     833                                goto finish;
     834                        } else {
     835                                goto recheck;
    827836                        }
    828 
     837                }
     838
     839                if (flags & IPC_FLAG_BLOCKING) {
    829840                        fibril_condvar_wait(&services_list_cv,
    830841                            &services_list_mutex);
     
    833844                rc = ENOENT;
    834845        } else {
    835                 //printf("%s: service '%s/%s' FOUND\n", NAME, ns_name, name);//DEBUG
    836846                rc = EOK;
    837847        }
     
    16211631
    16221632        /* Let sysman know we are broker */
    1623         printf("%s: sysman_broker_register : pre\n", NAME);
    16241633        rc = sysman_broker_register();
    1625         printf("%s: sysman_broker_register : post\n", NAME);
    16261634        if (rc != EOK) {
    16271635                printf("%s: Error registering at sysman (%i)\n", NAME, rc);
  • uspace/srv/sysman/connection_broker.c

    rdd5c623 r4224ef7  
    3737        sysman_log(LVL_DEBUG2, "%s", __func__);
    3838        async_answer_0(iid, EOK);
    39         // TODO implement
     39        /* TODO implement
     40         *  What exactly? Similar behavior that has locsrv with servers,
     41         *  so that subsequent calls can be assigned to broker. Still that
     42         *  makes sense only when brokers will somehow scope unit/exposee
     43         *  names. Why I wanted this registration?
     44         */
    4045}
    4146
  • uspace/srv/sysman/sysman.c

    rdd5c623 r4224ef7  
    160160/** Create and queue job for unit
    161161 *
    162  * @param[in]  callback  callback must explicitly delete reference to job
     162 * @param[in]  callback  (optional) callback must explicitly delete reference
     163 *                       to job
    163164 */
    164165int sysman_queue_job(unit_t *unit, unit_state_t target_state,
     
    170171        }
    171172
    172         job_add_ref(job);
    173         sysman_object_observer(job, callback, callback_arg);
     173        if (callback != NULL) {
     174                job_add_ref(job);
     175                sysman_object_observer(job, callback, callback_arg);
     176        }
    174177
    175178        job_add_ref(job);
  • uspace/srv/sysman/units/unit_mnt.c

    rdd5c623 r4224ef7  
    151151{
    152152        mount_data_t *mnt_data = arg;
    153         /*sysman_log(LVL_DEBUG2, "%s(%p, %p, %p, %p, %x, %u)",
     153        sysman_log(LVL_DEBUG2, "%s(%p, %p, %p, %p, %x, %u)",
    154154            __func__,
    155155            mnt_data->type, mnt_data->mountpoint, mnt_data->device, mnt_data->options,
    156             mnt_data->flags, mnt_data->instance);*/
     156            mnt_data->flags, mnt_data->instance);
     157
    157158        int rc = mount(mnt_data->type, mnt_data->mountpoint, mnt_data->device,
    158159            mnt_data->options ? mnt_data->options : "",
  • uspace/srv/sysman/units/unit_svc.c

    rdd5c623 r4224ef7  
    8787        int rc = task_spawnv(NULL, NULL, u_svc->exec_start.path,
    8888            u_svc->exec_start.argv);
    89         sysman_log(LVL_DEBUG2, "task_spawn(%s, %s)", u_svc->exec_start.path, u_svc->exec_start.argv[0]);
     89
    9090        if (rc != EOK) {
    9191                unit->state = STATE_FAILED;
  • uspace/srv/vfs/Makefile

    rdd5c623 r4224ef7  
    2929
    3030USPACE_PREFIX = ../..
     31LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a
     32EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include
    3133BINARY = vfs
    3234STATIC_NEEDED = y
  • uspace/srv/vfs/vfs.c

    rdd5c623 r4224ef7  
    4040#include <ipc/services.h>
    4141#include <abi/ipc/methods.h>
    42 #include <libarch/config.h>
    4342#include <ns.h>
     43#include <as.h>
    4444#include <async.h>
     45#include <atomic.h>
    4546#include <errno.h>
    4647#include <str_error.h>
    4748#include <stdio.h>
     49#include <ipc/services.h>
     50#include <macros.h>
    4851#include <stdbool.h>
     52#include <stdio.h>
    4953#include <str.h>
    50 #include <as.h>
    51 #include <macros.h>
     54#include <sysman/broker.h>
    5255#include "vfs.h"
    5356
     
    145148
    146149        /*
     150         * Let sysman know we are broker
     151         */
     152        rc = sysman_broker_register();
     153        if (rc != EOK) {
     154                printf("%s: Error registering at sysman (%i)\n", NAME, rc);
     155                return rc;
     156        }
     157       
     158        /*
    147159         * Start accepting connections.
    148160         */
  • uspace/srv/vfs/vfs_ops.c

    rdd5c623 r4224ef7  
    137137        while (true) {
    138138                fs_handle = fs_name_to_handle(instance, fsname, false);
     139                if (!fs_handle) {
     140                        if ((flags & IPC_FLAG_AUTOSTART)) {
     141                                /*
     142                                 * Temporarily release the lock, we don't need it while
     143                                 * waiting for start request (which may lead to deadlock).
     144                                 */
     145                                fibril_mutex_unlock(&fs_list_lock);
     146                                rc = vfs_fs_request_start(fs_name, instance);
     147                                fibril_mutex_lock(&fs_list_lock);
     148
     149                                if (rc != EOK) {
     150                                        fibril_mutex_unlock(&fs_list_lock);
     151                                        async_answer_0(callid, rc);
     152                                        async_answer_0(rid, rc);
     153                                        free(mp);
     154                                        free(fs_name);
     155                                        free(opts);
     156                                        return;
     157                                }
     158                                /*
     159                                 * Succesful start request, new server should be
     160                                 * registered.
     161                                 */
     162                                continue;
     163                        }
     164                }
    139165
    140166                if (fs_handle != 0 || !(flags & VFS_MOUNT_BLOCKING))
     
    188214
    189215        return EOK;
     216}
     217
     218static int vfs_fs_request_start(const char *fs_name, unsigned int instance)
     219{
     220        char *unit_name = NULL;
     221
     222        assert(instance == 0);
     223        /*
     224         * Unit name is made simply by considering service of the same name as
     225         * given FS name.
     226         * TODO instance identifier is not implemented.
     227         */
     228        asprintf(&unit_name, "%s%c%s", fs_name, UNIT_NAME_SEPARATOR,
     229            UNIT_SVC_TYPE_NAME);
     230        if (unit_name == NULL) {
     231                return ENOMEM;
     232        }
     233
     234        int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING);
     235
     236        free(unit_name);
     237        return rc;
    190238}
    191239
Note: See TracChangeset for help on using the changeset viewer.