Server Internals: Volumes

Next Previous Contents

## 2. Volumes

## 2.1 Volume Data Structures

The following volume related structures are around:

1. Volume: defined in volume.h. A VM structure held in a hash table. Contains quite a lot of information, such as a pointer to a volHeader, Device, partition, vol_index, vnodeIndex, locks and other run time data.
2. VolumeDiskData: defined in volume.h. An RVM structure holding the persistent data associated with the volume.
3. volHeader: defined in volume. h, appears to be a VM structure sitting on a dlist. Contains a VolumeDiskData structure and points to a Volume structure.
4. VolumeData: defined in camprivate.h. An RVM structure, points to VolumeDiskData and points to SmallVnodeLists (with some contstants related to these, and to BigVnodeLists.
5. VolHead: defined in camprivate.h. An RVM structure containing a VolumeHeader and VolumeData.
6. VolumeHeader: defined in volume.h. Contains the volumeid, type and parentid.

## 2.2 simple volume calls

In RVM an array is set up at initialization time: VolHead VolumeList[MAXVOLS].

The VInitVolumePackage sets up a lot of other structures related to volumes and vnodes.

1. InitLRU: calloc a sequence of volHeader's, then call ReleaseVolumeHeader to put it at the head of the volumeLRU.
2. InitVolTable: sets up a volhash table, hashing volid's to get the index in the VolumeList.
3. VolumeHashTable: Hash table used to store pointers to the Volume structure
4. VInitVnodes: setup of the vnode VM lru caches for small and large vnodes. Store summary information in the VnodeClassInfoArray for both small and large vnodes. The way to reach allocated vnode arrays is through the VnodeClassInfoArray.
5. InitLogStorage: go through the VolumeList and assign VM resolution log memory for every volume; store the pointer in VolLog[i]. The number of rlentries assigned is VolumeList[ i].data.volumeInfo->maxlogentries.
6. Check the vldb.
7. Find server partitions.
8. Run S_VolSalvage: this goes directly through the directory contents, without invoking the buffer cache.
9. FSYNC_fsInit: sets up a thread to watch over volume relocation issues. No idea if this still works.
10. Now iterate through all volumes and call VAttachVolumeById, to instantiate the VM volume information and attach the volumes. When attached, call InitVolLog which initialize pointers in VM for resolution. The pointers give olists, whose elements correspond to the vnode rec_smolists. Finally create a VNResLog for each of the olist. entries. Set the RVM log transients for this volume.
11. Finally write out the /vice/vol/VolumeList file (VListVolumes).
12. The Vinit variable is now set to 1.

Attaching a volume is described in AttachVolumebyId and attach2. It means allocating a Volume structure in VM, finding its partition, finding its VolHeader on the LRU, locating the VolumeDiskData. If the volume needs salvaging, or appears to be inuse already, or not blessed don't attach it. Now insert the Volume structure into the hash table, and initialize some vnode information in the volume structure.

### Creating a volume

The start of this is found in vol-create.cc in the volutil directory.

1. We first initialize the volumeid with VAllocateVolumeId.
2. VCreateVolume (vol/vutil.cc) now build a VolumeDiskData structure vol in VM. The recoverable resolution log vol.log is generated with recov_vol_log which does a RVMLIB_REC_MALLOC to allocate a certain number of pointers to recle's.

Next Previous Contents