Exemple #1
0
/*@
    ADIO_ResolveFileType - determines file system type and operations from
                           file name string; this is a collective call

Input Parameters:
. comm - communicator across which collective open is performed
. filename - name of file (string)

Output Parameters:
. fstype - (pointer to) int holding file system type
. ops - (address of) pointer to table of valid file operations
. error_code - (pointer to) int holding error code

Notes:
This code used to be in MPI_File_open(), but it has been moved into here in 
order to clean things up.  The goal is to separate all this "did we compile
for this fs type" code from the MPI layer and also to introduce the ADIOI_Fns
tables in a reasonable way. -- Rob, 06/06/2001
@*/
void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
			  ADIOI_Fns **ops, int *error_code)
{
    int myerrcode, file_system, min_code, max_code;
    char *tmp;
    static char myname[] = "ADIO_RESOLVEFILETYPE";
    char * p;

    file_system = -1;
    if (filename == NULL) {
	    *error_code = ADIOI_Err_create_code(myname, filename, ENOENT);
	    return;
    }
    tmp = strchr(filename, ':');
    if (!tmp) {
	int have_nfs_enabled=0;
	*error_code = MPI_SUCCESS;
	/* no prefix; use system-dependent function call to determine type */
	/* Optimization: we can reduce the 'storm of stats' that result from
	 * thousands of mpi processes determinig file type this way.  Let us
	 * have just one process stat the file and broadcast the result to
	 * everyone else.  
	 * - Note that we will not catch cases like
	 * http://www.mcs.anl.gov/web-mail-archive/lists/mpich-discuss/2007/08/msg00042.html
	 * (edit: now http://lists.mcs.anl.gov/pipermail/mpich-discuss/2007-August/002648.html)
	 *
	 * where file systems are not mounted or available on other processes,
	 * but we'll catch those a few functions later in ADIO_Open 
	 * - Note that if we have NFS enabled, we might have a situation where,
	 *   for example, /home/user/data.out is UFS on one process but NFS on
	 *   others, so we won't perform this optimization if NFS is enabled.
	 * - Another point: error codes and file system types are broadcast to
	 *   all members of the communicator, so we get to skip the allreduce
	 *   steps*/

#ifdef ROMIO_NFS
	have_nfs_enabled=1;
#endif
	if (!have_nfs_enabled) {
	    ADIO_FileSysType_fncall_scalable(comm, filename, &file_system, &myerrcode);
	    if (myerrcode != MPI_SUCCESS) {
		*error_code = myerrcode;
		return;
	    }
	} else {
	    ADIO_FileSysType_fncall(filename, &file_system, &myerrcode);

	    /* the check for file system type will hang if any process got
	     * an error in ADIO_FileSysType_fncall.  Processes encountering
	     * an error will return early, before the collective file
	     * system type check below.  This case could happen if a full
	     * path exists on one node but not on others, and no prefix
	     * like ufs: was provided.  see discussion at
	     * http://www.mcs.anl.gov/web-mail-archive/lists/mpich-discuss/2007/08/msg00042.html
	     * (edit: now
	     * http://lists.mcs.anl.gov/pipermail/mpich-discuss/2007-August/002648.html)
	     */

	    MPI_Allreduce(&myerrcode, &max_code, 1, MPI_INT, MPI_MAX, comm);
	    if (max_code != MPI_SUCCESS)  {
		*error_code = max_code;
		return;
	    }
	    /* ensure everyone came up with the same file system type */
	    MPI_Allreduce(&file_system, &min_code, 1, MPI_INT,
		    MPI_MIN, comm);
	    if (min_code == ADIO_NFS) file_system = ADIO_NFS;
	}
    }
    else {
	/* prefix specified; just match via prefix and assume everyone got 
	 * the same thing.
	 *
	 * perhaps we should have this code go through the allreduce as well?
	 */
	ADIO_FileSysType_prefix(filename, &file_system, &myerrcode);
	if (myerrcode != MPI_SUCCESS) {
	    *error_code = myerrcode;
	    return;
	}
    }

    /* lastly, there may be situations where one cannot override the file
     * system detection with a prefix -- maybe the file name is passed to both
     * posix and MPI-IO routines, or maybe the file name is hard-coded into an
     * application.
     * Assumes all processes set the same environment varialble.
     * Values: the same prefix you would stick on a file path. e.g. pvfs2: --
     * including the colon! */
    p = getenv("ROMIO_FSTYPE_FORCE");
    if (p != NULL) {
	ADIO_FileSysType_prefix(p, &file_system, &myerrcode);
	if (myerrcode != MPI_SUCCESS) {
	    *error_code = myerrcode;
	    return;
	}
    }

    /* verify that we support this file system type and set ops pointer */
    if (file_system == ADIO_PFS) {
#ifndef ROMIO_PFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_PFS_operations;
#endif
    }
    if (file_system == ADIO_PIOFS) {
#ifndef ROMIO_PIOFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_PIOFS_operations;
#endif
    }
    if (file_system == ADIO_UFS) {
#ifndef ROMIO_UFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_UFS_operations;
#endif
    }
    if (file_system == ADIO_NFS) {
#ifndef ROMIO_NFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_NFS_operations;
#endif
    }
    if (file_system == ADIO_PANFS) {
#ifndef ROMIO_PANFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_PANFS_operations;
#endif
    }
    if (file_system == ADIO_HFS) {
#ifndef ROMIO_HFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_HFS_operations;
#endif
    }
    if (file_system == ADIO_XFS) {
#ifndef ROMIO_XFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_XFS_operations;
#endif
    }
    if (file_system == ADIO_SFS) {
#ifndef ROMIO_SFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_SFS_operations;
#endif
    }
    if (file_system == ADIO_PVFS) {
#ifndef ROMIO_PVFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_PVFS_operations;
#endif
    }
    if (file_system == ADIO_PVFS2) {
#ifndef ROMIO_PVFS2
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_PVFS2_operations;
#endif
    }
    if (file_system == ADIO_NTFS) {
#ifndef ROMIO_NTFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_NTFS_operations;
#endif
    }
    if (file_system == ADIO_TESTFS) {
#ifndef ROMIO_TESTFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_TESTFS_operations;
#endif
    }

    if (file_system == ADIO_GPFS) {
#ifndef ROMIO_GPFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					myname, __LINE__, MPI_ERR_IO,
					"**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_GPFS_operations;
#endif
    }

    if (file_system == ADIO_GRIDFTP) {
#ifndef ROMIO_GRIDFTP
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_GRIDFTP_operations;
#endif
    }
    if (file_system == ADIO_LUSTRE) {
#ifndef ROMIO_LUSTRE 
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_LUSTRE_operations;
#endif
    }
    if (file_system == ADIO_ZOIDFS) {
#ifndef ROMIO_ZOIDFS
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**iofstypeunsupported", 0);
	return;
#else
	*ops = &ADIO_ZOIDFS_operations;
#endif
    }
    *error_code = MPI_SUCCESS;
    *fstype = file_system;
    return;
}
Exemple #2
0
/*@
    ADIO_ResolveFileType - determines file system type and operations from
                           file name string; this is a collective call

Input Parameters:
. comm - communicator across which collective open is performed
. filename - name of file (string)

Output Parameters:
. fstype - (pointer to) int holding file system type
. ops - (address of) pointer to table of valid file operations
. error_code - (pointer to) int holding error code

Notes:
This code used to be in MPI_File_open(), but it has been moved into here in 
order to clean things up.  The goal is to separate all this "did we compile
for this fs type" code from the MPI layer and also to introduce the ADIOI_Fns
tables in a reasonable way. -- Rob, 06/06/2001
@*/
void ADIO_ResolveFileType(MPI_Comm comm, char *filename, int *fstype, 
			  ADIOI_Fns **ops, int *error_code)
{
#ifndef PRINT_ERR_MSG
    static char myname[] = "ADIO_RESOLVEFILETYPE";
#endif
    int myerrcode, file_system, min_code;
    char *tmp;

    file_system = -1;
    tmp = strchr(filename, ':');
    if (!tmp) {
	/* no prefix; use system-dependent function call to determine type */
	ADIO_FileSysType_fncall(filename, &file_system, &myerrcode);
	if (myerrcode != MPI_SUCCESS) {
#ifdef PRINT_ERR_MSG
	    FPRINTF(stderr, "ADIO_ResolveFileType: Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:).\n");
	    MPI_Abort(MPI_COMM_WORLD, 1);
#else
	    myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_FSTYPE,
					myname, (char *) 0, (char *) 0);
	    *error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	    return;
#endif
	}

	/* ensure that everyone came up with the same file system type */
	MPI_Allreduce(&file_system, &min_code, 1, MPI_INT, MPI_MIN, comm);
	if (min_code == ADIO_NFS) file_system = ADIO_NFS;

    }
    else {
	/* prefix specified; just match via prefix and assume everyone got 
	 * the same thing.
	 *
	 * perhaps we should have this code go through the allreduce as well?
	 */
	ADIO_FileSysType_prefix(filename, &file_system, &myerrcode);
	if (myerrcode != MPI_SUCCESS) {
#ifdef PRINT_ERR_MSG
	    FPRINTF(stderr, "ADIO_ResolveFileType: Can't determine the file-system type from the specified prefix. Check the filename/path and prefix you provided and try again.\n");
	    MPI_Abort(MPI_COMM_WORLD, 1);
#else
	    myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_FSTYPE,
					myname, (char *) 0, (char *) 0);
	    *error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	    return;
#endif
	}
    }

    /* verify that we support this file system type and set ops pointer */
    if (file_system == ADIO_PFS) {
#ifndef PFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the PFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PFS,
				    myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_PFS_operations;
#endif
    }
    if (file_system == ADIO_PIOFS) {
#ifndef PIOFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the PIOFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PIOFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_PIOFS_operations;
#endif
    }
    if (file_system == ADIO_UFS) {
#ifndef UFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the UFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_UFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_UFS_operations;
#endif
    }
    if (file_system == ADIO_NFS) {
#ifndef NFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the NFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_NFS,
				     myname, (char *) 0, (char *) 0);
	*error_code =  ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_NFS_operations;
