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
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,8 @@ AC_CHECK_HEADERS([lustre/lustre_user.h linux/lustre/lustre_user.h],
if test "x$has_lustre" = xyes ; then
AC_DEFINE(HAVE_LUSTRE, 1, [Define for LUSTRE])
LIBS="$LIBS -llustreapi"
# llapi_get_obd_count() can get the total number of available OSTs
AC_CHECK_FUNCS([llapi_get_obd_count])
fi
AM_CONDITIONAL(HAVE_LUSTRE, [test x$has_lustre = xyes])

Expand Down
47 changes: 47 additions & 0 deletions src/drivers/pncio/pncio_lustre_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,52 @@
printf("\t%-14s = %-25s (0x%lx)\n",#val,PATTERN_STR(val, int_str),val); \
}

#ifdef HAVE_LLAPI_GET_OBD_COUNT

/*----< get_total_avail_osts() >---------------------------------------------*/
static
int get_total_avail_osts(const char *path)
{
char *dir_name=NULL, *path_dup=NULL;
int err, ost_count=0, is_mdt=0;
struct stat sb;

path_dup = NCI_Strdup(path);

err = stat(path_dup, &sb);
if (errno == ENOENT) { /* file does not exist, try folder */
/* get the parent folder name */
dir_name = dirname(path_dup);
err = stat(dir_name, &sb);
}
if (err != 0) {
printf("Warning at %s (%d): path \"%s\" stat() failed (%s)\n",
__func__,__LINE__,path,strerror(errno));
goto err_out;
}

/* llapi_get_obd_count() only works for directories */
if (S_ISDIR(sb.st_mode))
dir_name = (dir_name == NULL) ? path_dup : dir_name;
else
/* get the parent folder name */
dir_name = dirname(path_dup);

err = llapi_get_obd_count(dir_name, &ost_count, is_mdt);
if (err != 0) {
printf("Warning at %d: path \"%s\" llapi_get_obd_count() failed (%s)\n",
__LINE__,dir_name,strerror(errno));
ost_count = 0;
}

err_out:
if (path_dup != NULL) NCI_Free(path_dup);

return ost_count;
}

#else

/*----< get_total_avail_osts() >---------------------------------------------*/
static
int get_total_avail_osts(const char *filename)
Expand Down Expand Up @@ -192,6 +238,7 @@ int get_total_avail_osts(const char *filename)

return num_members;
}
#endif

static
int compare(const void *a, const void *b)
Expand Down
Loading