[Darshan-commits] [Git][darshan/darshan][master] add instrument_fs call to darshan-core

Shane Snyder xgitlab at cels.anl.gov
Thu Jul 7 22:52:30 CDT 2016


Shane Snyder pushed to branch master at darshan / darshan


Commits:
beac22fc by Shane Snyder at 2016-07-07T20:44:46-07:00
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.

- - - - -


4 changed files:

- darshan-runtime/darshan.h
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-posix.c
- darshan-runtime/lib/darshan-stdio.c


Changes:

=====================================
darshan-runtime/darshan.h
=====================================
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -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


=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -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();


=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -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.  
  *


=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -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++;
 



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/beac22fce555a77c766753d8dc5bb97b854f9eac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160707/1067d3d0/attachment-0001.html>


More information about the Darshan-commits mailing list