Commit 77323cd7 authored by Shane Snyder's avatar Shane Snyder

add back-compat code for the POSIX module ver=2

parent 5c5e4452
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define __DARSHAN_POSIX_LOG_FORMAT_H #define __DARSHAN_POSIX_LOG_FORMAT_H
/* current POSIX log format version */ /* current POSIX log format version */
#define DARSHAN_POSIX_VER 1 #define DARSHAN_POSIX_VER 2
#define POSIX_COUNTERS \ #define POSIX_COUNTERS \
/* count of posix opens */\ /* count of posix opens */\
...@@ -22,14 +22,6 @@ ...@@ -22,14 +22,6 @@
X(POSIX_STATS) \ X(POSIX_STATS) \
/* count of posix mmaps */\ /* count of posix mmaps */\
X(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 */\ /* count of posix fsyncs */\
X(POSIX_FSYNCS) \ X(POSIX_FSYNCS) \
/* count of posix fdatasyncs */\ /* count of posix fdatasyncs */\
......
...@@ -1223,11 +1223,10 @@ void posix_calc_file(hash_entry_t *file_hash, ...@@ -1223,11 +1223,10 @@ void posix_calc_file(hash_entry_t *file_hash,
bytes = file_rec->counters[POSIX_BYTES_READ] + bytes = file_rec->counters[POSIX_BYTES_READ] +
file_rec->counters[POSIX_BYTES_WRITTEN]; file_rec->counters[POSIX_BYTES_WRITTEN];
r = (file_rec->counters[POSIX_READS]+ /* XXX: need to update this to account for stdio counters, too */
file_rec->counters[POSIX_FREADS]); r = file_rec->counters[POSIX_READS];
w = (file_rec->counters[POSIX_WRITES]+ w = file_rec->counters[POSIX_WRITES];
file_rec->counters[POSIX_FWRITES]);
fdata->total += 1; fdata->total += 1;
fdata->total_size += bytes; fdata->total_size += bytes;
......
...@@ -30,6 +30,8 @@ char *posix_f_counter_names[] = { ...@@ -30,6 +30,8 @@ char *posix_f_counter_names[] = {
}; };
#undef X #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_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 int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf, int ver);
static void darshan_log_print_posix_file(void *file_rec, static void darshan_log_print_posix_file(void *file_rec,
...@@ -51,19 +53,52 @@ struct darshan_mod_logutil_funcs posix_logutils = ...@@ -51,19 +53,52 @@ struct darshan_mod_logutil_funcs posix_logutils =
static int darshan_log_get_posix_file(darshan_fd fd, void* posix_buf) 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 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) if(ret < 0)
return(-1); return(-1);
else if(ret < sizeof(struct darshan_posix_file)) else if(ret < rec_len)
return(0); return(0);
else else
{ {
file = (struct darshan_posix_file *)posix_buf;
if(fd->swap_flag) if(fd->swap_flag)
{ {
/* swap bytes if necessary */ /* swap bytes if necessary */
...@@ -263,10 +298,6 @@ static void darshan_log_agg_posix_files(void *rec, void *agg_rec, int init_flag) ...@@ -263,10 +298,6 @@ static void darshan_log_agg_posix_files(void *rec, void *agg_rec, int init_flag)
case POSIX_SEEKS: case POSIX_SEEKS:
case POSIX_STATS: case POSIX_STATS:
case POSIX_MMAPS: case POSIX_MMAPS:
case POSIX_FOPENS:
case POSIX_FREADS:
case POSIX_FWRITES:
case POSIX_FSEEKS:
case POSIX_FSYNCS: case POSIX_FSYNCS:
case POSIX_FDSYNCS: case POSIX_FDSYNCS:
case POSIX_BYTES_READ: case POSIX_BYTES_READ:
......
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