Initialization protocol for system services.

SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.

SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic 
registration / deregistration of system services.

VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.

RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
This commit is contained in:
Cristiano Giuffrida
2010-01-08 01:20:42 +00:00
parent acc3c30855
commit d1fd04e72a
70 changed files with 2575 additions and 1607 deletions

View File

@@ -352,6 +352,7 @@
# define SYS_RUNCTL (KERNEL_CALL + 46) /* sys_runctl() */
#define NR_SYS_CALLS 47 /* number of system calls */
#define SYS_CALL_MASK_SIZE BITMAP_CHUNKS(NR_SYS_CALLS)
/* Field names for SYS_MEMSET. */
#define MEM_PTR m2_p1 /* base */
@@ -626,6 +627,7 @@
#define RS_LOOKUP (RS_RQ_BASE + 8) /* lookup server name */
#define RS_INIT (RS_RQ_BASE + 20) /* service init message */
#define RS_LU_PREPARE (RS_RQ_BASE + 21) /* prepare to update message */
# define RS_CMD_ADDR m1_p1 /* command string */
@@ -638,6 +640,10 @@
# define RS_NAME m1_p1 /* name */
# define RS_NAME_LEN m1_i1 /* namelen */
# define RS_INIT_RESULT m1_i1 /* init result */
# define RS_INIT_TYPE m1_i2 /* init type */
# define RS_INIT_RPROCTAB_GID m1_i3 /* init rproc table gid */
# define RS_LU_RESULT m1_i1 /* live update result */
# define RS_LU_STATE m1_i2 /* state required to update */
# define RS_LU_PREPARE_MAXTIME m1_i3 /* the max time to prepare */
@@ -959,7 +965,12 @@
#define VCTLP_STATS_EP 2
/* Total. */
#define VM_NCALLS 41
#define NR_VM_CALLS 41
#define VM_CALL_MASK_SIZE BITMAP_CHUNKS(NR_VM_CALLS)
/* Basic vm calls allowed to every process. */
#define VM_BASIC_CALLS \
VM_MMAP, VM_MUNMAP, VM_MUNMAP_TEXT, VM_MAP_PHYS, VM_UNMAP_PHYS
/*===========================================================================*
* Messages for IPC server *

View File

@@ -38,6 +38,7 @@
*/
#define NR_PROCS _NR_PROCS
#define NR_SYS_PROCS _NR_SYS_PROCS
#define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS)
/* Number of controller tasks (/dev/cN device classes). */
#define NR_CTRLRS 2

View File

@@ -8,13 +8,25 @@ Interface to the reincarnation server
*/
#include <minix/bitmap.h>
#include <minix/com.h>
/* RSS definitions. */
#define RSS_NR_IRQ 16
#define RSS_NR_IO 16
#define RSS_NR_PCI_ID 32
#define RSS_NR_PCI_CLASS 4
#define RSS_NR_SYSTEM 2
#define RSS_NR_CONTROL 8
/* RSS flags. */
#define RSS_COPY 0x01 /* Copy the brinary into RS to make it possible
* to restart the driver without accessing FS
*/
#define RSS_IPC_VALID 0x02 /* rss_ipc and rss_ipclen are valid */
#define RSS_REUSE 0x04 /* Try to reuse previously copied binary */
/* Common definitions. */
#define RS_SYS_CALL_MASK_SIZE 2
#define RS_NR_CONTROL 8
#define RS_NR_PCI_DEVICE 32
#define RS_NR_PCI_CLASS 4
#define RS_MAX_LABEL_LEN 16
/* Labels are copied over separately. */
struct rss_label
@@ -40,38 +52,45 @@ struct rs_start
int rss_nr_io;
struct { unsigned base; unsigned len; } rss_io[RSS_NR_IO];
int rss_nr_pci_id;
struct { u16_t vid; u16_t did; } rss_pci_id[RSS_NR_PCI_ID];
struct { u16_t vid; u16_t did; } rss_pci_id[RS_NR_PCI_DEVICE];
int rss_nr_pci_class;
struct { u32_t class; u32_t mask; } rss_pci_class[RSS_NR_PCI_CLASS];
u32_t rss_system[RSS_NR_SYSTEM];
struct { u32_t class; u32_t mask; } rss_pci_class[RS_NR_PCI_CLASS];
u32_t rss_system[RS_SYS_CALL_MASK_SIZE];
struct rss_label rss_label;
char *rss_ipc;
size_t rss_ipclen;
#define RSS_VM_CALL_SIZE BITMAP_CHUNKS(VM_NCALLS)
bitchunk_t rss_vm[RSS_VM_CALL_SIZE];
bitchunk_t rss_vm[VM_CALL_MASK_SIZE];
int rss_nr_control;
struct rss_label rss_control[RSS_NR_CONTROL];
struct rss_label rss_control[RS_NR_CONTROL];
};
#define RF_COPY 0x01 /* Copy the brinary into RS to make it possible
* to restart the driver without accessing FS
*/
#define RF_IPC_VALID 0x02 /* rss_ipc and rss_ipclen are valid */
#define RF_REUSE 0x04 /* Try to reuse previously copied binary */
#define RSP_LABEL_SIZE 16
#define RSP_NR_DEVICE 32
#define RSP_NR_CLASS 4
/* ACL information for access to PCI devices */
struct rs_pci
{
char rsp_label[RSP_LABEL_SIZE]; /* Name of the driver */
char rsp_label[RS_MAX_LABEL_LEN];
int rsp_endpoint;
int rsp_nr_device;
struct { u16_t vid; u16_t did; } rsp_device[RSP_NR_DEVICE];
struct { u16_t vid; u16_t did; } rsp_device[RS_NR_PCI_DEVICE];
int rsp_nr_class;
struct { u32_t class; u32_t mask; } rsp_class[RSP_NR_CLASS];
struct { u32_t class; u32_t mask; } rsp_class[RS_NR_PCI_CLASS];
};
/* Definition of a public entry of the system process table. */
struct rprocpub {
short in_use; /* set when the entry is in use */
unsigned sys_flags; /* sys flags */
endpoint_t endpoint; /* process endpoint number */
dev_t dev_nr; /* major device number */
int dev_style; /* device style */
long period; /* heartbeat period (or zero) */
char label[RS_MAX_LABEL_LEN]; /* label of this service */
char proc_name[RS_MAX_LABEL_LEN]; /* process name of this service */
bitchunk_t vm_call_mask[VM_CALL_MASK_SIZE]; /* vm call mask */
struct rs_pci pci_acl; /* pci acl */
};
_PROTOTYPE( int minix_rs_lookup, (const char *name, endpoint_t *value));

