Print this page
7711 SMF: Finish implementing support for degraded state


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015, Joyent, Inc.

  25  */
  26 
  27 /*
  28  * startd.c - the master restarter
  29  *
  30  * svc.startd comprises two halves.  The graph engine is based in graph.c and
  31  * maintains the service dependency graph based on the information in the
  32  * repository.  For each service it also tracks the current state and the
  33  * restarter responsible for the service.  Based on the graph, events from the
  34  * repository (mostly administrative requests from svcadm), and messages from
  35  * the restarters, the graph engine makes decisions about how the services
  36  * should be manipulated and sends commands to the appropriate restarters.
  37  * Communication between the graph engine and the restarters is embodied in
  38  * protocol.c.
  39  *
  40  * The second half of svc.startd is the restarter for services managed by
  41  * svc.startd and is primarily contained in restarter.c.  It responds to graph
  42  * engine commands by executing methods, updating the repository, and sending
  43  * feedback (mostly state updates) to the graph engine.
  44  *


 222 #include <unistd.h>
 223 
 224 #include "startd.h"
 225 #include "protocol.h"
 226 
 227 ssize_t max_scf_name_size;
 228 ssize_t max_scf_fmri_size;
 229 ssize_t max_scf_value_size;
 230 
 231 mode_t fmask;
 232 mode_t dmask;
 233 
 234 graph_update_t *gu;
 235 restarter_update_t *ru;
 236 
 237 startd_state_t *st;
 238 
 239 boolean_t booting_to_single_user = B_FALSE;
 240 
 241 const char * const admin_actions[] = {

 242     SCF_PROPERTY_DEGRADED,

 243     SCF_PROPERTY_MAINT_OFF,
 244     SCF_PROPERTY_MAINT_ON,
 245     SCF_PROPERTY_MAINT_ON_IMMEDIATE,
 246     SCF_PROPERTY_REFRESH,
 247     SCF_PROPERTY_RESTART
 248 };
 249 
 250 const int admin_events[NACTIONS] = {

 251     RESTARTER_EVENT_TYPE_ADMIN_DEGRADED,

 252     RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF,
 253     RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON,
 254     RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE,
 255     RESTARTER_EVENT_TYPE_ADMIN_REFRESH,
 256     RESTARTER_EVENT_TYPE_ADMIN_RESTART
 257 };
 258 
 259 const char * const instance_state_str[] = {
 260         "none",
 261         "uninitialized",
 262         "maintenance",
 263         "offline",
 264         "disabled",
 265         "online",
 266         "degraded"
 267 };
 268 
 269 static int finished = 0;
 270 static int opt_reconfig = 0;
 271 static uint8_t prop_reconfig = 0;




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015, Joyent, Inc.
  25  * Copyright 2017 RackTop Systems.
  26  */
  27 
  28 /*
  29  * startd.c - the master restarter
  30  *
  31  * svc.startd comprises two halves.  The graph engine is based in graph.c and
  32  * maintains the service dependency graph based on the information in the
  33  * repository.  For each service it also tracks the current state and the
  34  * restarter responsible for the service.  Based on the graph, events from the
  35  * repository (mostly administrative requests from svcadm), and messages from
  36  * the restarters, the graph engine makes decisions about how the services
  37  * should be manipulated and sends commands to the appropriate restarters.
  38  * Communication between the graph engine and the restarters is embodied in
  39  * protocol.c.
  40  *
  41  * The second half of svc.startd is the restarter for services managed by
  42  * svc.startd and is primarily contained in restarter.c.  It responds to graph
  43  * engine commands by executing methods, updating the repository, and sending
  44  * feedback (mostly state updates) to the graph engine.
  45  *


 223 #include <unistd.h>
 224 
 225 #include "startd.h"
 226 #include "protocol.h"
 227 
 228 ssize_t max_scf_name_size;
 229 ssize_t max_scf_fmri_size;
 230 ssize_t max_scf_value_size;
 231 
 232 mode_t fmask;
 233 mode_t dmask;
 234 
 235 graph_update_t *gu;
 236 restarter_update_t *ru;
 237 
 238 startd_state_t *st;
 239 
 240 boolean_t booting_to_single_user = B_FALSE;
 241 
 242 const char * const admin_actions[] = {
 243     SCF_PROPERTY_RESTORE,
 244     SCF_PROPERTY_DEGRADED,
 245     SCF_PROPERTY_DEGRADE_IMMEDIATE,
 246     SCF_PROPERTY_MAINT_OFF,
 247     SCF_PROPERTY_MAINT_ON,
 248     SCF_PROPERTY_MAINT_ON_IMMEDIATE,
 249     SCF_PROPERTY_REFRESH,
 250     SCF_PROPERTY_RESTART
 251 };
 252 
 253 const int admin_events[NACTIONS] = {
 254     RESTARTER_EVENT_TYPE_ADMIN_RESTORE,
 255     RESTARTER_EVENT_TYPE_ADMIN_DEGRADED,
 256     RESTARTER_EVENT_TYPE_ADMIN_DEGRADE_IMMEDIATE,
 257     RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF,
 258     RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON,
 259     RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE,
 260     RESTARTER_EVENT_TYPE_ADMIN_REFRESH,
 261     RESTARTER_EVENT_TYPE_ADMIN_RESTART
 262 };
 263 
 264 const char * const instance_state_str[] = {
 265         "none",
 266         "uninitialized",
 267         "maintenance",
 268         "offline",
 269         "disabled",
 270         "online",
 271         "degraded"
 272 };
 273 
 274 static int finished = 0;
 275 static int opt_reconfig = 0;
 276 static uint8_t prop_reconfig = 0;