vfs_ceph: remove ceph_fallocate/ceph_ftruncate fallback
[vlendec/samba-autobuild/.git] / source3 / modules / vfs_ceph.c
index 457979ef5e4a4bea87d5df12270eb8ae719570db..3fb5943eca619b135d30b130e9dc0ab8fcd49b0c 100644 (file)
 #include <sys/statvfs.h>
 #include "cephfs/libcephfs.h"
 #include "smbprofile.h"
+#include "modules/posixacl_xattr.h"
+#include "lib/util/tevent_unix.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
+#ifndef LIBCEPHFS_VERSION
+#define LIBCEPHFS_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
+#define LIBCEPHFS_VERSION_CODE LIBCEPHFS_VERSION(0, 0, 0)
+#endif
+
 /*
  * Use %llu whenever we have a 64bit unsigned int, and cast to (long long unsigned)
  */
@@ -79,8 +86,9 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 {
        int ret;
        char buf[256];
-
-       const char * conf_file;
+       int snum = SNUM(handle->conn);
+       const char *conf_file;
+       const char *user_id;
 
        if (cmount) {
                handle->data = cmount; /* We have been here before */
@@ -88,36 +96,34 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
                return 0;
        }
 
-       conf_file = lp_parm_const_string(SNUM(handle->conn), "ceph", "config_file", NULL);
+       /* if config_file and/or user_id are NULL, ceph will use defaults */
+       conf_file = lp_parm_const_string(snum, "ceph", "config_file", NULL);
+       user_id = lp_parm_const_string(snum, "ceph", "user_id", NULL);
 
-       DEBUG(2, ( "[CEPH] calling: ceph_create\n" ));
-       ret = ceph_create(&cmount, NULL);
-       if (ret)
+       DBG_DEBUG("[CEPH] calling: ceph_create\n");
+       ret = ceph_create(&cmount, user_id);
+       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;
+       DBG_DEBUG("[CEPH] calling: ceph_conf_read_file with %s\n",
+                 (conf_file == NULL ? "default path" : conf_file));
+       ret = ceph_conf_read_file(cmount, conf_file);
+       if (ret) {
+               goto err_cm_release;
+       }
 
-       DEBUG(2, ( "[CEPH] calling: ceph_conf_get\n" ));
+       DBG_DEBUG("[CEPH] calling: ceph_conf_get\n");
        ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
-       if (ret < 0)
-               goto err_out;
+       if (ret < 0) {
+               goto err_cm_release;
+       }
 
-       DEBUG(2, ("[CEPH] calling: ceph_mount\n"));
+       DBG_DEBUG("[CEPH] calling: ceph_mount\n");
        ret = ceph_mount(cmount, NULL);
-       if (ret < 0)
-               goto err_out;
-
+       if (ret < 0) {
+               goto err_cm_release;
+       }
 
        /*
         * encode mount context/state into our vfs/connection holding structure
@@ -126,30 +132,48 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
        handle->data = cmount;
        cmount_cnt++;
 
+       /*
+        * Unless we have an async implementation of getxattrat turn this off.
+        */
+       lp_do_parameter(SNUM(handle->conn), "smbd:async dosmode", "false");
+
        return 0;
 
+err_cm_release:
+       ceph_release(cmount);
+       cmount = NULL;
 err_out:
        /*
         * Handle the error correctly. Ceph returns -errno.
         */
-       DEBUG(2, ("[CEPH] Error return: %s\n", strerror(-ret)));
+       DBG_DEBUG("[CEPH] Error return: %s\n", strerror(-ret));
        WRAP_RETURN(ret);
 }
 
 static void cephwrap_disconnect(struct vfs_handle_struct *handle)
 {
+       int ret;
+
        if (!cmount) {
-               DEBUG(0, ("[CEPH] Error, ceph not mounted\n"));
+               DBG_ERR("[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"));
+               DBG_DEBUG("[CEPH] Not shuting down CEPH because still more connections\n");
                return;
        }
 
-       ceph_shutdown(cmount);
+       ret = ceph_unmount(cmount);
+       if (ret < 0) {
+               DBG_ERR("[CEPH] failed to unmount: %s\n", strerror(-ret));
+       }
+
+       ret = ceph_release(cmount);
+       if (ret < 0) {
+               DBG_ERR("[CEPH] failed to release: %s\n", strerror(-ret));
+       }
 
        cmount = NULL;  /* Make it safe */
 }
@@ -157,30 +181,36 @@ static void cephwrap_disconnect(struct vfs_handle_struct *handle)
 /* Disk operations */
 
 static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
