A system that manages a file system for a file server. A file operation is
received that signals a reservation operation for a file having a file
size. Preferably, the file system uses a write anywhere file system
layout, the file operation that signals the reservation operation is a
zero length write request, and the file operation that signals the
reservation operation includes a parameter that specifies the file size.
A number of blocks needed to be reserved to accommodate the file is
computed. Preferably, computing the number of blocks needed to be
reserved to accommodate the file includes determining a total number of
direct and indirect blocks needed to accommodate the file size, and
subtracting a total number of blocks already allocated for the file and a
total number of cached unallocated blocks for the file from the total
number of direct and indirect blocks needed to accommodate the file size.
A number of unallocated blocks is reserved in the file system, with the
number of reserved blocks equal to the number of blocks needed to be
reserved to accommodate the file. Reserving the number of blocks
preferably includes setting a flag in an inode for the file that
indicates blocks have been reserved for the file, and incrementing a
reserved block count in a file system information block by the number of
blocks needed.