From 7a3cc61de03075ada0527f77b64d3456cb47e3a2 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 5 May 2020 20:43:12 -0400 Subject: [PATCH 1/3] libfuse: check the libfuse version from the pkconfig/fuse{3}.pc file Since libfuse 3.2 to 3.8 the minor version for FUSE library has stopped updating together with the releases. So we cannot check version by using the FUSE_VERSION macro in the fuse_common.h header file directly. This will check the major/minor version from the fuse{3}.pc pkconfig file. Fixes: https://tracker.ceph.com/issues/45396 Signed-off-by: Xiubo Li --- cmake/modules/FindFUSE.cmake | 25 ++++++++++++++++++------- src/ceph_fuse.cc | 1 + src/client/fuse_ll.cc | 1 + src/include/ceph_fuse.h | 13 ++++++++++++- src/include/config-h.in.cmake | 6 ++++++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/cmake/modules/FindFUSE.cmake b/cmake/modules/FindFUSE.cmake index 1d0766f3355..db489bdc1ad 100644 --- a/cmake/modules/FindFUSE.cmake +++ b/cmake/modules/FindFUSE.cmake @@ -28,14 +28,25 @@ find_library(FUSE_LIBRARIES NAMES ${fuse_names} PATHS /usr/local/lib64 /usr/local/lib) -foreach(ver "MAJOR" "MINOR") - file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line - REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$") - string(REGEX REPLACE ".*#define[\t ]+FUSE_${ver}_VERSION[\t ]+([0-9]+)$" - "\\1" FUSE_VERSION_${ver} "${fuse_ver_${ver}_line}") -endforeach() +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PKG_FUSE QUIET ${fuse_names}) + + string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)" + "\\1" FUSE_MAJOR_VERSION "${PKG_FUSE_VERSION}") + string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)" + "\\2" FUSE_MINOR_VERSION "${PKG_FUSE_VERSION}") +else() + foreach(ver "MAJOR" "MINOR") + file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line + REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$") + string(REGEX REPLACE ".*#define[\t ]+FUSE_${ver}_VERSION[\t ]+([0-9]+)$" + "\\1" FUSE_${ver}_VERSION "${fuse_ver_${ver}_line}") + endforeach() +endif() + set(FUSE_VERSION - "${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}") + "${FUSE_MAJOR_VERSION}.${FUSE_MINOR_VERSION}") include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FUSE diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index 3692b5c6ff6..02aed32ac69 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -44,6 +44,7 @@ #include #include +#include "include/ceph_fuse.h" #define dout_context g_ceph_context diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 43b33e32a06..034977b1832 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -34,6 +34,7 @@ #include "common/config.h" #include "include/ceph_assert.h" #include "include/cephfs/ceph_ll_client.h" +#include "include/ceph_fuse.h" #include "fuse_ll.h" #include diff --git a/src/include/ceph_fuse.h b/src/include/ceph_fuse.h index 45881930b87..ae504f6715d 100644 --- a/src/include/ceph_fuse.h +++ b/src/include/ceph_fuse.h @@ -15,8 +15,19 @@ #define CEPH_FUSE_H #define FUSE_USE_VERSION 30 -#include "acconfig.h" #include +#include "acconfig.h" + +/* + * Redefine the FUSE_VERSION macro defined in "fuse_common.h" + * header file, because the MINOR numner has been forgotten to + * update since libfuse 3.2 to 3.8. We need to fetch the MINOR + * number from pkgconfig file. + */ +#ifdef FUSE_VERSION +#undef FUSE_VERSION +#define FUSE_VERSION FUSE_MAKE_VERSION(CEPH_FUSE_MAJOR_VERSION, CEPH_FUSE_MINOR_VERSION) +#endif static inline int filler_compat(fuse_fill_dir_t filler, void *buf, const char *name, diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index e26671d3a00..40cbc430730 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -87,6 +87,12 @@ /* Define if you have fuse */ #cmakedefine HAVE_LIBFUSE +/* Define version major */ +#define CEPH_FUSE_MAJOR_VERSION @FUSE_MAJOR_VERSION@ + +/* Define version minor */ +#define CEPH_FUSE_MINOR_VERSION @FUSE_MINOR_VERSION@ + /* Define to 1 if you have libxfs */ #cmakedefine HAVE_LIBXFS 1 From ee3307431f70e327dee0189553e9d44887b6b521 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 8 May 2020 08:36:15 -0400 Subject: [PATCH 2/3] cmake: to get the header and library from specified path Since the pkg_search_module will help us set the header and lib path, which we should get the headers and lib from. To check from other paths will make no sense. Fixes: https://tracker.ceph.com/issues/45396 Signed-off-by: Xiubo Li --- cmake/modules/FindFUSE.cmake | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/cmake/modules/FindFUSE.cmake b/cmake/modules/FindFUSE.cmake index db489bdc1ad..b55a2d36f50 100644 --- a/cmake/modules/FindFUSE.cmake +++ b/cmake/modules/FindFUSE.cmake @@ -19,15 +19,6 @@ if(APPLE) list(APPEND fuse_suffixes osxfuse) endif() -find_path( - FUSE_INCLUDE_DIR - NAMES fuse_common.h fuse_lowlevel.h fuse.h - PATH_SUFFIXES ${fuse_suffixes}) - -find_library(FUSE_LIBRARIES - NAMES ${fuse_names} - PATHS /usr/local/lib64 /usr/local/lib) - find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) pkg_search_module(PKG_FUSE QUIET ${fuse_names}) @@ -36,7 +27,28 @@ if(PKG_CONFIG_FOUND) "\\1" FUSE_MAJOR_VERSION "${PKG_FUSE_VERSION}") string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)" "\\2" FUSE_MINOR_VERSION "${PKG_FUSE_VERSION}") + + find_path( + FUSE_INCLUDE_DIR + NAMES fuse_common.h fuse_lowlevel.h fuse.h + HINTS ${PKG_FUSE_INCLUDE_DIRS} + PATH_SUFFIXES ${fuse_suffixes} + NO_DEFAULT_PATH) + + find_library(FUSE_LIBRARIES + NAMES ${fuse_names} + HINTS ${PKG_FUSE_LIBDIR} + NO_DEFAULT_PATH) else() + find_path( + FUSE_INCLUDE_DIR + NAMES fuse_common.h fuse_lowlevel.h fuse.h + PATH_SUFFIXES ${fuse_suffixes}) + + find_library(FUSE_LIBRARIES + NAMES ${fuse_names} + PATHS /usr/local/lib64 /usr/local/lib) + foreach(ver "MAJOR" "MINOR") file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$") From 377c65693ff363d1c8a1d024cbf613ac778ceb45 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Thu, 23 Apr 2020 18:14:47 -0400 Subject: [PATCH 3/3] ceph-fuse: compatible with libfuse3.5 or higher Fixes: https://tracker.ceph.com/issues/45396 Signed-off-by: Xiubo Li --- src/client/fuse_ll.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 034977b1832..600cfbdd255 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -641,7 +641,13 @@ static void fuse_ll_flush(fuse_req_t req, fuse_ino_t ino, } #ifdef FUSE_IOCTL_COMPAT -static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi, +static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, +#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 5) + unsigned int cmd, +#else + int cmd, +#endif + void *arg, struct fuse_file_info *fi, unsigned flags, const void *in_buf, size_t in_bufsz, size_t out_bufsz) { CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);