-                                  const char *path, uint64_t *bsize,
-                                  uint64_t *dfree, uint64_t *dsize)
+                               const struct smb_filename *smb_fname,
+                               uint64_t *bsize,
+                               uint64_t *dfree,
+                               uint64_t *dsize)
 {
        struct statvfs statvfs_buf;
        int ret;
 
-       if (!(ret = ceph_statfs(handle->data, path, &statvfs_buf))) {
+       if (!(ret = ceph_statfs(handle->data, smb_fname->base_name,
+                       &statvfs_buf))) {
                /*
                 * Provide all the correct values.
                 */
                *bsize = statvfs_buf.f_bsize;
                *dfree = statvfs_buf.f_bavail;
                *dsize = statvfs_buf.f_blocks;
-               disk_norm(bsize, dfree, dsize);
-               DEBUG(10, ("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n",
-                       llu(*bsize), llu(*dfree), llu(*dsize)));
+               DBG_DEBUG("[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));
+               DBG_DEBUG("[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)
+static int cephwrap_get_quota(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               enum SMB_QUOTA_TYPE qtype,
+                               unid_t id,
+                               SMB_DISK_QUOTA *qt)
 {
        /* libceph: Ceph does not implement this */
 #if 0
@@ -220,57 +250,76 @@ static int cephwrap_set_quota(struct vfs_handle_struct *handle,  enum SMB_QUOTA_
 #endif
 }
 
-static int cephwrap_statvfs(struct vfs_handle_struct *handle,  const char *path, vfs_statvfs_struct *statbuf)
+static int cephwrap_statvfs(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               vfs_statvfs_struct *statbuf)
 {
        struct statvfs statvfs_buf;
        int ret;
 
-       ret = ceph_statfs(handle->data, path, &statvfs_buf);
+       ret = ceph_statfs(handle->data, smb_fname->base_name, &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",
-                       (long int)statvfs_buf.f_bsize, (long int)statvfs_buf.f_blocks,
-                       (long int)statvfs_buf.f_bfree, (long int)statvfs_buf.f_bavail));
        }
+
+       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;
+       DBG_DEBUG("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, f_bavail: %ld\n",
+               (long int)statvfs_buf.f_bsize, (long int)statvfs_buf.f_blocks,
+               (long int)statvfs_buf.f_bfree, (long int)statvfs_buf.f_bavail);
+
        return ret;
 }
 
+static uint32_t cephwrap_fs_capabilities(struct vfs_handle_struct *handle,
+                                        enum timestamp_set_resolution *p_ts_res)
+{
+       uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+
+#ifdef HAVE_CEPH_STATX
+       *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
+#else
+       *p_ts_res = TIMESTAMP_SET_MSEC;
+#endif
+
+       return caps;
+}
+
 /* Directory operations */
 
-static DIR *cephwrap_opendir(struct vfs_handle_struct *handle,  const char *fname, const char *mask, uint32 attr)
+static DIR *cephwrap_opendir(struct vfs_handle_struct *handle,
+                            const struct smb_filename *smb_fname,
+                            const char *mask, uint32_t attr)
 {
        int ret = 0;
        struct ceph_dir_result *result;
-       DEBUG(10, ("[CEPH] opendir(%p, %s)\n", handle, fname));
+       DBG_DEBUG("[CEPH] opendir(%p, %s)\n", handle, smb_fname->base_name);
 
        /* Returns NULL if it does not exist or there are problems ? */
-       ret = ceph_opendir(handle->data, fname, &result);
+       ret = ceph_opendir(handle->data, smb_fname->base_name, &result);
        if (ret < 0) {
                result = NULL;
                errno = -ret; /* We return result which is NULL in this case */
        }
 
-       DEBUG(10, ("[CEPH] opendir(...) = %d\n", ret));
+       DBG_DEBUG("[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)
+                              uint32_t attributes)
 {
        int ret = 0;
        struct ceph_dir_result *result;
-       DEBUG(10, ("[CEPH] fdopendir(%p, %p)\n", handle, fsp));
+       DBG_DEBUG("[CEPH] fdopendir(%p, %p)\n", handle, fsp);
 
        ret = ceph_opendir(handle->data, fsp->fsp_name->base_name, &result);
        if (ret < 0) {
@@ -278,7 +327,7 @@ static DIR *cephwrap_fdopendir(struct vfs_handle_struct *handle,
                errno = -ret; /* We return result which is NULL in this case */
        }
 
-       DEBUG(10, ("[CEPH] fdopendir(...) = %d\n", ret));
+       DBG_DEBUG("[CEPH] fdopendir(...) = %d\n", ret);
        return (DIR *) result;
 }
 
@@ -288,9 +337,9 @@ static struct dirent *cephwrap_readdir(struct vfs_handle_struct *handle,
 {
        struct dirent *result;
 
-       DEBUG(10, ("[CEPH] readdir(%p, %p)\n", handle, dirp));
+       DBG_DEBUG("[CEPH] readdir(%p, %p)\n", handle, dirp);
        result = ceph_readdir(handle->data, (struct ceph_dir_result *) dirp);
-       DEBUG(10, ("[CEPH] readdir(...) = %p\n", result));
+       DBG_DEBUG("[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. */
@@ -301,70 +350,55 @@ static struct dirent *cephwrap_readdir(struct vfs_handle_struct *handle,
 
 static void cephwrap_seekdir(struct vfs_handle_struct *handle, DIR *dirp, long offset)
 {
-       DEBUG(10, ("[CEPH] seekdir(%p, %p, %ld)\n", handle, dirp, offset));
+       DBG_DEBUG("[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));
+       DBG_DEBUG("[CEPH] telldir(%p, %p)\n", handle, dirp);
        ret = ceph_telldir(handle->data, (struct ceph_dir_result *) dirp);
-       DEBUG(10, ("[CEPH] telldir(...) = %ld\n", ret));
+       DBG_DEBUG("[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));
+       DBG_DEBUG("[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)
+static int cephwrap_mkdir(struct vfs_handle_struct *handle,
+                         const struct smb_filename *smb_fname,
+                         mode_t mode)
 {
        int result;
-       bool has_dacl = False;
        char *parent = NULL;
+       const char *path = smb_fname->base_name;
 
-       DEBUG(10, ("[CEPH] mkdir(%p, %s)\n", handle, path));
+       DBG_DEBUG("[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)))
+           && 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;
+       return WRAP_RETURN(result);
 }
 
-static int cephwrap_rmdir(struct vfs_handle_struct *handle,  const char *path)
+static int cephwrap_rmdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        int result;
 
-       DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, path));
-       result = ceph_rmdir(handle->data, path);
-       DEBUG(10, ("[CEPH] rmdir(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] rmdir(%p, %s)\n", handle, smb_fname->base_name);
+       result = ceph_rmdir(handle->data, smb_fname->base_name);
+       DBG_DEBUG("[CEPH] rmdir(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -372,9 +406,9 @@ static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp)
 {
        int result;
 
-       DEBUG(10, ("[CEPH] closedir(%p, %p)\n", handle, dirp));
+       DBG_DEBUG("[CEPH] closedir(%p, %p)\n", handle, dirp);
        result = ceph_closedir(handle->data, (struct ceph_dir_result *) dirp);
-       DEBUG(10, ("[CEPH] closedir(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] closedir(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -385,7 +419,8 @@ static int cephwrap_open(struct vfs_handle_struct *handle,
                        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));
+       DBG_DEBUG("[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;
@@ -393,7 +428,7 @@ static int cephwrap_open(struct vfs_handle_struct *handle,
 
        result = ceph_open(handle->data, smb_fname->base_name, flags, mode);
 out:
-       DEBUG(10, ("[CEPH] open(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] open(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -401,22 +436,10 @@ static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
 
-       DEBUG(10, ("[CEPH] close(%p, %p)\n", handle, fsp));
+       DBG_DEBUG("[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)));
+       DBG_DEBUG("[CEPH] close(...) = %d\n", result);
 
-       /* 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);
 }
 
@@ -425,28 +448,63 @@ static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fs
 {
        ssize_t result;
 
-       DEBUG(10, ("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)));
+       DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset));
 
        result = ceph_read(handle->data, fsp->fh->fd, data, n, offset);
-       DEBUG(10, ("[CEPH] pread(...) = %llu\n", llu(result)));
+       DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result));
        WRAP_RETURN(result);
 }
 
+struct cephwrap_pread_state {
+       ssize_t bytes_read;
+       struct vfs_aio_state vfs_aio_state;
+};
 
-static ssize_t cephwrap_write(struct vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
-{
-       ssize_t result;
+/*
+ * Fake up an async ceph read by calling the synchronous API.
+ */
+static struct tevent_req *cephwrap_pread_send(struct vfs_handle_struct *handle,
+                                             TALLOC_CTX *mem_ctx,
+                                             struct tevent_context *ev,
+                                             struct files_struct *fsp,
+                                             void *data,
+                                             size_t n, off_t offset)
+{
+       struct tevent_req *req = NULL;
+       struct cephwrap_pread_state *state = NULL;
+       int ret = -1;
+
+       DBG_DEBUG("[CEPH] %s\n", __func__);
+       req = tevent_req_create(mem_ctx, &state, struct cephwrap_pread_state);
+       if (req == NULL) {
+               return NULL;
+       }
 
-       DEBUG(10, ("[CEPH] write(%p, %p, %p, %llu)\n", handle, fsp, data, llu(n)));
+       ret = ceph_read(handle->data, fsp->fh->fd, data, n, offset);
+       if (ret < 0) {
+               /* ceph returns -errno on error. */
+               tevent_req_error(req, -ret);
+               return tevent_req_post(req, ev);
+       }
 
-       result = ceph_write(handle->data, fsp->fh->fd, data, n, -1);
+       state->bytes_read = ret;
+       tevent_req_done(req);
+       /* Return and schedule the completion of the call. */
+       return tevent_req_post(req, ev);
+}
 
-       DEBUG(10, ("[CEPH] write(...) = %llu\n", llu(result)));
-       if (result < 0) {
-               WRAP_RETURN(result);
+static ssize_t cephwrap_pread_recv(struct tevent_req *req,
+                                  struct vfs_aio_state *vfs_aio_state)
+{
+       struct cephwrap_pread_state *state =
+               tevent_req_data(req, struct cephwrap_pread_state);
+
+       DBG_DEBUG("[CEPH] %s\n", __func__);
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
+               return -1;
        }
-       fsp->fh->pos += result;
-       return result;
+       *vfs_aio_state = state->vfs_aio_state;
+       return state->bytes_read;
 }
 
 static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *fsp, const void *data,
@@ -454,17 +512,69 @@ static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *f
 {
        ssize_t result;
 
-       DEBUG(10, ("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)));
+       DBG_DEBUG("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset));
        result = ceph_write(handle->data, fsp->fh->fd, data, n, offset);
-       DEBUG(10, ("[CEPH] pwrite(...) = %llu\n", llu(result)));
+       DBG_DEBUG("[CEPH] pwrite(...) = %llu\n", llu(result));
        WRAP_RETURN(result);
 }
 
+struct cephwrap_pwrite_state {
+       ssize_t bytes_written;
+       struct vfs_aio_state vfs_aio_state;
+};
+
+/*
+ * Fake up an async ceph write by calling the synchronous API.
+ */
+static struct tevent_req *cephwrap_pwrite_send(struct vfs_handle_struct *handle,
+                                              TALLOC_CTX *mem_ctx,
+                                              struct tevent_context *ev,
+                                              struct files_struct *fsp,
+                                              const void *data,
+                                              size_t n, off_t offset)
+{
+       struct tevent_req *req = NULL;
+       struct cephwrap_pwrite_state *state = NULL;
+       int ret = -1;
+
+       DBG_DEBUG("[CEPH] %s\n", __func__);
+       req = tevent_req_create(mem_ctx, &state, struct cephwrap_pwrite_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       ret = ceph_write(handle->data, fsp->fh->fd, data, n, offset);
+       if (ret < 0) {
+               /* ceph returns -errno on error. */
+               tevent_req_error(req, -ret);
+               return tevent_req_post(req, ev);
+       }
+
+       state->bytes_written = ret;
+       tevent_req_done(req);
+       /* Return and schedule the completion of the call. */
+       return tevent_req_post(req, ev);
+}
+
+static ssize_t cephwrap_pwrite_recv(struct tevent_req *req,
+                                   struct vfs_aio_state *vfs_aio_state)
+{
+       struct cephwrap_pwrite_state *state =
+               tevent_req_data(req, struct cephwrap_pwrite_state);
+
+       DBG_DEBUG("[CEPH] %s\n", __func__);
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
+               return -1;
+       }
+       *vfs_aio_state = state->vfs_aio_state;
+       return state->bytes_written;
+}
+
 static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)
 {
        off_t result = 0;
 
-       DEBUG(10, ("[CEPH] cephwrap_lseek\n"));
+       DBG_DEBUG("[CEPH] cephwrap_lseek\n");
        /* Cope with 'stat' file opens. */
        if (fsp->fh->fd != -1) {
                result = ceph_lseek(handle->data, fsp->fh->fd, offset, whence);
@@ -478,7 +588,7 @@ static ssize_t cephwrap_sendfile(struct vfs_handle_struct *handle, int tofd, fil
        /*
         * We cannot support sendfile because libceph is in user space.
         */
-       DEBUG(10, ("[CEPH] cephwrap_sendfile\n"));
+       DBG_DEBUG("[CEPH] cephwrap_sendfile\n");
        errno = ENOTSUP;
        return -1;
 }
@@ -492,7 +602,7 @@ static ssize_t cephwrap_recvfile(struct vfs_handle_struct *handle,
        /*
         * We cannot support recvfile because libceph is in user space.
         */
-       DEBUG(10, ("[CEPH] cephwrap_recvfile\n"));
+       DBG_DEBUG("[CEPH] cephwrap_recvfile\n");
        errno=ENOTSUP;
        return -1;
 }
@@ -502,7 +612,7 @@ static int cephwrap_rename(struct vfs_handle_struct *handle,
                          const struct smb_filename *smb_fname_dst)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] cephwrap_rename\n"));
+       DBG_DEBUG("[CEPH] cephwrap_rename\n");
        if (smb_fname_src->stream_name || smb_fname_dst->stream_name) {
                errno = ENOENT;
                return result;
@@ -512,41 +622,202 @@ static int cephwrap_rename(struct vfs_handle_struct *handle,
        WRAP_RETURN(result);
 }
 
-static int cephwrap_fsync(struct vfs_handle_struct *handle, files_struct *fsp)
+/*
+ * Fake up an async ceph fsync by calling the synchronous API.
+ */
+
+static struct tevent_req *cephwrap_fsync_send(struct vfs_handle_struct *handle,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       files_struct *fsp)
 {
-       int result;
-       DEBUG(10, ("[CEPH] cephwrap_fsync\n"));
-       result = ceph_fsync(handle->data, fsp->fh->fd, false);
-       WRAP_RETURN(result);
+       struct tevent_req *req = NULL;
+       struct vfs_aio_state *state = NULL;
+       int ret = -1;
+
+       DBG_DEBUG("[CEPH] cephwrap_fsync_send\n");
+
+       req = tevent_req_create(mem_ctx, &state, struct vfs_aio_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       /* Make sync call. */
+       ret = ceph_fsync(handle->data, fsp->fh->fd, false);
+
+       if (ret != 0) {
+               /* ceph_fsync returns -errno on error. */
+               tevent_req_error(req, -ret);
+               return tevent_req_post(req, ev);
+       }
+
+       /* Mark it as done. */
+       tevent_req_done(req);
+       /* Return and schedule the completion of the call. */
+       return tevent_req_post(req, ev);
 }
 
-static void cephwrap_init_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
+static int cephwrap_fsync_recv(struct tevent_req *req,
+                               struct vfs_aio_state *vfs_aio_state)
 {
-       ZERO_STRUCT(*dst);
+       struct vfs_aio_state *state =
+               tevent_req_data(req, struct vfs_aio_state);
+
+       DBG_DEBUG("[CEPH] cephwrap_fsync_recv\n");
 
-       dst->st_ex_dev = src->st_dev;
-       dst->st_ex_ino = src->st_ino;
-       dst->st_ex_mode = src->st_mode;
-       dst->st_ex_nlink = src->st_nlink;
-       dst->st_ex_uid = src->st_uid;
-       dst->st_ex_gid = src->st_gid;
-       dst->st_ex_rdev = src->st_rdev;
-       dst->st_ex_size = src->st_size;
-       dst->st_ex_atime.tv_sec = src->st_atime;
-       dst->st_ex_mtime.tv_sec = src->st_mtime;
-       dst->st_ex_ctime.tv_sec = src->st_ctime;
-       dst->st_ex_btime.tv_sec = src->st_mtime;
-       dst->st_ex_blksize = src->st_blksize;
-       dst->st_ex_blocks = src->st_blocks;
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
+               return -1;
+       }
+       *vfs_aio_state = *state;
+       return 0;
+}
+
+#ifdef HAVE_CEPH_STATX
+#define SAMBA_STATX_ATTR_MASK  (CEPH_STATX_BASIC_STATS|CEPH_STATX_BTIME)
+
+static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct ceph_statx *stx)
+{
+       DBG_DEBUG("[CEPH]\tstx = {dev = %llx, ino = %llu, mode = 0x%x, "
+                 "nlink = %llu, uid = %d, gid = %d, rdev = %llx, size = %llu, "
+                 "blksize = %llu, blocks = %llu, atime = %llu, mtime = %llu, "
+                 "ctime = %llu, btime = %llu}\n",
+                 llu(stx->stx_dev), llu(stx->stx_ino), stx->stx_mode,
+                 llu(stx->stx_nlink), stx->stx_uid, stx->stx_gid,
+                 llu(stx->stx_rdev), llu(stx->stx_size), llu(stx->stx_blksize),
+                 llu(stx->stx_blocks), llu(stx->stx_atime.tv_sec),
+                 llu(stx->stx_mtime.tv_sec), llu(stx->stx_ctime.tv_sec),
+                 llu(stx->stx_btime.tv_sec));
+
+       if ((stx->stx_mask & SAMBA_STATX_ATTR_MASK) != SAMBA_STATX_ATTR_MASK) {
+               DBG_WARNING("%s: stx->stx_mask is incorrect (wanted %x, got %x)",
+                               __func__, SAMBA_STATX_ATTR_MASK, stx->stx_mask);
+       }
+
+       dst->st_ex_dev = stx->stx_dev;
+       dst->st_ex_rdev = stx->stx_rdev;
+       dst->st_ex_ino = stx->stx_ino;
+       dst->st_ex_mode = stx->stx_mode;
+       dst->st_ex_uid = stx->stx_uid;
+       dst->st_ex_gid = stx->stx_gid;
+       dst->st_ex_size = stx->stx_size;
+       dst->st_ex_nlink = stx->stx_nlink;
+       dst->st_ex_atime = stx->stx_atime;
+       dst->st_ex_btime = stx->stx_btime;
+       dst->st_ex_ctime = stx->stx_ctime;
+       dst->st_ex_mtime = stx->stx_mtime;
+       dst->st_ex_calculated_birthtime = false;
+       dst->st_ex_blksize = stx->stx_blksize;
+       dst->st_ex_blocks = stx->stx_blocks;
 }
 
+static int cephwrap_stat(struct vfs_handle_struct *handle,
+                       struct smb_filename *smb_fname)
+{
+       int result = -1;
+       struct ceph_statx stx;
+
+       DBG_DEBUG("[CEPH] stat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname));
+
+       if (smb_fname->stream_name) {
+               errno = ENOENT;
+               return result;
+       }
+
+       result = ceph_statx(handle->data, smb_fname->base_name, &stx,
+                               SAMBA_STATX_ATTR_MASK, 0);
+       DBG_DEBUG("[CEPH] statx(...) = %d\n", result);
+       if (result < 0) {
+               WRAP_RETURN(result);
+       }
+
+       init_stat_ex_from_ceph_statx(&smb_fname->st, &stx);
+       DBG_DEBUG("[CEPH] mode = 0x%x\n", smb_fname->st.st_ex_mode);
+       return result;
+}
+
+static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
+{
+       int result = -1;
+       struct ceph_statx stx;
+
+       DBG_DEBUG("[CEPH] fstat(%p, %d)\n", handle, fsp->fh->fd);
+       result = ceph_fstatx(handle->data, fsp->fh->fd, &stx,
+                               SAMBA_STATX_ATTR_MASK, 0);
+       DBG_DEBUG("[CEPH] fstat(...) = %d\n", result);
+       if (result < 0) {
+               WRAP_RETURN(result);
+       }
+
+       init_stat_ex_from_ceph_statx(sbuf, &stx);
+       DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode);
+       return result;
+}
+
+static int cephwrap_lstat(struct vfs_handle_struct *handle,
+                        struct smb_filename *smb_fname)
+{
+       int result = -1;
+       struct ceph_statx stx;
+
+       DBG_DEBUG("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname));
+
+       if (smb_fname->stream_name) {
+               errno = ENOENT;
+               return result;
+       }
+
+       result = ceph_statx(handle->data, smb_fname->base_name, &stx,
+                               SAMBA_STATX_ATTR_MASK, AT_SYMLINK_NOFOLLOW);
+       DBG_DEBUG("[CEPH] lstat(...) = %d\n", result);
+       if (result < 0) {
+               WRAP_RETURN(result);
+       }
+
+       init_stat_ex_from_ceph_statx(&smb_fname->st, &stx);
+       return result;
+}
+
+static int cephwrap_ntimes(struct vfs_handle_struct *handle,
+                        const struct smb_filename *smb_fname,
+                        struct smb_file_time *ft)
+{
+       struct ceph_statx stx = { 0 };
+       int result;
+       int mask = 0;
+
+       if (!null_timespec(ft->atime)) {
+               stx.stx_atime = ft->atime;
+               mask |= CEPH_SETATTR_ATIME;
+       }
+       if (!null_timespec(ft->mtime)) {
+               stx.stx_mtime = ft->mtime;
+               mask |= CEPH_SETATTR_MTIME;
+       }
+       if (!null_timespec(ft->create_time)) {
+               stx.stx_btime = ft->create_time;
+               mask |= CEPH_SETATTR_BTIME;
+       }
+
+       if (!mask) {
+               return 0;
+       }
+
+       result = ceph_setattrx(handle->data, smb_fname->base_name, &stx, mask, 0);
+       DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname),
+                               ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec,
+                               ft->create_time.tv_sec, result);
+       return result;
+}
+
+#else /* HAVE_CEPH_STATX */
+
 static int cephwrap_stat(struct vfs_handle_struct *handle,
                        struct smb_filename *smb_fname)
 {
        int result = -1;
        struct stat stbuf;
 
-       DEBUG(10, ("[CEPH] stat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
+       DBG_DEBUG("[CEPH] stat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname));
 
        if (smb_fname->stream_name) {
                errno = ENOENT;
@@ -554,19 +825,22 @@ static int cephwrap_stat(struct vfs_handle_struct *handle,
        }
 
        result = ceph_stat(handle->data, smb_fname->base_name, (struct stat *) &stbuf);
-       DEBUG(10, ("[CEPH] stat(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] stat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               DEBUG(10, ("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
-                          "uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
-                          "blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
-                          llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
-                          stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
-                          llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime)));
        }
-       cephwrap_init_stat_ex_from_stat(&(smb_fname->st), &stbuf);
-       DEBUG(10, ("[CEPH] mode = 0x%x\n", smb_fname->st.st_ex_mode));
+
+       DBG_DEBUG("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
+                  "uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
+                  "blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
+                  llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
+                  stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
+                  llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime));
+
+       init_stat_ex_from_stat(
+                       &smb_fname->st, &stbuf,
+                       lp_fake_directory_create_times(SNUM(handle->conn)));
+       DBG_DEBUG("[CEPH] mode = 0x%x\n", smb_fname->st.st_ex_mode);
        return result;
 }
 
@@ -575,22 +849,24 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, S
        int result = -1;
        struct stat stbuf;
 
-       DEBUG(10, ("[CEPH] fstat(%p, %d)\n", handle, fsp->fh->fd));
+       DBG_DEBUG("[CEPH] fstat(%p, %d)\n", handle, fsp->fh->fd);
        result = ceph_fstat(handle->data, fsp->fh->fd, (struct stat *) &stbuf);
-       DEBUG(10, ("[CEPH] fstat(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] fstat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               DEBUG(10, ("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
-                          "uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
-                          "blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
-                          llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
-                          stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
-                          llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime)));
        }
 
-       cephwrap_init_stat_ex_from_stat(sbuf, &stbuf);
-       DEBUG(10, ("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode));
+       DBG_DEBUG("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
+                  "uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
+                  "blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
+                  llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
+                  stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
+                  llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime));
+
+       init_stat_ex_from_stat(
+                       sbuf, &stbuf,
+                       lp_fake_directory_create_times(SNUM(handle->conn)));
+       DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode);
        return result;
 }
 
@@ -600,7 +876,7 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle,
        int result = -1;
        struct stat stbuf;
 
-       DEBUG(10, ("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
+       DBG_DEBUG("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname));
 
        if (smb_fname->stream_name) {
                errno = ENOENT;
@@ -608,53 +884,75 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle,
        }
 
        result = ceph_lstat(handle->data, smb_fname->base_name, &stbuf);
-       DEBUG(10, ("[CEPH] lstat(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] lstat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
        }
-       cephwrap_init_stat_ex_from_stat(&(smb_fname->st), &stbuf);
+
+       init_stat_ex_from_stat(
+                       &smb_fname->st, &stbuf,
+                       lp_fake_directory_create_times(SNUM(handle->conn)));
        return result;
 }
 
+static int cephwrap_ntimes(struct vfs_handle_struct *handle,
+                        const struct smb_filename *smb_fname,
+                        struct smb_file_time *ft)
+{
+       struct utimbuf buf;
+       int result;
+
+       if (null_timespec(ft->atime)) {
+               buf.actime = smb_fname->st.st_ex_atime.tv_sec;
+       } else {
+               buf.actime = ft->atime.tv_sec;
+       }
+       if (null_timespec(ft->mtime)) {
+               buf.modtime = smb_fname->st.st_ex_mtime.tv_sec;
+       } else {
+               buf.modtime = ft->mtime.tv_sec;
+       }
+       if (!null_timespec(ft->create_time)) {
+               set_create_timespec_ea(handle->conn, smb_fname,
+                                      ft->create_time);
+       }
+       if (buf.actime == smb_fname->st.st_ex_atime.tv_sec &&
+           buf.modtime == smb_fname->st.st_ex_mtime.tv_sec) {
+               return 0;
+       }
+
+       result = ceph_utime(handle->data, smb_fname->base_name, &buf);
+       DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname),
+                               ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec,
+                               ft->create_time.tv_sec, result);
+       return result;
+}
+#endif /* HAVE_CEPH_STATX */
+
 static int cephwrap_unlink(struct vfs_handle_struct *handle,
                          const struct smb_filename *smb_fname)
 {
        int result = -1;
 
-       DEBUG(10, ("[CEPH] unlink(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
+       DBG_DEBUG("[CEPH] unlink(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname));
        if (smb_fname->stream_name) {
                errno = ENOENT;
                return result;
        }
        result = ceph_unlink(handle->data, smb_fname->base_name);
-       DEBUG(10, ("[CEPH] unlink(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] unlink(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static int cephwrap_chmod(struct vfs_handle_struct *handle,  const char *path, mode_t mode)
+static int cephwrap_chmod(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode)
 {
        int result;
 
-       DEBUG(10, ("[CEPH] chmod(%p, %s, %d)\n", handle, path, mode));
-
-       /*
-        * We need to do this due to the fact that the default POSIX ACL
-        * chmod modifies the ACL *mask* for the group owner, not the
-        * group owner bits directly. JRA.
-        */
-
-
-       {
-               int saved_errno = errno; /* We might get ENOSYS */
-               if ((result = SMB_VFS_CHMOD_ACL(handle->conn, path, mode)) == 0) {
-                       return result;
-               }
-               /* Error - return the old errno. */
-               errno = saved_errno;
-       }
-
-       result = ceph_chmod(handle->data, path, mode);
-       DEBUG(10, ("[CEPH] chmod(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] chmod(%p, %s, %d)\n", handle, smb_fname->base_name, mode);
+       result = ceph_chmod(handle->data, smb_fname->base_name, mode);
+       DBG_DEBUG("[CEPH] chmod(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -662,26 +960,11 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp,
 {
        int result;
 
-       DEBUG(10, ("[CEPH] fchmod(%p, %p, %d)\n", handle, fsp, mode));
-
-       /*
-        * We need to do this due to the fact that the default POSIX ACL
-        * chmod modifies the ACL *mask* for the group owner, not the
-        * group owner bits directly. JRA.
-        */
-
-       {
-               int saved_errno = errno; /* We might get ENOSYS */
-               if ((result = SMB_VFS_FCHMOD_ACL(fsp, mode)) == 0) {
-                       return result;
-               }
-               /* Error - return the old errno. */
-               errno = saved_errno;
-       }
+       DBG_DEBUG("[CEPH] fchmod(%p, %p, %d)\n", handle, fsp, mode);
 
 #if defined(HAVE_FCHMOD)
        result = ceph_fchmod(handle->data, fsp->fh->fd, mode);
-       DEBUG(10, ("[CEPH] fchmod(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] fchmod(...) = %d\n", result);
        WRAP_RETURN(result);
 #else
        errno = ENOSYS;
@@ -689,12 +972,15 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp,
        return -1;
 }
 
-static int cephwrap_chown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int cephwrap_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
-       DEBUG(10, ("[CEPH] chown(%p, %s, %d, %d)\n", handle, path, uid, gid));
-       result = ceph_chown(handle->data, path, uid, gid);
-       DEBUG(10, ("[CEPH] chown(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] chown(%p, %s, %d, %d)\n", handle, smb_fname->base_name, uid, gid);
+       result = ceph_chown(handle->data, smb_fname->base_name, uid, gid);
+       DBG_DEBUG("[CEPH] chown(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -703,9 +989,9 @@ static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct *fsp,
        int result;
 #ifdef HAVE_FCHOWN
 
-       DEBUG(10, ("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid));
+       DBG_DEBUG("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid);
        result = ceph_fchown(handle->data, fsp->fh->fd, uid, gid);
-       DEBUG(10, ("[CEPH] fchown(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] fchown(...) = %d\n", result);
        WRAP_RETURN(result);
 #else
        errno = ENOSYS;
@@ -714,78 +1000,44 @@ static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct *fsp,
        return result;
 }
 
-static int cephwrap_lchown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int cephwrap_lchown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
-
-       DEBUG(10, ("[CEPH] lchown(%p, %s, %d, %d)\n", handle, path, uid, gid));
-       result = ceph_lchown(handle->data, path, uid, gid);
-       DEBUG(10, ("[CEPH] lchown(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] lchown(%p, %s, %d, %d)\n", handle, smb_fname->base_name, uid, gid);
+       result = ceph_lchown(handle->data, smb_fname->base_name, uid, gid);
+       DBG_DEBUG("[CEPH] lchown(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static int cephwrap_chdir(struct vfs_handle_struct *handle,  const char *path)
+static int cephwrap_chdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] chdir(%p, %s)\n", handle, path));
-       /*
-        * If the path is just / use chdir because Ceph is below / and
-        * cannot deal with changing directory above its mount point
-        */
-       if (path && !strcmp(path, "/"))
-               return chdir(path);
-
-       result = ceph_chdir(handle->data, path);
-       DEBUG(10, ("[CEPH] chdir(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] chdir(%p, %s)\n", handle, smb_fname->base_name);
+       result = ceph_chdir(handle->data, smb_fname->base_name);
+       DBG_DEBUG("[CEPH] chdir(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static char *cephwrap_getwd(struct vfs_handle_struct *handle)
+static struct smb_filename *cephwrap_getwd(struct vfs_handle_struct *handle,
+                       TALLOC_CTX *ctx)
 {
        const char *cwd = ceph_getcwd(handle->data);
-       DEBUG(10, ("[CEPH] getwd(%p) = %s\n", handle, cwd));
-       return SMB_STRDUP(cwd);
-}
-
-static int cephwrap_ntimes(struct vfs_handle_struct *handle,
-                        const struct smb_filename *smb_fname,
-                        struct smb_file_time *ft)
-{
-       struct utimbuf buf;
-       int result;
-
-       if (null_timespec(ft->atime)) {
-               buf.actime = smb_fname->st.st_ex_atime.tv_sec;
-       } else {
-               buf.actime = ft->atime.tv_sec;
-       }
-       if (null_timespec(ft->mtime)) {
-               buf.modtime = smb_fname->st.st_ex_mtime.tv_sec;
-       } else {
-               buf.modtime = ft->mtime.tv_sec;
-       }
-       if (!null_timespec(ft->create_time)) {
-               set_create_timespec_ea(handle->conn, smb_fname,
-                                      ft->create_time);
-       }
-       if (buf.actime == smb_fname->st.st_ex_atime.tv_sec &&
-           buf.modtime == smb_fname->st.st_ex_mtime.tv_sec) {
-               return 0;
-       }
-
-       result = ceph_utime(handle->data, smb_fname->base_name, &buf);
-       DEBUG(10, ("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname),
-                               ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec,
-                               ft->create_time.tv_sec, result));
-       return result;
+       DBG_DEBUG("[CEPH] getwd(%p) = %s\n", handle, cwd);
+       return synthetic_smb_fname(ctx,
+                               cwd,
+                               NULL,
+                               NULL,
+                               0);
 }
 
 static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
 {
        off_t space_to_write;
-       uint64_t space_avail;
-       uint64_t bsize,dfree,dsize;
-       int ret;
+       int result;
        NTSTATUS status;
        SMB_STRUCT_STAT *pst;
 
@@ -804,134 +1056,66 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str
                return 0;
 
        /* Shrink - just ftruncate. */
-       if (pst->st_ex_size > len)
-               return ftruncate(fsp->fh->fd, len);
-
-       space_to_write = len - pst->st_ex_size;
-
-       /* for allocation try fallocate first. This can fail on some
-          platforms e.g. when the filesystem doesn't support it and no
-          emulation is being done by the libc (like on AIX with JFS1). In that
-          case we do our own emulation. fallocate implementations can
-          return ENOTSUP or EINVAL in cases like that. */
-       ret = SMB_VFS_FALLOCATE(fsp, 0, pst->st_ex_size, space_to_write);
-       if (ret == -1 && errno == ENOSPC) {
-               return -1;
-       }
-       if (ret == 0) {
-               return 0;
-       }
-       DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
-               "error %d. Falling back to slow manual allocation\n", errno));
-
-       /* available disk space is enough or not? */
-       space_avail = get_dfree_info(fsp->conn,
-                                    fsp->fsp_name->base_name,
-                                    &bsize, &dfree, &dsize);
-       /* space_avail is 1k blocks */
-       if (space_avail == (uint64_t)-1 ||
-                       ((uint64_t)space_to_write/1024 > space_avail) ) {
-               errno = ENOSPC;
-               return -1;
+       if (pst->st_ex_size > len) {
+               result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
+               WRAP_RETURN(result);
        }
 
-       /* Write out the real space on disk. */
-       return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
+       space_to_write = len - pst->st_ex_size;
+       result = ceph_fallocate(handle->data, fsp->fh->fd, 0, pst->st_ex_size,
+                               space_to_write);
+       WRAP_RETURN(result);
 }
 
 static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
 {
        int result = -1;
-       SMB_STRUCT_STAT st;
-       char c = 0;
-       off_t currpos;
 
-       DEBUG(10, ("[CEPH] ftruncate(%p, %p, %llu\n", handle, fsp, llu(len)));
+       DBG_DEBUG("[CEPH] ftruncate(%p, %p, %llu\n", handle, fsp, llu(len));
 
        if (lp_strict_allocate(SNUM(fsp->conn))) {
-               result = strict_allocate_ftruncate(handle, fsp, len);
-               return result;
+               return strict_allocate_ftruncate(handle, fsp, len);
        }
 
-       /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
-          sys_ftruncate if the system supports it. Then I discovered that
-          you can have some filesystems that support ftruncate
-          expansion and some that don't! On Linux fat can't do
-          ftruncate extend but ext2 can. */
-
        result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
-       if (result == 0)
-               goto done;
-
-       /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
-          extend a file with ftruncate. Provide alternate implementation
-          for this */
-       currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
-       if (currpos == -1) {
-               goto done;
-       }
-
-       /* Do an fstat to see if the file is longer than the requested
-          size in which case the ftruncate above should have
-          succeeded or shorter, in which case seek to len - 1 and
-          write 1 byte of zero */
-       if (SMB_VFS_FSTAT(fsp, &st) == -1) {
-               goto done;
-       }
-
-#ifdef S_ISFIFO
-       if (S_ISFIFO(st.st_ex_mode)) {
-               result = 0;
-               goto done;
-       }
-#endif
-
-       if (st.st_ex_size == len) {
-               result = 0;
-               goto done;
-       }
-
-       if (st.st_ex_size > len) {
-               /* the sys_ftruncate should have worked */
-               goto done;
-       }
-
-       if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
-               goto done;
-
-       if (SMB_VFS_WRITE(fsp, &c, 1)!=1)
-               goto done;
-
-       /* Seek to where we were */
-       if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
-               goto done;
-       result = 0;
+       WRAP_RETURN(result);
+}
 
-  done:
+static int cephwrap_fallocate(struct vfs_handle_struct *handle,
+                             struct files_struct *fsp,
+                             uint32_t mode,
+                             off_t offset,
+                             off_t len)
+{
+       int result;
 
-       return result;
+       DBG_DEBUG("[CEPH] fallocate(%p, %p, %u, %llu, %llu\n",
+                 handle, fsp, mode, llu(offset), llu(len));
+       /* unsupported mode flags are rejected by libcephfs */
+       result = ceph_fallocate(handle->data, fsp->fh->fd, mode, offset, len);
+       DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result);
+       WRAP_RETURN(result);
 }
 
 static bool cephwrap_lock(struct vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type)
 {
-       DEBUG(10, ("[CEPH] lock\n"));
+       DBG_DEBUG("[CEPH] lock\n");
        return true;
 }
 
 static int cephwrap_kernel_flock(struct vfs_handle_struct *handle, files_struct *fsp,
-                               uint32 share_mode, uint32 access_mask)
+                               uint32_t share_mode, uint32_t access_mask)
 {
-       DEBUG(10, ("[CEPH] kernel_flock\n"));
-       /*
-        * We must return zero here and pretend all is good.
-        * One day we might have this in CEPH.
-        */
-       return 0;
+       DBG_ERR("[CEPH] flock unsupported! Consider setting "
+               "\"kernel share modes = no\"\n");
+
+       errno = ENOSYS;
+       return -1;
 }
 
 static bool cephwrap_getlock(struct vfs_handle_struct *handle, files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
 {
-       DEBUG(10, ("[CEPH] getlock returning false and errno=0\n"));
+       DBG_DEBUG("[CEPH] getlock returning false and errno=0\n");
 
        errno = 0;
        return false;
@@ -947,44 +1131,63 @@ static int cephwrap_linux_setlease(struct vfs_handle_struct *handle, files_struc
 {
        int result = -1;
 
-       DEBUG(10, ("[CEPH] linux_setlease\n"));
+       DBG_DEBUG("[CEPH] linux_setlease\n");
        errno = ENOSYS;
        return result;
 }
 
-static int cephwrap_symlink(struct vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
+static int cephwrap_symlink(struct vfs_handle_struct *handle,
+               const char *link_target,
+               const struct smb_filename *new_smb_fname)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] symlink(%p, %s, %s)\n", handle, oldpath, newpath));
-       result = ceph_symlink(handle->data, oldpath, newpath);
-       DEBUG(10, ("[CEPH] symlink(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] symlink(%p, %s, %s)\n", handle,
+                       link_target,
+                       new_smb_fname->base_name);
+       result = ceph_symlink(handle->data,
+                       link_target,
+                       new_smb_fname->base_name);
+       DBG_DEBUG("[CEPH] symlink(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static int cephwrap_readlink(struct vfs_handle_struct *handle,  const char *path, char *buf, size_t bufsiz)
+static int cephwrap_readlink(struct vfs_handle_struct *handle,
+               const struct smb_filename *smb_fname,
+               char *buf,
+               size_t bufsiz)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] readlink(%p, %s, %p, %llu)\n", handle, path, buf, llu(bufsiz)));
-       result = ceph_readlink(handle->data, path, buf, bufsiz);
-       DEBUG(10, ("[CEPH] readlink(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] readlink(%p, %s, %p, %llu)\n", handle,
+                       smb_fname->base_name, buf, llu(bufsiz));
+       result = ceph_readlink(handle->data, smb_fname->base_name, buf, bufsiz);
+       DBG_DEBUG("[CEPH] readlink(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static int cephwrap_link(struct vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
+static int cephwrap_link(struct vfs_handle_struct *handle,
+               const struct smb_filename *old_smb_fname,
+               const struct smb_filename *new_smb_fname)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] link(%p, %s, %s)\n", handle, oldpath, newpath));
-       result = ceph_link(handle->data, oldpath, newpath);
-       DEBUG(10, ("[CEPH] link(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] link(%p, %s, %s)\n", handle,
+                       old_smb_fname->base_name,
+                       new_smb_fname->base_name);
+       result = ceph_link(handle->data,
+                               old_smb_fname->base_name,
+                               new_smb_fname->base_name);
+       DBG_DEBUG("[CEPH] link(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
-static int cephwrap_mknod(struct vfs_handle_struct *handle,  const char *pathname, mode_t mode, SMB_DEV_T dev)
+static int cephwrap_mknod(struct vfs_handle_struct *handle,
+               const struct smb_filename *smb_fname,
+               mode_t mode,
+               SMB_DEV_T dev)
 {
        int result = -1;
-       DEBUG(10, ("[CEPH] mknod(%p, %s)\n", handle, pathname));
-       result = ceph_mknod(handle->data, pathname, mode, dev);
-       DEBUG(10, ("[CEPH] mknod(...) = %d\n", result));
+       DBG_DEBUG("[CEPH] mknod(%p, %s)\n", handle, smb_fname->base_name);
+       result = ceph_mknod(handle->data, smb_fname->base_name, mode, dev);
+       DBG_DEBUG("[CEPH] mknod(...) = %d\n", result);
        WRAP_RETURN(result);
 }
 
@@ -992,53 +1195,48 @@ static int cephwrap_mknod(struct vfs_handle_struct *handle,  const char *pathnam
  * This is a simple version of real-path ... a better version is needed to
  * ask libceph about symbolic links.
  */
-static char *cephwrap_realpath(struct vfs_handle_struct *handle,  const char *path)
+static struct smb_filename *cephwrap_realpath(struct vfs_handle_struct *handle,
+                               TALLOC_CTX *ctx,
+                               const struct smb_filename *smb_fname)
 {
-       char *result;
+       char *result = NULL;
+       const char *path = smb_fname->base_name;
        size_t len = strlen(path);
+       struct smb_filename *result_fname = NULL;
+       int r = -1;
 
-       result = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
        if (len && (path[0] == '/')) {
-               int r = asprintf(&result, "%s", path);
-               if (r < 0) return NULL;
+               r = asprintf(&result, "%s", path);
        } else if ((len >= 2) && (path[0] == '.') && (path[1] == '/')) {
                if (len == 2) {
-                       int r = asprintf(&result, "%s",
+                       r = asprintf(&result, "%s",
                                        handle->conn->connectpath);
-                       if (r < 0) return NULL;
                } else {
-                       int r = asprintf(&result, "%s/%s",
+                       r = asprintf(&result, "%s/%s",
                                        handle->conn->connectpath, &path[2]);
-                       if (r < 0) return NULL;
                }
        } else {
-               int r = asprintf(&result, "%s/%s",
+               r = asprintf(&result, "%s/%s",
                                handle->conn->connectpath, path);
-               if (r < 0) return NULL;
        }
-       DEBUG(10, ("[CEPH] realpath(%p, %s) = %s\n", handle, path, result));
-       return result;
-}
 
-static NTSTATUS cephwrap_notify_watch(struct vfs_handle_struct *vfs_handle,
-                                    struct sys_notify_context *ctx,
-                                    const char *path,
-                                    uint32_t *filter,
-                                    uint32_t *subdir_filter,
-                                    void (*callback)(struct sys_notify_context *ctx,
-                                                     void *private_data,
-                                                     struct notify_event *ev),
-                                    void *private_data,
-                                    void *handle_p)
-{
-       /*
-        * We cannot call inotify on files the kernel does not know about
-        */
-       return NT_STATUS_OK;
+       if (r < 0) {
+               return NULL;
+       }
+
+       DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle, path, result);
+       result_fname = synthetic_smb_fname(ctx,
+                               result,
+                               NULL,
+                               NULL,
+                               0);
+       SAFE_FREE(result);
+       return result_fname;
 }
 
-static int cephwrap_chflags(struct vfs_handle_struct *handle, const char *path,
-                          unsigned int flags)
+static int cephwrap_chflags(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        errno = ENOSYS;
        return -1;
@@ -1059,7 +1257,7 @@ static int cephwrap_get_real_filename(struct vfs_handle_struct *handle,
 }
 
 static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
-                                      const char *fname)
+                                      const struct smb_filename *smb_fname)
 {
        return handle->conn->connectpath;
 }
@@ -1068,106 +1266,124 @@ static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
  Extended attribute operations.
 *****************************************************************/
 
-static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
+static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *name,
+                       void *value,
+                       size_t size)
 {
        int ret;
-       DEBUG(10, ("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle, path, name, value, llu(size)));
-       ret = ceph_getxattr(handle->data, path, name, value, size);
-       DEBUG(10, ("[CEPH] getxattr(...) = %d\n", ret));
+       DBG_DEBUG("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle,
+                       smb_fname->base_name, name, value, llu(size));
+       ret = ceph_getxattr(handle->data,
+                       smb_fname->base_name, name, value, size);
+       DBG_DEBUG("[CEPH] getxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
 
 static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
 {
        int ret;
-       DEBUG(10, ("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size)));
+       DBG_DEBUG("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size));
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+       ret = ceph_fgetxattr(handle->data, fsp->fh->fd, name, value, size);
+#else
        ret = ceph_getxattr(handle->data, fsp->fsp_name->base_name, name, value, size);
-       DEBUG(10, ("[CEPH] fgetxattr(...) = %d\n", ret));
-       if (ret < 0) {
-               WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
-       }
-}
-
-static ssize_t cephwrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
-{
-       int ret;
-       DEBUG(10, ("[CEPH] listxattr(%p, %s, %p, %llu)\n", handle, path, list, llu(size)));
-       ret = ceph_listxattr(handle->data, path, list, size);
-       DEBUG(10, ("[CEPH] listxattr(...) = %d\n", ret));
+#endif
+       DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
 
-#if 0
-static ssize_t cephwrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
+static ssize_t cephwrap_listxattr(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       char *list,
+                       size_t size)
 {
        int ret;
-       DEBUG(10, ("[CEPH] llistxattr(%p, %s, %p, %llu)\n", handle, path, list, llu(size)));
-       ret = ceph_llistxattr(handle->data, path, list, size);
-       DEBUG(10, ("[CEPH] listxattr(...) = %d\n", ret));
+       DBG_DEBUG("[CEPH] listxattr(%p, %s, %p, %llu)\n", handle,
+                       smb_fname->base_name, list, llu(size));
+       ret = ceph_listxattr(handle->data, smb_fname->base_name, list, size);
+       DBG_DEBUG("[CEPH] listxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
-#endif
 
 static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
 {
        int ret;
-       DEBUG(10, ("[CEPH] flistxattr(%p, %p, %s, %llu)\n", handle, fsp, list, llu(size)));
+       DBG_DEBUG("[CEPH] flistxattr(%p, %p, %s, %llu)\n", handle, fsp, list, llu(size));
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+       ret = ceph_flistxattr(handle->data, fsp->fh->fd, list, size);
+#else
        ret = ceph_listxattr(handle->data, fsp->fsp_name->base_name, list, size);
-       DEBUG(10, ("[CEPH] flistxattr(...) = %d\n", ret));
+#endif
+       DBG_DEBUG("[CEPH] flistxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
 
-static int cephwrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
+static int cephwrap_removexattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name)
 {
        int ret;
-       DEBUG(10, ("[CEPH] removexattr(%p, %s, %s)\n", handle, path, name));
-       ret = ceph_removexattr(handle->data, path, name);
-       DEBUG(10, ("[CEPH] removexattr(...) = %d\n", ret));
+       DBG_DEBUG("[CEPH] removexattr(%p, %s, %s)\n", handle,
+                       smb_fname->base_name, name);
+       ret = ceph_removexattr(handle->data, smb_fname->base_name, name);
+       DBG_DEBUG("[CEPH] removexattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
 
 static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
 {
        int ret;
-       DEBUG(10, ("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name));
+       DBG_DEBUG("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name);
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+       ret = ceph_fremovexattr(handle->data, fsp->fh->fd, name);
+#else
        ret = ceph_removexattr(handle->data, fsp->fsp_name->base_name, name);
-       DEBUG(10, ("[CEPH] fremovexattr(...) = %d\n", ret));
+#endif
+       DBG_DEBUG("[CEPH] fremovexattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
 
-static int cephwrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
+static int cephwrap_setxattr(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               const char *name,
+                               const void *value,
+                               size_t size,
+                               int flags)
 {
        int ret;
-       DEBUG(10, ("[CEPH] setxattr(%p, %s, %s, %p, %llu, %d)\n", handle, path, name, value, llu(size), flags));
-       ret = ceph_setxattr(handle->data, path, name, value, size, flags);
-       DEBUG(10, ("[CEPH] setxattr(...) = %d\n", ret));
+       DBG_DEBUG("[CEPH] setxattr(%p, %s, %s, %p, %llu, %d)\n", handle,
+                       smb_fname->base_name, name, value, llu(size), flags);
+       ret = ceph_setxattr(handle->data, smb_fname->base_name,
+                       name, value, size, flags);
+       DBG_DEBUG("[CEPH] setxattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
 
 static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
 {
        int ret;
-       DEBUG(10, ("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags));
+       DBG_DEBUG("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags);
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+       ret = ceph_fsetxattr(handle->data, fsp->fh->fd,
+                            name, value, size, flags);
+#else
        ret = ceph_setxattr(handle->data, fsp->fsp_name->base_name, name, value, size, flags);
-       DEBUG(10, ("[CEPH] fsetxattr(...) = %d\n", ret));
+#endif
+       DBG_DEBUG("[CEPH] fsetxattr(...) = %d\n", ret);
        WRAP_RETURN(ret);
 }
 
@@ -1178,25 +1394,11 @@ static bool cephwrap_aio_force(struct vfs_handle_struct *handle, struct files_st
         * We do not support AIO yet.
         */
 
-       DEBUG(10, ("[CEPH] cephwrap_aio_force(%p, %p) = false (errno = ENOTSUP)\n", handle, fsp));
+       DBG_DEBUG("[CEPH] cephwrap_aio_force(%p, %p) = false (errno = ENOTSUP)\n", handle, fsp);
        errno = ENOTSUP;
        return false;
 }
 
-static bool cephwrap_is_offline(struct vfs_handle_struct *handle,
-                               const struct smb_filename *fname,
-                               SMB_STRUCT_STAT *sbuf)
-{
-       return false;
-}
-
-static int cephwrap_set_offline(struct vfs_handle_struct *handle,
-                               const struct smb_filename *fname)
-{
-       errno = ENOTSUP;
-       return -1;
-}
-
 static struct vfs_fn_pointers ceph_fns = {
        /* Disk operations */
 
@@ -1206,6 +1408,7 @@ static struct vfs_fn_pointers ceph_fns = {
        .get_quota_fn = cephwrap_get_quota,
        .set_quota_fn = cephwrap_set_quota,
        .statvfs_fn = cephwrap_statvfs,
+       .fs_capabilities_fn = cephwrap_fs_capabilities,
 
        /* Directory operations */
 
@@ -1223,15 +1426,18 @@ static struct vfs_fn_pointers ceph_fns = {
 
        .open_fn = cephwrap_open,
        .close_fn = cephwrap_close,
-       .read_fn = cephwrap_read,
        .pread_fn = cephwrap_pread,
-       .write_fn = cephwrap_write,
+       .pread_send_fn = cephwrap_pread_send,
+       .pread_recv_fn = cephwrap_pread_recv,
        .pwrite_fn = cephwrap_pwrite,
+       .pwrite_send_fn = cephwrap_pwrite_send,
+       .pwrite_recv_fn = cephwrap_pwrite_recv,
        .lseek_fn = cephwrap_lseek,
        .sendfile_fn = cephwrap_sendfile,
        .recvfile_fn = cephwrap_recvfile,
        .rename_fn = cephwrap_rename,
-       .fsync_fn = cephwrap_fsync,
+       .fsync_send_fn = cephwrap_fsync_send,
+       .fsync_recv_fn = cephwrap_fsync_recv,
        .stat_fn = cephwrap_stat,
        .fstat_fn = cephwrap_fstat,
        .lstat_fn = cephwrap_lstat,
@@ -1245,6 +1451,7 @@ static struct vfs_fn_pointers ceph_fns = {
        .getwd_fn = cephwrap_getwd,
        .ntimes_fn = cephwrap_ntimes,
        .ftruncate_fn = cephwrap_ftruncate,
+       .fallocate_fn = cephwrap_fallocate,
        .lock_fn = cephwrap_lock,
        .kernel_flock_fn = cephwrap_kernel_flock,
        .linux_setlease_fn = cephwrap_linux_setlease,
@@ -1254,13 +1461,14 @@ static struct vfs_fn_pointers ceph_fns = {
        .link_fn = cephwrap_link,
        .mknod_fn = cephwrap_mknod,
        .realpath_fn = cephwrap_realpath,
-       .notify_watch_fn = cephwrap_notify_watch,
        .chflags_fn = cephwrap_chflags,
        .get_real_filename_fn = cephwrap_get_real_filename,
        .connectpath_fn = cephwrap_connectpath,
 
        /* EA operations. */
        .getxattr_fn = cephwrap_getxattr,
+       .getxattrat_send_fn = vfs_not_implemented_getxattrat_send,
+       .getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
        .fgetxattr_fn = cephwrap_fgetxattr,
        .listxattr_fn = cephwrap_listxattr,
        .flistxattr_fn = cephwrap_flistxattr,
@@ -1269,16 +1477,21 @@ static struct vfs_fn_pointers ceph_fns = {
        .setxattr_fn = cephwrap_setxattr,
        .fsetxattr_fn = cephwrap_fsetxattr,
 
+       /* Posix ACL Operations */
+       .sys_acl_get_file_fn = posixacl_xattr_acl_get_file,
+       .sys_acl_get_fd_fn = posixacl_xattr_acl_get_fd,
+       .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
+       .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
+       .sys_acl_set_file_fn = posixacl_xattr_acl_set_file,
+       .sys_acl_set_fd_fn = posixacl_xattr_acl_set_fd,
+       .sys_acl_delete_def_file_fn = posixacl_xattr_acl_delete_def_file,
+
        /* aio operations */
        .aio_force_fn = cephwrap_aio_force,
-
-       /* offline operations */
-       .is_offline_fn = cephwrap_is_offline,
-       .set_offline_fn = cephwrap_set_offline
 };
 
-NTSTATUS vfs_ceph_init(void);
-NTSTATUS vfs_ceph_init(void)
+static_decl_vfs;
+NTSTATUS vfs_ceph_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
                                "ceph", &ceph_fns);