Commit beac22fc authored by Shane Snyder's avatar Shane Snyder

add instrument_fs call to darshan-core

This function can be called by modules to allow FS-specific
modules to gather data for a given file path/file descriptor.
Currently integrated into POSIX and STDIO modules.
parent b904f795
......@@ -144,6 +144,12 @@ void *darshan_core_register_record(
int rec_len,
struct darshan_fs_info *fs_info);
/* TODO */
void darshan_instrument_fs_data(
int fs_type,
const char *path,
int fd);
/* darshan_core_wtime()
*
* Returns the elapsed time relative to (roughly) the start of
......
......@@ -80,6 +80,13 @@ void (*mod_static_init_fns[])(void) =
NULL
};
#ifdef DARSHAN_LUSTRE
/* XXX need to use extern to get Lustre module's instrumentation function
* since modules have no way of providing this to darshan-core
*/
extern void darshan_instrument_lustre_file(const char *filepath, int fd);
#endif
#define DARSHAN_CORE_LOCK() pthread_mutex_lock(&darshan_core_mutex)
#define DARSHAN_CORE_UNLOCK() pthread_mutex_unlock(&darshan_core_mutex)
......@@ -1986,6 +1993,19 @@ void *darshan_core_register_record(
return(rec_buf);;
}
void darshan_instrument_fs_data(int fs_type, const char *path, int fd)
{
#ifdef DARSHAN_LUSTRE
/* allow lustre to generate a record if we configured with lustre support */
if(fs_type == LL_SUPER_MAGIC)
{
darshan_instrument_lustre_file(path, fd);
return;
}
#endif
return;
}
double darshan_core_wtime()
{
DARSHAN_CORE_LOCK();
......
......@@ -37,9 +37,6 @@ typedef int64_t off64_t;
#define aiocb64 aiocb
#endif
#ifdef DARSHAN_LUSTRE
#include <lustre/lustre_user.h>
#endif
DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(open64, int, (const char *path, int flags, ...));
......@@ -142,8 +139,6 @@ static void posix_runtime_initialize(
void);
static struct posix_file_record_ref *posix_track_new_file_record(
darshan_record_id rec_id, const char *path);
static void posix_instrument_fs_data(
int fs_type, const char *path, int fd);
static void posix_aio_tracker_add(
int fd, void *aiocbp);
static struct posix_aio_tracker* posix_aio_tracker_del(
......@@ -162,13 +157,6 @@ static void posix_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **posix_buf, int *posix_buf_sz);
#ifdef DARSHAN_LUSTRE
/* XXX modules don't expose an API for other modules, so use extern to get
* Lustre instrumentation function
*/
extern void darshan_instrument_lustre_file(const char *filepath, int fd);
#endif
static struct posix_runtime *posix_runtime = NULL;
static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
......@@ -221,7 +209,7 @@ static int darshan_mem_alignment = 1;
DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[POSIX_F_META_TIME], \
__tm1, __tm2, rec_ref->last_meta_end); \
darshan_add_record_ref(&(posix_runtime->fd_hash), &__ret, sizeof(int), rec_ref); \
posix_instrument_fs_data(rec_ref->fs_type, newpath, __ret); \
darshan_instrument_fs_data(rec_ref->fs_type, newpath, __ret); \
if(newpath != __path) free(newpath); \
} while(0)
......@@ -1313,26 +1301,13 @@ static struct posix_file_record_ref *posix_track_new_file_record(
file_rec->base_rec.rank = my_rank;
file_rec->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
file_rec->counters[POSIX_FILE_ALIGNMENT] = fs_info.block_size;
rec_ref->file_rec = file_rec;
rec_ref->fs_type = fs_info.fs_type;
rec_ref->file_rec = file_rec;
posix_runtime->file_rec_count++;
return(rec_ref);
}
static void posix_instrument_fs_data(int fs_type, const char *path, int fd)
{
#ifdef DARSHAN_LUSTRE
/* allow lustre to generate a record if we configured with lustre support */
if(fs_type == LL_SUPER_MAGIC)
{
darshan_instrument_lustre_file(path, fd);
return;
}
#endif
return;
}
/* finds the tracker structure for a given aio operation, removes it from
* the associated linked list for this file record, and returns a pointer.
*
......
......@@ -119,6 +119,7 @@ struct stdio_file_record_ref
double last_meta_end;
double last_read_end;
double last_write_end;
int fs_type;
};
/* The stdio_runtime structure maintains necessary state for storing
......@@ -174,6 +175,7 @@ static void stdio_cleanup_runtime();
darshan_record_id rec_id; \
struct stdio_file_record_ref* rec_ref; \
char *newpath; \
int __fd; \
if(__ret == NULL) break; \
newpath = darshan_clean_file_path(__path); \
if(!newpath) newpath = (char*)__path; \
......@@ -196,6 +198,8 @@ static void stdio_cleanup_runtime();
rec_ref->file_rec->fcounters[STDIO_F_OPEN_END_TIMESTAMP] = __tm2; \
DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[STDIO_F_META_TIME], __tm1, __tm2, rec_ref->last_meta_end); \
darshan_add_record_ref(&(stdio_runtime->stream_hash), &(__ret), sizeof(__ret), rec_ref); \
__fd = fileno(__ret); \
darshan_instrument_fs_data(rec_ref->fs_type, newpath, __fd); \
if(newpath != (char*)__path) free(newpath); \
} while(0)
......@@ -1182,6 +1186,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
{
struct darshan_stdio_file *file_rec = NULL;
struct stdio_file_record_ref *rec_ref = NULL;
struct darshan_fs_info fs_info;
int ret;
rec_ref = malloc(sizeof(*rec_ref));
......@@ -1206,7 +1211,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
path,
DARSHAN_STDIO_MOD,
sizeof(struct darshan_stdio_file),
NULL);
&fs_info);
if(!file_rec)
{
......@@ -1219,6 +1224,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
/* registering this file record was successful, so initialize some fields */
file_rec->base_rec.id = rec_id;
file_rec->base_rec.rank = my_rank;
rec_ref->fs_type = fs_info.fs_type;
rec_ref->file_rec = file_rec;
stdio_runtime->file_rec_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