- extend opal_path_nfs to retrieve the file system type
- use opal_path_nfs in the fs_base function to avoid code duplication.
Этот коммит содержится в:
родитель
6d149554a7
Коммит
722aab92e6
@ -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 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 void mca_fs_base_get_parent_dir (char *filename, char **dirnamep);
|
||||||
|
OMPI_DECLSPEC int mca_fs_base_get_fstype(char *fname);
|
||||||
/*
|
/*
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* 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
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
@ -25,9 +25,11 @@
|
|||||||
|
|
||||||
#include "ompi/mca/mca.h"
|
#include "ompi/mca/mca.h"
|
||||||
#include "opal/mca/base/base.h"
|
#include "opal/mca/base/base.h"
|
||||||
|
#include "opal/util/path.h"
|
||||||
|
|
||||||
#include "ompi/mca/fs/fs.h"
|
#include "ompi/mca/fs/fs.h"
|
||||||
#include "ompi/mca/fs/base/base.h"
|
#include "ompi/mca/fs/base/base.h"
|
||||||
|
#include "ompi/mca/io/ompio/io_ompio.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STATFS_H
|
#ifdef HAVE_SYS_STATFS_H
|
||||||
#include <sys/statfs.h> /* or <sys/vfs.h> */
|
#include <sys/statfs.h> /* or <sys/vfs.h> */
|
||||||
@ -93,3 +95,24 @@ void mca_fs_base_get_parent_dir ( char *filename, char **dirnamep)
|
|||||||
*dirnamep = dir;
|
*dirnamep = dir;
|
||||||
return;
|
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 ) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
|
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -93,21 +93,7 @@ mca_fs_lustre_component_file_query (mca_io_ompio_file_t *fh, int *priority)
|
|||||||
tmp = strchr (fh->f_filename, ':');
|
tmp = strchr (fh->f_filename, ':');
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
if (OMPIO_ROOT == fh->f_rank) {
|
if (OMPIO_ROOT == fh->f_rank) {
|
||||||
do {
|
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
|
||||||
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_comm->c_coll.coll_bcast (&(fh->f_fstype),
|
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
|
||||||
1,
|
1,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
|
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -96,18 +96,7 @@ mca_fs_pvfs2_component_file_query (mca_io_ompio_file_t *fh, int *priority)
|
|||||||
tmp = strchr (fh->f_filename, ':');
|
tmp = strchr (fh->f_filename, ':');
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
if (OMPIO_ROOT == fh->f_rank) {
|
if (OMPIO_ROOT == fh->f_rank) {
|
||||||
do {
|
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
|
||||||
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_comm->c_coll.coll_bcast (&(fh->f_fstype),
|
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
|
||||||
1,
|
1,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2010-2014 Los Alamos National Security, LLC.
|
* Copyright (c) 2010-2014 Los Alamos National Security, LLC.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2016 University of Houston. All rights reserved.
|
||||||
*
|
*
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
@ -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
|
* 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.
|
* 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];
|
char hn[MAXHOSTNAMELEN];
|
||||||
gethostname(hn, MAXHOSTNAMELEN - 1);
|
gethostname(hn, MAXHOSTNAMELEN - 1);
|
||||||
hn[MAXHOSTNAMELEN - 1] = '\0';
|
hn[MAXHOSTNAMELEN - 1] = '\0';
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
|
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
||||||
|
* Copyright (c) 2016 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -444,7 +445,8 @@ static char *opal_check_mtab(char *dev_path)
|
|||||||
* If the file is not created, the parent directory is checked.
|
* If the file is not created, the parent directory is checked.
|
||||||
* This allows checking for NFS prior to opening the file.
|
* 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 true If fname is on NFS, Lustre, Panasas or GPFS
|
||||||
* @retval false otherwise
|
* @retval false otherwise
|
||||||
@ -493,11 +495,14 @@ static char *opal_check_mtab(char *dev_path)
|
|||||||
#ifndef AUTOFS_SUPER_MAGIC
|
#ifndef AUTOFS_SUPER_MAGIC
|
||||||
#define AUTOFS_SUPER_MAGIC 0x0187
|
#define AUTOFS_SUPER_MAGIC 0x0187
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef PVFS2_SUPER_MAGIC
|
||||||
|
#define PVFS2_SUPER_MAGIC 0x20030528
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MASK2 0xffff
|
#define MASK2 0xffff
|
||||||
#define MASK4 0xffffffff
|
#define MASK4 0xffffffff
|
||||||
|
|
||||||
bool opal_path_nfs(char *fname)
|
bool opal_path_nfs(char *fname, char **ret_fstype)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int fsrc = -1;
|
int fsrc = -1;
|
||||||
@ -523,7 +528,8 @@ bool opal_path_nfs(char *fname)
|
|||||||
{NFS_SUPER_MAGIC, MASK2, "nfs"},
|
{NFS_SUPER_MAGIC, MASK2, "nfs"},
|
||||||
{AUTOFS_SUPER_MAGIC, MASK2, "autofs"},
|
{AUTOFS_SUPER_MAGIC, MASK2, "autofs"},
|
||||||
{PAN_KERNEL_FS_CLIENT_SUPER_MAGIC, MASK4, "panfs"},
|
{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]))
|
#define FS_TYPES_NUM (int)(sizeof (fs_types)/sizeof (fs_types[0]))
|
||||||
|
|
||||||
@ -555,6 +561,9 @@ again:
|
|||||||
fname, errno, file));
|
fname, errno, file));
|
||||||
if (EPERM == errno) {
|
if (EPERM == errno) {
|
||||||
free(file);
|
free(file);
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype = NULL;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,6 +572,9 @@ again:
|
|||||||
if (NULL == last_sep || (1 == strlen(last_sep) &&
|
if (NULL == last_sep || (1 == strlen(last_sep) &&
|
||||||
OPAL_PATH_SEP[0] == *last_sep)) {
|
OPAL_PATH_SEP[0] == *last_sep)) {
|
||||||
free (file);
|
free (file);
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype=NULL;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*last_sep = '\0';
|
*last_sep = '\0';
|
||||||
@ -609,6 +621,9 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
free (file);
|
free (file);
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype=NULL;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
found:
|
found:
|
||||||
@ -625,16 +640,25 @@ found:
|
|||||||
if (0 == strcasecmp(fs_types[x].f_fsname, fs_type)) {
|
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));
|
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n", fname, fs_type));
|
||||||
free(fs_type);
|
free(fs_type);
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype = strdup(fs_types[x].f_fsname);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(fs_type);
|
free(fs_type);
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype=NULL;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n",
|
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n",
|
||||||
fname, fs_types[i].f_fsname));
|
fname, fs_types[i].f_fsname));
|
||||||
|
if ( NULL != ret_fstype ) {
|
||||||
|
*ret_fstype = strdup (fs_types[i].f_fsname);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#undef FS_TYPES_NUM
|
#undef FS_TYPES_NUM
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2012 Los Alamos National Security, LLC.
|
* Copyright (c) 2012 Los Alamos National Security, LLC.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2016 University of Houston. All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -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
|
* @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
|
* 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.
|
* If the file is not created, the parent directory is checked.
|
||||||
* This allows checking for NFS prior to opening the file.
|
* 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 true If fname is on NFS, Lustre or Panasas
|
||||||
* @retval false otherwise
|
* @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.
|
* @brief Returns the disk usage of path.
|
||||||
|
@ -67,7 +67,7 @@ int main(int argc, char* argv[])
|
|||||||
printf("Interactive opal_path_nfs() test:\n");
|
printf("Interactive opal_path_nfs() test:\n");
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
printf ("Is dir[%d]:%s one of the detected network file systems? %s\n",
|
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;
|
return 0;
|
||||||
@ -100,7 +100,7 @@ int main(int argc, char* argv[])
|
|||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
printf ("Is dir[%d]:%s one of the detected network file systems? %s\n",
|
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);
|
get_mounts (&num_dirs, &dirs, &nfs);
|
||||||
@ -119,7 +119,7 @@ void test(char* file, bool expect)
|
|||||||
printf ("test(): file:%s bool:%d\n",
|
printf ("test(): file:%s bool:%d\n",
|
||||||
file, expect);
|
file, expect);
|
||||||
#endif
|
#endif
|
||||||
if (expect == opal_path_nfs (file)) {
|
if (expect == opal_path_nfs (file, NULL)) {
|
||||||
test_success();
|
test_success();
|
||||||
} else {
|
} else {
|
||||||
char * msg;
|
char * msg;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user