c460ee
From 2c0d11bb406e50fb515abf0c5a4006e1b362ac8e Mon Sep 17 00:00:00 2001
c460ee
From: Emmanuel Dreyfus <manu@netbsd.org>
c460ee
Date: Tue, 30 Jun 2020 16:42:36 +0200
c460ee
Subject: [PATCH 571/584] NetBSD build fixes
c460ee
c460ee
- Make sure -largp is used at link time
c460ee
- PTHREAD_MUTEX_ADAPTIVE_NP is not available, use PTHREAD_MUTEX_DEFAULT instead
c460ee
- Avoid non POSIX [[ ]] in scripts
c460ee
- Do not check of lock.spinlock is NULL since it is not a pointer
c460ee
  (it is not a pointer on Linux either)
c460ee
c460ee
Backport of:
c460ee
> Upstream-patch: https://review.gluster.org/#/c/glusterfs/+/24648/
c460ee
> Change-Id: I5e04a7c552d24f8a473c2b837828d1bddfa7e128
c460ee
> Fixes: #1347
c460ee
> Type: Bug
c460ee
> Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
c460ee
c460ee
BUG: 1925425
c460ee
Change-Id: I5e04a7c552d24f8a473c2b837828d1bddfa7e128
c460ee
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
c460ee
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/245040
c460ee
Tested-by: RHGS Build Bot <nigelb@redhat.com>
c460ee
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
c460ee
---
c460ee
 configure.ac                                        | 3 +++
c460ee
 rpc/rpc-lib/src/rpcsvc.c                            | 4 ++++
c460ee
 tools/gfind_missing_files/gfind_missing_files.sh    | 2 +-
c460ee
 xlators/performance/write-behind/src/write-behind.c | 4 ++--
c460ee
 4 files changed, 10 insertions(+), 3 deletions(-)
c460ee
c460ee
diff --git a/configure.ac b/configure.ac
c460ee
index 327733e..6138a59 100644
c460ee
--- a/configure.ac
c460ee
+++ b/configure.ac
c460ee
@@ -998,6 +998,9 @@ case $host_os in
c460ee
     CFLAGS="${CFLAGS} -isystem /usr/local/include"
c460ee
     ARGP_LDADD=-largp
c460ee
     ;;
c460ee
+    *netbsd*)
c460ee
+    ARGP_LDADD=-largp
c460ee
+    ;;
c460ee
 esac
c460ee
 dnl argp-standalone does not provide a pkg-config file
c460ee
 AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
c460ee
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
c460ee
index 3f184bf..b031d93 100644
c460ee
--- a/rpc/rpc-lib/src/rpcsvc.c
c460ee
+++ b/rpc/rpc-lib/src/rpcsvc.c
c460ee
@@ -46,6 +46,10 @@
c460ee
 #include "xdr-rpcclnt.h"
c460ee
 #include <glusterfs/glusterfs-acl.h>
c460ee
 
c460ee
+#ifndef PTHREAD_MUTEX_ADAPTIVE_NP
c460ee
+#define PTHREAD_MUTEX_ADAPTIVE_NP PTHREAD_MUTEX_DEFAULT
c460ee
+#endif
c460ee
+
c460ee
 struct rpcsvc_program gluster_dump_prog;
c460ee
 
c460ee
 #define rpcsvc_alloc_request(svc, request)                                     \
c460ee
diff --git a/tools/gfind_missing_files/gfind_missing_files.sh b/tools/gfind_missing_files/gfind_missing_files.sh
c460ee
index f42fe7b..e7aaa0b 100644
c460ee
--- a/tools/gfind_missing_files/gfind_missing_files.sh
c460ee
+++ b/tools/gfind_missing_files/gfind_missing_files.sh
c460ee
@@ -61,7 +61,7 @@ mount_slave()
c460ee
 
c460ee
 parse_cli()
c460ee
 {
c460ee
-    if [[ $# -ne 4 ]]; then
c460ee
+    if [ "$#" -ne 4 ]; then
c460ee
         echo "Usage: gfind_missing_files <brick-path> <slave-host> <slave-vol> <OUTFILE>"
c460ee
         exit 1
c460ee
     else
c460ee
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
c460ee
index 31ab723..76d257f 100644
c460ee
--- a/xlators/performance/write-behind/src/write-behind.c
c460ee
+++ b/xlators/performance/write-behind/src/write-behind.c
c460ee
@@ -2490,7 +2490,7 @@ wb_mark_readdirp_start(xlator_t *this, inode_t *directory)
c460ee
 
c460ee
     wb_directory_inode = wb_inode_create(this, directory);
c460ee
 
c460ee
-    if (!wb_directory_inode || !wb_directory_inode->lock.spinlock)
c460ee
+    if (!wb_directory_inode)
c460ee
         return;
c460ee
 
c460ee
     LOCK(&wb_directory_inode->lock);
c460ee
@@ -2510,7 +2510,7 @@ wb_mark_readdirp_end(xlator_t *this, inode_t *directory)
c460ee
 
c460ee
     wb_directory_inode = wb_inode_ctx_get(this, directory);
c460ee
 
c460ee
-    if (!wb_directory_inode || !wb_directory_inode->lock.spinlock)
c460ee
+    if (!wb_directory_inode)
c460ee
         return;
c460ee
 
c460ee
     LOCK(&wb_directory_inode->lock);
c460ee
-- 
c460ee
1.8.3.1
c460ee