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 74D9EA0562; Mon, 30 Mar 2020 09:04:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE26C1C02D; Mon, 30 Mar 2020 09:04:30 +0200 (CEST) Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by dpdk.org (Postfix) with ESMTP id 048041C02A for ; Mon, 30 Mar 2020 09:04:29 +0200 (CEST) Received: by mail-io1-f65.google.com with SMTP id r25so4746202ioc.11 for ; Mon, 30 Mar 2020 00:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tj+uZnskoPfuKGmFa4IUU1JEuD/n1f900qz5miaDx40=; b=X8XyFFY1Kstq/0AGDPl3F5JPiuQATYKrX6Jtf7NNv3B8xdLCs3JEHL0ciFb9L0ccgc 5AnTGgrdzU6T0CmHqqNGHp9OgxJoLX1Qr9lMA4TFmI5EgC0rGb3nJ9ZIvwZhvTIBY8lg 0wMNF834ItiNPczmmWMDceD8PP2DYAttMAHYQhYS2cnF5HKdWsQ/dJ38ehjHRWNn3ld/ jsk3CxAXT4YcvNVw5FkkNAA3LrXjW2WHZGNEmAXTYcu8oaWp6LC+a0ZlXGInN0lyk2N6 8p5fiQ8ikwid5wuGkYZun8eCarqCfedntViKDJ7JR5d1ajHD2cIcIAB2rTBiOgcO1WnQ aMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tj+uZnskoPfuKGmFa4IUU1JEuD/n1f900qz5miaDx40=; b=tnNCisx2pmRmZ7stnH7Qh5Fh+J+TPK87zPCNa2Q4MrShNHbqqR7JknYM/ISNVkWPbg wfIztim4nTred7L6V2PWkVc9wLtJQJ5QqeYg73C4bv+MdSPBPPUsku/yYgBFf+zA4amv WRE0cqfN47oAZJFLvEOqcikJ3C2SDCJ5R+LzvWdm8VyiRwbuli/4bFd+Es9QBS3DZBG5 cf150nFCzaGetEYPd0JK3EtrpSWq+XDLcoH1eU5oKAimZ1WtRGidhFYjH+l22P4ftt2u 1CKMErDAWF2BsoFdSAazrSD4hxrZkhOlP6Xcp5u9zzFeD6nco+2LlYwQVwT++d5pS2ub YaUQ== X-Gm-Message-State: ANhLgQ31io7WiO9PiDwSnLHJVAX0VgePP0WiOyEGFkDpDyXiC6YmUDYv 2R5rXw+UxgCSdZPzXrdOlW/3YUKFFGqmASVnCBQ= X-Google-Smtp-Source: ADFU+vuzJuodrOhPSq+c78pd5S8PI8ZMNteqmZboVHesxrXVibZpUTQkvLK9u2XkgVBI0Ni5VVNfyEHhoVZiZoXFOQE= X-Received: by 2002:a02:455:: with SMTP id 82mr9515692jab.112.1585551869175; Mon, 30 Mar 2020 00:04:29 -0700 (PDT) MIME-Version: 1.0 References: <20200330041026.784624-1-dmitry.kozliuk@gmail.com> <20200330041026.784624-6-dmitry.kozliuk@gmail.com> In-Reply-To: <20200330041026.784624-6-dmitry.kozliuk@gmail.com> From: Jerin Jacob Date: Mon, 30 Mar 2020 12:34:13 +0530 Message-ID: To: Dmitry Kozlyuk Cc: dpdk-dev , "Dmitry Malloy (MESHCHANINOV)" , Bruce Richardson , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [RFC PATCH 5/9] 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 Mon, Mar 30, 2020 at 9:41 AM Dmitry Kozlyuk wrote: > > EAL common code uses file locking and truncation. Introduce > OS-independent wrapeprs in order to support both POSIX 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. > > Signed-off-by: Dmitry Kozlyuk > > WIP2 > --- > lib/librte_eal/common/eal_private.h | 45 ++++++++++++++++ > lib/librte_eal/freebsd/eal/eal.c | 40 ++++++++++++++ > lib/librte_eal/linux/eal/eal.c | 40 ++++++++++++++ > lib/librte_eal/windows/eal/eal.c | 83 +++++++++++++++++++++++++++++ > 4 files changed, 208 insertions(+) > > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h > index ddcfbe2e4..0130571e8 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 rte_flock_op { > + RTE_FLOCK_SHARED, /**< Acquire a shared lock. */ > + RTE_FLOCK_EXCLUSIVE, /**< Acquire an exclusive lock. */ > + RTE_FLOCK_UNLOCK /**< Release a previously taken lock. */ > +}; > + > +/** Behavior on file locking conflict. */ > +enum rte_flock_mode { > + RTE_FLOCK_WAIT, /**< Wait until the file gets unlocked to lock it. */ > + RTE_FLOCK_RETURN /**< Return immediately if the file is locked. */ > +}; Avoid using RTE_ for internal symbols. IMO, EAL_FLOCK_* would be enough for some something defined in eal_private.h.