[Darshan-commits] [Git][darshan/darshan][master] add back-compat code for the POSIX module ver=2

Shane Snyder xgitlab at cels.anl.gov
Wed Jul 6 17:51:35 CDT 2016


Shane Snyder pushed to branch master at darshan / darshan


Commits:
77323cd7 by Shane Snyder at 2016-07-06T17:35:54-05:00
add back-compat code for the POSIX module ver=2

- - - - -


3 changed files:

- darshan-posix-log-format.h
- darshan-util/darshan-parser.c
- darshan-util/darshan-posix-logutils.c


Changes:

=====================================
darshan-posix-log-format.h
=====================================
--- a/darshan-posix-log-format.h
+++ b/darshan-posix-log-format.h
@@ -7,7 +7,7 @@
 #define __DARSHAN_POSIX_LOG_FORMAT_H
 
 /* current POSIX log format version */
-#define DARSHAN_POSIX_VER 1
+#define DARSHAN_POSIX_VER 2
 
 #define POSIX_COUNTERS \
     /* count of posix opens */\
@@ -22,14 +22,6 @@
     X(POSIX_STATS) \
     /* count of posix mmaps */\
     X(POSIX_MMAPS) \
-    /* count of posix fopens */\
-    X(POSIX_FOPENS) \
-    /* count of posix freads */\
-    X(POSIX_FREADS) \
-    /* count of posix fwrites */\
-    X(POSIX_FWRITES) \
-    /* count of posix fseeks */\
-    X(POSIX_FSEEKS) \
     /* count of posix fsyncs */\
     X(POSIX_FSYNCS) \
     /* count of posix fdatasyncs */\


=====================================
darshan-util/darshan-parser.c
=====================================
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -1223,11 +1223,10 @@ void posix_calc_file(hash_entry_t *file_hash,
         bytes = file_rec->counters[POSIX_BYTES_READ] +
                 file_rec->counters[POSIX_BYTES_WRITTEN];
 
-        r = (file_rec->counters[POSIX_READS]+
-             file_rec->counters[POSIX_FREADS]);
+        /* XXX: need to update this to account for stdio counters, too */
+        r = file_rec->counters[POSIX_READS];
 
-        w = (file_rec->counters[POSIX_WRITES]+
-             file_rec->counters[POSIX_FWRITES]);
+        w = file_rec->counters[POSIX_WRITES];
 
         fdata->total += 1;
         fdata->total_size += bytes;


=====================================
darshan-util/darshan-posix-logutils.c
=====================================
--- a/darshan-util/darshan-posix-logutils.c
+++ b/darshan-util/darshan-posix-logutils.c
@@ -30,6 +30,8 @@ char *posix_f_counter_names[] = {
 };
 #undef X
 
+#define DARSHAN_POSIX_FILE_SIZE_1 680
+
 static int darshan_log_get_posix_file(darshan_fd fd, void* posix_buf);
 static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf, int ver);
 static void darshan_log_print_posix_file(void *file_rec,
@@ -51,19 +53,52 @@ struct darshan_mod_logutil_funcs posix_logutils =
 
 static int darshan_log_get_posix_file(darshan_fd fd, void* posix_buf)
 {
-    struct darshan_posix_file *file;
+    struct darshan_posix_file *file = (struct darshan_posix_file *)posix_buf;
+    int rec_len;
+    char *buffer, *p;
     int i;
-    int ret;
+    int ret = -1;
+
+    /* read the POSIX record from file, checking the version first so we
+     * can correctly up-convert to the current darshan version
+     */
+    if(fd->mod_ver[DARSHAN_POSIX_MOD] == 1)
+    {
+        buffer = malloc(DARSHAN_POSIX_FILE_SIZE_1);
+        if(!buffer)
+            return(-1);
+
+        rec_len = DARSHAN_POSIX_FILE_SIZE_1;
+        ret = darshan_log_get_mod(fd, DARSHAN_POSIX_MOD, buffer, rec_len);
+        if(ret == rec_len)
+        {
+            /* copy record data directly from the temporary buffer into the 
+             * corresponding locations in the output file record
+             */
+            p = buffer;
+            memcpy(&(file->base_rec), p, sizeof(struct darshan_base_record));
+            p += sizeof(struct darshan_base_record);
+            memcpy(&(file->counters[0]), p, 6 * sizeof(int64_t));
+            p += (6 * sizeof(int64_t));
+            p += (4 * sizeof(int64_t)); /* skip old stdio counters */
+            memcpy(&(file->counters[6]), p, 58 * sizeof(int64_t));
+            p += (58 * sizeof(int64_t));
+            memcpy(&(file->fcounters[0]), p, 15 * sizeof(double));
+        }
+        free(buffer);
+    }
+    else if(fd->mod_ver[DARSHAN_POSIX_MOD] == 2)
+    {
+        rec_len = sizeof(struct darshan_posix_file);
+        ret = darshan_log_get_mod(fd, DARSHAN_POSIX_MOD, posix_buf, rec_len);
+    }
 
-    ret = darshan_log_get_mod(fd, DARSHAN_POSIX_MOD, posix_buf,
-        sizeof(struct darshan_posix_file));
     if(ret < 0)
         return(-1);
-    else if(ret < sizeof(struct darshan_posix_file))
+    else if(ret < rec_len)
         return(0);
     else
     {
-        file = (struct darshan_posix_file *)posix_buf;
         if(fd->swap_flag)
         {
             /* swap bytes if necessary */
@@ -263,10 +298,6 @@ static void darshan_log_agg_posix_files(void *rec, void *agg_rec, int init_flag)
             case POSIX_SEEKS:
             case POSIX_STATS:
             case POSIX_MMAPS:
-            case POSIX_FOPENS:
-            case POSIX_FREADS:
-            case POSIX_FWRITES:
-            case POSIX_FSEEKS:
             case POSIX_FSYNCS:
             case POSIX_FDSYNCS:
             case POSIX_BYTES_READ:



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/77323cd7f29e3ebfa646b7fdabf3a7236a0fd1ff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160706/5f58c1d2/attachment-0001.html>


More information about the Darshan-commits mailing list