Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ompi/mca/fs/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OMPI_DECLSPEC int mca_fs_base_init_file (struct mca_io_ompio_file_t *file);

OMPI_DECLSPEC int mca_fs_base_get_param (struct mca_io_ompio_file_t *file, int keyval);
OMPI_DECLSPEC void mca_fs_base_get_parent_dir (char *filename, char **dirnamep);
OMPI_DECLSPEC int mca_fs_base_get_fstype(char *fname);
/*
* Globals
*/
Expand Down
30 changes: 29 additions & 1 deletion ompi/mca/fs/base/fs_base_get_parent_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 University of Houston. All rights reserved.
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
Expand All @@ -25,9 +25,11 @@

#include "ompi/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/util/path.h"

#include "ompi/mca/fs/fs.h"
#include "ompi/mca/fs/base/base.h"
#include "ompi/mca/io/ompio/io_ompio.h"

#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h> /* or <sys/vfs.h> */
Expand Down Expand Up @@ -93,3 +95,29 @@ void mca_fs_base_get_parent_dir ( char *filename, char **dirnamep)
*dirnamep = dir;
return;
}

int mca_fs_base_get_fstype(char *fname )
{
int ompio_type = UFS;
char *fstype=NULL;
bool ret = opal_path_nfs ( fname, &fstype );

if ( false == ret ) {
char *dir;
mca_fs_base_get_parent_dir (fname, &dir );
ret = opal_path_nfs (dir, &fstype);
if ( false == ret ) {
return ompio_type;
}
}
if ( 0 == strncasecmp(fstype, "lustre", sizeof("lustre")) ) {
ompio_type = LUSTRE;
}
else if ( 0 == strncasecmp(fstype, "pvfs2", sizeof("pvfs2"))) {
ompio_type = PVFS2;
}

free (fstype);
return ompio_type;
}

20 changes: 3 additions & 17 deletions ompi/mca/fs/lustre/fs_lustre.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -93,22 +93,8 @@ mca_fs_lustre_component_file_query (mca_io_ompio_file_t *fh, int *priority)
tmp = strchr (fh->f_filename, ':');
if (!tmp) {
if (OMPIO_ROOT == fh->f_rank) {
do {
err = statfs (fh->f_filename, &fsbuf);
} while (err && (errno == ESTALE));

if (err && (errno == ENOENT)) {
mca_fs_base_get_parent_dir (fh->f_filename, &dir);
err = statfs (dir, &fsbuf);
free (dir);
}
#ifndef LL_SUPER_MAGIC
#define LL_SUPER_MAGIC 0x0BD00BD0
#endif
if (fsbuf.f_type == LL_SUPER_MAGIC) {
fh->f_fstype = LUSTRE;
}
}
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
}
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
1,
MPI_INT,
Expand Down
15 changes: 2 additions & 13 deletions ompi/mca/fs/pvfs2/fs_pvfs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -96,18 +96,7 @@ mca_fs_pvfs2_component_file_query (mca_io_ompio_file_t *fh, int *priority)
tmp = strchr (fh->f_filename, ':');
if (!tmp) {
if (OMPIO_ROOT == fh->f_rank) {
do {
err = statfs (fh->f_filename, &fsbuf);
} while (err && (errno == ESTALE));

if (err && (errno == ENOENT)) {
mca_fs_base_get_parent_dir (fh->f_filename, &dir);
err = statfs (dir, &fsbuf);
free (dir);
}
if (fsbuf.f_type == PVFS2_SUPER_MAGIC) {
fh->f_fstype = PVFS2;
}
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
}
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
1,
Expand Down
3 changes: 2 additions & 1 deletion opal/mca/shmem/mmap/shmem_mmap_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2010-2014 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2016 University of Houston. All rights reserved.
*
* $COPYRIGHT$
*
Expand Down Expand Up @@ -363,7 +364,7 @@ segment_create(opal_shmem_ds_t *ds_buf,
* this is an important check because if the backing store is located on
* a network filesystem, the user may see a shared memory performance hit.
*/
if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name)) {
if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name, NULL)) {
char hn[MAXHOSTNAMELEN];
gethostname(hn, MAXHOSTNAMELEN - 1);
hn[MAXHOSTNAMELEN - 1] = '\0';
Expand Down
32 changes: 28 additions & 4 deletions opal/util/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2016 University of Houston. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -444,8 +445,9 @@ static char *opal_check_mtab(char *dev_path)
* If the file is not created, the parent directory is checked.
* This allows checking for NFS prior to opening the file.
*
* @param[in] fname File name to check
*
* @fname[in] File name to check
* @fstype[out] File system type if retval is true
*
* @retval true If fname is on NFS, Lustre, Panasas or GPFS
* @retval false otherwise
*
Expand Down Expand Up @@ -493,11 +495,14 @@ static char *opal_check_mtab(char *dev_path)
#ifndef AUTOFS_SUPER_MAGIC
#define AUTOFS_SUPER_MAGIC 0x0187
#endif
#ifndef PVFS2_SUPER_MAGIC
#define PVFS2_SUPER_MAGIC 0x20030528
#endif

#define MASK2 0xffff
#define MASK4 0xffffffff

bool opal_path_nfs(char *fname)
bool opal_path_nfs(char *fname, char **ret_fstype)
{
int i;
int fsrc = -1;
Expand All @@ -523,7 +528,8 @@ bool opal_path_nfs(char *fname)
{NFS_SUPER_MAGIC, MASK2, "nfs"},
{AUTOFS_SUPER_MAGIC, MASK2, "autofs"},
{PAN_KERNEL_FS_CLIENT_SUPER_MAGIC, MASK4, "panfs"},
{GPFS_SUPER_MAGIC, MASK4, "gpfs"}
{GPFS_SUPER_MAGIC, MASK4, "gpfs"},
{PVFS2_SUPER_MAGIC, MASK4, "pvfs2"}
};
#define FS_TYPES_NUM (int)(sizeof (fs_types)/sizeof (fs_types[0]))

Expand Down Expand Up @@ -555,6 +561,9 @@ bool opal_path_nfs(char *fname)
fname, errno, file));
if (EPERM == errno) {
free(file);
if ( NULL != ret_fstype ) {
*ret_fstype = NULL;
}
return false;
}

