checking for filesystem type(e.g. parallel, lustre, ext3 etc.)

Hi,

Is there a good way to test whether a user is actually on a parallel file system during run-time so the code can adapt accordingly?

Here is something....

#include <stdio.h>
#include <fstab.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    struct fstab *fstab_info;

    if (argc <= 1)
    {
        printf("You must specify a mount point or top-level\n"
               "directory of a filesystem where you wish to\n"
               "create a file\n");
        exit(1);
    }

    if ((fstab_info = getfsfile(argv[1])) != 0)
    {
        printf("For \"%s\", got...\n", argv[1]);
        printf(" fs_spec = \"%s\"\n", fstab_info->fs_spec);
        printf(" fs_file = \"%s\"\n", fstab_info->fs_file);
        printf(" fs_vfstype = \"%s\"\n", fstab_info->fs_vfstype);
        printf(" fs_mntops = \"%s\"\n", fstab_info->fs_mntops);
        printf(" fs_type = \"%s\"\n", fstab_info->fs_type);
        printf(" fs_freq = %d\n", fstab_info->fs_freq);
        printf(" fs_passno = %d\n", fstab_info->fs_passno);
    }
    else
    {
        printf("getfsfile returned null\n");
    }
    return 0;
}

Here is output from a couple of systems at LLNL...

For "/p/lscratcha", got...
      fs_spec = "levi-mds1-lnet0@tcp0:/lsa"
      fs_file = "/p/lscratcha"
   fs_vfstype = "lustre"
    fs_mntops = "lazystatfs,flock,nosuid,noauto,defaults"
      fs_type = "??"
      fs_freq = 0
    fs_passno = 0
For "/g/g11", got...
      fs_spec = "chip-nfs.llnl.gov:/vol/g11"
      fs_file = "/g/g11"
   fs_vfstype = "nfs"
    fs_mntops = "rsize=8192,wsize=8192,exec,dev,intr,nosuid,rw,noauto"
      fs_type = "rw"
      fs_freq = 0
    fs_passno = 0

It looks like 'fs_vfstype' field of fstab is most useful in determing
whether or not system is parallel. Note 'lustre' for /p/lscratcha and
'nfs' for the other.

To use something like this, you'll have to determine the mount point
given the filename to be created. So, you'd have to map filename to
absolute (full) filename and from that chop off the 'mount point' part
of the name to query fstab as described here.

Mark

···

On Tue, 2010-12-07 at 05:16 -0800, Roger Martin wrote:

Hi,

Is there a good way to test whether a user is actually on a parallel
file system during run-time so the code can adapt accordingly?

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Mark C. Miller, Lawrence Livermore National Laboratory
================!!LLNL BUSINESS ONLY!!================
miller86@llnl.gov urgent: miller86@pager.llnl.gov
T:8-6 (925)-423-5901 M/W/Th:7-12,2-7 (530)-753-8511

Thanks Mark!

Exactly what I needed. All my word/phrase combinations on the web and sites weren't hitting what you just gave me. Hopefully other people searching will hit your reply.

PBS/SGE can select nodes on a stack which have access to lustre mounts yet I needed the code to adapt when users don't have parallel file system and at least warn them instead of freezing. If the process won't take too long it can also be run without parallel hdf5. But what we want users to experience is the difference between using parallel file systems and not so they want the parallel.

···

On 12/07/2010 08:34 PM, Mark Miller wrote:

Here is something....

#include<stdio.h>
#include<fstab.h>
#include<stdlib.h>

int main(int argc, char **argv)
{
     struct fstab *fstab_info;

     if (argc<= 1)
     {
         printf("You must specify a mount point or top-level\n"
                "directory of a filesystem where you wish to\n"
                "create a file\n");
         exit(1);
     }

     if ((fstab_info = getfsfile(argv[1])) != 0)
     {
         printf("For \"%s\", got...\n", argv[1]);
         printf(" fs_spec = \"%s\"\n", fstab_info->fs_spec);
         printf(" fs_file = \"%s\"\n", fstab_info->fs_file);
         printf(" fs_vfstype = \"%s\"\n", fstab_info->fs_vfstype);
         printf(" fs_mntops = \"%s\"\n", fstab_info->fs_mntops);
         printf(" fs_type = \"%s\"\n", fstab_info->fs_type);
         printf(" fs_freq = %d\n", fstab_info->fs_freq);
         printf(" fs_passno = %d\n", fstab_info->fs_passno);
     }
     else
     {
         printf("getfsfile returned null\n");
     }
     return 0;
}

Here is output from a couple of systems at LLNL...

For "/p/lscratcha", got...
       fs_spec = "levi-mds1-lnet0@tcp0:/lsa"
       fs_file = "/p/lscratcha"
    fs_vfstype = "lustre"
     fs_mntops = "lazystatfs,flock,nosuid,noauto,defaults"
       fs_type = "??"
       fs_freq = 0
     fs_passno = 0
For "/g/g11", got...
       fs_spec = "chip-nfs.llnl.gov:/vol/g11"
       fs_file = "/g/g11"
    fs_vfstype = "nfs"
     fs_mntops = "rsize=8192,wsize=8192,exec,dev,intr,nosuid,rw,noauto"
       fs_type = "rw"
       fs_freq = 0
     fs_passno = 0

It looks like 'fs_vfstype' field of fstab is most useful in determing
whether or not system is parallel. Note 'lustre' for /p/lscratcha and
'nfs' for the other.

To use something like this, you'll have to determine the mount point
given the filename to be created. So, you'd have to map filename to
absolute (full) filename and from that chop off the 'mount point' part
of the name to query fstab as described here.

Mark

On Tue, 2010-12-07 at 05:16 -0800, Roger Martin wrote:

Hi,

Is there a good way to test whether a user is actually on a parallel
file system during run-time so the code can adapt accordingly?

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org