Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 27facab

Browse files
committed
Merge pull request #935 from ggouaillardet/topic/v2.x/solaris-statfs-fix
Topic/v2.x/solaris statfs fix
2 parents 8948c6f + 24d4f47 commit 27facab

File tree

9 files changed

+77
-55
lines changed

9 files changed

+77
-55
lines changed

ompi/mca/fs/base/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ OMPI_DECLSPEC int mca_fs_base_init_file (struct mca_io_ompio_file_t *file);
4848

4949
OMPI_DECLSPEC int mca_fs_base_get_param (struct mca_io_ompio_file_t *file, int keyval);
5050
OMPI_DECLSPEC void mca_fs_base_get_parent_dir (char *filename, char **dirnamep);
51+
OMPI_DECLSPEC int mca_fs_base_get_fstype(char *fname);
5152
/*
5253
* Globals
5354
*/

ompi/mca/fs/base/fs_base_get_parent_dir.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2011 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -25,9 +25,11 @@
2525

2626
#include "ompi/mca/mca.h"
2727
#include "opal/mca/base/base.h"
28+
#include "opal/util/path.h"
2829

2930
#include "ompi/mca/fs/fs.h"
3031
#include "ompi/mca/fs/base/base.h"
32+
#include "ompi/mca/io/ompio/io_ompio.h"
3133

3234
#ifdef HAVE_SYS_STATFS_H
3335
#include <sys/statfs.h> /* or <sys/vfs.h> */
@@ -93,3 +95,29 @@ void mca_fs_base_get_parent_dir ( char *filename, char **dirnamep)
9395
*dirnamep = dir;
9496
return;
9597
}
98+
99+
int mca_fs_base_get_fstype(char *fname )
100+
{
101+
int ompio_type = UFS;
102+
char *fstype=NULL;
103+
bool ret = opal_path_nfs ( fname, &fstype );
104+
105+
if ( false == ret ) {
106+
char *dir;
107+
mca_fs_base_get_parent_dir (fname, &dir );
108+
ret = opal_path_nfs (dir, &fstype);
109+
if ( false == ret ) {
110+
return ompio_type;
111+
}
112+
}
113+
if ( 0 == strncasecmp(fstype, "lustre", sizeof("lustre")) ) {
114+
ompio_type = LUSTRE;
115+
}
116+
else if ( 0 == strncasecmp(fstype, "pvfs2", sizeof("pvfs2"))) {
117+
ompio_type = PVFS2;
118+
}
119+
120+
free (fstype);
121+
return ompio_type;
122+
}
123+

ompi/mca/fs/lustre/fs_lustre.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
1313
* $COPYRIGHT$
1414
*
1515
* Additional copyrights may follow
@@ -93,22 +93,8 @@ mca_fs_lustre_component_file_query (mca_io_ompio_file_t *fh, int *priority)
9393
tmp = strchr (fh->f_filename, ':');
9494
if (!tmp) {
9595
if (OMPIO_ROOT == fh->f_rank) {
96-
do {
97-
err = statfs (fh->f_filename, &fsbuf);
98-
} while (err && (errno == ESTALE));
99-
100-
if (err && (errno == ENOENT)) {
101-
mca_fs_base_get_parent_dir (fh->f_filename, &dir);
102-
err = statfs (dir, &fsbuf);
103-
free (dir);
104-
}
105-
#ifndef LL_SUPER_MAGIC
106-
#define LL_SUPER_MAGIC 0x0BD00BD0
107-
#endif
108-
if (fsbuf.f_type == LL_SUPER_MAGIC) {
109-
fh->f_fstype = LUSTRE;
110-
}
111-
}
96+
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
97+
}
11298
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
11399
1,
114100
MPI_INT,