View File

@@ -13,6 +13,61 @@ _PROTOTYPE( int sef_receive, (endpoint_t src, message *m_ptr) );
#define sef_debug_begin() (void)(NULL)
#define sef_debug_end() fflush(stdout)
/*===========================================================================*
* SEF Init *
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_INIT_REQUESTS 1
#define IS_SEF_INIT_REQUEST(mp) ((mp)->m_type == RS_INIT \
&& (mp)->m_source == RS_PROC_NR)
/* Type definitions. */
typedef struct {
int rproctab_gid;
} sef_init_info_t;
/* Callback type definitions. */
typedef int(*sef_cb_init_fresh_t)(int type, sef_init_info_t *info);
typedef int(*sef_cb_init_lu_t)(int type, sef_init_info_t *info);
typedef int(*sef_cb_init_restart_t)(int type, sef_init_info_t *info);
/* Callback registration helpers. */
_PROTOTYPE( void sef_setcb_init_fresh, (sef_cb_init_fresh_t cb));
_PROTOTYPE( void sef_setcb_init_lu, (sef_cb_init_lu_t cb));
_PROTOTYPE( void sef_setcb_init_restart, (sef_cb_init_restart_t cb));
/* Predefined callback implementations. */
_PROTOTYPE( int sef_cb_init_fresh_null, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_lu_null, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_restart_null, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_restart_fail, (int type, sef_init_info_t *info) );
/* Macros for predefined callback implementations. */
#define SEF_CB_INIT_FRESH_NULL sef_cb_init_fresh_null
#define SEF_CB_INIT_LU_NULL sef_cb_init_lu_null
#define SEF_CB_INIT_RESTART_NULL sef_cb_init_restart_null
#define SEF_CB_INIT_FRESH_DEFAULT sef_cb_init_fresh_null
#define SEF_CB_INIT_LU_DEFAULT sef_cb_init_lu_null
#define SEF_CB_INIT_RESTART_DEFAULT sef_cb_init_restart_null
/* Init types. */
#define SEF_INIT_FRESH 0 /* init fresh */
#define SEF_INIT_LU 1 /* init after live update */
#define SEF_INIT_RESTART 2 /* init after restart */
/* Debug. */
#define SEF_INIT_DEBUG_DEFAULT 0
#ifndef SEF_INIT_DEBUG
#define SEF_INIT_DEBUG SEF_INIT_DEBUG_DEFAULT
#endif
#define sef_init_dprint sef_dprint
#define sef_init_debug_begin sef_debug_begin
#define sef_init_debug_end sef_debug_end
/*===========================================================================*
* SEF Ping *
*===========================================================================*/

View File

@@ -49,6 +49,7 @@
#define SI_KPROC_TAB 7 /* copy of kernel process table */
#define SI_CALL_STATS 8 /* system call statistics */
#define SI_PCI_INFO 9 /* get kernel info via PM */
#define SI_PROCPUB_TAB 10 /* copy of public entries of process table */
/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
#define NULL ((void *)0)