#endif
    }
    if (file_system == ADIO_HFS) {
#ifndef HFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the HFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_HFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_HFS_operations;
#endif
    }
    if (file_system == ADIO_XFS) {
#ifndef XFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the XFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_XFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_XFS_operations;
#endif
    }
    if (file_system == ADIO_SFS) {
#ifndef SFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the SFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_SFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_SFS_operations;
#endif
    }
    if (file_system == ADIO_PVFS) {
#ifndef ROMIO_PVFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the PVFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PVFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_PVFS_operations;
#endif
    }
    if (file_system == ADIO_NTFS) {
#ifndef ROMIO_NTFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the NTFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_NTFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_NTFS_operations;
#endif
    }
    if (file_system == ADIO_TESTFS) {
#ifndef ROMIO_TESTFS
# ifdef PRINT_ERR_MSG
	FPRINTF(stderr, "ADIO_ResolveFileType: ROMIO has not been configured to use the TESTFS file system\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
# else
	myerrcode = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_TESTFS,
				     myname, (char *) 0, (char *) 0);
	*error_code = ADIOI_Error(MPI_FILE_NULL, myerrcode, myname);
	return;
# endif
#else
	*ops = &ADIO_TESTFS_operations;
#endif
    }
    *error_code = MPI_SUCCESS;
    *fstype = file_system;
    return;
}