📄 ad_fstype.c
字号:
err = stat(dir, &sbuf); ADIOI_Free(dir); } if (err) { /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */ return; } else { if (!strcmp(sbuf.st_fstype, "nfs")) *fstype = ADIO_NFS; else *fstype = ADIO_SFS; /* assuming SX4 for now */ }#endif /* STAT APPROACH */#ifdef ROMIO_NTFS ADIOI_UNREFERENCED_ARG(filename); ADIOI_UNREFERENCED_ARG(error_code); *fstype = ADIO_NTFS; /* only supported FS on Windows */#elif defined(ROMIO_NFS) *fstype = ADIO_NFS;#elif defined(ROMIO_UFS) *fstype = ADIO_UFS;#else /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */#endif}/* all proceeses opening, creating, or deleting a file end up invoking several * stat system calls (unless a fs prefix is given). Cary out this file system * detection in a more scalable way by having rank 0 stat the file and broadcast the result (fs type and error code) to the other mpi processes */static void ADIO_FileSysType_fncall_scalable(MPI_Comm comm, char *filename, int * file_system, int * error_code){ int rank; int buf[2]; MPI_Comm_rank(comm, &rank); if (rank == 0) { ADIO_FileSysType_fncall(filename, file_system, error_code); buf[0] = *file_system; buf[1] = *error_code; } MPI_Bcast(buf, 2, MPI_INT, 0, comm); *file_system = buf[0]; *error_code = buf[1];}/* ADIO_FileSysType_prefix - determines file system type for a file using a prefix on the file name. upper layer should have already determined that a prefix is present.Input Parameters:. filename - path to file, including prefix (xxx:)Output Parameters:. fstype - pointer to integer in which to store file system type (ADIO_XXX). error_code - pointer to integer in which to store error code Returns MPI_SUCCESS in error_code on success. Filename not having a prefix is considered an error. Except for on Windows systems where the default is NTFS. */static void ADIO_FileSysType_prefix(char *filename, int *fstype, int *error_code){ static char myname[] = "ADIO_RESOLVEFILETYPE_PREFIX"; *error_code = MPI_SUCCESS; if (!strncmp(filename, "pfs:", 4) || !strncmp(filename, "PFS:", 4)) { *fstype = ADIO_PFS; } else if (!strncmp(filename, "piofs:", 6) || !strncmp(filename, "PIOFS:", 6)) { *fstype = ADIO_PIOFS; } else if (!strncmp(filename, "ufs:", 4) || !strncmp(filename, "UFS:", 4)) { *fstype = ADIO_UFS; } else if (!strncmp(filename, "nfs:", 4) || !strncmp(filename, "NFS:", 4)) { *fstype = ADIO_NFS; } else if (!strncmp(filename, "panfs:", 6) || !strncmp(filename, "PANFS:", 6)) { *fstype = ADIO_PANFS; } else if (!strncmp(filename, "hfs:", 4) || !strncmp(filename, "HFS:", 4)) { *fstype = ADIO_HFS; } else if (!strncmp(filename, "xfs:", 4) || !strncmp(filename, "XFS:", 4)) { *fstype = ADIO_XFS; } else if (!strncmp(filename, "sfs:", 4) || !strncmp(filename, "SFS:", 4)) { *fstype = ADIO_SFS; } else if (!strncmp(filename, "pvfs:", 5) || !strncmp(filename, "PVFS:", 5)) { *fstype = ADIO_PVFS; } else if (!strncmp(filename, "pvfs2:", 6)||!strncmp(filename, "PVFS2:", 6)) { *fstype = ADIO_PVFS2; } else if (!strncmp(filename, "testfs:", 7) || !strncmp(filename, "TESTFS:", 7)) { *fstype = ADIO_TESTFS; } else if (!strncmp(filename, "ftp:", 4) || !strncmp(filename, "gsiftp:", 7)) { *fstype = ADIO_GRIDFTP; } else if (!strncmp(filename, "lustre:", 7) || !strncmp(filename, "LUSTRE:", 7)) { *fstype = ADIO_LUSTRE; } else if (!strncmp(filename, "bgl:", 4) || !strncmp(filename, "BGL:", 4)) { *fstype = ADIO_BGL; } else if (!strncmp(filename, "bglockless:", 11) || !strncmp(filename, "BGLOCKLESS:", 11)) { *fstype = ADIO_BGLOCKLESS; } else {#ifdef ROMIO_NTFS *fstype = ADIO_NTFS;#else *fstype = 0; /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NO_SUCH_FILE, "**filename", "**filename %s", filename); /* --END ERROR HANDLING-- */#endif }}/*@ ADIO_ResolveFileType - determines file system type and operations from file name string; this is a collective callInput 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 codeNotes: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 compilefor this fs type" code from the MPI layer and also to introduce the ADIOI_Fnstables in a reasonable way. -- Rob, 06/06/2001@*/void ADIO_ResolveFileType(MPI_Comm comm, 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"; file_system = -1; 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 * 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); if (myerrcode != MPI_SUCCESS) { *error_code = 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 */ MPI_Allreduce(error_code, &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; } } /* 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_BGL) {#ifndef ROMIO_BGL *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_BGL_operations;#endif } if (file_system == ADIO_BGLOCKLESS) {#ifndef ROMIO_BGLOCKLESS *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_BGLOCKLESS_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 = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iofstypeunsupported", 0); return;#else *ops = &ADIO_LUSTRE_operations;#endif } *error_code = MPI_SUCCESS; *fstype = file_system; return;}/* * vim: ts=8 sts=4 sw=4 noexpandtab */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -