IBM Books

Managing Shared Disks

fence subroutine


fence - Allows you to request and change the virtual shared disk fence map. The fence map controls whether virtual shared disks can send or satisfy requests from virtual shared disks at remote nodes.


#include <vsd_ioctl.h>
int ioctl(FileDescriptor, Command, Argument)
int FileDescriptor, Command;
void *Argument;


Specifies the open file descriptor for which the control operation is to be performed.

Specifies the control function to be performed. The value of this parameter is always GIOCFENCE.

Specifies a pointer to a vsd_fence_map structure.

The flags field of the vsd_fence_map structure determines the type of operation that is performed. The flags could be set with one or more options using the OR operator. These options are as follows:

Indicates that all the bits in the node_FenceMask bitmap represent the current status for a given VSD minor, and the node_FenceMask bitmap is the new status to be applied by this request. The request will succeed only if the current status depicted in the node_FenceMask is valid.

If this option is specified, a node can unfence itself.

Denotes a query request.

Denotes a fence request.

Indicates that the node_FenceMask bitmap denotes which bits in the node_FenceMap the request applies to. Only nodes whose bit is turned on in the node_FenceMask bitmap may change status.


The fence-map is an array with the following definition:

typedef struct
unsigned int   nvsds; /* number of elements in the vsd_Fence
                         array */
ulong          flags; /* specifies the type of request */
vsd_Fence_t    *Map;  /* array of vsd_Fence structures */
} vsd_FenceMap_t;

nvsds represents the number of elements in the vsd_Fence array. The flags specify the type of request. The map is an array of the following structure:

typedef struct
    unsigned int      vsd_minor;       /* The bitmap is associated
                                          with this minor */
    vsd_Fence_Bitmap  node_FenceMap;   /* Nodes status - fenced or
                                          unfenced */
    vsd_Fence_Bitmap  node_FenceMask;  /* Determine how node_FenceMap
                                          is used */
} vsd_Fence_t;

The vsd_minor represents the virtual shared disk device's minor number. The node_FenceMap bitmap denotes which nodes are fenced (bit turned on) or unfenced (bit turned off) from the virtual shared disk. You could use the MAP_SET and MAP_CLR macros defined in vsd_ioctl.h to turn a given bit in the map on or off. The node_FenceMask is used to interpret the node_FenceMap bitmap, depending on the flags field.

You can submit a fence map that changes the current virtual shared disk map (maintained by the IBM Virtual Shared Disk subsystem) according to the flags set in the vsd_fence_map structure. The request is considered a delta to the current virtual shared disk map. You can also utilize this ioctl to query the current virtual shared disk map.

Return values

If the request succeeds, the ioctl returns 0. In the case of an error, a value of -1 is returned with the global variable errno set to identify the error.

Error values

The fence ioctl subroutine can return the following error codes:

Indicates that an unfence was requested from a fenced node without the VSD_FENCE_FORCE option.

Indicates an invalid request (ambiguous flags or unidentified virtual shared disks).

Indicates that either the primary or the secondary node for a virtual shared disk to be fenced is not a member of the virtual shared disk group, or the virtual shared disk in question is in the stopped state.

Indicates, in the case of a query request, that the current virtual shared disk fence map is larger than the one specified in the query request. The query fails and the nvsds field in the request is changed to reflect the current size of the fence map.

Indicates that the group is not active or IBM Recoverable Virtual Shared Disk is not available.

Indicates that the IBM Virtual Shared Disk driver is being unloaded.


The following is an example of how to fence a virtual shared disk with a minor number of 7 from node 4 and 5, and to unfence a virtual shared disk with a minor number of 5 from node 1:

int fd;
vsd_FenceMap_t FenceMap;
/* two VSDs to work with */
FenceMap.Map=(vsd_Fence *) malloc (2*sizeof(vsd_Fence));
FenceMap.nvsds = 2;
/* Clear the Map and Mask*/
/* fence nodes 4,5 from minor 7 */
FenceMap.Map[0].vsd_minor = 7;
MAP_SET(4, FenceMap.Map[0]node_FenceMap);
MAP_SET(4, FenceMap.Map[0].node_FenceMask);
MAP_SET(5, FenceMap.Map[0].node_FenceMap);
MAP_SET(5, FenceMap.Map[0].node_FenceMask)
/* Unfence node 1 from minor 5*/
FenceMap.Map[1].vsd_minor = 5;
MAP_SET(1, FenceMap.Map[1].node_FenceMask);
/* Issue the fence request */

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]