Commit 50b90b8f authored by Philip Carns's avatar Philip Carns

use statfs() on mount point to detect default block size for mount points


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@653 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 846df9ec
......@@ -230,7 +230,7 @@ void darshan_shutdown(int timing_flag);
void darshan_shutdown_bench(int argc, char** argv, int rank, int nprocs);
void darshan_walk_file_accesses(struct darshan_job_runtime* final_job);
double darshan_wtime(void);
int64_t darshan_mnt_id_from_path(const char* path);
void darshan_mnt_id_from_path(const char* path, int64_t* device_id, int64_t* block_size);
char* darshan_get_exe_and_mounts(struct darshan_job_runtime* final_job);
uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
......
......@@ -20,6 +20,7 @@
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <zlib.h>
#include <assert.h>
#include <search.h>
......@@ -208,7 +209,9 @@ static struct darshan_file_runtime* darshan_file_by_name_setfh(const char* name,
#define CP_MAX_MNTS 32
static uint64_t mnt_hash_array[CP_MAX_MNTS] = {0};
static int64_t mnt_id_array[CP_MAX_MNTS] = {0};
static int64_t mnt_block_size_array[CP_MAX_MNTS] = {0};
static char* mnt_path_array[CP_MAX_MNTS] = {0};
static uint64_t mnt_hash_array_root[CP_MAX_MNTS] = {0};
static int64_t mnt_id_array_root[CP_MAX_MNTS] = {0};
struct
......@@ -2046,6 +2049,7 @@ char* darshan_get_exe_and_mounts(struct darshan_job_runtime* final_job)
int tmp_index = 0;
int ret;
struct stat statbuf;
struct statfs statfsbuf;
int skip = 0;
char* trailing_data;
int space_left;
......@@ -2154,6 +2158,19 @@ char* darshan_get_exe_and_mounts(struct darshan_job_runtime* final_job)
strlen(mnt_path_array[i]), 0);
mnt_id_array[i] = tmp_st_dev;
}
/* NOTE: we now try to detect default block size for each file system, but we
* skip this step on Lustre, which appears to always report a 4K block size
* through statfs().
*/
#ifndef LL_SUPER_MAGIC
#define LL_SUPER_MAGIC 0x0BD00BD0
#endif
ret = statfs(mnt_path_array[i], &statfsbuf);
if(ret == 0 && statfsbuf.f_type != LL_SUPER_MAGIC)
mnt_block_size_array[i] = statfsbuf.f_bsize;
else
mnt_block_size_array[i] = -1;
}
return(trailing_data);
}
......@@ -2407,18 +2424,22 @@ static struct darshan_file_runtime* darshan_file_by_fh(MPI_File fh)
return(tmp_file);
}
/* find the device id for the specified file, based on data from the mount
* entries.
/* find the device id and block size for the specified file, based on
* data from the mount entries.
*/
int64_t darshan_mnt_id_from_path(const char* path)
void darshan_mnt_id_from_path(const char* path, int64_t* device_id, int64_t* block_size)
{
int i;
*device_id = -1;
*block_size = -1;
for(i=0; (i<CP_MAX_MNTS && mnt_hash_array[i] != 0); i++)
{
if(!(strncmp(mnt_path_array[i], path, strlen(mnt_path_array[i]))))
{
return(mnt_id_array[i]);
*device_id = mnt_id_array[i];
*block_size = mnt_block_size_array[i];
return;
}
}
......
......@@ -256,7 +256,7 @@ static char* clean_path(const char* path);
#define CP_RECORD_STAT(__file, __statbuf, __tm1, __tm2) do { \
if(!CP_VALUE((__file), CP_FILE_ALIGNMENT)){ \
if(!CP_VALUE((__file), CP_POSIX_STATS) && !CP_VALUE((__file), CP_POSIX_OPENS)){ \
CP_SET((__file), CP_DEVICE, (__statbuf)->st_dev); \
CP_SET((__file), CP_FILE_ALIGNMENT, (__statbuf)->st_blksize); \
CP_SET((__file), CP_SIZE_AT_OPEN, (__statbuf)->st_size); \
......@@ -286,7 +286,7 @@ static inline dev_t get_device(const char* path, struct stat64* statbuf)
#ifdef __CP_STAT_AT_OPEN
#define CP_STAT_FILE(_f, _p, _r) do { \
if(!CP_VALUE(_f, CP_FILE_ALIGNMENT)){ \
if(!CP_VALUE((_f), CP_POSIX_STATS) && !CP_VALUE((_f), CP_POSIX_OPENS)){ \
if(fstat64(_r, &cp_stat_buf) == 0) { \
CP_SET(_f, CP_DEVICE, get_device(_p, &cp_stat_buf)); \
CP_SET(_f, CP_FILE_ALIGNMENT, cp_stat_buf.st_blksize); \
......@@ -1648,6 +1648,7 @@ struct darshan_file_runtime* darshan_file_by_name(const char* name)
int hash_index;
char* newname = NULL;
int64_t device_id;
int64_t block_size;
if(!darshan_global_job)
return(NULL);
......@@ -1693,8 +1694,9 @@ struct darshan_file_runtime* darshan_file_by_name(const char* name)
/* new, unique file */
tmp_file = &darshan_global_job->file_runtime_array[darshan_global_job->file_count];
device_id = darshan_mnt_id_from_path(newname);
darshan_mnt_id_from_path(newname, &device_id, &block_size);
CP_SET(tmp_file, CP_DEVICE, device_id);
CP_SET(tmp_file, CP_FILE_ALIGNMENT, block_size);
CP_SET(tmp_file, CP_MEM_ALIGNMENT, darshan_mem_alignment);
tmp_file->log_file->hash = tmp_hash;
......@@ -1712,8 +1714,8 @@ struct darshan_file_runtime* darshan_file_by_name(const char* name)
*/
#ifndef __CP_STAT_AT_OPEN
CP_SET(tmp_file, CP_SIZE_AT_OPEN, -1);
CP_SET(tmp_file, CP_FILE_ALIGNMENT, -1);
CP_SET(tmp_file, CP_FILE_NOT_ALIGNED, -1);
if(CP_VALUE(tmp_file, CP_FILE_ALIGNMENT) == -1)
CP_SET(tmp_file, CP_FILE_NOT_ALIGNED, -1);
#endif
darshan_global_job->file_count++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment