?? NEWTITLE := '  NOS/VE Set Management ' ??
MODULE stm$disk_volume_inactive;
?? RIGHT := 110 ??

{  PURPOSE:
{    This module provides the compilation unit for stp$disk_volume_inactive.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc ste$error_condition_codes
*copyc dmt$internal_vsn
*copyc ost$status
*copyc rmt$recorded_vsn
*copyc stt$set_ordinal
?? POP ??
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc stp$clear_exclusive_access
*copyc stp$deallocate_ast_entry
*copyc stp$dm_mount_volume
*copyc stp$inactivate_master
*copyc stp$inactivate_member
*copyc stp$search_ast_by_unique_set
*copyc stp$set_exclusive_access
*copyc stp$store_dm_packet_in_master
?? OLDTITLE ??
?? NEWTITLE := '  [XDCL, #GATE] stp$disk_volume_inactive', EJECT ??
*copyc sth$disk_volume_inactive

  PROCEDURE [XDCL, #GATE] stp$disk_volume_inactive
    (    inactive_volume: rmt$recorded_vsn;
         internal_vsn: dmt$internal_vsn;
         set_ordinal: stt$set_ordinal;
         dm_packet: stt$dm_packet;
     VAR status: ost$status);

{  PURPOSE:
{    This procedure manages the operations, when a volume becomes inactive
{    in the system, as detected by device management.  Included in these
{    operations is whether the volume belongs to a set, and then updating
{    the active set table to reflect this.  Note. The request is only
{    called by device management.

    VAR
      active_set_entry: stt$active_set_entry,
      ast_index: stt$ast_index,
      unique_set_found: boolean;

    status.normal := TRUE;
    IF set_ordinal.entry_type = stc$unused THEN
{ The volume does not belong to a set.
      RETURN; {----->
    IFEND;

    stp$set_exclusive_access;
    stp$search_ast_by_unique_set (set_ordinal.unique_set_name, active_set_entry, ast_index, unique_set_found);

    IF NOT unique_set_found THEN
{ Sets does not know about this volume, or the set that this volume belongs to, this is a system error.
      stp$clear_exclusive_access;
      osp$set_status_abnormal (stc$set_management_id, ste$dm_ast_mismatch, inactive_volume, status);
      RETURN; {----->
    IFEND;

    stp$update_on_inactive_vol (inactive_volume, internal_vsn, dm_packet, active_set_entry, ast_index,
          status);
    stp$clear_exclusive_access;

    IF status.normal THEN
      { or do we always want to do this ???? }
      IF active_set_entry.number_of_jobs_using_set > 0 THEN
{ The set that this volume belongs to is in use, attempt to re-mount.
        stp$dm_mount_volume (inactive_volume, status);
        IF NOT status.normal THEN
          osp$set_status_abnormal (stc$set_management_id, ste$down_vol_used, inactive_volume, status);
          osp$append_status_parameter (osc$status_parameter_delimiter, active_set_entry.set_name, status);
          RETURN; {----->
        IFEND;
      IFEND;
    IFEND;

  PROCEND stp$disk_volume_inactive;
?? OLDTITLE ??
?? NEWTITLE := 'stp$update_on_inactive_volume', EJECT ??

  PROCEDURE stp$update_on_inactive_vol
    (    inactive_volume: rmt$recorded_vsn;
         internal_vsn: dmt$internal_vsn;
         dm_packet: stt$dm_packet;
         active_set_entry: stt$active_set_entry;
         ast_index: stt$ast_index;
     VAR status: ost$status);

{  PURPOSE:
{    This routine updates the active set table when a volume becomes inactive.
{    The master volume set table may also be updated with a new dm packet,
{    if it was a member volume that became inactive.

    VAR
      dm_packet_storage: stt$dm_packet_storage;

    dm_packet_storage.dm_packet_ever_stored := TRUE;
    dm_packet_storage.dm_packet := dm_packet;
    IF inactive_volume = active_set_entry.master_vsn THEN
      IF internal_vsn = active_set_entry.master_internal_vsn THEN
        stp$inactivate_master (ast_index, dm_packet_storage, status);
      ELSE
        osp$set_status_abnormal (stc$set_management_id, ste$internal_vsn_mismatch, inactive_volume, status);
      IFEND;
    ELSE
      stp$inactivate_member (ast_index, inactive_volume, internal_vsn, dm_packet_storage, status);
      IF active_set_entry.master_ever_up AND (active_set_entry.master_volume_activity.volume_activity_status =
            stc$active) THEN
        stp$store_dm_packet_in_master (active_set_entry.master_vsn, inactive_volume, dm_packet_storage,
              status);
      IFEND;
    IFEND;

    IF status.normal THEN
      stp$deallocate_ast_entry (ast_index, status);
    IFEND;

  PROCEND stp$update_on_inactive_vol;
?? OLDTITLE ??
MODEND stm$disk_volume_inactive;
