0%

nfs-ganesha配置

[TOC]

README

下载,配置,构建nfs-ganesha 的NFS服务端

包括两个主要构件:nfs-ganesha 与 libntirpc 库(传输层使用),nfs-ganesha和 libntirpc 库位于不同的 Git 仓库中,libntirpc 是nfs-ganeshe的一个git子模块

1
git clone --recursive https://github.com/nfs-ganesha/nfs-ganesha.git
  • --recursive 会克隆并初始化 libntirpc 的子模块

初始化模块

若直接下载源码压缩包,不需要这一步

若从git获取,则在 clone 以及拉取更新后,进入仓库根目录执行以下指令来初始化子模块

1
git submodule update --init
  • ntirpc 目录的当前 HEAD 是一项被跟踪的状态。请勿无意中提交对该状态的更改
  • 构建 nfs-ganesha 时需要使用相应版本的 libntirpc,若不匹配,则需要执行 git update

CMAKE 构建

Cmake 可以在源码外构建(构建目录与源码目录独立),Cmake生成的Makefile在构建目录,objects与targets在构建目录,构建过程的源码引用源码目录

  • 也可以进行源码内构建,但会像autotools一样在git仓库留下额外的中间文件

构建过程:

  • 运行Cmake配置 build
  • 回到 build 目录,执行make

配置和build参数会保存在构建目录中

  • 可以创建多个build目标,多组参数对应多个构件目录

系统级Ntirpc

libntirpc也可以独立安装在系统上,此时使用 -DUSE_SYSTEM_NTIRPC 的编译选项来构建ganesha,此时不需要子模块,所以不需要构建 ntirpc

配置参数

cmake可以从命令行设置配置参数,与autools的使用方式类似

可以通过以下方式获取可调整的参数

1
2
mkdir tweaktest; cd tweaktest
cmake -i ~/git/nfs-ganesha/src

将进入 guide 模式,只需要逐步浏览配置,就可以获取可配置的参数以及默认值,进而通过命令行显式地修改参数。

1
2
3
4
5
mkdir mybuild; cd mybuild
# 禁用9P的构建,在 PROXY fsal 中使用句柄映射,并选择 tcmalloc 分配器。

cmake -D_USE_9P=OFF -D_HANDLE_MAPPING=ON -DALLOCATOR=tcmalloc \
~/git/nfs-ganesha/src

两个值得关注的参数:

  • CMAKE_BUILD_TYPE :这是构建类型的全局设置。具体含义请参阅 CMake 文档。我还添加了一个”Maintainer”类型,它会强制启用严格编译。我打算在构建时使用该类型。
  • BUILD_CONFIG :该设置会触发加载 src/cmake/build_configurations 目录下的一个文件。这对于使用”预设”配置非常有用。目前只有一个正在使用的文件,它会启用所有可用选项。
1
2
cmake -DCMAKE_BUILD_TYPE=Maintainer -DBUILD_CONFIG=everything \
~/git/nfs-ganesha/src
  • 查看 src/cmake/build_configuration/everything.cmake 文件,了解它启用了哪些选项;
  • 如果您想要自定义配置(例如仅用于 9P 服务器,或只启用某些功能),请参照 everything.cmake 的格式在该目录下创建一个新文件,然后在命令行中引用它

VFS

环境

硬件:Phytium,FT-2000+/64

操作系统:麒麟v10

1
2
uname -r
4.19.90-52.23.v2207.ky10.aarch64

安装依赖

可执行程序

  • g++

    1
    yum install gcc-c++ -y
  • cmake

    1
    yum install cmake -y
  • sqlite-devel.aarch64

    1
    yum install sqlite-devel -y
  • libacl

    1
    yum install libacl-devel -y
  • kylin-lsb

    1
    yum install kylin-lsb -y
  • krb5-devel

    1
    yum install krb5-devel -y
  • libcap-devel

    1
    yum install -y libcap-devel
  • xfsprogs

    1
    yum install xfsprogs-devel xfsprogs -y
  • dbus-devel

    1
    yum install dbus-devel -y
  • autoconf

    1
    yum install autoconf -y
  • automake

    1
    yum install automake -y
  • libtool

    1
    yum install libtool -y
  • userspace-rcu需要编译安装

    userspace-rcu

    1
    2
    3
    4
    5
    6
    进入源码目录
    ./bootstrap # skip if using tarball
    ./configure
    make
    make install
    ldconfig
  • doxygen需要编译安装

    doxygen

    install doxygen

    1
    2
    3
    4
    5
    6
    7
    tar -zxvf doxygen-Release_1_9_7.tar.gz
    cd doxygen-Release_1_9_7
    mkdir build && cd build
    cmake -G "Unix Makefiles" ..
    make
    make install
    ldconfig
1
2
3
4
5
6
# 编译依赖
yum install -y bison flex

# 框架依赖
yum install -y openssl-devel libuuid-devel
yum install libnfs-utils userspace-rcu libnsl

