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 CF82C6EC63; Sat, 24 Apr 2021 00:17:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CF82C6EC63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619212625; bh=IaVAn/4i5hQltrQ/Vj9fX+qLhj6Bthkb3TocPoJYgBI=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ioIx98laR6tcIoM1UK4zMWXl5cYDH7m5URNs5xEoktJYwhXh8h3R7HIzn4TZuSdnC wAu/t/fW0rJIjXvDXO1aQiKooMId+AsW+ILlSpiTfq47twPQFo1NacPak8GvRegMBg LWMCSSUSELYnTNzkHhaS1nXhXkxPiEXN/Cfm246A= Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 73B4F6EC63 for ; Sat, 24 Apr 2021 00:17:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 73B4F6EC63 Received: by mail-lf1-f54.google.com with SMTP id y4so39269899lfl.10 for ; Fri, 23 Apr 2021 14:17:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CkzoAnl2B3GTW2AD49gX1LapJgoCoshXRlnep1uPf9U=; b=bg0a8vFid7ancyW2q0I1dZiISCNSWsZO3OhqmSp4iSa3OFZ/mDcqmepK7Zq12D59Bz eAtoOmxq+lP3PjD7u3o50Ri8dnvBL39KUVslZBGTRcG0Kcl17MHYXX/gSeeLEHY26bik M6f45jE916GQ+CmWSbczrCuqWDWwxBeSDGaTrl5Q1xtRjZYN9GQbe8GP64Zi6i/Q+OSt SsxWavxyiQcP5MjjFVZ5oW0VrEmJPupoFOH+8wvR9lYgFVIdvJVkA90j6v8Xu6aY0ntc PxrXzl90yve0pmUgmKqbKsjUj8lkIPUwEUTVWzrItb8rrshxENLD2iqadhbQ25qiDkF6 4UWg== X-Gm-Message-State: AOAM531o2ne3S1vFs5uzlCVCF1LN9hbtgg2tYOnFoiFZI/P7hFnGW7NG nMik+AS7foI9pcz+/vroImrhHlYyv88= X-Google-Smtp-Source: ABdhPJx6RnLUrQh3ZP0XxaE4pX1VFH02GapXppCxwA1muv2HL3XPh5/S8Sp7xmcaxlArH7EXQCmgLg== X-Received: by 2002:a05:6512:10c5:: with SMTP id k5mr4235693lfg.320.1619212623393; Fri, 23 Apr 2021 14:17:03 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id a5sm650486lff.231.2021.04.23.14.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 14:17:02 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 29A865601BD; Sat, 24 Apr 2021 00:17:01 +0300 (MSK) Date: Sat, 24 Apr 2021 00:17:01 +0300 To: Vladislav Shpilevoy Cc: tml Message-ID: References: <20210419083719.29689-1-gorcunov@gmail.com> <20210419083719.29689-2-gorcunov@gmail.com> <68c7c11c-758b-5513-de57-1150c16689d8@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68c7c11c-758b-5513-de57-1150c16689d8@tarantool.org> User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Fri, Apr 23, 2021 at 10:57:11PM +0200, Vladislav Shpilevoy wrote: > Hi! Thanks for the patch! > > > 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]; > > 1. Why do you need to declare in the header the array size? > The old version with [] was just fine. And less places to change > if becomes necessary. If the size is known better to point it explicitly. Thus when you read this code you will notise the array size (yes, it doesn't matter from compiler pov if we declare it as a double pointer but still). But fine I'll leave this declaration untouched. > > 2. Please, keep the global variable where it was. We usually group > global variable declarations. It was grouped with wal_dir_lock > below. --- From: Cyrill Gorcunov Date: Fri, 16 Apr 2021 15:54:52 +0300 Subject: [PATCH] wal: sanitize wal_mode - 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 | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/box/wal.c b/src/box/wal.c index 5b6200b81..6468df884 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..36fcd39bd 100644 --- a/src/box/wal.h +++ b/src/box/wal.h @@ -41,7 +41,26 @@ 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 +}; enum { /** -- 2.30.2