8 Star 0 Fork 5

src-anolis-os/glusterfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0572-locks-remove-unused-conditional-switch-to-spin_lock-.patch 6.87 KB
一键复制 编辑 原始数据 按行查看 历史
ZhouWeitao 提交于 2022-02-17 21:00 . update to glusterfs-6.0-61.el8
From 1491b33007e84be0a0a74354e89deca8a21ed198 Mon Sep 17 00:00:00 2001
From: Vinayak hariharmath <[email protected]>
Date: Tue, 19 Jan 2021 15:39:35 +0530
Subject: [PATCH 572/584] locks: remove unused conditional switch to spin_lock
code
use of spin_locks is depend on the variable use_spinlocks
but the same is commented in the current code base through
https://review.gluster.org/#/c/glusterfs/+/14763/. So it is
of no use to have conditional switching to spin_lock or
mutex. Removing the dead code as part of the patch
Backport of:
> Upstream-patch: https://github.com/gluster/glusterfs/pull/2007
> Fixes: #1996
> Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129
> Signed-off-by: Vinayakswami Hariharmath <[email protected]>
BUG: 1925425
Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129
Signed-off-by: Vinayakswami Hariharmath <[email protected]>
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244965
Tested-by: RHGS Build Bot <[email protected]>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <[email protected]>
---
configure.ac | 7 -----
libglusterfs/src/Makefile.am | 2 +-
libglusterfs/src/common-utils.c | 5 ----
libglusterfs/src/glusterfs/locking.h | 51 ------------------------------------
libglusterfs/src/locking.c | 27 -------------------
5 files changed, 1 insertion(+), 91 deletions(-)
delete mode 100644 libglusterfs/src/locking.c
diff --git a/configure.ac b/configure.ac
index 6138a59..3d99f6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -585,13 +585,6 @@ AC_CHECK_HEADERS([linux/falloc.h])
AC_CHECK_HEADERS([linux/oom.h], AC_DEFINE(HAVE_LINUX_OOM_H, 1, [have linux/oom.h]))
-dnl Mac OS X does not have spinlocks
-AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
-if test "x${have_spinlock}" = "xyes"; then
- AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
-fi
-AC_SUBST(HAVE_SPINLOCK)
-
dnl some os may not have GNU defined strnlen function
AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
if test "x${have_strnlen}" = "xyes"; then
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index 970f4b7..830a0c3 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -35,7 +35,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
strfd.c parse-utils.c $(CONTRIBDIR)/mount/mntent.c \
$(CONTRIBDIR)/libexecinfo/execinfo.c quota-common-utils.c rot-buffs.c \
$(CONTRIBDIR)/timer-wheel/timer-wheel.c \
- $(CONTRIBDIR)/timer-wheel/find_last_bit.c default-args.c locking.c \
+ $(CONTRIBDIR)/timer-wheel/find_last_bit.c default-args.c \
$(CONTRIBDIR)/xxhash/xxhash.c \
compound-fop-utils.c throttle-tbf.c monitoring.c
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index d351b93..c2dfe28 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -860,11 +860,6 @@ gf_dump_config_flags()
gf_msg_plain_nomem(GF_LOG_ALERT, "setfsid 1");
#endif
-/* define if found spinlock */
-#ifdef HAVE_SPINLOCK
- gf_msg_plain_nomem(GF_LOG_ALERT, "spinlock 1");
-#endif
-
/* Define to 1 if you have the <sys/epoll.h> header file. */
#ifdef HAVE_SYS_EPOLL_H
gf_msg_plain_nomem(GF_LOG_ALERT, "epoll.h 1");
diff --git a/libglusterfs/src/glusterfs/locking.h b/libglusterfs/src/glusterfs/locking.h
index 43cc877..63097bb 100644
--- a/libglusterfs/src/glusterfs/locking.h
+++ b/libglusterfs/src/glusterfs/locking.h
@@ -22,55 +22,6 @@
#define pthread_spin_init(l, v) (*l = v)
#endif
-#if defined(HAVE_SPINLOCK)
-
-typedef union {
- pthread_spinlock_t spinlock;
- pthread_mutex_t mutex;
-} gf_lock_t;
-
-#if !defined(LOCKING_IMPL)
-extern int use_spinlocks;
-
-/*
- * Using a dispatch table would be unpleasant because we're dealing with two
- * different types. If the dispatch contains direct pointers to pthread_xx
- * or mutex_xxx then we have to hope that every possible union alternative
- * starts at the same address as the union itself. I'm old enough to remember
- * compilers where this was not the case (for alignment reasons) so I'm a bit
- * paranoid about that. Also, I don't like casting arguments through "void *"
- * which we'd also have to do to avoid type errors. The other alternative would
- * be to define actual functions which pick out the right union member, and put
- * those in the dispatch tables. Now we have a pointer dereference through the
- * dispatch table plus a function call, which is likely to be worse than the
- * branching here from the ?: construct. If it were a clear win it might be
- * worth the extra complexity, but for now this way seems preferable.
- */
-
-#define LOCK_INIT(x) \
- (use_spinlocks ? pthread_spin_init(&((x)->spinlock), 0) \
- : pthread_mutex_init(&((x)->mutex), 0))
-
-#define LOCK(x) \
- (use_spinlocks ? pthread_spin_lock(&((x)->spinlock)) \
- : pthread_mutex_lock(&((x)->mutex)))
-
-#define TRY_LOCK(x) \
- (use_spinlocks ? pthread_spin_trylock(&((x)->spinlock)) \
- : pthread_mutex_trylock(&((x)->mutex)))
-
-#define UNLOCK(x) \
- (use_spinlocks ? pthread_spin_unlock(&((x)->spinlock)) \
- : pthread_mutex_unlock(&((x)->mutex)))
-
-#define LOCK_DESTROY(x) \
- (use_spinlocks ? pthread_spin_destroy(&((x)->spinlock)) \
- : pthread_mutex_destroy(&((x)->mutex)))
-
-#endif
-
-#else
-
typedef pthread_mutex_t gf_lock_t;
#define LOCK_INIT(x) pthread_mutex_init(x, 0)
@@ -79,6 +30,4 @@ typedef pthread_mutex_t gf_lock_t;
#define UNLOCK(x) pthread_mutex_unlock(x)
#define LOCK_DESTROY(x) pthread_mutex_destroy(x)
-#endif /* HAVE_SPINLOCK */
-
#endif /* _LOCKING_H */
diff --git a/libglusterfs/src/locking.c b/libglusterfs/src/locking.c
deleted file mode 100644
index 7577054..0000000
--- a/libglusterfs/src/locking.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com>
- This file is part of GlusterFS.
-
- This file is licensed to you under your choice of the GNU Lesser
- General Public License, version 3 or any later version (LGPLv3 or
- later), or the GNU General Public License, version 2 (GPLv2), in all
- cases as published by the Free Software Foundation.
-*/
-
-#if defined(HAVE_SPINLOCK)
-/* None of this matters otherwise. */
-
-#include <pthread.h>
-#include <unistd.h>
-
-#define LOCKING_IMPL
-#include "glusterfs/locking.h"
-
-int use_spinlocks = 0;
-
-static void __attribute__((constructor)) gf_lock_setup(void)
-{
- // use_spinlocks = (sysconf(_SC_NPROCESSORS_ONLN) > 1);
-}
-
-#endif
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/glusterfs.git
[email protected]:src-anolis-os/glusterfs.git
src-anolis-os
glusterfs
glusterfs
a8

搜索帮助