示例#1
0
/* Preallocate the file
   This functon is wrapped in case we want to provide more 
   feedback / checking
*/
int
preallocateFile(int fileHandle, long long startOffset, long long bytesToAllocate) 
{
    int rc = gpfs_prealloc(fileHandle, startOffset, bytesToAllocate);
    if (rc < 0)
    {
        fprintf(stderr, "Error %d: preallocation at %lld for %lld in %s\n",
             errno, startOffset, bytesToAllocate, fileName);
		return (-1);
    }
	
	return (TRUE);
}
示例#2
0
static int preallocate_space(int fd, SMB_OFF_T size)
{
	int err;
#ifndef HAVE_GPFS
	lock_type fl = {0};

	if (size <= 0) {
		return 0;
	}

	fl.l_whence = SEEK_SET;
	fl.l_start = 0;
	fl.l_len = size;

	/* IMPORTANT: We use RESVSP because we want the extents to be
	 * allocated, but we don't want the allocation to show up in
	 * st_size or persist after the close(2).
	 */

#if defined(XFS_IOC_RESVSP64)
	/* On Linux this comes in via libxfs.h. */
	err = xfsctl(NULL, fd, XFS_IOC_RESVSP64, &fl);
#elif defined(F_RESVSP64)
	/* On IRIX, this comes from fcntl.h. */
	err = fcntl(fd, F_RESVSP64, &fl);
#else
	err = -1;
	errno = ENOSYS;
#endif
#else /* GPFS uses completely different interface */
       err = gpfs_prealloc(fd, (gpfs_off64_t)0, (gpfs_off64_t)size);
#endif

	if (err) {
		DEBUG(module_debug,
			("%s: preallocate failed on fd=%d size=%lld: %s\n",
			MODULE, fd, (long long)size, strerror(errno)));
	}

	return err;
}