ompi/mca/fs/pvfs2/fs_pvfs2.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
1313
* $COPYRIGHT$
1414
*
1515
* Additional copyrights may follow
@@ -96,18 +96,7 @@ mca_fs_pvfs2_component_file_query (mca_io_ompio_file_t *fh, int *priority)
9696
tmp = strchr (fh->f_filename, ':');
9797
if (!tmp) {
9898
if (OMPIO_ROOT == fh->f_rank) {
99-
do {
100-
err = statfs (fh->f_filename, &fsbuf);
101-
} while (err && (errno == ESTALE));
102-
103-
if (err && (errno == ENOENT)) {
104-
mca_fs_base_get_parent_dir (fh->f_filename, &dir);
105-
err = statfs (dir, &fsbuf);
106-
free (dir);
107-
}
108-
if (fsbuf.f_type == PVFS2_SUPER_MAGIC) {
109-
fh->f_fstype = PVFS2;
110-
}
99+
fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
111100
}
112101
fh->f_comm->c_coll.coll_bcast (&(fh->f_fstype),
113102
1,

ompi/mca/io/ompio/io_ompio_component.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,11 @@ file_query(struct ompi_file_t *file,
281281
rank = ompi_comm_rank ( file->f_comm);
282282
if (!tmp) {
283283
if ( 0 == rank) {
284-
do {
285-
err = statfs (file->f_filename, &fsbuf);
286-
} while (err && (errno == ESTALE));
287-
288-
if (err && (errno == ENOENT)) {
289-
mca_fs_base_get_parent_dir (file->f_filename, &dir);
290-
err = statfs (dir, &fsbuf);
291-
free (dir);
292-
}
293-
#ifndef LL_SUPER_MAGIC
294-
#define LL_SUPER_MAGIC 0x0BD00BD0
295-
#endif
296-
if (fsbuf.f_type == LL_SUPER_MAGIC) {
284+
if (LUSTRE == mca_fs_base_get_fstype(file->f_filename)) {
297285
is_lustre = 1; //true
298286
}
299287
}
288+
300289
file->f_comm->c_coll.coll_bcast (&is_lustre,
301290
1,
302291
MPI_INT,

opal/mca/shmem/mmap/shmem_mmap_module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1515
* Copyright (c) 2010-2014 Los Alamos National Security, LLC.
1616
* All rights reserved.
17+
* Copyright (c) 2016 University of Houston. All rights reserved.
1718
*
1819
* $COPYRIGHT$
1920
*
@@ -363,7 +364,7 @@ segment_create(opal_shmem_ds_t *ds_buf,
363364
* this is an important check because if the backing store is located on
364365
* a network filesystem, the user may see a shared memory performance hit.
365366
*/
366-
if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name)) {
367+
if (opal_shmem_mmap_nfs_warning && opal_path_nfs(real_file_name, NULL)) {
367368
char hn[MAXHOSTNAMELEN];
368369
gethostname(hn, MAXHOSTNAMELEN - 1);
369370
hn[MAXHOSTNAMELEN - 1] = '\0';

opal/util/path.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
1515
* All rights reserved.
1616
* Copyright (c) 2014 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2016 University of Houston. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -444,8 +445,9 @@ static char *opal_check_mtab(char *dev_path)
444445
* If the file is not created, the parent directory is checked.
445446
* This allows checking for NFS prior to opening the file.
446447
*
447-
* @param[in] fname File name to check
448-
*
448+
* @fname[in] File name to check
449+
* @fstype[out] File system type if retval is true
450+
*
449451
* @retval true If fname is on NFS, Lustre, Panasas or GPFS
450452
* @retval false otherwise
451453
*
@@ -493,11 +495,14 @@ static char *opal_check_mtab(char *dev_path)
493495
#ifndef AUTOFS_SUPER_MAGIC
494496
#define AUTOFS_SUPER_MAGIC 0x0187
495497
#endif
498+
#ifndef PVFS2_SUPER_MAGIC
499+
#define PVFS2_SUPER_MAGIC 0x20030528
500+
#endif
496501

497502
#define MASK2 0xffff
498503
#define MASK4 0xffffffff
499504

500-
bool opal_path_nfs(char *fname)
505+
bool opal_path_nfs(char *fname, char **ret_fstype)
501506
{
502507
int i;
503508
int fsrc = -1;
@@ -523,7 +528,8 @@ bool opal_path_nfs(char *fname)
523528
{NFS_SUPER_MAGIC, MASK2, "nfs"},
524529
{AUTOFS_SUPER_MAGIC, MASK2, "autofs"},
525530
{PAN_KERNEL_FS_CLIENT_SUPER_MAGIC, MASK4, "panfs"},
526-
{GPFS_SUPER_MAGIC, MASK4, "gpfs"}
531+
{GPFS_SUPER_MAGIC, MASK4, "gpfs"},
532+
{PVFS2_SUPER_MAGIC, MASK4, "pvfs2"}
527533
};
528534
#define FS_TYPES_NUM (int)(sizeof (fs_types)/sizeof (fs_types[0]))
529535

@@ -555,6 +561,9 @@ bool opal_path_nfs(char *fname)
555561
fname, errno, file));
556562
if (EPERM == errno) {
557563
free(file);
564+
if ( NULL != ret_fstype ) {
565+
*ret_fstype = NULL;
566+
}
558567
return false;
559568
}
560569

@@ -563,6 +572,9 @@ bool opal_path_nfs(char *fname)
563572
if (NULL == last_sep || (1 == strlen(last_sep) &&
564573
OPAL_PATH_SEP[0] == *last_sep)) {
565574
free (file);
575+
if ( NULL != ret_fstype ) {
576+
*ret_fstype=NULL;
577+
}
566578
return false;
567579
}
568580
*last_sep = '\0';
@@ -609,6 +621,9 @@ bool opal_path_nfs(char *fname)
609621
}
610622

611623
free (file);
624+
if ( NULL != ret_fstype ) {
625+
*ret_fstype=NULL;
626+
}
612627
return false;
613628

614629
found:
@@ -625,16 +640,25 @@ bool opal_path_nfs(char *fname)
625640
if (0 == strcasecmp(fs_types[x].f_fsname, fs_type)) {
626641
OPAL_OUTPUT_VERBOSE((10, 0, "opal_path_nfs: file:%s on fs:%s\n", fname, fs_type));
627642
free(fs_type);
643+
if ( NULL != ret_fstype ) {
644+
*ret_fstype = strdup(fs_types[x].f_fsname);
645+
}
628646
return true;
629647
}
630648
}
631649
free(fs_type);
650+
if ( NULL != ret_fstype ) {
651+
*ret_fstype=NULL;
652+
}
632653
return false;
633654
}
634655
}
635656

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

640664
#undef FS_TYPES_NUM

opal/util/path.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2012 Los Alamos National Security, LLC.
1313
* All rights reserved.
14+
* Copyright (c) 2016 University of Houston. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -126,19 +127,22 @@ OPAL_DECLSPEC char *opal_path_access(char *fname, char *path, int mode) __opal_a
126127

127128
/**
128129
* @brief Figure out, whether fname is on network file system
130+
* and return fstype if known
129131
*
130132
* Try to figure out, whether the file name specified through fname is
131-
* on any network file system (currently NFS, Lustre and Panasas).
133+
* on any network file system (currently NFS, Lustre, GPFS, Panasas
134+
* and PVFS2 ).
132135
*
133136
* If the file is not created, the parent directory is checked.
134137
* This allows checking for NFS prior to opening the file.
135138
*
136-
* @param[in] fname File name to check
139+
* @fname[in] File name to check
140+
* @fstype[out] File system type if retval is true
137141
*
138142
* @retval true If fname is on NFS, Lustre or Panasas
139143
* @retval false otherwise
140144
*/
141-
OPAL_DECLSPEC bool opal_path_nfs(char *fname) __opal_attribute_warn_unused_result__;
145+
OPAL_DECLSPEC bool opal_path_nfs(char *fname, char **fstype) __opal_attribute_warn_unused_result__;
142146

143147
/**
144148
* @brief Returns the disk usage of path.

test/util/opal_path_nfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int main(int argc, char* argv[])
6767
printf("Interactive opal_path_nfs() test:\n");
6868
for (i = 1; i < argc; i++) {
6969
printf ("Is dir[%d]:%s one of the detected network file systems? %s\n",
70-
i, argv[i], opal_path_nfs (argv[i]) ? "Yes": "No");
70+
i, argv[i], opal_path_nfs (argv[i], NULL) ? "Yes": "No");
7171
}
7272

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

106106
get_mounts (&num_dirs, &dirs, &nfs);
@@ -119,7 +119,7 @@ void test(char* file, bool expect)
119119
printf ("test(): file:%s bool:%d\n",
120120
file, expect);
121121
#endif
122-
if (expect == opal_path_nfs (file)) {
122+
if (expect == opal_path_nfs (file, NULL)) {
123123
test_success();
124124
} else {
125125
char * msg;

0 commit comments

Comments
 (0)