mount, fuse: Add mfsmount3

This commit adds mfsmount3 executable linked to FUSE3 library.

Change-Id: I327e8afbf1370c4f53c09b7538e5cc35558cac5b
This commit is contained in:
Hazeman 2018-02-01 10:53:44 +01:00
parent 4af83dbb53
commit 7085958ee6
13 changed files with 108 additions and 30 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2016-2017 Skytechnology sp. z o.o..
# Copyright 2016-2018 Skytechnology sp. z o.o..
#
# This file is part of LizardFS.
#
@ -29,16 +29,19 @@ if(APPLE)
find_path(FUSE_INCLUDE_DIR "fuse.h" PATHS ${PC_FUSE_INCLUDE_DIRS} ${PC_FUSE_INCLUDE_DIRS}/.. PATH_SUFFIXES "fuse")
endif()
else()
find_library(FUSE_LIBRARY NAMES fuse3 fuse)
find_path(FUSE_INCLUDE_DIR "fuse.h" PATH_SUFFIXES "fuse3" "fuse")
find_library(FUSE_LIBRARY fuse)
find_path(FUSE_INCLUDE_DIR "fuse/fuse.h")
file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_version_str REGEX "^#define[\t ]+FUSE.+VERSION[\t ]+[0-9]+")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_major "${fuse_version_str}")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_minor "${fuse_version_str}")
if(FUSE_INCLUDE_DIR)
set(FUSE_INCLUDE_DIR "${FUSE_INCLUDE_DIR}/fuse")
set(FUSE_VERSION_STRING "${fuse_version_major}.${fuse_version_minor}")
file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_version_str REGEX "^#define[\t ]+FUSE.+VERSION[\t ]+[0-9]+")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_major "${fuse_version_str}")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_minor "${fuse_version_str}")
set(FUSE_VERSION_STRING "${fuse_version_major}.${fuse_version_minor}")
endif()
endif()
find_package_handle_standard_args(FUSE REQUIRED_VARS FUSE_LIBRARY FUSE_INCLUDE_DIR
VERSION_VAR FUSE_VERSION_STRING)

32
cmake/FindFUSE3.cmake Normal file
View File

@ -0,0 +1,32 @@
# Copyright 2016-2018 Skytechnology sp. z o.o..
#
# This file is part of LizardFS.
#
# LizardFS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# LizardFS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LizardFS If not, see <http://www.gnu.org/licenses/>.
find_library(FUSE3_LIBRARY fuse3)
find_path(FUSE3_INCLUDE_DIR "fuse3/fuse.h")
if(FUSE3_INCLUDE_DIR)
set(FUSE3_INCLUDE_DIR "${FUSE3_INCLUDE_DIR}/fuse3")
file(STRINGS "${FUSE3_INCLUDE_DIR}/fuse_common.h" fuse_version_str REGEX "^#define[\t ]+FUSE.+VERSION[\t ]+[0-9]+")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_major "${fuse_version_str}")
string(REGEX REPLACE ".*#define[\t ]+FUSE_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" fuse_version_minor "${fuse_version_str}")
set(FUSE3_VERSION_STRING "${fuse_version_major}.${fuse_version_minor}")
endif()
find_package_handle_standard_args(FUSE3 REQUIRED_VARS FUSE3_LIBRARY FUSE3_INCLUDE_DIR
VERSION_VAR FUSE3_VERSION_STRING)

View File

@ -17,7 +17,11 @@ find_package(Socket REQUIRED)
find_package(Threads REQUIRED)
if(NOT MINGW)
find_package(FUSE REQUIRED)
find_package(FUSE)
find_package(FUSE3)
if(NOT (FUSE_FOUND OR FUSE3_FOUND))
message(FATAL_ERROR "Could not find FUSE library (required)")
endif()
endif()
find_library(RT_LIBRARY rt)

7
configure vendored
View File