Expand All @@ -563,6 +572,9 @@ bool opal_path_nfs(char *fname)
if (NULL == last_sep || (1 == strlen(last_sep) &&
OPAL_PATH_SEP[0] == *last_sep)) {
free (file);
if ( NULL != ret_fstype ) {
*ret_fstype=NULL;
}
return false;
}
*last_sep = '\0';
Expand Down Expand Up @@ -609,6 +621,9 @@ bool opal_path_nfs(char *fname)
}

free (file);
if ( NULL != ret_fstype ) {
*ret_fstype=NULL;
}
return false;

found:
Expand All @@ -625,16 +640,25 @@ bool opal_path_nfs(char *fname)
if (0 == strcasecmp(fs_types[x].f_fsname, fs_type)) {
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n", fname, fs_type));
free(fs_type);
if ( NULL != ret_fstype ) {
*ret_fstype = strdup(fs_types[x].f_fsname);
}
return true;
}
}
free(fs_type);
if ( NULL != ret_fstype ) {
*ret_fstype=NULL;
}
return false;
}
}

OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n",
fname, fs_types[i].f_fsname));
if ( NULL != ret_fstype ) {
*ret_fstype = strdup (fs_types[i].f_fsname);
}
return true;

#undef FS_TYPES_NUM
Expand Down
10 changes: 7 additions & 3 deletions opal/util/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2016 University of Houston. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -126,19 +127,22 @@ OPAL_DECLSPEC char *opal_path_access(char *fname, char *path, int mode) __opal_a

/**
* @brief Figure out, whether fname is on network file system
* and return fstype if known
*
* Try to figure out, whether the file name specified through fname is
* on any network file system (currently NFS, Lustre and Panasas).
* on any network file system (currently NFS, Lustre, GPFS, Panasas
* and PVFS2 ).
*
* If the file is not created, the parent directory is checked.
* This allows checking for NFS prior to opening the file.
*
* @param[in] fname File name to check
* @fname[in] File name to check
* @fstype[out] File system type if retval is true
*
* @retval true If fname is on NFS, Lustre or Panasas
* @retval false otherwise
*/
OPAL_DECLSPEC bool opal_path_nfs(char *fname) __opal_attribute_warn_unused_result__;
OPAL_DECLSPEC bool opal_path_nfs(char *fname, char **fstype) __opal_attribute_warn_unused_result__;

/**
* @brief Returns the disk usage of path.
Expand Down
6 changes: 3 additions & 3 deletions test/util/opal_path_nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, char* argv[])
printf("Interactive opal_path_nfs() test:\n");
for (i = 1; i < argc; i++) {
printf ("Is dir[%d]:%s one of the detected network file systems? %s\n",
i, argv[i], opal_path_nfs (argv[i]) ? "Yes": "No");
i, argv[i], opal_path_nfs (argv[i], NULL) ? "Yes": "No");
}

return 0;
Expand Down Expand Up @@ -100,7 +100,7 @@ int main(int argc, char* argv[])
int i;
for (i = 1; i < argc; i++)
printf ("Is dir[%d]:%s one of the detected network file systems? %s\n",
i, argv[i], opal_path_nfs (argv[i]) ? "Yes": "No");
i, argv[i], opal_path_nfs (argv[i], NULL) ? "Yes": "No");
}

get_mounts (&num_dirs, &dirs, &nfs);
Expand All @@ -119,7 +119,7 @@ void test(char* file, bool expect)
printf ("test(): file:%s bool:%d\n",
file, expect);
#endif
if (expect == opal_path_nfs (file)) {
if (expect == opal_path_nfs (file, NULL)) {
test_success();
} else {
char * msg;
Expand Down