diff options
author | Vito Caputo <vito.caputo@coreos.com> | 2016-02-12 04:59:57 -0800 |
---|---|---|
committer | Vito Caputo <vito.caputo@coreos.com> | 2016-02-19 18:50:20 -0800 |
commit | ac2e41f5103ce2c679089c4f8fb6be61d7caec07 (patch) | |
tree | aa9015d7a0e9466e783704d857dd5db0fec70512 /src/journal/journal-file.h | |
parent | 69a3a6fd3d96101d42a01d0e7d33ae2ef613e54a (diff) |
journal: asynchronous journal_file_set_offline()
This adds a wait flag to journal_file_set_offline(), when false the offline is
performed asynchronously in a separate thread.
When wait is true, if an asynchronous offline is already in-progress it is
restarted and waited for. Otherwise the offline is performed synchronously
without the use of a thread.
journal_file_set_online() cancels or waits for the asynchronous offline to
complete if in-flight, depending on where in the offline process the thread
happens to be. If the thread is in the fsync() phase, it is cancelled and
waiting is unnecessary. Otherwise, the thread is joined before proceeding.
A new offline_state member is added to JournalFile which is used via
atomic operations for communicating between the offline thread and the
journal_file_set_{offline,online}() functions.
Diffstat (limited to 'src/journal/journal-file.h')
-rw-r--r-- | src/journal/journal-file.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index 07b9561b8a..fad4f78bdc 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -63,6 +63,16 @@ typedef enum LocationType { LOCATION_SEEK } LocationType; +typedef enum OfflineState { + OFFLINE_JOINED, + OFFLINE_SYNCING, + OFFLINE_OFFLINING, + OFFLINE_CANCEL, + OFFLINE_AGAIN_FROM_SYNCING, + OFFLINE_AGAIN_FROM_OFFLINING, + OFFLINE_DONE +} OfflineState; + typedef struct JournalFile { int fd; @@ -105,6 +115,9 @@ typedef struct JournalFile { OrderedHashmap *chain_cache; + pthread_t offline_thread; + volatile OfflineState offline_state; + #if defined(HAVE_XZ) || defined(HAVE_LZ4) void *compress_buffer; size_t compress_buffer_size; @@ -139,7 +152,7 @@ int journal_file_open( JournalFile *template, JournalFile **ret); -int journal_file_set_offline(JournalFile *f); +int journal_file_set_offline(JournalFile *f, bool wait); JournalFile* journal_file_close(JournalFile *j); int journal_file_open_reliably( |