From: Vinit Agnihotri Date: Wed, 12 Nov 2025 12:09:54 +0000 (+0530) Subject: source3/wscript: Add new vfs module 'vfs_ceph_rgw' X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d0c8fd93d3a48d867d7fe73e02e78124b79f33f;p=thirdparty%2Fsamba.git source3/wscript: Add new vfs module 'vfs_ceph_rgw' Define new vfs module 'vfs_ceph_rgw' which serves as a handler for hosting s3 bucket over object store defined by ceph-rgw. This shall make use of librgw library to interface with s3 bucket - Add configuration option --enable-cephrgw. - Add 'vfs_ceph_rgw' module to build system. Signed-off-by: Vinit Agnihotri Reviewed-by: Shachar Sharon Reviewed-by: Anoop C S Reviewed-by: Guenther Deschner --- diff --git a/source3/modules/vfs_ceph_rgw.c b/source3/modules/vfs_ceph_rgw.c new file mode 100644 index 00000000000..135c7c2e2a8 --- /dev/null +++ b/source3/modules/vfs_ceph_rgw.c @@ -0,0 +1,122 @@ +/* + * Bridge between Samba's VFS layer and Ceph-RGW. + * + * Copyright (c) 2025 Vinit Agnihotri + * + * This program 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; either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, see . + */ + +/* + * Add the following smb.conf parameter to each share that will be hosted on + * Ceph with rgw: + * + * vfs objects = ceph_rgw + */ +#include "includes.h" +#include "smbd/smbd.h" +#include "system/filesys.h" +#include +#include "smbprofile.h" +#include "lib/util/tevent_unix.h" +#include +#include + +static struct vfs_fn_pointers ceph_rgw_fns = { + /* Disk operations */ + + .connect_fn = vfs_not_implemented_connect, + .disconnect_fn = vfs_not_implemented_disconnect, + .disk_free_fn = vfs_not_implemented_disk_free, + .get_quota_fn = vfs_not_implemented_get_quota, + .set_quota_fn = vfs_not_implemented_set_quota, + .fstatvfs_fn = vfs_not_implemented_fstatvfs, + .fs_capabilities_fn = vfs_not_implemented_fs_capabilities, + + /* Directory operations */ + + .fdopendir_fn = vfs_not_implemented_fdopendir, + .readdir_fn = vfs_not_implemented_readdir, + .rewind_dir_fn = vfs_not_implemented_rewind_dir, + .mkdirat_fn = vfs_not_implemented_mkdirat, + .closedir_fn = vfs_not_implemented_closedir, + + /* File operations */ + + .create_dfs_pathat_fn = vfs_not_implemented_create_dfs_pathat, + .read_dfs_pathat_fn = vfs_not_implemented_read_dfs_pathat, + .openat_fn = vfs_not_implemented_openat, + .close_fn = vfs_not_implemented_close_fn, + .pread_fn = vfs_not_implemented_pread, + .pread_send_fn = vfs_not_implemented_pread_send, + .pread_recv_fn = vfs_not_implemented_pread_recv, + .pwrite_fn = vfs_not_implemented_pwrite, + .pwrite_send_fn = vfs_not_implemented_pwrite_send, + .pwrite_recv_fn = vfs_not_implemented_pwrite_recv, + .lseek_fn = vfs_not_implemented_lseek, + .sendfile_fn = vfs_not_implemented_sendfile, + .recvfile_fn = vfs_not_implemented_recvfile, + .renameat_fn = vfs_not_implemented_renameat, + .fsync_send_fn = vfs_not_implemented_fsync_send, + .fsync_recv_fn = vfs_not_implemented_fsync_recv, + .stat_fn = vfs_not_implemented_stat, + .fstat_fn = vfs_not_implemented_fstat, + .lstat_fn = vfs_not_implemented_lstat, + .fstatat_fn = vfs_not_implemented_fstatat, + .unlinkat_fn = vfs_not_implemented_unlinkat, + .fchmod_fn = vfs_not_implemented_fchmod, + .fchown_fn = vfs_not_implemented_fchown, + .lchown_fn = vfs_not_implemented_lchown, + .chdir_fn = vfs_not_implemented_chdir, + .fntimes_fn = vfs_not_implemented_fntimes, + .ftruncate_fn = vfs_not_implemented_ftruncate, + .fallocate_fn = vfs_not_implemented_fallocate, + .lock_fn = vfs_not_implemented_lock, + .filesystem_sharemode_fn = vfs_not_implemented_filesystem_sharemode, + .fcntl_fn = vfs_not_implemented_fcntl, + .linux_setlease_fn = vfs_not_implemented_linux_setlease, + .getlock_fn = vfs_not_implemented_getlock, + .symlinkat_fn = vfs_not_implemented_symlinkat, + .readlinkat_fn = vfs_not_implemented_vfs_readlinkat, + .linkat_fn = vfs_not_implemented_linkat, + .mknodat_fn = vfs_not_implemented_mknodat, + .realpath_fn = vfs_not_implemented_realpath, + .fchflags_fn = vfs_not_implemented_fchflags, + .get_real_filename_at_fn = vfs_not_implemented_get_real_filename_at, + .fget_dos_attributes_fn = vfs_not_implemented_fget_dos_attributes, + .fset_dos_attributes_fn = vfs_not_implemented_fset_dos_attributes, + + /* EA operations. */ + .getxattrat_send_fn = vfs_not_implemented_getxattrat_send, + .getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv, + .fgetxattr_fn = vfs_not_implemented_fgetxattr, + .flistxattr_fn = vfs_not_implemented_flistxattr, + .fremovexattr_fn = vfs_not_implemented_fremovexattr, + .fsetxattr_fn = vfs_not_implemented_fsetxattr, + + /* Posix ACL Operations */ + .sys_acl_get_fd_fn = vfs_not_implemented_sys_acl_get_fd, + .sys_acl_blob_get_fd_fn = vfs_not_implemented_sys_acl_blob_get_fd, + .sys_acl_set_fd_fn = vfs_not_implemented_sys_acl_set_fd, + .sys_acl_delete_def_fd_fn = vfs_not_implemented_sys_acl_delete_def_fd, + + /* aio operations */ + .aio_force_fn = vfs_not_implemented_aio_force, +}; + +NTSTATUS vfs_ceph_rgw_init(TALLOC_CTX *ctx) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, + "ceph_rgw", + &ceph_rgw_fns); +} diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build index d078293763d..4ad568bf6af 100644 --- a/source3/modules/wscript_build +++ b/source3/modules/wscript_build @@ -565,6 +565,14 @@ bld.SAMBA3_MODULE('vfs_ceph_snapshots', internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_ceph_snapshots'), enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_ceph_snapshots')) +bld.SAMBA3_MODULE('vfs_ceph_rgw', + subsystem='vfs', + source='vfs_ceph_rgw.c', + deps='samba-util rgw', + init_function='', + internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_ceph_rgw'), + enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_ceph_rgw')) + bld.SAMBA3_MODULE('vfs_glusterfs', subsystem='vfs', source='vfs_glusterfs.c', diff --git a/source3/wscript b/source3/wscript index 06f329e05ae..7be7bc736fb 100644 --- a/source3/wscript +++ b/source3/wscript @@ -89,6 +89,7 @@ def options(opt): opt.samba_add_onoff_option('glusterfs', with_name="enable", without_name="disable", default=True) opt.samba_add_onoff_option('cephfs', with_name="enable", without_name="disable", default=None) + opt.samba_add_onoff_option('cephrgw', with_name="enable", without_name="disable", default=None) opt.add_option('--enable-vxfs', help=("enable support for VxFS (default=no)"), @@ -1686,6 +1687,16 @@ int main(void) { Logs.warn("acl support disabled or ceph_statx/ceph_openat not " "available, not building ceph vfs modules") + if (Options.options.with_cephrgw is not False and + conf.CHECK_HEADERS('rados/rgw_file.h', lib='rgw') and + conf.CHECK_LIB('rgw', shlib=True)): + conf.DEFINE('HAVE_CEPHRGW', '1') + Logs.info("building ceph rgw vfs modules") + elif (Options.options.with_cephrgw is True and + not conf.CONFIG_SET('HAVE_CEPHRGW')): + Logs.error("librgw not present, cannot build ceph rgw module") + conf.fatal("librgw not present, but --enable-cephrgw was specified") + if Options.options.with_glusterfs: conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs', msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI") @@ -1916,6 +1927,9 @@ int main(void) { default_shared_modules.extend(['vfs_ceph_snapshots']) default_shared_modules.extend(['vfs_ceph_new']) + if conf.CONFIG_SET("HAVE_CEPHRGW"): + default_shared_modules.extend(['vfs_ceph_rgw']) + if conf.CONFIG_SET('HAVE_GLUSTERFS'): default_shared_modules.extend(['vfs_glusterfs'])