From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id BCDEF6EC5F; Mon, 19 Apr 2021 11:37:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BCDEF6EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618821476; bh=C4J/yiEXesUEXDnDZ6plwe82dwqp2ic1ElY8K+lV/GU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=c9g81WfRALUl5xImdpKQX3/OfXodzjCBANmoQkfrGHZK50YU1qKhoHVJ+CQjYhoq/ 6nqgfSaZamrrKwIYGbpeaxIzQcza7sIVi4RKy+ythGgdrOPUY9vmT25Y7PnojOklAc j1k60pSCuHk+4oVsxW68uyAAamrcEHUFkfp2LDX4= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 11D6F6EC5F for ; Mon, 19 Apr 2021 11:37:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 11D6F6EC5F Received: by mail-lf1-f49.google.com with SMTP id x20so24350878lfu.6 for ; Mon, 19 Apr 2021 01:37:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=URpdbBgoQ7GnZZGTw4ihhABtbutKDJh4WO+jTsjvuYo=; b=jadkWjr55xpN2Pz9RT5b7ruwxFHcjzDyzE8hoCXL8aVPKhEjidt0Idk/FRQa9wkMqg MKjT+qoi3oym+ZNZx8BAuYmzlr145kxzWOvSD68JXH0RhsT/ZyPliSDt4ddlVeN6CjAD VqAjDxVm3ZG/ioFFjfUXoTw4rDG48zjBFYqtlvqBooM7/a0c6N94p4CVlI9Xq8oyiRrO XhxGc602sSZV12QdOmjgN14UI4ETooZkHrRXQU7Clq5zgFAbg97nkFY7Afd8C0jdSS22 9ixXhj4iE3ykus79mzzC1ewINq6onCWn/9gdSFj5slaUE3d/4u6csnz9kuJKRwyIG9ET mA9Q== X-Gm-Message-State: AOAM530ieqk899Zq0tV9C7iFgT71wH5EQuNPoJmS3T7m/BN449cX9H3a NzqKCnHvg6pE8AsTCy3MkiosL/CnuEaDaQ== X-Google-Smtp-Source: ABdhPJxQk5BS+ZGxYmX7vdTAfVhratflQU3OILWxPELE0T/lKUsBnZ1iT/gzudWU2tX3LaOeVuiVng== X-Received: by 2002:a05:6512:108f:: with SMTP id j15mr11340999lfg.76.1618821456043; Mon, 19 Apr 2021 01:37:36 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id a2sm1755117lfh.19.2021.04.19.01.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 01:37:35 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 46C8056009D; Mon, 19 Apr 2021 11:37:22 +0300 (MSK) To: tml Date: Mon, 19 Apr 2021 11:37:17 +0300 Message-Id: <20210419083719.29689-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419083719.29689-1-gorcunov@gmail.com> References: <20210419083719.29689-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/3] wal: sanitize wal_mode X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" - 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 --- 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