[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Apr 24 15:59:03 MDT 2013
The branch, master has been updated
via 727c611 source4/libcli: Only set ctemp set on success
via 301a1f9 Implements a vfs module for cephfs, a distributed file system with posix semantics, built on the ceph distributed object storage layer. The ceph vfs module interfaces to the libcephfs userspace API, and is primarily a lightweight wrapper around libcephfs, translating error codes and parameters as necessary.
from 4b97a19 BUG 9817: Fix 'map untrusted to domain' with NTLMv2.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 727c611fe3c903d905871a46909ed1e7639add15
Author: Sam Lang <sam.lang at inktank.com>
Date: Mon Apr 22 10:23:16 2013 -0500
source4/libcli: Only set ctemp set on success
If open fails ctemp.out.name probably won't be valid and strdup
will cause a segv. Only set the path if open succeeds.
Signed-off-by: Sam Lang <sam.lang at inktank.com>
Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Apr 24 23:58:44 CEST 2013 on sn-devel-104
commit 301a1f919202c90c629a4926ebdf054b9f2fe1e8
Author: Sam Lang <sam.lang at inktank.com>
Date: Wed Apr 24 12:52:57 2013 -0700
Implements a vfs module for cephfs, a distributed file system
with posix semantics, built on the ceph distributed object
storage layer. The ceph vfs module interfaces to the libcephfs
userspace API, and is primarily a lightweight wrapper around
libcephfs, translating error codes and parameters as necessary.
Signed-off-by: Sam Lang <sam.lang at inktank.com>
Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/Makefile.in | 5 +
source3/configure.in | 31 +
source3/modules/vfs_ceph.c | 1261 +++++++++++++++++++++++++++++++++++++++++
source3/modules/wscript_build | 10 +
source3/wscript | 15 +
source4/libcli/clifile.c | 15 +-
6 files changed, 1330 insertions(+), 7 deletions(-)
create mode 100644 source3/modules/vfs_ceph.c
Changeset truncated at 500 lines:
diff --git a/source3/Makefile.in b/source3/Makefile.in
index a868685..c701fd1 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -913,6 +913,7 @@ VFS_LINUX_XFS_SGID_OBJ = modules/vfs_linux_xfs_sgid.o
VFS_TIME_AUDIT_OBJ = modules/vfs_time_audit.o
VFS_MEDIA_HARMONY_OBJ = modules/vfs_media_harmony.o
VFS_BTRFS_OBJ = modules/vfs_btrfs.o
+VFS_CEPH_OBJ = modules/vfs_ceph.o
PAM_ERRORS_OBJ = ../libcli/auth/pam_errors.o
PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o $(PAM_ERRORS_OBJ)
@@ -2965,6 +2966,10 @@ bin/btrfs. at SHLIBEXT@: $(BINARY_PREREQS) $(VFS_BTRFS_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_BTRFS_OBJ)
+bin/ceph. at SHLIBEXT@: $(BINARY_PREREQS) $(VFS_CEPH_OBJ)
+ @echo "Building plugin $@"
+ @$(SHLD_MODULE) $(VFS_CEPH_OBJ)
+
#########################################################
## IdMap NSS plugins
diff --git a/source3/configure.in b/source3/configure.in
index 88c71d4..d2aa215 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1023,6 +1023,36 @@ if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
default_shared_modules="$default_shared_modules vfs_gpfs"
fi
+#############################
+# check if building with libcephfs
+# fail if --with-libcephfs specified but no headers found
+printf "%s" "checking for CephFS... "
+AC_CHECK_HEADERS(cephfs/libcephfs.h)
+
+save_LIBS="$LIBS"
+LIBS="$LIBS -lcephfs"
+AC_TRY_LINK([#include <cephfs/libcephfs.h>],
+ [ceph_version(0, 0, 0)],
+ samba_cv_HAVE_CEPHFS=yes,
+ samba_cv_HAVE_CEPHFS=no
+ )
+
+if test x"$ac_cv_header_cephfs_libcephfs_h" = x"yes" && test x"$samba_cv_HAVE_CEPHFS" = x"yes"; then
+ AC_DEFINE(HAVE_CEPH, 1, [Whether CEPH headers are available])
+ default_shared_modules="$default_shared_modules vfs_ceph"
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ save_LIBS="$save_LIBS -lcephfs"
+else
+ if test x"$CEPHFS_PATH_SPEC" = x"yes"; then
+ AC_MSG_ERROR([No valid libcephfs found in ${CEPHFS_PATH}])
+ fi
+fi
+
+CFLAGS="$save_CFLAGS"
+LDFLAGS="$save_LDFLAGS"
+LIBS="$save_LIBS"
+
# Note that all the libunwind symbols in the API are defined to internal
# platform-specific version, so we must include libunwind.h before checking
# any of them.
@@ -6455,6 +6485,7 @@ SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$
SMB_MODULE(vfs_time_audit, \$(VFS_TIME_AUDIT_OBJ), "bin/time_audit.$SHLIBEXT", VFS)
SMB_MODULE(vfs_media_harmony, \$(VFS_MEDIA_HARMONY_OBJ), "bin/media_harmony.$SHLIBEXT", VFS)
SMB_MODULE(vfs_btrfs, \$(VFS_BTRFS_OBJ), "bin/btrfs.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_ceph, \$(VFS_CEPH_OBJ), "bin/ceph.$SHLIBEXT", VFS)
SMB_SUBSYSTEM(VFS,smbd/vfs.o)
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
new file mode 100644
index 0000000..fdb7feb
--- /dev/null
+++ b/source3/modules/vfs_ceph.c
@@ -0,0 +1,1261 @@
+/*
+ Unix SMB/CIFS implementation.
+ Wrap disk only vfs functions to sidestep dodgy compilers.
+ Copyright (C) Tim Potter 1998
+ Copyright (C) Jeremy Allison 2007
+ Copyright (C) Brian Chrisman 2011 <bchrisman at gmail.com>
+ Copyright (C) Richard Sharpe 2011 <realrichardsharpe at gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * This VFS only works with the libceph.so user-space client. It is not needed
+ * if you are using the kernel client or the FUSE client.
+ *
+ * Add the following smb.conf parameter to each share that will be hosted on
+ * Ceph:
+ *
+ * vfs objects = ceph [any others you need go here]
+ */
+
+#include "includes.h"
+#include "smbd/smbd.h"
+#include <dirent.h>
+#include <sys/statvfs.h>
+#include "cephfs/libcephfs.h"
+#include "smbprofile.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_VFS
+
+/*
+ * Use %llu whenever we have a 64bit unsigned int, and cast to (long long unsigned)
+ */
+#define llu(_var) ((long long unsigned)_var)
+
+/*
+ * Note, libceph's return code model is to return -errno! So we have to convert
+ * to what Samba expects, with is set errno to -return and return -1
+ */
+#define WRAP_RETURN(_res) \
+ errno = 0; \
+ if (_res < 0) { \
+ errno = -_res; \
+ return -1; \
+ } \
+ return _res \
+
+/*
+ * We mount only one file system and then all shares are assumed to be in that.
+ * FIXME: If we want to support more than one FS, then we have to deal with
+ * this differently.
+ *
+ * So, cmount tells us if we have been this way before and whether
+ * we need to mount ceph and cmount_cnt tells us how many times we have
+ * connected
+ */
+static struct ceph_mount_info * cmount = NULL;
+static uint32_t cmount_cnt = 0;
+
+/* Check for NULL pointer parameters in cephwrap_* functions */
+
+/* We don't want to have NULL function pointers lying around. Someone
+ is sure to try and execute them. These stubs are used to prevent
+ this possibility. */
+
+static int cephwrap_connect(struct vfs_handle_struct *handle, const char *service, const char *user)
+{
+ int ret;
+ char buf[256];
+
+ const char * conf_file;
+
+ if (cmount) {
+ handle->data = cmount; /* We have been here before */
+ cmount_cnt++;
+ return 0;
+ }
+
+ conf_file = lp_parm_const_string(SNUM(handle->conn), "ceph", "config_file", NULL);
+
+ DEBUG(2, ( "[CEPH] calling: ceph_create\n" ));
+ ret = ceph_create(&cmount, NULL);
+ if (ret)
+ goto err_out;
+
+ if (conf_file) {
+ /* Override the config file */
+ DEBUG(2, ( "[CEPH] calling: ceph_conf_read_file\n" ));
+ ret = ceph_conf_read_file(cmount, conf_file);
+ } else {
+
+ DEBUG(2, ( "[CEPH] calling: ceph_conf_read_file with %s\n", conf_file));
+ ret = ceph_conf_read_file(cmount, NULL);
+ }
+
+ if (ret)
+ goto err_out;
+
+ DEBUG(2, ( "[CEPH] calling: ceph_conf_get\n" ));
+ ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
+ if (ret < 0)
+ goto err_out;
+
+ DEBUG(2, ("[CEPH] calling: ceph_mount\n"));
+ ret = ceph_mount(cmount, NULL);
+ if (ret < 0)
+ goto err_out;
+
+
+ /*
+ * encode mount context/state into our vfs/connection holding structure
+ * cmount is a ceph_mount_t*
+ */
+ handle->data = cmount;
+ cmount_cnt++;
+
+ return 0;
+
+err_out:
+ /*
+ * Handle the error correctly. Ceph returns -errno.
+ */
+ DEBUG(2, ("[CEPH] Error return: %s\n", strerror(-ret)));
+ WRAP_RETURN(ret);
+}
+
+static void cephwrap_disconnect(struct vfs_handle_struct *handle)
+{
+ if (!cmount) {
+ DEBUG(0, ("[CEPH] Error, ceph not mounted\n"));
+ return;
+ }
+
+ /* Should we unmount/shutdown? Only if the last disconnect? */
+ if (--cmount_cnt) {
+ DEBUG(10, ("[CEPH] Not shuting down CEPH because still more connections\n"));
+ return;
+ }
+
+ ceph_shutdown(cmount);
+
+ cmount = NULL; /* Make it safe */
+}
+
+/* Disk operations */
+
+static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
+ uint64_t *dfree, uint64_t *dsize)
+{
+ struct statvfs statvfs_buf;
+ int ret;
+
+ if (!(ret = ceph_statfs(handle->data, path, &statvfs_buf))) {
+ /*
+ * Provide all the correct values.
+ */
+ *bsize = statvfs_buf.f_bsize;
+ *dfree = statvfs_buf.f_bsize * statvfs_buf.f_bavail;
+ *dsize = statvfs_buf.f_bsize * statvfs_buf.f_blocks;
+ DEBUG(10, ("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n",
+ llu(*bsize), llu(*dfree), llu(*dsize)));
+ return *dfree;
+ } else {
+ DEBUG(10, ("[CEPH] ceph_statfs returned %d\n", ret));
+ WRAP_RETURN(ret);
+ }
+}
+
+static int cephwrap_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+{
+ /* libceph: Ceph does not implement this */
+#if 0
+/* was ifdef HAVE_SYS_QUOTAS */
+ int ret;
+
+ ret = ceph_get_quota(handle->conn->connectpath, qtype, id, qt);
+
+ if (ret) {
+ errno = -ret;
+ ret = -1;
+ }
+
+ return ret;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+{
+ /* libceph: Ceph does not implement this */
+#if 0
+/* was ifdef HAVE_SYS_QUOTAS */
+ int ret;
+
+ ret = ceph_set_quota(handle->conn->connectpath, qtype, id, qt);
+ if (ret) {
+ errno = -ret;
+ ret = -1;
+ }
+
+ return ret;
+#else
+ WRAP_RETURN(-ENOSYS);
+#endif
+}
+
+static int cephwrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf)
+{
+ struct statvfs statvfs_buf;
+ int ret;
+
+ ret = ceph_statfs(handle->data, path, &statvfs_buf);
+ if (ret < 0) {
+ WRAP_RETURN(ret);
+ } else {
+ statbuf->OptimalTransferSize = statvfs_buf.f_frsize;
+ statbuf->BlockSize = statvfs_buf.f_bsize;
+ statbuf->TotalBlocks = statvfs_buf.f_blocks;
+ statbuf->BlocksAvail = statvfs_buf.f_bfree;
+ statbuf->UserBlocksAvail = statvfs_buf.f_bavail;
+ statbuf->TotalFileNodes = statvfs_buf.f_files;
+ statbuf->FreeFileNodes = statvfs_buf.f_ffree;
+ statbuf->FsIdentifier = statvfs_buf.f_fsid;
+ DEBUG(10, ("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, f_bavail: %ld\n",
+ statvfs_buf.f_bsize, statvfs_buf.f_blocks,
+ statvfs_buf.f_bfree, statvfs_buf.f_bavail));
+ }
+ return ret;
+}
+
+/* Directory operations */
+
+static DIR *cephwrap_opendir(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
+{
+ int ret = 0;
+ struct ceph_dir_result *result;
+ DEBUG(10, ("[CEPH] opendir(%p, %s)\n", handle, fname));
+
+ /* Returns NULL if it does not exist or there are problems ? */
+ ret = ceph_opendir(handle->data, fname, &result);
+ if (ret < 0) {
+ result = NULL;
+ errno = -ret; /* We return result which is NULL in this case */
+ }
+
+ DEBUG(10, ("[CEPH] opendir(...) = %d\n", ret));
+ return (DIR *) result;
+}
+
+static DIR *cephwrap_fdopendir(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ const char *mask,
+ uint32 attributes)
+{
+ int ret = 0;
+ struct ceph_dir_result *result;
+ DEBUG(10, ("[CEPH] fdopendir(%p, %p)\n", handle, fsp));
+
+ ret = ceph_opendir(handle->data, fsp->fsp_name->base_name, &result);
+ if (ret < 0) {
+ result = NULL;
+ errno = -ret; /* We return result which is NULL in this case */
+ }
+
+ DEBUG(10, ("[CEPH] fdopendir(...) = %d\n", ret));
+ return (DIR *) result;
+}
+
+static struct dirent *cephwrap_readdir(struct vfs_handle_struct *handle,
+ DIR *dirp,
+ SMB_STRUCT_STAT *sbuf)
+{
+ struct dirent *result;
+
+ DEBUG(10, ("[CEPH] readdir(%p, %p)\n", handle, dirp));
+ result = ceph_readdir(handle->data, (struct ceph_dir_result *) dirp);
+ DEBUG(10, ("[CEPH] readdir(...) = %p\n", result));
+
+ /* Default Posix readdir() does not give us stat info.
+ * Set to invalid to indicate we didn't return this info. */
+ if (sbuf)
+ SET_STAT_INVALID(*sbuf);
+ return result;
+}
+
+static void cephwrap_seekdir(struct vfs_handle_struct *handle, DIR *dirp, long offset)
+{
+ DEBUG(10, ("[CEPH] seekdir(%p, %p, %ld)\n", handle, dirp, offset));
+ ceph_seekdir(handle->data, (struct ceph_dir_result *) dirp, offset);
+}
+
+static long cephwrap_telldir(struct vfs_handle_struct *handle, DIR *dirp)
+{
+ long ret;
+ DEBUG(10, ("[CEPH] telldir(%p, %p)\n", handle, dirp));
+ ret = ceph_telldir(handle->data, (struct ceph_dir_result *) dirp);
+ DEBUG(10, ("[CEPH] telldir(...) = %ld\n", ret));
+ WRAP_RETURN(ret);
+}
+
+static void cephwrap_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
+{
+ DEBUG(10, ("[CEPH] rewinddir(%p, %p)\n", handle, dirp));
+ ceph_rewinddir(handle->data, (struct ceph_dir_result *) dirp);
+}
+
+static int cephwrap_mkdir(struct vfs_handle_struct *handle, const char *path, mode_t mode)
+{
+ int result;
+ bool has_dacl = False;
+ char *parent = NULL;
+
+ DEBUG(10, ("[CEPH] mkdir(%p, %s)\n", handle, path));
+
+ if (lp_inherit_acls(SNUM(handle->conn))
+ && parent_dirname(talloc_tos(), path, &parent, NULL)
+ && (has_dacl = directory_has_default_acl(handle->conn, parent)))
+ mode = 0777;
+
+ TALLOC_FREE(parent);
+
+ result = ceph_mkdir(handle->data, path, mode);
+
+ /*
+ * Note. This order is important
+ */
+ if (result) {
+ WRAP_RETURN(result);
+ } else if (result == 0 && !has_dacl) {
+ /*
+ * We need to do this as the default behavior of POSIX ACLs
+ * is to set the mask to be the requested group permission
+ * bits, not the group permission bits to be the requested
+ * group permission bits. This is not what we want, as it will
+ * mess up any inherited ACL bits that were set. JRA.
+ */
+ int saved_errno = errno; /* We may get ENOSYS */
+ if ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS))
+ errno = saved_errno;
+ }
+
+ return result;
+}
+
+static int cephwrap_rmdir(struct vfs_handle_struct *handle, const char *path)
+{
+ int result;
+
+ DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, path));
+ result = ceph_rmdir(handle->data, path);
+ DEBUG(10, ("[CEPH] rmdir(...) = %d\n", result));
+ WRAP_RETURN(result);
+}
+
+static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp)
+{
+ int result;
+
+ DEBUG(10, ("[CEPH] closedir(%p, %p)\n", handle, dirp));
+ result = ceph_closedir(handle->data, (struct ceph_dir_result *) dirp);
+ DEBUG(10, ("[CEPH] closedir(...) = %d\n", result));
+ WRAP_RETURN(result);
+}
+
+/* File operations */
+
+static int cephwrap_open(struct vfs_handle_struct *handle,
+ struct smb_filename *smb_fname,
+ files_struct *fsp, int flags, mode_t mode)
+{
+ int result = -ENOENT;
+ DEBUG(10, ("[CEPH] open(%p, %s, %p, %d, %d)\n", handle, smb_fname_str_dbg(smb_fname), fsp, flags, mode));
+
+ if (smb_fname->stream_name) {
+ goto out;
+ }
+
+ result = ceph_open(handle->data, smb_fname->base_name, flags, mode);
+out:
+ DEBUG(10, ("[CEPH] open(...) = %d\n", result));
+ WRAP_RETURN(result);
+}
+
+static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp)
+{
+ int result;
+
+ DEBUG(10, ("[CEPH] close(%p, %p)\n", handle, fsp));
+ result = ceph_close(handle->data, fsp->fh->fd);
+ DEBUG(10, ("[CEPH] close(...) = %d\n", result));
+
+ WRAP_RETURN(result);
+}
+
+static ssize_t cephwrap_read(struct vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
+{
+ ssize_t result;
+
+ DEBUG(10, ("[CEPH] read(%p, %p, %p, %llu)\n", handle, fsp, data, llu(n)));
+
+ /* Using -1 for the offset means read/write rather than pread/pwrite */
+ result = ceph_read(handle->data, fsp->fh->fd, data, n, -1);
+ DEBUG(10, ("[CEPH] read(...) = %llu\n", llu(result)));
+ WRAP_RETURN(result);
+}
+
+static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fsp, void *data,
+ size_t n, off_t offset)
--
Samba Shared Repository
More information about the samba-cvs
mailing list