Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp809181lqt; Thu, 6 Jun 2024 21:37:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwsyqxcOT0AfWAxFvGDUZm2ovnCq34E6zwm6o+V1wK5l5w7yb9PZb5TLS8cL68SZigQaKRje6xhGPAvnshL81fayTrkakqqB86dQhqaw== X-Google-Smtp-Source: AGHT+IEl1O/H5fy/4PYXIkCem2Q5cvJtBrkcY3pntwFzTqOWSQSFOyaBtvrWk+s3W6/NOp/Hrdl9 X-Received: by 2002:a05:6e02:154c:b0:374:9c0b:e18f with SMTP id e9e14a558f8ab-3758032d547mr18035935ab.16.1717735042562; Thu, 06 Jun 2024 21:37:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717735042; cv=pass; d=google.com; s=arc-20160816; b=WX0gYWCg0hTOXj/oYuDU7X2kCv5TTXahJVE92TyDzNSYfgU8MtIKJgltg6mQ23zMDt uU0UfeCzkG2bTkgF4qHbyvtXSCquoXhcvjpInQSJUVbb/wXUuc6fqCwYzhCOB0tEyUUc OOxGzQ7ERjqqyiBqMcKNhK0H5iE5hTn01uJ3kCi4LS+A+kmdzu2qWRzGV/XL8FFTpmeZ ij7fqWRG1KzZwJLkvz1EDmrz3vpNZLT21O9pSUX8XGtROw7YMOnb+YkeDfSKz/2jb2Lm ZtIF9oJ9mVtkOtfMdn5XoBt2nPD5A9sNhRDxZe2Mtfb/KSpQG3qQi81c81lPNfwRoL+I wH2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=uE0Jia4uDhYnGgkXpZgoKWUdt9m9tTPF1cXpRwGnkeQ=; fh=yXYChwFvQA/NaaLzCC0IJdkW11OhjXgO4DHXzVmnGFw=; b=R7gp72Ce+m/Mx0AT04ZZ0bDtopeQS5k4ida7bm+pW8KeyEjLz/6U+JoW61BqoY9k1H 7OGSZUf5YEXty1vqn1Yh/rLu0L40pUE7fHN/ojlftT5ydmBe5WQ06SyFqrD+Ou/quavb be9uD2feM7E0ketU3hx898MMY4ByguoWKOKe82hG4nlB9cFGkdiVT9ogVxxXfFWdUaWo fqT9Nfvx6B7hknwhS+lNbVGY3L/4VHsPZ7doq7a+HxezNDtES6hUmfjhewy6XkVZgCb8 vsb7fmn+e2AYdFYiwjvDMORwx2+CnXefRbNBQZR2w7HVFNZl92Otoo1uIp390GDJKYUc d3EQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2073c908si2287971a12.156.2024.06.06.21.37.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 14CF3B2308C for ; Fri, 7 Jun 2024 04:32:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11FB215381B; Fri, 7 Jun 2024 04:27:00 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE0AA144307 for ; Fri, 7 Jun 2024 04:26:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734419; cv=none; b=h6n3kR7bBa7mbD9ZWTSVese6l85P8Qat7vR80SpP+A/5N6aWfwCZGRgbvn/lrPTYSASXcs0H8OIlhTkEKPr51iA3F2dTYCs9IgfSgh/IcgZoMmQ+I8+boIT6tGl4FWG8jL90oQvvw44g4Y2Us9LnwN3HkicUP/H1QGzGScH4RFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734419; c=relaxed/simple; bh=Zc6EOgTnbsWVpInWfKdXHRjy5bUAvZLsvm52pPL054Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AkmKLT4p6xUqI3GhzFay0vrnyuax5fa8vWYXiUVgIOHB8yZlGjnWLhknKOMIsHwg8t7oI0IlBgTYgnGg07aZqTfj+lVxZ4zIjMhLOT3FGJdAUnTWVsqAnmq/NECGV32Qqvto2fC+JXmnraN3NbC0mKKuiPb83D5xoHhWB0yDDEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VwShl6mSbzmYTF; Fri, 7 Jun 2024 12:22:15 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id C1F0B14038F; Fri, 7 Jun 2024 12:26:51 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 12:26:45 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 025/110] ubifs-utils: Add spinlock implementations Date: Fri, 7 Jun 2024 12:24:50 +0800 Message-ID: <20240607042615.2069840-26-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607042615.2069840-1-chengzhihao1@huawei.com> References: <20240607042615.2069840-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) Add spinlock implementations, because there are some spinlocks (eg. c->cnt_lock, c->buds_lock) used in UBIFS linux kernel libs. The spinlock is implementated based on pthread mutex. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng --- ubifs-utils/Makemodule.am | 3 ++- ubifs-utils/common/spinlock.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ubifs-utils/common/spinlock.h diff --git a/ubifs-utils/Makemodule.am b/ubifs-utils/Makemodule.am index 9e075071..7849114e 100644 --- a/ubifs-utils/Makemodule.am +++ b/ubifs-utils/Makemodule.am @@ -5,6 +5,7 @@ common_SOURCES = \ ubifs-utils/common/atomic.h \ ubifs-utils/common/bitops.h \ ubifs-utils/common/bitops.c \ + ubifs-utils/common/spinlock.h \ ubifs-utils/common/kmem.h \ ubifs-utils/common/kmem.c \ ubifs-utils/common/defs.h \ @@ -39,7 +40,7 @@ mkfs_ubifs_SOURCES = \ $(common_SOURCES) \ ubifs-utils/mkfs.ubifs/mkfs.ubifs.c -mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) -lm +mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) -lm -lpthread mkfs_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common diff --git a/ubifs-utils/common/spinlock.h b/ubifs-utils/common/spinlock.h new file mode 100644 index 00000000..b9ed3938 --- /dev/null +++ b/ubifs-utils/common/spinlock.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_SPINLOCK_H_ +#define __LINUX_SPINLOCK_H_ + +#include + +#define spinlock_t pthread_mutex_t +#define DEFINE_SPINLOCK(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER +#define spin_lock_init(x) pthread_mutex_init(x, NULL) + +#define spin_lock(x) pthread_mutex_lock(x) +#define spin_unlock(x) pthread_mutex_unlock(x) + +#endif -- 2.13.6