rpm包

  • gdb

    1
    yum install gdb -y
  • rpmbuild

    1
    2
    rpm -i chrpath-0.16-12.ky10.aarch64.rpm
    rpm -i rpm-build-4.15.1-36.p01.gfb04.ky10.aarch64.rpm --nodeps --force
  • selinux-policy-devel

    1
    yum install selinux-policy-devel -y
  • libnsl2-devel

    1
    2
    rpm -ivh libnsl2-devel-1.3.0-2.ky10.aarch64.rpm --nodeps
    yum install libnsl2-devel
  • userspace-rcu-devel

    1
    rpm -ivh userspace-rcu-devel-0.14.0-4.ky10.aarch64.rpm 
  • libnfsidmap-devel

    1
    rpm -ivh libnfsidmap-devel-0.25-19.el7.aarch64.rpm --nodeps

    安装完后,动态库链接文件错误,需要在 /usr/lib64 下,调整链接

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    [root@localhost lib64]# ls -alh libnfsidmap*
    lrwxrwxrwx 1 root root 20 8月 24 2018 libnfsidmap.so -> libnfsidmap.so.0.3.0
    lrwxrwxrwx 1 root root 20 2月 21 2022 libnfsidmap.so.1 -> libnfsidmap.so.1.0.0
    -rwxr-xr-x 1 root root 67K 2月 21 2022 libnfsidmap.so.1.0.0

    libnfsidmap:
    总用量 412K
    drwxr-xr-x 2 root root 93 7月 29 10:29 .
    dr-xr-xr-x 66 root root 48K 8月 11 09:35 ..
    -rwxr-xr-x 1 root root 67K 2月 21 2022 nsswitch.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 regex.so
    -rwxr-xr-x 1 root root 67K 3月 30 2022 sss.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 static.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 umich_ldap.so
    [root@localhost lib64]# readlink libnfsidmap.so
    libnfsidmap.so.0.3.0

    [root@localhost lib64]# rm libnfsidmap.so
    [root@localhost lib64]# ln -sf libnfsidmap.so.1.0.0 libnfsidmap.so

下载源码

nfs-ganesha

ntirpc

将ntirpc解压后,放入 /path/to/nfs-ganesha-x.x/src/libntirpc

创建配置文件

在 /etc/ganesha/ganesha.conf 中设置导出目录

1
2
3
4
5
6
# 创建导出目录
mkdir -p /ganesha/uid0

# 创建ganesha配置文件

vim /etc/ganesha/ganesha.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* 详细的配置在源码 src/config_samples/config.txt */

NFS_CORE_PARAM {
Enable_UDP = false;
NFS_Port = 2049;
MNT_Port = 20048;
}

EXPORT {
# Export Id (mandatory, each EXPORT must have a unique Export_Id)
Export_Id = 1123;

# Exported path (mandatory)
Path = /ganesha/uid0;

# Pseudo Path (required for NFSv4 or if mount_path_pseudo = true)
Pseudo = /ganesha_uid0;

# Restrict the protocols that may use this export. This cannot allow
# access that is denied in NFS_CORE_PARAM.
Protocols = 3, 4;

# Access type for clients. Default is None, so some access must be
# given. It can be here, in the EXPORT_DEFAULTS, or in a CLIENT block
Access_Type = RW;

# Whether to squash various users.
Squash = no_root_squash;

# Allowed security types for this export
Sectype = sys,krb5,krb5i,krb5p;

# Exporting FSAL
FSAL {
Name = VFS;
}
}

编译为可执行程序

由于编译通过需要先解决一下问题,所以编译指令放在最后

Q1:若不指定NSL路径,则会报错

1
2
3
4
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
NSL_LIBRARY (ADVANCED)
linked by target "ntirpc" in directory /root/ganesha/nfs-ganesha-5.7/src/libntirpc/src

在编译时,添加宏定义

1
2
mkdir build && cd build
cmake -DUSE_FSAL_RGW=ON -DUSE_FSAL_CEPH=ON -DNSL_LIBRARY=/usr/lib64/libnsl-2.28.so ../src/

Q2:/usr/bin/ld: 找不到 -lhandle

CMake 在检测 open_by_handle 函数,

open_by_handle 是 Linux 内核系统调用(open_by_handle_at),不需要额外库。

CMake 的 CheckFunctionExists 模块错误地尝试链接 -lhandle 库,是一个 CMake 检测逻辑的问题。

修改 CMakeLists.txt

1
2
3
4
5
6
7
8
9
10
# 注释掉检测依赖的部分

if(EXISTS /lib/libhandle.so)
check_library_exists(handle "open_by_handle" "/./lib" HAVE_XFS_LIB)
if(HAVE_XFS_LIB)
set(PATH_LIBHANDLE "/lib/libhandle.so" CACHE INTERNAL "debian stretch and ubuntu xenial hack")
endif(HAVE_XFS_LIB)
else(EXISTS /lib/libhandle.so)
check_library_exists(handle "open_by_handle" "" HAVE_XFS_LIB)
endif(EXISTS /lib/libhandle.so)

或者直接强制设置变量跳过检测:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cd /root/nfs-ganesha
rm -rf tweaktest
mkdir tweaktest && cd tweaktest

cmake \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DNSL_LIBRARY=/usr/lib64/libnsl-2.28.so \
-DUSE_FSAL_VFS=ON \
-DUSE_FSAL_CEPH=OFF \
-DUSE_FSAL_RGW=OFF \
-DHAVE_ACL_GET_FD_NP=0 \
-DHAVE_ACL_SET_FD_NP=0 \
-DHAVE_OPEN_BY_HANDLE=1 \
../src

Q3:/usr/bin/ld: 找不到 -lwbclient、lrados

缺少ceph相关依赖

将以下所有的ON变为OFF

1
2
3
4
5
6
7
8
9
10
11
# MSPAC support -lwbclient link flag
goption(_MSPAC_SUPPORT "enable mspac Winbind support" OFF)

# Enable Rados KV store for recovery
goption(USE_RADOS_RECOV "Enable Rados KV Recovery" OFF)

# Enable RADOS URL config file sections
goption(RADOS_URLS "Enable config file inclusion from RADOS objects" OFF)

# Enable CephFS POSIX ACL
goption(CEPHFS_POSIX_ACL "Enable CephFS POSIX ACL" OFF)

Q4:STRING sub-command SUBSTRING requires four arguments

Found PkgConfig: /usr/bin/pkg-config (found version “1.7.3”)
— Compilation from within a git repository. Using git rev-parse HEAD
CMake Error at CMakeLists.txt:208 (STRING):
STRING sub-command SUBSTRING requires four arguments.

git rev-parse HEAD 返回了空值(可能是 EXECUTE_PROCESS 在特定环境下输出捕获失败),导致 STRING(SUBSTRING "" 0 7 ...) 参数数量错误。

在 src/CMakeLists.txt:208 加一个空值检查

1
2
3
4
5
if(_GIT_HEAD_COMMIT)
STRING(SUBSTRING ${_GIT_HEAD_COMMIT} 0 7 _GIT_HEAD_COMMIT_ABBREV )
else()
set(_GIT_HEAD_COMMIT_ABBREV "unknown")
endif()

Q5:make时报错,assert相关

1
2
3
4
5
6
7
/root/ganesha/nfs-ganesha-
5.7/src/libntirpc/src/work_pool.c:301:3: note: ‘assert’ is defined in header ‘<assert.h>’; did you forget to ‘#include <assert.h>’?
/root/ganesha/nfs-ganesha-5.7/src/libntirpc/src/work_pool.c:59:1:
+#include <assert.h>

/root/ganesha/nfs-ganesha-5.7/src/libntirpc/src/work_pool.c:301:3:
assert(!wpt->wakeup);

在相应位置添加 #include <assert.h>

Q6:编译通过,运行时报错Cannot acquire credentials for principal nfs

主要原因是 RPC 注册失败,具体是由 GSSAPI/Kerberos 凭证获取失败 导致的。

解决方案:编译时,禁用 GSSAPI

1
option (USE_GSS "enable RPCSEC_GSS support" OFF)

编译指令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
cd /root/tzj/nfs-ganesha
rm -rf tweaktest
mkdir tweaktest && cd tweaktest

cmake \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DNSL_LIBRARY=/usr/lib64/libnsl.so.2 \
-DUSE_FSAL_VFS=ON \
-DUSE_FSAL_CEPH=OFF \
-DUSE_FSAL_RGW=OFF \
-DUSE_FSAL_GLUSTER=OFF \
-DUSE_FSAL_LUSTRE=OFF \
-DUSE_FSAL_GPFS=OFF \
-DUSE_FSAL_KVSFS=OFF \
-DUSE_FSAL_MEM=OFF \
-DUSE_FSAL_PROXY_V3=ON \
-DUSE_FSAL_PROXY_V4=ON \
-DUSE_FSAL_PSEUDO=OFF \
-DUSE_FSAL_NULL=OFF \
-DUSE_9P=OFF \
-DUSE_RQUOTA=OFF \
-DHAVE_ACL_GET_FD_NP=0 \
-DHAVE_ACL_SET_FD_NP=0 \
../src

make
make install

make[1]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 2%] Built target gshdbus
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 20%] Built target ntirpc
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 21%] Built target log
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 23%] Built target config_parsing
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 26%] Built target cidr
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 28%] Built target avltree
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 29%] Built target hashtable
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 35%] Built target sal
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 36%] Built target rpcal
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 37%] Built target nfs4callbacks
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 64%] Built target nfsproto
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 67%] Built target nfs_mnt_xdr
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 71%] Built target nlm
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 72%] Built target nfsacl
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 72%] Built target hash
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 73%] Built target uid2grp
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 77%] Built target support
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 78%] Built target string_utils
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 78%] Built target netgroup_cache
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 78%] Built target gos
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 82%] Built target fsalmdcache
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 83%] Built target fsalpseudo
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 83%] Built target idmap
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 85%] Built target MainServices
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 90%] Built target ganesha_nfsd
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 90%] Built target ganesha.nfsd
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 91%] Built target sm_notify.ganesha
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 92%] Built target rpcping
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 92%] Built target fsal_os
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 96%] Built target fsalvfs
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[ 98%] Built target fsalproxy_v4
make[2]: 进入目录“/root/tzj/nfs-ganesha/tweaktest”
make[2]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
[100%] Built target fsalproxy_v3
make[1]: 离开目录“/root/tzj/nfs-ganesha/tweaktest”
Install the project...
-- Install configuration: "Debug"
-- Installing: /etc/ganesha/ganesha.conf
-- Installing: /usr/bin/ganesha.nfsd
-- Set runtime path of "/usr/bin/ganesha.nfsd" to ""
-- Installing: /usr/lib64/pkgconfig/libntirpc.pc
-- Installing: /usr/include/ntirpc
-- Installing: /usr/include/ntirpc/fpmath.h
-- Installing: /usr/include/ntirpc/getpeereid.h
-- Installing: /usr/include/ntirpc/intrinsic.h
-- Installing: /usr/include/ntirpc/libc_private.h
-- Installing: /usr/include/ntirpc/lttng
-- Installing: /usr/include/ntirpc/lttng/rpcping.h
-- Installing: /usr/include/ntirpc/lttng/xprt.h
-- Installing: /usr/include/ntirpc/misc
-- Installing: /usr/include/ntirpc/misc/abstract_atomic.h
-- Installing: /usr/include/ntirpc/misc/bsd_epoll.h
-- Installing: /usr/include/ntirpc/misc/city.h
-- Installing: /usr/include/ntirpc/misc/citycrc.h
-- Installing: /usr/include/ntirpc/misc/event.h
-- Installing: /usr/include/ntirpc/misc/macpthreads.h
-- Installing: /usr/include/ntirpc/misc/opr.h
-- Installing: /usr/include/ntirpc/misc/opr_queue.h
-- Installing: /usr/include/ntirpc/misc/os_epoll.h
-- Installing: /usr/include/ntirpc/misc/portable.h
-- Installing: /usr/include/ntirpc/misc/queue.h
-- Installing: /usr/include/ntirpc/misc/rbtree.h
-- Installing: /usr/include/ntirpc/misc/rbtree_x.h
-- Installing: /usr/include/ntirpc/misc/socket.h
-- Installing: /usr/include/ntirpc/misc/stdint.h
-- Installing: /usr/include/ntirpc/misc/stdio.h
-- Installing: /usr/include/ntirpc/misc/timespec.h
-- Installing: /usr/include/ntirpc/misc/wait_queue.h
-- Installing: /usr/include/ntirpc/misc/winpthreads.h
-- Installing: /usr/include/ntirpc/namespace.h
-- Installing: /usr/include/ntirpc/netconfig.h
-- Installing: /usr/include/ntirpc/reentrant.h
-- Installing: /usr/include/ntirpc/rpc
-- Installing: /usr/include/ntirpc/rpc/auth.h
-- Installing: /usr/include/ntirpc/rpc/auth_gss.h
-- Installing: /usr/include/ntirpc/rpc/auth_inline.h
-- Installing: /usr/include/ntirpc/rpc/auth_stat.h
-- Installing: /usr/include/ntirpc/rpc/auth_unix.h
-- Installing: /usr/include/ntirpc/rpc/clnt.h
-- Installing: /usr/include/ntirpc/rpc/clnt_stat.h
-- Installing: /usr/include/ntirpc/rpc/des.h
-- Installing: /usr/include/ntirpc/rpc/des_crypt.h
-- Installing: /usr/include/ntirpc/rpc/gss_internal.h
-- Installing: /usr/include/ntirpc/rpc/nettype.h
-- Installing: /usr/include/ntirpc/rpc/pmap_prot.h
-- Installing: /usr/include/ntirpc/rpc/pmap_rmt.h
-- Installing: /usr/include/ntirpc/rpc/pool_queue.h
-- Installing: /usr/include/ntirpc/rpc/rpc.h
-- Installing: /usr/include/ntirpc/rpc/rpcb_clnt.h
-- Installing: /usr/include/ntirpc/rpc/rpcb_prot.h
-- Installing: /usr/include/ntirpc/rpc/rpcb_prot.x
-- Installing: /usr/include/ntirpc/rpc/rpcent.h
-- Installing: /usr/include/ntirpc/rpc/rpc_cksum.h
-- Installing: /usr/include/ntirpc/rpc/rpc_com.h
-- Installing: /usr/include/ntirpc/rpc/rpc_err.h
-- Installing: /usr/include/ntirpc/rpc/rpc_msg.h
-- Installing: /usr/include/ntirpc/rpc/svc.h
-- Installing: /usr/include/ntirpc/rpc/svc_auth.h
-- Installing: /usr/include/ntirpc/rpc/svc_rqst.h
-- Installing: /usr/include/ntirpc/rpc/tirpc_compat.h
-- Installing: /usr/include/ntirpc/rpc/types.h
-- Installing: /usr/include/ntirpc/rpc/work_pool.h
-- Installing: /usr/include/ntirpc/rpc/xdr.h
-- Installing: /usr/include/ntirpc/rpc/xdr_inline.h
-- Installing: /usr/include/ntirpc/rpc/xdr_ioq.h
-- Installing: /usr/include/ntirpc/rpcsvc
-- Installing: /usr/include/ntirpc/rpcsvc/crypt.h
-- Installing: /usr/include/ntirpc/un-namespace.h
-- Installing: /usr/include/ntirpc/version.h
-- Installing: /usr/lib64/libntirpc.so.5.0
-- Set runtime path of "/usr/lib64/libntirpc.so.5.0" to ""
-- Installing: /usr/lib64/libntirpc.so
-- Installing: /usr/lib64/ganesha/libfsalvfs.so
-- Set runtime path of "/usr/lib64/ganesha/libfsalvfs.so" to ""
-- Installing: /usr/lib64/ganesha/libfsalproxy_v4.so
-- Set runtime path of "/usr/lib64/ganesha/libfsalproxy_v4.so" to ""
-- Installing: /usr/lib64/ganesha/libfsalproxy_v3.so
-- Set runtime path of "/usr/lib64/ganesha/libfsalproxy_v3.so" to ""
-- Installing: /usr/lib64/libganesha_nfsd.so.5.7
-- Set runtime path of "/usr/lib64/libganesha_nfsd.so.5.7" to ""
-- Installing: /usr/lib64/libganesha_nfsd.so

Q7:error while loading shared libraries: liburcu-bp.so.8

找到 liburcu 实际安装位置

1
find / -name "liburcu-bp*" 2>/dev/null

检查是否安装了开发包

1
2
3
4
5
# CentOS/RHEL
yum provides "*/liburcu-bp.so*"

# Ubuntu/Debian
apt-file search liburcu-bp.so

安装依赖(任选其一)

1
2
3
4
5
# CentOS/RHEL 7
yum install userspace-rcu-devel

# Ubuntu/Debian
apt-get install liburcu-bp-dev

如果库已安装但不在标准路径

1
2
3
# 找到后添加到 ldconfig
echo "/usr/local/lib" > /etc/ld.so.conf.d/liburcu.conf
ldconfig

如果还不行,先确认路径已注册

1
2
3
4
5
6
cat /etc/ld.so.conf
cat /etc/ld.so.conf.d/*.conf

# 如果没有 /usr/local/lib,手动加一下:
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf
ldconfig

将ganesha注册到dbus

gsh_dbus_pkginit :DBUS :CRIT :server bus reg failed (org.ganesha.nfsd, Connection “:1.74” is not allowed to own the service “org.ganesha.nfsd” due to security policies in the configuration file)

在 /etc/dbus-1/system.d/ganesha.conf 创建配置文件

1
2
3
4
5
6
7
8
9
10
11
sudo tee /etc/dbus-1/system.d/ganesha.conf << 'EOF'
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="org.ganesha.nfsd"/>
<allow send_destination="org.ganesha.nfsd"/>
<allow send_interface="org.ganesha.nfsd"/>
</policy>
</busconfig>
EOF

重启dbus守护进程

1
systemctl restart dbus

启动

在编译目录内,会有可执行文件 ganesha.nfsd

前台启动

1
mkdir -p /var/run/ganesha/;mkdir -p /var/log/ganesha ; /usr/bin/ganesha.nfsd -F -L /var/log/ganesha/ganesha.log -f /etc/ganesha/ganesha.conf -N NIV_DEBUG

编译为rpm包

在源码目录生成Makefile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
CLIENT_DIR=nfs-ganesha

CLIENT_BUILD_DIR=build_cli

RPMS_DIR=/root/rpmbuild/RPMS

all: dist

.PHONY: build_cli
build_cli:
[ -e ${CLIENT_BUILD_DIR} ] || mkdir ${CLIENT_BUILD_DIR}
-[ -e .git ] && mv .git .git.bak
cd ${CLIENT_BUILD_DIR} && cmake ../src \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DNSL_LIBRARY=/usr/lib64/libnsl.so.2 \
-DUSE_FSAL_VFS=ON \
-DUSE_FSAL_CEPH=OFF \
-DUSE_FSAL_RGW=OFF \
-DUSE_FSAL_GLUSTER=OFF \
-DUSE_FSAL_LUSTRE=OFF \
-DUSE_FSAL_GPFS=OFF \
-DUSE_FSAL_KVSFS=OFF \
-DUSE_FSAL_MEM=OFF \
-DUSE_FSAL_PROXY_V3=ON \
-DUSE_FSAL_PROXY_V4=ON \
-DUSE_FSAL_PSEUDO=OFF \
-DUSE_FSAL_NULL=OFF \
-DUSE_9P=OFF \
-DUSE_RQUOTA=OFF \
-DHAVE_ACL_GET_FD_NP=0 \
-DHAVE_ACL_SET_FD_NP=0 \
-DCMAKE_BUILD_TYPE=Release

-[ -e .git.bak ] && mv .git.bak .git


client: build_cli
@echo build ganesha client
cd ${CLIENT_BUILD_DIR} && make -j`nproc`

install_cli: client
@echo copy gap client dynamic to lib64 ...
cp ${CLIENT_BUILD_DIR}/ganesha.nfsd /usr/bin/ganesha.nfsd
cp ${CLIENT_BUILD_DIR}/MainNFSD/libganesha_nfsd.so* /usr/lib64/
cp ${CLIENT_BUILD_DIR}/libntirpc/src/libntirpc.so.5.0 /usr/lib64/

rpm_cli: build_cli
@echo make client rpm package
cd ${CLIENT_BUILD_DIR} && make -j`nproc` rpm
@for i in `rpmspec -q --rpms src/nfs-ganesha.spec`; do \
find ${RPMS_DIR} -name "$$i*" -name "*vfs*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*nfs-ganesha-5.7*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*nfs-ganesha-selinux*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*libntirpc-5.0*" -exec cp {} ./ \;; \
done

.PHONY: dist
dist: rpm_cli

.PHONY: clean
clean:
rm -rf ${CLIENT_BUILD_DIR}
rm -fr *.rpm

Cephfs

环境

硬件:Phytium,FT-2000+/64

操作系统:麒麟v10

1
2
uname -r
4.19.90-52.23.v2207.ky10.aarch64

安装依赖

可执行程序

  • g++

    1
    yum install gcc-c++ -y
  • cmake

    1
    yum install cmake -y
  • sqlite-devel.aarch64

    1
    yum install sqlite-devel -y
  • libacl

    1
    yum install libacl-devel -y
  • kylin-lsb

    1
    yum install kylin-lsb -y
  • krb5-devel

    1
    yum install krb5-devel -y
  • libcap-devel

    1
    yum install -y libcap-devel
  • xfsprogs

    1
    yum install xfsprogs-devel xfsprogs -y
  • dbus-devel

    1
    yum install dbus-devel -y
  • autoconf

    1
    yum install autoconf -y
  • automake

    1
    yum install automake -y
  • libtool

    1
    yum install libtool -y
  • userspace-rcu需要编译安装

    userspace-rcu

    1
    2
    3
    4
    5
    6
    进入源码目录
    ./bootstrap # skip if using tarball
    ./configure
    make
    make install
    ldconfig
  • doxygen需要编译安装

    doxygen

    install doxygen

    1
    2
    3
    4
    5
    6
    7
    tar -zxvf doxygen-Release_1_9_7.tar.gz
    cd doxygen-Release_1_9_7
    mkdir build && cd build
    cmake -G "Unix Makefiles" ..
    make
    make install
    ldconfig
1
2
3
4
5
6
# 编译依赖
yum install -y bison flex

# 框架依赖
yum install -y openssl-devel libuuid-devel
yum install libnfs-utils userspace-rcu libnsl

以ceph为存储,则需要安装额外的依赖

  • librados-devel

    1
    yum install -y librados-devel
  • librgw、cephfs 等

    1
    yum install -y librgw-devel libcephfs-devel ceph-radosgw
  • libwbclient-devel

    1
    yum install -y libwbclient-devel

rpm包

  • gdb

    1
    yum install gdb -y
  • rpmbuild

    1
    2
    rpm -i chrpath-0.16-12.ky10.aarch64.rpm
    rpm -i rpm-build-4.15.1-36.p01.gfb04.ky10.aarch64.rpm --nodeps --force
  • selinux-policy-devel

    1
    yum install selinux-policy-devel -y
  • libnsl2-devel

    1
    2
    rpm -ivh libnsl2-devel-1.3.0-2.ky10.aarch64.rpm --nodeps
    yum install libnsl2-devel
  • userspace-rcu-devel

    1
    rpm -ivh userspace-rcu-devel-0.14.0-4.ky10.aarch64.rpm 
  • libnfsidmap-devel

    1
    rpm -ivh libnfsidmap-devel-0.25-19.el7.aarch64.rpm --nodeps

    安装完后,动态库链接文件错误,需要在 /usr/lib64 下,调整链接

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    [root@localhost lib64]# ls -alh libnfsidmap*
    lrwxrwxrwx 1 root root 20 8月 24 2018 libnfsidmap.so -> libnfsidmap.so.0.3.0
    lrwxrwxrwx 1 root root 20 2月 21 2022 libnfsidmap.so.1 -> libnfsidmap.so.1.0.0
    -rwxr-xr-x 1 root root 67K 2月 21 2022 libnfsidmap.so.1.0.0

    libnfsidmap:
    总用量 412K
    drwxr-xr-x 2 root root 93 7月 29 10:29 .
    dr-xr-xr-x 66 root root 48K 8月 11 09:35 ..
    -rwxr-xr-x 1 root root 67K 2月 21 2022 nsswitch.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 regex.so
    -rwxr-xr-x 1 root root 67K 3月 30 2022 sss.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 static.so
    -rwxr-xr-x 1 root root 67K 2月 21 2022 umich_ldap.so
    [root@localhost lib64]# readlink libnfsidmap.so
    libnfsidmap.so.0.3.0

    [root@localhost lib64]# rm libnfsidmap.so
    [root@localhost lib64]# ln -sf libnfsidmap.so.1.0.0 libnfsidmap.so

创建用户

1
2
3
4
5
6
7
8
9
10
11
# 将输出保存到文件
ceph auth get-or-create client.ganesha \
mgr 'allow command "osd blocklist"' \
mon 'allow r, allow command "osd blocklist"' \
mds 'allow r, allow rw path=/' \
osd 'allow rw' > /etc/ceph/ceph.client.ganesha.keyring

# 将ganesha.keyring复制到集群所有节点
scp /etc/ceph/ceph.client.ganesha.keyring root@node1:/etc/ceph/

ceph auth get client.ganesha -k /etc/ceph/ceph.client.admin.keyring -o /etc/ceph/ceph.client.ganesha.keyring

生成配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# NFS Ganesha - CephFS Export Configuration (Standalone)
# Ceph Octopus (v15.2.17) cluster
# MDS: node1(active), node2(standby)
# No RADOS recovery pool - local recovery only

# ============================================================
# Core NFS Parameters
# ============================================================
NFS_CORE_PARAM
{
# Disable NLM (Network Lock Manager) - not needed for CephFS
Enable_NLM = false;

# 路径映射,用于NFS3协议的短名称
mount_path_pseudo = true;

# Only support NFSv4
Protocols = 3, 4;
NFS_Port = 2049;
MNT_Port = 20048;
}

# ============================================================
# NFSv4 Parameters
# ============================================================
NFSv4
{
# Use NFSv4.1+ for session support
Minor_Versions = 1, 2;
}

# ============================================================
# Metadata Cache - minimize caching for CephFS coherency
# ============================================================
MDCACHE
{
# Disable directory chunk caching
Dir_Chunk = 0;
}

# ============================================================
# Logging
# ============================================================
LOG
{
Default_Log_Level = DEBUG;
}

# ============================================================
# FSAL_CEPH Configuration
# ============================================================
CEPH
{
# Path to ceph.conf on the NFS gateway node
Ceph_Conf = /etc/ceph/ceph.conf;

# File creation umask (default 022)
Umask = 022;
}

# ============================================================
# Export: CephFS Root
# ============================================================
EXPORT
{
Export_ID = 100;
Protocols = 3, 4;
Transports = TCP;

# Export the entire CephFS tree
# 这里只能是根目录
Path = "/";

# Pseudo path visible to NFS clients
Pseudo = "/cephfs";

# Read/Write access
Access_Type = RW;

# Disable attribute caching for coherency
Attr_Expiration_Time = 0;

# Squash root user requests to nobody (recommended for CephFS)
Squash = no_root_squash;

FSAL{
name = "CEPH";
# Ceph filesystem name (only needed if libcephfs supports named filesystems)
filesystem = "cephfs";

# Ganesha Ceph client user ID (without "client." prefix)
User_Id = "ganesha";

Secret_Access_Key = "AQAeaY1qaJdOORAADtNa2bB+nuB75MJEAY2FDA==";

cmount_path = "/";
}
}

自定义导出路径

创建ceph导出目录

默认情况下,cephfs只能导出一个 / ,如果需要变更导出目录名,需要创建subvolume

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 允许创建多个导出目录
[root@node1]# ceph fs flag set enable_multiple true --yes-i-really-mean-it

# 创建volume组
[root@node1]# ceph fs subvolumegroup create cephfs ganesha

[root@node1]# ceph fs subvolumegroup ls cephfs
[
{
"name": "_nogroup"
},
{
"name": "_deleting"
},
{
"name": "ganesha"
}
]

# 创建volume
[root@node1]# ceph fs subvolume create cephfs share1 ganesha
[root@node1]# ceph fs subvolume create cephfs share2 ganesha
[root@node1]# ceph fs subvolume ls cephfs
[]
[root@node1]# ceph fs subvolume ls cephfs ganesha
[
{
"name": "share2"
},
{
"name": "share1"
}
]

# 获取share的路径
[root@node1 ~]# ceph fs subvolume getpath cephfs share1 ganesha
/volumes/ganesha/share1/997cf317-3833-4586-85fe-e55a45099b7f

[root@node1 share1]# ceph fs subvolume getpath cephfs share2 ganesha
/volumes/ganesha/share2/39e8dc49-9967-4f6f-be63-cc7e72113b84

创建ganehsa.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# NFS Ganesha - CephFS Export Configuration (Standalone)
# Ceph Octopus (v15.2.17) cluster
# MDS: node1(active), node2(standby)
# No RADOS recovery pool - local recovery only

# ============================================================
# Core NFS Parameters
# ============================================================
NFS_CORE_PARAM
{
# Disable NLM (Network Lock Manager) - not needed for CephFS
Enable_NLM = false;

# 路径映射,用于NFS3协议的短名称
mount_path_pseudo = true;

# Only support NFSv4
Protocols = 3, 4;
NFS_Port = 2049;
MNT_Port = 20048;
}

# ============================================================
# NFSv4 Parameters
# ============================================================
NFSv4
{
# Use NFSv4.1+ for session support
Minor_Versions = 1, 2;
}

# ============================================================
# Metadata Cache - minimize caching for CephFS coherency
# ============================================================
MDCACHE
{
# Disable directory chunk caching
Dir_Chunk = 0;
}

# ============================================================
# Logging
# ============================================================
LOG
{
Default_Log_Level = WARN;
}

# ============================================================
# FSAL_CEPH Configuration
# ============================================================
CEPH
{
# Path to ceph.conf on the NFS gateway node
Ceph_Conf = /etc/ceph/ceph.conf;

# File creation umask (default 022)
Umask = 022;
}

# ============================================================
# Export: CephFS Root
# ============================================================

EXPORT
{
Export_ID = 100;
Protocols = 3,4;
Transports = TCP;

# Export the entire CephFS tree
Path = "/volumes/ganesha/share1/709892c1-72b4-46b4-8712-20ff1ba85161";

# Pseudo path visible to NFS clients
Pseudo = "/share1";

# Read/Write access
Access_Type = RW;

# Disable attribute caching for coherency
Attr_Expiration_Time = 0;

# Squash root user requests to nobody (recommended for CephFS)
Squash = no_root_squash;

FSAL{
name = "CEPH";
# Ceph filesystem name (only needed if libcephfs supports named filesystems)
filesystem = "cephfs";

# Ganesha Ceph client user ID (without "client." prefix)
User_Id = "ganesha";

# Secret_Access_Key = "AQAeaY1qaJdOORAADtNa2bB+nuB75MJEAY2FDA==";

cmount_path = "/volumes/ganesha/share1/709892c1-72b4-46b4-8712-20ff1ba85161";
}
}

EXPORT
{
Export_ID = 101;
Protocols = 3,4;
Transports = TCP;

# Export the entire CephFS tree
Path = "/volumes/ganesha/share2/fa2fe31f-1e64-4295-aa26-7dee95274a57";

# Pseudo path visible to NFS clients
Pseudo = "/share2";

# Read/Write access
Access_Type = RW;

# Disable attribute caching for coherency
Attr_Expiration_Time = 0;

# Squash root user requests to nobody (recommended for CephFS)
Squash = no_root_squash;

FSAL{
name = "CEPH";
# Ceph filesystem name (only needed if libcephfs supports named filesystems)
filesystem = "cephfs";

# Ganesha Ceph client user ID (without "client." prefix)
User_Id = "ganesha";

# Secret_Access_Key = "AQAeaY1qaJdOORAADtNa2bB+nuB75MJEAY2FDA==";

cmount_path = "/volumes/ganesha/share2/fa2fe31f-1e64-4295-aa26-7dee95274a57";
}
}

重启ganesha

1
2
3
4
5
[root@node1 ~]# systemctl restart nfs-ganesha
[root@node1 ~]# showmount -e
Export list for node1:
/volumes/ganesha/share1/997cf317-3833-4586-85fe-e55a45099b7f (everyone)
/volumes/ganesha/share2/39e8dc49-9967-4f6f-be63-cc7e72113b84 (everyone)

编译

可执行程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cd /root/tzj/nfs-ganesha
rm -rf build_cephfs
mkdir build_cephfs && cd build_cephfs

cmake \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DNSL_LIBRARY=/usr/lib64/libnsl.so.2 \
-DUSE_FSAL_VFS=OFF \
-DUSE_FSAL_CEPH=ON \
-DCEPHFS_POSIX_ACL=ON \
-DUSE_FSAL_RGW=OFF \
-DUSE_FSAL_GLUSTER=OFF \
-DUSE_FSAL_LUSTRE=OFF \
-DUSE_FSAL_LIZARDFS=OFF \
-DUSE_FSAL_GPFS=OFF \
-DUSE_FSAL_KVSFS=OFF \
-DUSE_FSAL_MEM=OFF \
-DUSE_FSAL_PROXY_V3=ON \
-DUSE_FSAL_PROXY_V4=ON \
-DUSE_FSAL_PSEUDO=OFF \
-DUSE_FSAL_NULL=OFF \
-DUSE_FSAL_XFS=OFF \
-DUSE_9P=OFF \
-DUSE_RQUOTA=OFF \
-DHAVE_ACL_GET_FD_NP=0 \
-DHAVE_ACL_SET_FD_NP=0 \
../src

make
make install
启动
1
mkdir -p /var/run/ganesha/;mkdir -p /var/log/ganesha ; /usr/bin/ganesha.nfsd -F -L /var/log/ganesha/ganesha.log -f /etc/ganesha/ganesha.conf -N NIV_DEBUG

rpm包

在源码目录生成Makefile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

CLIENT_DIR=nfs-ganesha

CLIENT_BUILD_DIR=build_cli

RPMS_DIR=/root/rpmbuild/RPMS

all: dist

.PHONY: build_cli
build_cli:
[ -e ${CLIENT_BUILD_DIR} ] || mkdir ${CLIENT_BUILD_DIR}
-[ -e .git ] && mv .git .git.bak
cd ${CLIENT_BUILD_DIR} && cmake ../src \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DNSL_LIBRARY=/usr/lib64/libnsl.so.2 \
-DUSE_FSAL_VFS=OFF \
-DUSE_FSAL_CEPH=ON \
-DCEPHFS_POSIX_ACL=ON \
-DUSE_FSAL_RGW=OFF \
-DUSE_FSAL_GLUSTER=OFF \
-DUSE_FSAL_LUSTRE=OFF \
-DUSE_FSAL_LIZARDFS=OFF \
-DUSE_FSAL_GPFS=OFF \
-DUSE_FSAL_KVSFS=OFF \
-DUSE_FSAL_MEM=OFF \
-DUSE_FSAL_PROXY_V3=ON \
-DUSE_FSAL_PROXY_V4=ON \
-DUSE_FSAL_PSEUDO=OFF \
-DUSE_FSAL_NULL=OFF \
-DUSE_FSAL_XFS=OFF \
-DUSE_9P=OFF \
-DUSE_RQUOTA=OFF \
-DHAVE_ACL_GET_FD_NP=0 \
-DHAVE_ACL_SET_FD_NP=0 \
-DCMAKE_BUILD_TYPE=Release

client: build_cli
@echo build ganesha client
cd ${CLIENT_BUILD_DIR} && make -j`nproc`

install_cli: client
@echo copy gap client dynamic to lib64 ...
cp ${CLIENT_BUILD_DIR}/ganesha.nfsd /usr/bin/ganesha.nfsd
cp ${CLIENT_BUILD_DIR}/MainNFSD/libganesha_nfsd.so* /usr/lib64/
cp ${CLIENT_BUILD_DIR}/libntirpc/src/libntirpc.so.5.0 /usr/lib64/

rpm_cli: build_cli
@echo make client rpm package
cd ${CLIENT_BUILD_DIR} && make -j`nproc` rpm
@for i in `rpmspec -q --rpms src/nfs-ganesha.spec`; do \
find ${RPMS_DIR} -name "$$i*" -name "*ceph*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*nfs-ganesha-5.7*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*nfs-ganesha-selinux*" -exec cp {} ./ \;; \
find ${RPMS_DIR} -name "$$i*" -name "*libntirpc-5.0*" -exec cp {} ./ \;; \
done

.PHONY: dist
dist: rpm_cli

.PHONY: clean
clean:
rm -rf ${CLIENT_BUILD_DIR}
rm -fr *.rpm
-------------本文结束-------------