Skip to content

Commit a4b1913

Browse files
authored
Merge pull request ceph#52933 from dang/wip-dang-posix-driver
RGW - Add POSIX Driver Reviewed-by: Casey Bodley <cbodley@redhat.com> Reviewed-by: Matt Benjamin <mbenjamin@redhat.com>
2 parents 980a0a4 + 5258bcb commit a4b1913

30 files changed

+13561
-21
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ option(WITH_RADOSGW_DBSTORE "DBStore backend for RADOS Gateway" ON)
454454
option(WITH_RADOSGW_MOTR "CORTX-Motr backend for RADOS Gateway" OFF)
455455
option(WITH_RADOSGW_DAOS "DAOS backend for RADOS Gateway" OFF)
456456
option(WITH_RADOSGW_D4N "D4N wrapper for RADOS Gateway" ON)
457+
option(WITH_RADOSGW_POSIX "POSIX backend for Rados Gateway" ON)
457458
option(WITH_RADOSGW_SELECT_PARQUET "Support for s3 select on parquet objects" ON)
458459
option(WITH_RADOSGW_ARROW_FLIGHT "Build arrow flight when not using system-provided arrow" OFF)
459460
option(WITH_RADOSGW_BACKTRACE_LOGGING "Enable backtraces in rgw logs" OFF)

ceph.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ BuildRequires: xfsprogs-devel
270270
BuildRequires: xmlstarlet
271271
BuildRequires: nasm
272272
BuildRequires: lua-devel
273+
BuildRequires: lmdb-devel
273274
%if 0%{with seastar} || 0%{with jaeger}
274275
BuildRequires: yaml-cpp-devel >= 0.6
275276
%endif

cmake/modules/FindLMDB.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright (c) 2014, The Monero Project
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without modification, are
5+
# permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice, this list of
8+
# conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
11+
# of conditions and the following disclaimer in the documentation and/or other
12+
# materials provided with the distribution.
13+
#
14+
# 3. Neither the name of the copyright holder nor the names of its contributors may be
15+
# used to endorse or promote products derived from this software without specific
16+
# prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
19+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21+
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26+
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
MESSAGE(STATUS "Looking for liblmdb")
29+
30+
FIND_PATH(LMDB_INCLUDE_DIR
31+
NAMES lmdb.h
32+
PATH_SUFFIXES include/ include/lmdb/
33+
PATHS "${PROJECT_SOURCE_DIR}"
34+
${LMDB_ROOT}
35+
$ENV{LMDB_ROOT}
36+
/usr/local/
37+
/usr/
38+
)
39+
40+
if(STATIC)
41+
if(MINGW)
42+
find_library(LMDB_LIBRARIES liblmdb.dll.a)
43+
else()
44+
find_library(LMDB_LIBRARIES liblmdb.a)
45+
endif()
46+
else()
47+
find_library(LMDB_LIBRARIES lmdb)
48+
endif()
49+
50+
IF(LMDB_INCLUDE_DIR)
51+
MESSAGE(STATUS "Found liblmdb include (lmdb.h) in ${LMDB_INCLUDE_DIR}")
52+
IF(LMDB_LIBRARIES)
53+
MESSAGE(STATUS "Found liblmdb library")
54+
set(LMDB_INCLUDE ${LMDB_INCLUDE_DIR})
55+
set(LMDB_LIBRARY ${LMDB_LIBRARIES})
56+
ELSE()
57+
MESSAGE(FATAL_ERROR "${BoldRed}Could not find liblmdb library, please make sure you have installed liblmdb or liblmdb-dev or the equivalent${ColourReset}")
58+
ENDIF()
59+
ELSE()
60+
MESSAGE(FATAL_ERROR "${BoldRed}Could not find liblmdb library, please make sure you have installed liblmdb or liblmdb-dev or the equivalent${ColourReset}")
61+
ENDIF()

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Build-Depends: automake,
6565
libsqlite3-dev,
6666
libssl-dev,
6767
libtool,
68+
liblmdb-dev,
6869
libudev-dev,
6970
libnl-genl-3-dev,
7071
libxml2-dev,

src/common/cohort_lru.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
#include <boost/intrusive/list.hpp>
1717
#include <boost/intrusive/slist.hpp>
1818

19+
#ifdef __CEPH__
20+
# include "include/ceph_assert.h"
21+
#else
22+
# include <assert.h>
23+
#endif
24+
1925
#include "common/likely.h"
2026

2127
#ifndef CACHE_LINE_SIZE

