Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Cristian Simarro
darshan
Commits
d72958de
Commit
d72958de
authored
Mar 31, 2015
by
Shane Snyder
Browse files
more posix wrappers: stat family
parent
6af7ad39
Changes
4
Hide whitespace changes
Inline
Side-by-side
darshan-posix-log-format.h
View file @
d72958de
...
...
@@ -15,8 +15,8 @@ enum darshan_posix_indices
POSIX_READS
,
/* count of posix reads */
POSIX_WRITES
,
/* count of posix writes */
POSIX_SEEKS
,
/* count of posix seeks */
#if 0
POSIX_STATS
,
/* count of posix stat/lstat/fstats */
#if 0
POSIX_MMAPS, /* count of posix mmaps */
#endif
POSIX_FOPENS
,
/* count of posix fopens */
...
...
@@ -39,8 +39,8 @@ enum darshan_posix_indices
MEM_NOT_ALIGNED, /* count of accesses not mem aligned */
MEM_ALIGNMENT, /* mem alignment in bytes */
FILE_NOT_ALIGNED, /* count of accesses not file aligned */
FILE_ALIGNMENT, /* file alignment in bytes */
#endif
FILE_ALIGNMENT
,
/* file alignment in bytes */
POSIX_MAX_READ_TIME_SIZE
,
POSIX_MAX_WRITE_TIME_SIZE
,
#if 0
...
...
@@ -84,7 +84,9 @@ enum darshan_posix_indices
ACCESS3_COUNT,
ACCESS4_COUNT,
DEVICE, /* device id reported by stat */
#endif
SIZE_AT_OPEN
,
#if 0
FASTEST_RANK,
FASTEST_RANK_BYTES,
SLOWEST_RANK,
...
...
darshan-runtime/darshan-posix-ld-opts
View file @
d72958de
...
...
@@ -17,6 +17,12 @@
--wrap=lseek
--wrap=lseek64
--wrap=fseek
--wrap=__xstat
--wrap=__xstat64
--wrap=__lxstat
--wrap=__lxstat64
--wrap=__fxstat
--wrap=__fxstat64
--wrap=fsync
--wrap=fdatasync
--wrap=close
...
...
darshan-runtime/lib/darshan-posix.c
View file @
d72958de
...
...
@@ -56,12 +56,20 @@ DARSHAN_FORWARD_DECL(fwrite, size_t, (const void *ptr, size_t size, size_t nmemb
DARSHAN_FORWARD_DECL
(
lseek
,
off_t
,
(
int
fd
,
off_t
offset
,
int
whence
));
DARSHAN_FORWARD_DECL
(
lseek64
,
off64_t
,
(
int
fd
,
off64_t
offset
,
int
whence
));
DARSHAN_FORWARD_DECL
(
fseek
,
int
,
(
FILE
*
stream
,
long
offset
,
int
whence
));
/* stats */
/* mmaps */
DARSHAN_FORWARD_DECL
(
__xstat
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
));
DARSHAN_FORWARD_DECL
(
__xstat64
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat64
*
buf
));
DARSHAN_FORWARD_DECL
(
__lxstat
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
));
DARSHAN_FORWARD_DECL
(
__lxstat64
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat64
*
buf
));
DARSHAN_FORWARD_DECL
(
__fxstat
,
int
,
(
int
vers
,
int
fd
,
struct
stat
*
buf
));
DARSHAN_FORWARD_DECL
(
__fxstat64
,
int
,
(
int
vers
,
int
fd
,
struct
stat64
*
buf
));
/* TODO mmaps */
DARSHAN_FORWARD_DECL
(
fsync
,
int
,
(
int
fd
));
DARSHAN_FORWARD_DECL
(
fdatasync
,
int
,
(
int
fd
));
DARSHAN_FORWARD_DECL
(
close
,
int
,
(
int
fd
));
DARSHAN_FORWARD_DECL
(
fclose
,
int
,
(
FILE
*
fp
));
/* TODO mkstemp */
/* TODO aio */
/* TODO listio */
static
void
posix_runtime_initialize
(
void
);
static
struct
posix_file_runtime
*
posix_file_by_name
(
const
char
*
name
);
...
...
@@ -275,6 +283,33 @@ static int my_rank = -1;
DARSHAN_COUNTER_SET(file->file_record, POSIX_MAX_WRITE_TIME_SIZE, __ret); } \
} while(0)
#define POSIX_LOOKUP_RECORD_STAT(__path, __statbuf, __tm1, __tm2) do { \
char* exclude; \
int tmp_index = 0; \
struct posix_file_runtime* file; \
while((exclude = darshan_path_exclusions[tmp_index])) { \
if(!(strncmp(exclude, __path, strlen(exclude)))) \
break; \
tmp_index++; \
} \
if(exclude) break; \
file = posix_file_by_name(__path); \
if(file) \
{ \
POSIX_RECORD_STAT(file, __statbuf, __tm1, __tm2); \
} \
} while(0)
#define POSIX_RECORD_STAT(__file, __statbuf, __tm1, __tm2) do { \
if(!DARSHAN_COUNTER_VALUE((__file)->file_record, POSIX_STATS) && !DARSHAN_COUNTER_VALUE((__file)->file_record, POSIX_OPENS)){ \
DARSHAN_COUNTER_SET((__file)->file_record, FILE_ALIGNMENT, (__statbuf)->st_blksize); \
DARSHAN_COUNTER_SET((__file)->file_record, SIZE_AT_OPEN, (__statbuf)->st_size); \
}\
(__file)->file_record->rank = my_rank; \
DARSHAN_COUNTER_F_INC_NO_OVERLAP((__file)->file_record, __tm1, __tm2, (__file)->last_meta_end, POSIX_F_META_TIME); \
DARSHAN_COUNTER_INC((__file)->file_record, POSIX_STATS, 1); \
} while(0)
/**********************************************************
* Wrappers for POSIX I/O functions of interest *
**********************************************************/
...
...
@@ -764,7 +799,7 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
file
=
posix_file_by_fd
(
fileno
(
stream
));
if
(
file
)
{
file
->
offset
=
ftell
(
stream
);
/* TODO: this seems wrong. ftell? */
file
->
offset
=
ftell
(
stream
);
DARSHAN_COUNTER_F_INC_NO_OVERLAP
(
file
->
file_record
,
tm1
,
tm2
,
file
->
last_meta_end
,
POSIX_F_META_TIME
);
DARSHAN_COUNTER_INC
(
file
->
file_record
,
POSIX_FSEEKS
,
1
);
...
...
@@ -775,6 +810,162 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
return
(
ret
);
}
int
DARSHAN_DECL
(
__xstat
)(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__xstat
);
tm1
=
darshan_core_wtime
();
ret
=
__real___xstat
(
vers
,
path
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_LOOKUP_RECORD_STAT
(
path
,
buf
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
__xstat64
)(
int
vers
,
const
char
*
path
,
struct
stat64
*
buf
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__xstat64
);
tm1
=
darshan_core_wtime
();
ret
=
__real___xstat64
(
vers
,
path
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_LOOKUP_RECORD_STAT
(
path
,
buf
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
__lxstat
)(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__lxstat
);
tm1
=
darshan_core_wtime
();
ret
=
__real___lxstat
(
vers
,
path
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_LOOKUP_RECORD_STAT
(
path
,
buf
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
__lxstat64
)(
int
vers
,
const
char
*
path
,
struct
stat64
*
buf
)
{
int
ret
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__lxstat64
);
tm1
=
darshan_core_wtime
();
ret
=
__real___lxstat64
(
vers
,
path
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
POSIX_LOCK
();
posix_runtime_initialize
();
POSIX_LOOKUP_RECORD_STAT
(
path
,
buf
,
tm1
,
tm2
);
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
__fxstat
)(
int
vers
,
int
fd
,
struct
stat
*
buf
)
{
int
ret
;
struct
posix_file_runtime
*
file
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__fxstat
);
tm1
=
darshan_core_wtime
();
ret
=
__real___fxstat
(
vers
,
fd
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
/* TODO */
#if 0
/* skip logging if this was triggered internally */
if((void*)buf == (void*)&cp_stat_buf)
return(ret);
#endif
POSIX_LOCK
();
posix_runtime_initialize
();
file
=
posix_file_by_fd
(
fd
);
if
(
file
)
{
POSIX_RECORD_STAT
(
file
,
buf
,
tm1
,
tm2
);
}
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
__fxstat64
)(
int
vers
,
int
fd
,
struct
stat64
*
buf
)
{
int
ret
;
struct
posix_file_runtime
*
file
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
__fxstat64
);
tm1
=
darshan_core_wtime
();
ret
=
__real___fxstat64
(
vers
,
fd
,
buf
);
tm2
=
darshan_core_wtime
();
if
(
ret
<
0
||
!
S_ISREG
(
buf
->
st_mode
))
return
(
ret
);
/* TODO */
#if 0
/* skip logging if this was triggered internally */
if((void*)buf == (void*)&cp_stat_buf)
return(ret);
#endif
POSIX_LOCK
();
posix_runtime_initialize
();
file
=
posix_file_by_fd
(
fd
);
if
(
file
)
{
POSIX_RECORD_STAT
(
file
,
buf
,
tm1
,
tm2
);
}
POSIX_UNLOCK
();
return
(
ret
);
}
int
DARSHAN_DECL
(
fsync
)(
int
fd
)
{
int
ret
;
...
...
darshan-util/darshan-posix-parser.c
View file @
d72958de
...
...
@@ -174,6 +174,7 @@ int main(int argc, char **argv)
"
\t\t
POSIX_READS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_WRITES:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_SEEKS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_STATS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_FOPENS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_FREADS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_FWRITES:
\t
%"
PRIu64
"
\n
"
...
...
@@ -190,8 +191,10 @@ int main(int argc, char **argv)
"
\t\t
POSIX_SEQ_READS:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_SEQ_WRITES:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_RW_SWITCHES:
\t
%"
PRIu64
"
\n
"
"
\t\t
FILE_ALIGNMENT:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_MAX_READ_TIME_SIZE:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_MAX_WRITE_TIME_SIZE:
\t
%"
PRIu64
"
\n
"
"
\t\t
SIZE_AT_OPEN:
\t
%"
PRIu64
"
\n
"
"
\t\t
POSIX_F_OPEN_TIMESTAMP:
\t
%lf
\n
"
"
\t\t
POSIX_F_READ_START_TIMESTAMP:
\t
%lf
\n
"
"
\t\t
POSIX_F_WRITE_START_TIMESTAMP:
\t
%lf
\n
"
...
...
@@ -206,6 +209,7 @@ int main(int argc, char **argv)
next_file
.
counters
[
POSIX_READS
],
next_file
.
counters
[
POSIX_WRITES
],
next_file
.
counters
[
POSIX_SEEKS
],
next_file
.
counters
[
POSIX_STATS
],
next_file
.
counters
[
POSIX_FOPENS
],
next_file
.
counters
[
POSIX_FREADS
],
next_file
.
counters
[
POSIX_FWRITES
],
...
...
@@ -222,8 +226,10 @@ int main(int argc, char **argv)
next_file
.
counters
[
POSIX_SEQ_READS
],
next_file
.
counters
[
POSIX_SEQ_WRITES
],
next_file
.
counters
[
POSIX_RW_SWITCHES
],
next_file
.
counters
[
FILE_ALIGNMENT
],
next_file
.
counters
[
POSIX_MAX_READ_TIME_SIZE
],
next_file
.
counters
[
POSIX_MAX_WRITE_TIME_SIZE
],
next_file
.
counters
[
SIZE_AT_OPEN
],
next_file
.
fcounters
[
POSIX_F_OPEN_TIMESTAMP
],
next_file
.
fcounters
[
POSIX_F_READ_START_TIMESTAMP
],
next_file
.
fcounters
[
POSIX_F_WRITE_START_TIMESTAMP
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment