Skip to content

Commit

Permalink
Merge nebd and split nbd
Browse files Browse the repository at this point in the history
Change-Id: I165a8738ef01cd00b9fa0386973fc9f3e5a09007
  • Loading branch information
wu-hanqing committed Jul 14, 2020
1 parent 7afc740 commit 700f935
Show file tree
Hide file tree
Showing 131 changed files with 11,525 additions and 403 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ bazel-testlogs

.clang-format
!curve-snapshotcloneserver-nginx/app/lib
!nebd/nebd-package/usr/bin
3 changes: 0 additions & 3 deletions curvefs_python/BUILD_bak
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ cc_library(
],
copts = COPTS,
linkopts = [
"-lbraft",
"-lcbd",
"-lcurve_client",
"-lbrpc",
Expand All @@ -70,7 +69,6 @@ cc_library(
"-lcc_brpc_internal_proto",
"-lcc_brpc_idl_options_proto",
"-lleveldb",
"-lcc_braft_internal_proto",
"-lcurve_common",
"-lcurve_auth",
"-lcurve_concurrent",
Expand All @@ -83,7 +81,6 @@ cc_library(
"-lprotobuf_lite",
"-lssl",
"-lrt",
"-lssl",
"-lcrypto",
"-ldl",
"-lz",
Expand Down
12 changes: 9 additions & 3 deletions curvefs_python/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

#!/bin/sh
#!/bin/bash
echo "********************************************************************"
echo "***********Prepare for curvefs python API build env.****************"
echo "********************************************************************"
Expand All @@ -30,12 +30,18 @@ echo "Prepare bazel build file"
cp BUILD_bak BUILD -f

echo "copy libs to tmplib directory"
libs=`cat BUILD | tr -d "[:blank:]" | grep "^\"-l" | sed 's/[",]//g' | awk '{ print substr($0, 3) }'`

mkdir tmplib
for i in `find $curve_path/bazel-bin/|grep -w so|grep -v solib|grep -v params`
do
echo $i
cp -f $i ./tmplib/
basename=$(basename $i)
linkname=`echo $basename | awk -F'.' '{ print $1 }' | awk '{ print substr($0, 4) }'`
if [[ $libs =~ $linkname ]]
then
echo $i
cp -f $i ./tmplib/
fi
done

echo "Prepare env done, you can build curvefs now."
Expand Down
33 changes: 24 additions & 9 deletions mk-deb.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

#!/bin/sh
#!/bin/bash
dir=`pwd`
#step1 清除生成的目录和文件
bazel clean
Expand Down Expand Up @@ -65,7 +65,7 @@ then
echo "build phase1 failed"
exit
fi
sh ./curvefs_python/configure.sh
bash ./curvefs_python/configure.sh
if [ $? -ne 0 ]
then
echo "configure failed"
Expand All @@ -90,7 +90,7 @@ then
echo "build phase1 failed"
exit
fi
sh ./curvefs_python/configure.sh
bash ./curvefs_python/configure.sh
if [ $? -ne 0 ]
then
echo "configure failed"
Expand All @@ -107,7 +107,7 @@ then
exit
fi
fi

set -e
#step3 创建临时目录,拷贝二进制、lib库和配置模板
mkdir build
if [ $? -ne 0 ]
Expand Down Expand Up @@ -319,11 +319,6 @@ if [ $? -ne 0 ]
then
exit
fi
cp ./bazel-bin/src/tools/nbd/curve-nbd build/curve-sdk/usr/bin/curve-nbd
if [ $? -ne 0 ]
then
exit
fi
#cp ./conf/client.conf build/curve-sdk/etc/curve/client.conf
#if [ $? -ne 0 ]
#then
Expand Down Expand Up @@ -395,6 +390,22 @@ if [ $? -ne 0 ]
then
exit
fi
# step 3.1 prepare for nebd-package
cp -r nebd/nebd-package build/
mkdir -p build/nebd-package/usr/bin
mkdir -p build/nebd-package/usr/lib/nebd

for i in `find bazel-bin/|grep -w so|grep -v solib|grep -v params|grep -v test|grep -v fake`
do
cp -f $i build/nebd-package/usr/lib/nebd
done

cp bazel-bin/nebd/src/part2/nebd-server build/nebd-package/usr/bin

# step 3.2 prepare for curve-nbd package
cp -r nbd/nbd-package build
mkdir -p build/nbd-package/usr/bin
cp bazel-bin/nbd/src/curve-nbd build/nbd-package/usr/bin

#step4 获取git提交版本信息,记录到debian包的配置文件
commit_id=`git show --abbrev-commit HEAD|head -n 1|awk '{print $2}'`
Expand All @@ -412,6 +423,8 @@ echo ${version} >> build/curve-tools/DEBIAN/control
echo ${version} >> build/curve-monitor/DEBIAN/control
echo ${version} >> build/curve-snapshotcloneserver/DEBIAN/control
echo ${version} >> build/curve-nginx/DEBIAN/control
echo ${version} >> build/nebd-package/DEBIAN/control
echo ${version} >> build/nbd-package/DEBIAN/control

#step5 打包debian包
dpkg-deb -b build/curve-mds .
Expand All @@ -421,6 +434,8 @@ dpkg-deb -b build/curve-tools .
dpkg-deb -b build/curve-monitor .
dpkg-deb -b build/curve-snapshotcloneserver .
dpkg-deb -b build/curve-nginx .
dpkg-deb -b build/nebd-package .
dpkg-deb -b build/nbd-package .
#aws-c-common(commit=0302570a3cbabd98293ee03971e0867f28355086)
#aws-checksums(commit=78be31b81a2b0445597e60ecb2412bc44e762a99)
#aws-c-event-stream(commit=ad9a8b2a42d6c6ef07ccf251b5038b89487eacb3)
Expand Down
30 changes: 25 additions & 5 deletions mk-tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,6 @@ if [ $? -ne 0 ]
then
exit
fi
cp ./bazel-bin/src/tools/nbd/curve-nbd build/curve/curve-sdk/bin/curve-nbd
if [ $? -ne 0 ]
then
exit
fi
# curve-snapshotcloneserver
mkdir -p build/curve/curve-snapshotcloneserver/bin
if [ $? -ne 0 ]
Expand Down Expand Up @@ -359,6 +354,23 @@ then
fi
echo "end copy"

# step 3.1 prepare for nebd-package
cp -r nebd/nebd-package build/
mkdir -p build/nebd-package/usr/bin
mkdir -p build/nebd-package/usr/lib/nebd

for i in `find bazel-bin/|grep -w so|grep -v solib|grep -v params|grep -v test|grep -v fake`
do
cp -f $i build/nebd-package/usr/lib/nebd
done

cp bazel-bin/nebd/src/part2/nebd-server build/nebd-package/usr/bin

# step 3.2 prepare for curve-nbd package
cp -r nbd/nbd-package build
mkdir -p build/nbd-package/usr/bin
cp bazel-bin/nbd/src/curve-nbd build/nbd-package/usr/bin

#step4 获取git提交版本信息
commit_id=`git show --abbrev-commit HEAD|head -n 1|awk '{print $2}'`
if [ "$1" = "debug" ]
Expand All @@ -379,6 +391,14 @@ monitor_name="curve-monitor_${tag_version}+${commit_id}${debug}.tar.gz"
echo "curve_name: ${curve_name}"
tar zcvf ${monitor_name} curve-monitor
cp ${monitor_name} $dir
nebd_name="nebd_${tag_version}+${commit_id}${debug}.tar.gz"
echo "nebd_name: ${nebd_name}"
tar zcvf ${nebd_name} nebd-package
cp ${nebd_name} $dir
nbd_name="nbd_${tag_version}+${commit_id}${debug}.tar.gz"
echo "nbd_name: ${nbd_name}"
tar zcvf ${nbd_name} nbd-package
cp ${nbd_name} $dir
echo "end make tarball"

#step6 清理libetcdclient.so编译出现的临时文件
Expand Down
10 changes: 10 additions & 0 deletions nbd/nbd-package/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: curve-nbd
Section:
Priority: optional
Depends: libunwind8
Suggests:
Architecture: amd64
Installed-Size:
Maintainer: curve-dev
Provides:
Description: NBD-based client for curve
34 changes: 2 additions & 32 deletions src/tools/nbd/BUILD → nbd/src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,10 @@ cc_library(
deps = [
"//external:gflags",
"//external:glog",
"//nebd/src/part1:nebdclient",
],
copts = COPTS,
linkopts = [
"-L/usr/lib/nebd",
"-lnebdclient",
"-lclient_proto",
"-lnebd_common",
"-lbrpc",
"-lcc_brpc_idl_options_proto",
"-lcc_brpc_internal_proto",
"-lbthread",
"-lbvar",
"-ljson2pb",
"-lmcpack2pb",
"-lbutil",
"-lprotoc_lib",
"-lleveldb",
"-lprotobuf",
"-lprotobuf_lite",
"-lssl",
"-lrt",
"-lssl",
"-lcrypto",
"-ldl",
"-lz",
"-lpthread",
"-lunwind",
"-lstdc++",
"-lm",
"-lnl-3",
"-lnl-genl-3",
],
Expand All @@ -88,12 +63,7 @@ cc_binary(
]
),
deps = [
"//src/tools/nbd:curvenbd"
"//nbd/src:curvenbd"
],
copts = COPTS,
linkopts = [
"-Wl,-rpath=/usr/lib/nebd"
],
)


Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Author: wuhanqing
*/

#include "src/tools/nbd/ImageInstance.h"
#include "nbd/src/ImageInstance.h"
#include <glog/logging.h>

namespace curve {
Expand Down
9 changes: 5 additions & 4 deletions src/tools/nbd/ImageInstance.h → nbd/src/ImageInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
* Author: wuhanqing
*/

#ifndef SRC_TOOLS_NBD_IMAGEINSTANCE_H_
#define SRC_TOOLS_NBD_IMAGEINSTANCE_H_
#ifndef NBD_SRC_IMAGEINSTANCE_H_
#define NBD_SRC_IMAGEINSTANCE_H_

#include <string>
#include <memory>
#include "src/tools/nbd/libnebd.h"

#include "nebd/src/part1/libnebd.h"

namespace curve {
namespace nbd {
Expand Down Expand Up @@ -95,4 +96,4 @@ using ImagePtr = std::shared_ptr<ImageInstance>;
} // namespace nbd
} // namespace curve

#endif // SRC_TOOLS_NBD_IMAGEINSTANCE_H_
#endif // NBD_SRC_IMAGEINSTANCE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*
*/

#include "src/tools/nbd/NBDController.h"
#include "nbd/src/NBDController.h"

namespace curve {
namespace nbd {
Expand Down
12 changes: 6 additions & 6 deletions src/tools/nbd/NBDController.h → nbd/src/NBDController.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
*
*/

#ifndef SRC_TOOLS_NBD_NBDCONTROLLER_H_
#define SRC_TOOLS_NBD_NBDCONTROLLER_H_
#ifndef NBD_SRC_NBDCONTROLLER_H_
#define NBD_SRC_NBDCONTROLLER_H_

#include <linux/nbd.h>
#include <linux/fs.h>
Expand All @@ -51,9 +51,9 @@
#include <string>
#include <memory>

#include "src/tools/nbd/nbd-netlink.h"
#include "src/tools/nbd/define.h"
#include "src/tools/nbd/util.h"
#include "nbd/src/nbd-netlink.h"
#include "nbd/src/define.h"
#include "nbd/src/util.h"

namespace curve {
namespace nbd {
Expand Down Expand Up @@ -182,4 +182,4 @@ class NetLinkController : public NBDController {
} // namespace nbd
} // namespace curve

#endif // SRC_TOOLS_NBD_NBDCONTROLLER_H_
#endif // NBD_SRC_NBDCONTROLLER_H_
4 changes: 2 additions & 2 deletions src/tools/nbd/NBDServer.cpp → nbd/src/NBDServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
*
*/

#include "src/tools/nbd/NBDServer.h"
#include "nbd/src/NBDServer.h"

#include <signal.h>
#include <glog/logging.h>
#include <inttypes.h>
#include <netinet/in.h>

#include "src/tools/nbd/util.h"
#include "nbd/src/util.h"

namespace curve {
namespace nbd {
Expand Down
14 changes: 7 additions & 7 deletions src/tools/nbd/NBDServer.h → nbd/src/NBDServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
*
*/

#ifndef SRC_TOOLS_NBD_NBDSERVER_H_
#define SRC_TOOLS_NBD_NBDSERVER_H_
#ifndef NBD_SRC_NBDSERVER_H_
#define NBD_SRC_NBDSERVER_H_

#include <linux/nbd.h>
#include <atomic>
Expand All @@ -49,10 +49,10 @@
#include <string>
#include <thread> // NOLINT

#include "src/tools/nbd/ImageInstance.h"
#include "src/tools/nbd/NBDController.h"
#include "src/tools/nbd/SafeIO.h"
#include "src/tools/nbd/libnebd.h"
#include "nbd/src/ImageInstance.h"
#include "nbd/src/NBDController.h"
#include "nbd/src/SafeIO.h"
#include "nebd/src/part1/libnebd.h"

namespace curve {
namespace nbd {
Expand Down Expand Up @@ -201,4 +201,4 @@ using NBDServerPtr = std::shared_ptr<NBDServer>;
} // namespace nbd
} // namespace curve

#endif // SRC_TOOLS_NBD_NBDSERVER_H_
#endif // NBD_SRC_NBDSERVER_H_
6 changes: 3 additions & 3 deletions src/tools/nbd/NBDTool.cpp → nbd/src/NBDTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <limits.h>
#include <memory>
#include <string>
#include "src/tools/nbd/NBDTool.h"
#include "src/tools/nbd/argparse.h"
#include "src/tools/nbd/texttable.h"
#include "nbd/src/NBDTool.h"
#include "nbd/src/argparse.h"
#include "nbd/src/texttable.h"

namespace curve {
namespace nbd {
Expand Down
Loading

0 comments on commit 700f935

Please sign in to comment.