src/common/options/rgw.yaml.in

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,6 +3618,7 @@ options:
36183618
- none
36193619
- base
36203620
- d4n
3621+
- posix
36213622
- name: dbstore_db_dir
36223623
type: str
36233624
level: advanced
@@ -3705,6 +3706,51 @@ options:
37053706
default: false
37063707
services:
37073708
- rgw
3709+
- name: rgw_posix_base_path
3710+
type: str
3711+
level: advanced
3712+
desc: experimental Option to set base path for POSIX Driver
3713+
long_desc: Base path for the POSIX driver. All operations are relative to this path.
3714+
Defaults to /tmp/rgw_posix_driver
3715+
default: /tmp/rgw_posix_driver
3716+
services:
3717+
- rgw
3718+
- name: rgw_posix_database_root
3719+
type: str
3720+
level: advanced
3721+
desc: experimental Path to parent of POSIX Driver LMDB bucket listing cache
3722+
long_desc: Parent directory of LMDB bucket listing cache databases.
3723+
default: /var/lib/ceph/radosgw
3724+
services:
3725+
- rgw
3726+
- name: rgw_posix_cache_max_buckets
3727+
type: int
3728+
level: advanced
3729+
desc: experimental Number of buckets to maintain in the ordered listing cache
3730+
default: 100
3731+
services:
3732+
- rgw
3733+
- name: rgw_posix_cache_lanes
3734+
type: int
3735+
level: advanced
3736+
desc: experimental Number of lanes in cache LRU
3737+
default: 3
3738+
services:
3739+
- rgw
3740+
- name: rgw_posix_cache_partitions
3741+
type: int
3742+
level: advanced
3743+
desc: experimental Number of partitions in cache AVL
3744+
default: 3
3745+
services:
3746+
- rgw
3747+
- name: rgw_posix_cache_lmdb_count
3748+
type: int
3749+
level: advanced
3750+
desc: experimental Number of lmdb partitions in the ordered listing cache
3751+
default: 3
3752+
services:
3753+
- rgw
37083754
- name: rgw_luarocks_location
37093755
type: str
37103756
level: advanced

src/include/config-h.in.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@
363363
/* Backend CORTX-DAOS for Rados Gateway */
364364
#cmakedefine WITH_RADOSGW_DAOS
365365

366+
/* Backend POSIX for Rados Gateway */
367+
#cmakedefine WITH_RADOSGW_POSIX
368+
366369
/* Defined if std::map::merge() is supported */
367370
#cmakedefine HAVE_STDLIB_MAP_SPLICING
368371

src/rgw/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ if(WITH_RADOSGW_D4N)
227227
list(APPEND librgw_common_srcs driver/d4n/d4n_datacache.cc)
228228
list(APPEND librgw_common_srcs driver/d4n/rgw_sal_d4n.cc)
229229
endif()
230+
if(WITH_RADOSGW_POSIX)
231+
#add_subdirectory(driver/posix)
232+
find_package(LMDB REQUIRED)
233+
add_compile_definitions(LMDB_SAFE_NO_CPP_UTILITIES)
234+
list(APPEND librgw_common_srcs
235+
driver/posix/rgw_sal_posix.cc
236+
driver/posix/lmdb-safe.cc
237+
driver/posix/notify.cpp)
238+
endif()
230239
if(WITH_JAEGER)
231240
list(APPEND librgw_common_srcs rgw_tracer.cc)
232241
endif()
@@ -236,7 +245,6 @@ if(WITH_RADOSGW_ARROW_FLIGHT)
236245
list(APPEND librgw_common_srcs rgw_flight.cc rgw_flight_frontend.cc)
237246
endif(WITH_RADOSGW_ARROW_FLIGHT)
238247

239-
240248
add_library(rgw_common STATIC ${librgw_common_srcs})
241249

242250
include(CheckCXXCompilerFlag)
@@ -270,6 +278,7 @@ target_link_libraries(rgw_common
270278
${EXPAT_LIBRARIES}
271279
${ARROW_LIBRARIES}
272280
${ARROW_FLIGHT_LIBRARIES}
281+
${LMDB_LIBRARIES}
273282
${ALLOC_LIBS}
274283
PUBLIC
275284
${LUA_LIBRARIES}

src/rgw/driver/posix/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# POSIX Driver
2+
Standalone Rados Gateway (RGW) on a local POSIX filesystem (Experimental)
3+
4+
5+
## CMake Option
6+
Add below cmake option (enabled by default)
7+
8+
-DWITH_RADOSGW_POSIX=ON
9+
10+
11+
## Build
12+
13+
cd build
14+
ninja [vstart]
15+
16+
17+
## Running Test cluster
18+
Currently, POSIXDriver depends on DBStore for user storage. This will change, eventually, but for now, it's run as a filter on top of DBStore. Not that only users are stored in DBStore, the rest is in the POSIX filesystem.
19+
Edit ceph.conf to add below option
20+
21+
[client]
22+
rgw backend store = dbstore
23+
rgw config store = dbstore
24+
rgw filter = posix
25+
26+
Start vstart cluster
27+
28+
MON=0 OSD=0 MDS=0 MGR=0 RGW=1 ../src/vstart.sh -o rgw_backend_store=dbstore -o rgw_config_store=dbstore -o rgw_filter=posix -n -d
29+
30+
The above vstart command brings up RGW server on POSIXDriver. It creates default zonegroup, zone and few default users (eg., testid) to be used for s3 operations.
31+
32+
`radosgw-admin` can be used to create and remove other users, zonegroups and zones.
33+
34+
By default, the directory exported is *'/tmp/rgw_posix_driver'*. This can be changed with the `rgw_posix_base_path` option, either in ceph.conf or on the vstart command line above.
35+
36+
The POSIXDriver keeps a LMDB based cache of directories, so that it can provide ordered listings. This directory lives in `rgw_posix_database_root`, which by default is in *'/var/lib/ceph/radosgw'*
37+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab ft=cpp
3+
#include "bucket_cache.h"
4+

0 commit comments

Comments
 (0)