@ -16,10 +16,10 @@ mkdir -p build-pack
cd build-pack
rm -f CMakeCache.txt
if [ -z $LIZARDFS_OFFICIAL_BUILD ]; then
if [ -z ${LIZARDFS_OFFICIAL_BUILD:-} ]; then
LIZARDFS_OFFICIAL_BUILD=NO
fi
if [ -z $LIZARDFS_SET_RC_BUILD_NUMBER ]; then
if [ -z ${LIZARDFS_SET_RC_BUILD_NUMBER:-} ]; then
LIZARDFS_SET_RC_BUILD_NUMBER=NO
fi
@ -32,7 +32,8 @@ cmake .. \
-DENABLE_OFFICIAL_BUILD=$LIZARDFS_OFFICIAL_BUILD \
-DSET_RC_BUILD_NUMBER=$LIZARDFS_SET_RC_BUILD_NUMBER \
-DENABLE_CLIENT_LIB=YES \
-DENABLE_NFS_GANESHA=YES
-DENABLE_NFS_GANESHA=YES \
-DENABLE_POLONAISE=OFF
cat >../Makefile <<END
all:

View File

@ -30,6 +30,7 @@ cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTS=NO \
-DENABLE_DOCS=YES
make
make DESTDIR=${working_dir}/lizardfs/build-osx/ install

6
debian/control vendored
View File

@ -66,6 +66,12 @@ Provides: mfs-client
Description: LizardFS client
LizardFS clients: mfsmount and mfstools.
Package: lizardfs-client3
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, lizardfs-client
Description: LizardFS client using FUSE3
LizardFS client: mfsmount3.
Package: lizardfs-lib-client
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}

1
debian/lizardfs-client3.install vendored Normal file
View File

@ -0,0 +1 @@
usr/bin/mfsmount3

3
debian/lizardfs-client3.postinst vendored Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
ln -s usr/share/man/man1/mfsmount.1 usr/share/man/man1/mfsmount3.1

View File

@ -81,6 +81,14 @@ Requires: bash-completion
%description client
LizardFS client: mfsmount and mfstools.
%package client3
Summary: LizardFS client using FUSE3
Group: System Environment/Daemons
Requires: lizardfs-client
%description client3
LizardFS client: mfsmount and mfstools.
%package lib-client
Summary: LizardFS client C/C++ library
Group: Development/Libraries
@ -287,6 +295,12 @@ fi
%systemd_postun_with_restart lizardfs-cgiserv.service
%endif
# Scriptlets - client3
############################################################
%post client3
/bin/ln -s %{_mandir}/man1/mfsmount.1 %{_mandir}/man1/mfsmount3.1
# Prep, build, install, files...
############################################################
@ -438,6 +452,9 @@ rm -rf $RPM_BUILD_ROOT
%{liz_confdir}/iolimits.cfg.dist
%{_sysconfdir}/bash_completion.d/lizardfs
%files client3
%attr(755,root,root) %{_bindir}/mfsmount3
%files lib-client
%{_libdir}/liblizardfsmount_shared.so
%{_libdir}/liblizardfs-client.so

View File

