[Tarantool-patches] [PATCH 1/3] wal: sanitize wal_mode

Cyrill Gorcunov gorcunov at gmail.com
Mon Apr 19 11:37:17 MSK 2021


 - there is no need to set WAN_NONE to 0 explicitly
 - add comments about modes
 - there is no need to carry NULL in wal_mode_STRS
 - use designated assignment in wal_mode_STRS

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/wal.c |  6 +++++-
 src/box/wal.h | 27 +++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/box/wal.c b/src/box/wal.c
index 34af0bda6..05f30769a 100644
--- a/src/box/wal.c
+++ b/src/box/wal.c
@@ -55,7 +55,11 @@ enum {
 	WAL_FALLOCATE_LEN = 1024 * 1024,
 };
 
-const char *wal_mode_STRS[] = { "none", "write", "fsync", NULL };
+const char *wal_mode_STRS[WAL_MODE_MAX] = {
+	[WAL_NONE]	= "none",
+	[WAL_WRITE]	= "write",
+	[WAL_FSYNC]	= "fsync",
+};
 
 int wal_dir_lock = -1;
 
diff --git a/src/box/wal.h b/src/box/wal.h
index a8a16ba2e..470aa1cc8 100644
--- a/src/box/wal.h
+++ b/src/box/wal.h
@@ -41,7 +41,29 @@ struct fiber;
 struct wal_writer;
 struct tt_uuid;
 
-enum wal_mode { WAL_NONE = 0, WAL_WRITE, WAL_FSYNC, WAL_MODE_MAX };
+enum wal_mode {
+	/**
+	 * Do not write data at all.
+	 */
+	WAL_NONE,
+
+	/**
+	 * Write without waiting the data to be
+	 * flushed to the storage device.
+	 */
+	WAL_WRITE,
+
+	/**
+	 * Write data and wait the record to be
+	 * flushed to the storage device.
+	 */
+	WAL_FSYNC,
+
+	WAL_MODE_MAX
+};
+
+/** String constants for the supported modes. */
+extern const char *wal_mode_STRS[WAL_MODE_MAX];
 
 enum {
 	/**
@@ -52,9 +74,6 @@ enum {
 	WAL_ROWS_PER_YIELD = 1 << 15,
 };
 
-/** String constants for the supported modes. */
-extern const char *wal_mode_STRS[];
-
 extern int wal_dir_lock;
 
 #if defined(__cplusplus)
-- 
2.30.2



More information about the Tarantool-patches mailing list