From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A2E90A058A; Fri, 17 Apr 2020 14:24:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A3AE1E542; Fri, 17 Apr 2020 14:24:34 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DCF3629CB for ; Fri, 17 Apr 2020 14:24:32 +0200 (CEST) IronPort-SDR: wZ4sm4ikmxrqS7i7D6gdwYP6Nn4JxNl3Kr3Vu5P2GEIZ4Wr7cr76A6C5bLZqUzHvWJzpL4roiG rl7YNK0FRzEg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2020 05:24:31 -0700 IronPort-SDR: Fv6MLxVSQ0/0unq3BX2pMv6sOn0RDJXXVd3qxugJ8hp7cOvJfqhte+LOemr9mVCZKmIRRQzPq9 2km80azJ4KMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,395,1580803200"; d="scan'208";a="278366302" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.252.62.102]) ([10.252.62.102]) by fmsmga004.fm.intel.com with ESMTP; 17 Apr 2020 05:24:29 -0700 To: Dmitry Kozlyuk , dev@dpdk.org Cc: "Dmitry Malloy (MESHCHANINOV)" , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon References: <20200410164342.1194634-1-dmitry.kozliuk@gmail.com> <20200414194426.1640704-1-dmitry.kozliuk@gmail.com> <20200414194426.1640704-6-dmitry.kozliuk@gmail.com> From: "Burakov, Anatoly" Message-ID: <458481db-0e16-7f6f-692e-1ec47c4e6845@intel.com> Date: Fri, 17 Apr 2020 13:24:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200414194426.1640704-6-dmitry.kozliuk@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 05/10] eal: introduce internal wrappers for file operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 14-Apr-20 8:44 PM, Dmitry Kozlyuk wrote: > EAL common code uses file locking and truncation. Introduce > OS-independent wrappers in order to support both Linux/FreeBSD > and Windows: > > * eal_file_lock: lock or unlock an open file. > * eal_file_truncate: enforce a given size for an open file. > > Wrappers follow POSIX semantics, but interface is not POSIX, > so that it can be made more clean, e.g. by not mixing locking > operation and behaviour on conflict. > > Implementation for Linux and FreeBSD is placed in "unix" subdirectory, > which is intended for common code between the two. Files should be named > after the ones from which the code is factored in OS subdirectory. > > Signed-off-by: Dmitry Kozlyuk > --- > lib/librte_eal/common/eal_private.h | 45 ++++++++++++++++ > lib/librte_eal/meson.build | 4 ++ > lib/librte_eal/unix/eal.c | 47 ++++++++++++++++ > lib/librte_eal/unix/meson.build | 6 +++ > lib/librte_eal/windows/eal.c | 83 +++++++++++++++++++++++++++++ > 5 files changed, 185 insertions(+) > create mode 100644 lib/librte_eal/unix/eal.c > create mode 100644 lib/librte_eal/unix/meson.build > > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h > index ddcfbe2e4..65d61ff13 100644 > --- a/lib/librte_eal/common/eal_private.h > +++ b/lib/librte_eal/common/eal_private.h > @@ -443,4 +443,49 @@ rte_option_usage(void); > uint64_t > eal_get_baseaddr(void); > > +/** File locking operation. */ > +enum eal_flock_op { > + EAL_FLOCK_SHARED, /**< Acquire a shared lock. */ > + EAL_FLOCK_EXCLUSIVE, /**< Acquire an exclusive lock. */ > + EAL_FLOCK_UNLOCK /**< Release a previously taken lock. */ > +}; > + > +/** Behavior on file locking conflict. */ > +enum eal_flock_mode { > + EAL_FLOCK_WAIT, /**< Wait until the file gets unlocked to lock it. */ > + EAL_FLOCK_RETURN /**< Return immediately if the file is locked. */ > +}; Nitpicking, but why not blocking/unblocking? The terminology seems pretty standard. -- Thanks, Anatoly