6.2 Extending Files Using Allocation

Extend an NLM application file using default file allocation:

  1. Determine if space is available.

    Call DFSReturnVolumeMappingInformation to obtain the volume size, allocation unit size, sector size, number of free blocks, number of blocks available in deleted files, number of blocks not available in deleted files, and so forth. If the desired number of blocks is not available on the volume, skip to Step 4.

    Since the OS is multitasking, it is possible (and likely) that other processes allocate (and free) volume blocks at any time, making information returned by DFSReturnVolumeMappingInformation obsolete. As a result you must design DFS NLM applications to repeat this procedure multiple times to deal with the failure of DFSExpandFile and DFSFreeLimboVolumeSpace.

  2. Determine the current allocation of the file, specifically the file block where the file is to be extended.

    Call DFSReturnFileMappingInformation to determine the file’s current mapping, including volume segments and blocks allocated. The starting file block to be extended must be specified in the extend request made in Step 3.

    A file might not be extended by specifying file block addresses that already exist. This means that an extend request to allocate file space for a hole in a sparse file must not specify a number or contiguous blocks that exceed the size of the hole.

  3. Allocate blocks to expand the file.

    Call DFSExpandFile specifying the number of blocks to be extended and wildcards (-1) for the volume block number and optionally for the volume segment number. This allows DFS to select the range of contiguous blocks used to extend the file.

    For normal files, extending a file a single block at a time and specifying wildcards for both the volume block address and the volume segment is identical in function to letting the NetWare® OS allocate for normal files.

    Specifying a wildcard segment number in conjunction with a wildcard volume block address allows the OS to alternate its selection of volume segments for file allocation, thus facilitating file striping on systems where it is advantageous to stripe files. Specifying a larger number of blocks with a wildcard volume segment stripes the file (provided that multiple volume segments exist) with the larger granularity. If there is not enough contiguous available space to expand the file by the requested number of blocks, applications may be required to make several calls specifying smaller request sizes, or fail the request.

    If the return code indicates that the above operation was not successful, proceed to Step 4. Otherwise, the file has been extended as requested.

  4. Free up volume space.

    Call DFSFreeLimboVolumeSpace specifying the volume number and the requested number of blocks to be freed. This causes one or more deleted files to be purged from the volume in order of time of deletion. Go to Step 1.