The branch, master has been updated
       via  8c92702d152 vfs_ceph: refactor if-error-return-else logic
       via  9c2d15c254b vfs_glusterfs: check for VFS_ADD_FSP_EXTENSION() failure
      from  d4baed454fb WHATSNEW: winbind authentication logging

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


- Log -----------------------------------------------------------------
commit 8c92702d152e16277b658be81496a60841a03e85
Author: David Disseldorp <[email protected]>
Date:   Tue Feb 19 00:33:06 2019 +0100

    vfs_ceph: refactor if-error-return-else logic
    
    vfs_ceph has quite a few occurrences of:
        if (result < 0) {
                WRAP_RETURN(result);    /* calls return */
        } else {
                ...
        }
    
    This change drops the superfluous else {} encapsulation and also removes
    duplication of ceph statx debug messages.
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>
    
    Autobuild-User(master): Günther Deschner <[email protected]>
    Autobuild-Date(master): Wed Feb 20 13:56:09 CET 2019 on sn-devel-144

commit 9c2d15c254b6b3f7c46d72c7fe22a402ef110a64
Author: David Disseldorp <[email protected]>
Date:   Mon Feb 18 17:41:08 2019 +0100

    vfs_glusterfs: check for VFS_ADD_FSP_EXTENSION() failure
    
    Signed-off-by: David Disseldorp <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

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

Summary of changes:
 source3/modules/vfs_ceph.c      | 102 +++++++++++++++++++---------------------
 source3/modules/vfs_glusterfs.c |  10 +++-
 2 files changed, 58 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index d863c8add5a..60afd73efe6 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -260,19 +260,20 @@ static int cephwrap_statvfs(struct vfs_handle_struct 
*handle,
        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;
-               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);
        }
+
+       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;
 }
 
@@ -676,9 +677,21 @@ static int cephwrap_fsync_recv(struct tevent_req *req,
 
 static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct 
ceph_statx *stx)
 {
-       if ((stx->stx_mask & SAMBA_STATX_ATTR_MASK) != SAMBA_STATX_ATTR_MASK)
+       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;
@@ -715,16 +728,8 @@ static int cephwrap_stat(struct vfs_handle_struct *handle,
        DBG_DEBUG("[CEPH] statx(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               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));
        }
+
        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;
@@ -741,16 +746,8 @@ static int cephwrap_fstat(struct vfs_handle_struct 
*handle, files_struct *fsp, S
        DBG_DEBUG("[CEPH] fstat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               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));
        }
+
        init_stat_ex_from_ceph_statx(sbuf, &stx);
        DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode);
        return result;
@@ -775,6 +772,7 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle,
        if (result < 0) {
                WRAP_RETURN(result);
        }
+
        init_stat_ex_from_ceph_statx(&smb_fname->st, &stx);
        return result;
 }
@@ -830,14 +828,15 @@ static int cephwrap_stat(struct vfs_handle_struct *handle,
        DBG_DEBUG("[CEPH] stat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               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));
        }
+
+       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)));
@@ -855,15 +854,15 @@ static int cephwrap_fstat(struct vfs_handle_struct 
*handle, files_struct *fsp, S
        DBG_DEBUG("[CEPH] fstat(...) = %d\n", result);
        if (result < 0) {
                WRAP_RETURN(result);
-       } else {
-               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));
        }
 
+       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)));
@@ -889,6 +888,7 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle,
        if (result < 0) {
                WRAP_RETURN(result);
        }
+
        init_stat_ex_from_stat(
                        &smb_fname->st, &stbuf,
                        lp_fake_directory_create_times(SNUM(handle->conn)));
@@ -1343,9 +1343,8 @@ static ssize_t cephwrap_getxattr(struct vfs_handle_struct 
*handle,
        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)
@@ -1360,9 +1359,8 @@ static ssize_t cephwrap_fgetxattr(struct 
vfs_handle_struct *handle, struct files
        DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
 
 static ssize_t cephwrap_listxattr(struct vfs_handle_struct *handle,
@@ -1377,9 +1375,8 @@ static ssize_t cephwrap_listxattr(struct 
vfs_handle_struct *handle,
        DBG_DEBUG("[CEPH] listxattr(...) = %d\n", ret);
        if (ret < 0) {
                WRAP_RETURN(ret);
-       } else {
-               return (ssize_t)ret;
        }
+       return (ssize_t)ret;
 }
 
 static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct 
files_struct *fsp, char *list, size_t size)
@@ -1394,9 +1391,8 @@ static ssize_t cephwrap_flistxattr(struct 
vfs_handle_struct *handle, struct file
        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,
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 601be5a2da4..82a7c2ce9b4 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -592,6 +592,12 @@ static int vfs_gluster_open(struct vfs_handle_struct 
*handle,
        glfs_fd_t *glfd;
        glfs_fd_t **p_tmp;
 
+       p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
+       if (p_tmp == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        if (flags & O_DIRECTORY) {
                glfd = glfs_opendir(handle->data, smb_fname->base_name);
        } else if (flags & O_CREAT) {
@@ -602,9 +608,11 @@ static int vfs_gluster_open(struct vfs_handle_struct 
*handle,
        }
 
        if (glfd == NULL) {
+               /* no extension destroy_fn, so no need to save errno */
+               VFS_REMOVE_FSP_EXTENSION(handle, fsp);
                return -1;
        }
-       p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
+
        *p_tmp = glfd;
        /* An arbitrary value for error reporting, so you know its us. */
        return 13371337;


-- 
Samba Shared Repository

Reply via email to