The branch, master has been updated
       via  eb62dc39eb4 docs: fix minor typo in smb.conf "log level" section
       via  f43cc62fb25 vfs_ceph: drop ifdef HAVE_FCHOWN/_FCHMOD
       via  155f1289ba7 vfs_ceph: remove ceph_fallocate/ceph_ftruncate fallback
       via  70329c36ed9 vfs_ceph: fix strict_allocate_ftruncate()
       via  5a7e7280813 vfs_ceph: add missing fallocate hook
      from  4f307f2302b selftest: force running with TZ=UTC

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit eb62dc39eb48b4e2207c80c232664ca37af9c2e6
Author: David Disseldorp <[email protected]>
Date:   Wed Feb 27 12:09:52 2019 +0100

    docs: fix minor typo in smb.conf "log level" section
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>
    
    Autobuild-User(master): David Disseldorp <[email protected]>
    Autobuild-Date(master): Wed Feb 27 16:22:27 UTC 2019 on sn-devel-144

commit f43cc62fb25d607a489cafd96b21cf0788773bbf
Author: David Disseldorp <[email protected]>
Date:   Tue Feb 26 13:54:21 2019 +0100

    vfs_ceph: drop ifdef HAVE_FCHOWN/_FCHMOD
    
    The cephwrap_fchown() and cephwrap_fchmod() wrappers call the
    corresponding libcephfs functions. It doesn't make sense to make this
    logic dependent on regular fchown()/fchmod() function presence, so remove
    the ifdefs.
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

commit 155f1289ba7a4802fbb99fbc9ea90d8bc6cff0c9
Author: David Disseldorp <[email protected]>
Date:   Wed Feb 27 11:52:42 2019 +0100

    vfs_ceph: remove ceph_fallocate/ceph_ftruncate fallback
    
    Both libcephfs functions are supported and capable of extending files,
    so fallback can be dropped.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

commit 70329c36ed91dd0e50ff66f9b0a85c62ac8a621e
Author: David Disseldorp <[email protected]>
Date:   Tue Feb 26 16:07:27 2019 +0100

    vfs_ceph: fix strict_allocate_ftruncate()
    
    The vfs_ceph "strict allocate = yes" ftruncate wrapper may attempt
    *local* filesystem ftruncate(). Fix this.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

commit 5a7e7280813559fb70a9fc8e4238cb6015ee3b53
Author: David Disseldorp <[email protected]>
Date:   Tue Feb 26 21:26:27 2019 +0100

    vfs_ceph: add missing fallocate hook
    
    SMB_VFS_FALLOCATE() calls atop a vfs_ceph share currently fall through
    to vfs_default, which results in a local filesystem I/O attempt using a
    libcephfs file-descriptor. Add the missing fallocate hook to vfs_ceph.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/smbdotconf/logging/loglevel.xml |   2 +-
 source3/modules/vfs_ceph.c               | 124 +++++++------------------------
 2 files changed, 26 insertions(+), 100 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/logging/loglevel.xml 
b/docs-xml/smbdotconf/logging/loglevel.xml
index 1bc4146dac9..d3bed8a939b 100644
--- a/docs-xml/smbdotconf/logging/loglevel.xml
+++ b/docs-xml/smbdotconf/logging/loglevel.xml
@@ -6,7 +6,7 @@
 <synonym>debuglevel</synonym>
 <description>
     <para>
-    The value of the parameter (a astring) allows the debug level (logging 
level) to be specified in the 
+    The value of the parameter (a string) allows the debug level (logging 
level) to be specified in the
     <filename moreinfo="none">smb.conf</filename> file. 
     </para>
 
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 60afd73efe6..67b8d139891 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -961,15 +961,9 @@ static int cephwrap_fchmod(struct vfs_handle_struct 
*handle, files_struct *fsp,
        int result;
 
        DBG_DEBUG("[CEPH] fchmod(%p, %p, %d)\n", handle, fsp, mode);
-
-#if defined(HAVE_FCHMOD)
        result = ceph_fchmod(handle->data, fsp->fh->fd, mode);
        DBG_DEBUG("[CEPH] fchmod(...) = %d\n", result);
        WRAP_RETURN(result);
-#else
-       errno = ENOSYS;
-#endif
-       return -1;
 }
 
 static int cephwrap_chown(struct vfs_handle_struct *handle,
@@ -987,17 +981,11 @@ static int cephwrap_chown(struct vfs_handle_struct 
*handle,
 static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct 
*fsp, uid_t uid, gid_t gid)
 {
        int result;
-#ifdef HAVE_FCHOWN
 
        DBG_DEBUG("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid);
        result = ceph_fchown(handle->data, fsp->fh->fd, uid, gid);
        DBG_DEBUG("[CEPH] fchown(...) = %d\n", result);
        WRAP_RETURN(result);
-#else
-       errno = ENOSYS;
-       result = -1;
-#endif
-       return result;
 }
 
 static int cephwrap_lchown(struct vfs_handle_struct *handle,
@@ -1037,9 +1025,7 @@ static struct smb_filename *cephwrap_getwd(struct 
vfs_handle_struct *handle,
 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;
 
@@ -1058,106 +1044,45 @@ 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, &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;
 
        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_PWRITE(fsp, &c, 1, len-1)!=1) {
-               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)
@@ -1514,6 +1439,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,


-- 
Samba Shared Repository

Reply via email to