@ -1,21 +1,20 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DAPPNAME=mfsmount)
collect_sources(MOUNT_FUSE)
if(NOT FUSE_VERSION_STRING VERSION_LESS "3")
add_definitions(-DFUSE_USE_VERSION=30)
else()
add_definitions(-DFUSE_USE_VERSION=26)
if(FUSE_FOUND)
add_executable(mfsmount ${MOUNT_FUSE_MAIN} ${MOUNT_FUSE_SOURCES})
target_link_libraries(mfsmount mount mfscommon ${FUSE_LIBRARY})
target_include_directories(mfsmount PRIVATE ${FUSE_INCLUDE_DIR})
target_compile_definitions(mfsmount PRIVATE "-DAPPNAME=mfsmount" ${FUSE_CFLAGS_OTHER} "-DFUSE_USE_VERSION=26")
install(TARGETS mfsmount RUNTIME DESTINATION ${BIN_SUBDIR})
endif()
add_library(mount_fuse ${MOUNT_FUSE_SOURCES})
target_link_libraries(mount_fuse mount mfscommon)
add_definitions(${FUSE_CFLAGS_OTHER})
include_directories(${FUSE_INCLUDE_DIR})
add_executable(mfsmount ${MOUNT_FUSE_MAIN})
target_link_libraries(mfsmount mount_fuse ${FUSE_LIBRARY})
install(TARGETS mfsmount RUNTIME DESTINATION ${BIN_SUBDIR})
if(FUSE3_FOUND)
add_executable(mfsmount3 ${MOUNT_FUSE_MAIN} ${MOUNT_FUSE_SOURCES})
target_link_libraries(mfsmount3 mount mfscommon ${FUSE3_LIBRARY})
target_include_directories(mfsmount3 PRIVATE ${FUSE3_INCLUDE_DIR})
target_compile_definitions(mfsmount3 PRIVATE "-DAPPNAME=mfsmount3" ${FUSE3_CFLAGS_OTHER} "-DFUSE_USE_VERSION=30")
install(TARGETS mfsmount3 RUNTIME DESTINATION ${BIN_SUBDIR})
endif()

View File

@ -1,4 +1,4 @@
timeout_set 2 minutes
timeout_set 4 minutes
CHUNKSERVERS=2 \
USE_RAMDISK="YES" \

View File

@ -3,6 +3,7 @@ timeout_set 12 minutes
CHUNKSERVERS=2 \
USE_RAMDISK=YES \
MASTERSERVERS=2 \
LZFS_MOUNT_COMMAND="mfsmount" \
MOUNT_EXTRA_CONFIG="mfscachemode=NEVER" \
CHUNKSERVER_1_EXTRA_CONFIG="CREATE_NEW_CHUNKS_IN_MOOSEFS_FORMAT = 0" \
MASTER_EXTRA_CONFIG="CHUNKS_LOOP_TIME = 1|OPERATIONS_DELAY_INIT = 0" \

View File

@ -116,7 +116,7 @@ setup_local_empty_lizardfs() {
}
lizardfs_fusermount() {
fuse_version=$(mfsmount --version | grep "FUSE library" | grep -Eo "[0-9]+\..+")
fuse_version=$(${LZFS_MOUNT_COMMAND} --version 2>&1 | grep "FUSE library" | grep -Eo "[0-9]+\..+")
if [[ "$fuse_version" =~ ^3\..+$ ]]; then
fusermount3 "$@"
else
@ -493,14 +493,24 @@ add_mount_() {
lizardfs_info_[mount${mount_id}]="$mount_dir"
lizardfs_info_[mount${mount_id}_cfg]="$mount_cfg"
max_tries=30
if [ -z ${LZFS_MOUNT_COMMAND+x} ]; then
if (($RANDOM % 2)); then
LZFS_MOUNT_COMMAND=mfsmount3
echo "Using libfuse3 for mounting filesystem."
else
LZFS_MOUNT_COMMAND=mfsmount
fi
fi
fuse_options=""
for fuse_option in $(echo ${FUSE_EXTRA_CONFIG-} | tr '|' '\n'); do
fuse_option_name=$(echo $fuse_option | cut -f1 -d'=')
mfsmount --help |& grep " -o ${fuse_option_name}[ =]" > /dev/null \
${LZFS_MOUNT_COMMAND} --help |& grep " -o ${fuse_option_name}[ =]" > /dev/null \
|| test_fail "Your libfuse doesn't support $fuse_option_name flag"
fuse_options+="-o $fuse_option "
done
local call="${command_prefix} mfsmount -c ${mount_cfg} ${mount_dir} ${fuse_options}"
local call="${command_prefix} ${LZFS_MOUNT_COMMAND} -c ${mount_cfg} ${mount_dir} ${fuse_options}"
lizardfs_info_[mntcall$mount_id]=$call
do_mount_ ${mount_id}
}