diff options
author | Dave Barach <dave@barachs.net> | 2018-03-22 10:54:45 -0400 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-03-22 22:36:20 +0000 |
commit | 6ddede72126a8e5854908b6fcf4c80f55bf450cc (patch) | |
tree | 9d99aaa2f6437a7676a656ba9edbc6e0097ea376 /src/vppinfra/maplog.h | |
parent | f3639d00aa1ccb37987dc90f974540a5c70187de (diff) |
Add circular logging
Change-Id: Ide8bf41e24a427643a3a17b1c9089993790c12a6
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/maplog.h')
-rw-r--r-- | src/vppinfra/maplog.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/vppinfra/maplog.h b/src/vppinfra/maplog.h index 9bc8596de1b..67a83a72cf3 100644 --- a/src/vppinfra/maplog.h +++ b/src/vppinfra/maplog.h @@ -45,12 +45,12 @@ typedef struct u8 maplog_major_version; /**< library major version number */ u8 maplog_minor_version; /**< library minor version number */ u8 maplog_patch_version; /**< library patch version number */ - u8 pad; + u8 maplog_flag_wrapped; /**< log has wrapped */ u32 application_id; /**< application identifier */ u8 application_major_version; /**< application major version number */ u8 application_minor_version; /**< application minor version number */ u8 application_patch_version; /**< application patch version number */ - u8 pad2; + u8 maplog_flag_circular; /**< log is circular */ u32 record_size_in_cachelines; /**< record size in cache lines */ u32 cacheline_size; /**< cache line size */ u64 file_size_in_records; /**< file size in records */ @@ -60,7 +60,7 @@ typedef struct } clib_maplog_header_t; #define MAPLOG_MAJOR_VERSION 1 -#define MAPLOG_MINOR_VERSION 0 +#define MAPLOG_MINOR_VERSION 1 #define MAPLOG_PATCH_VERSION 0 /** Process-private main data structure */ @@ -90,6 +90,8 @@ typedef struct /* flag bits */ #define CLIB_MAPLOG_FLAG_INIT (1<<0) +#define CLIB_MAPLOG_FLAG_CIRCULAR (1<<1) +#define CLIB_MAPLOG_FLAG_WRAPPED (1<<2) /** log initialization structure */ typedef struct @@ -102,6 +104,7 @@ typedef struct u8 application_major_version; /**< applcation major version number */ u8 application_minor_version; /**< applcation minor version number */ u8 application_patch_version; /**< applcation patch version number */ + u8 maplog_is_circular; /**< single, circular log */ } clib_maplog_init_args_t; /* function prototypes */ @@ -139,9 +142,15 @@ clib_maplog_get_entry (clib_maplog_main_t * mm) /* Time to unmap and create a new logfile? */ if (PREDICT_FALSE ((my_record_index & (mm->file_size_in_records - 1)) == 0)) { - /* Yes, but not the very first time... (;-)... */ - if (my_record_index) - return _clib_maplog_get_entry_slowpath (mm, my_record_index); + /* Regular log? Switch file... */ + if (!(mm->flags & CLIB_MAPLOG_FLAG_CIRCULAR)) + { + /* Yes, but not the very first time... (;-)... */ + if (my_record_index) + return _clib_maplog_get_entry_slowpath (mm, my_record_index); + } + else /* Circular log: set the wrap bit and move along */ + mm->flags |= CLIB_MAPLOG_FLAG_WRAPPED; /* FALLTHROUGH */ } |