The branch, master has been updated
       via  5e07731 dbwrap: Slightly simplify dbwrap_watch_record_stored
       via  64bae74 vfs_glusterfs: Remove "integer fd" code and store the glfs 
pointers.
       via  86aa43c vfs_glusterfs: smb_stat_ex_from_stat commenting and cleanup.
       via  910a56a vfs_glusterfs: Comment the top of the file.
      from  148bbdd s3-printing: Fix obvious memory leak in 
printer_list_get_printer().

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


- Log -----------------------------------------------------------------
commit 5e07731cf689705957f706b6430a7ed67f099f79
Author: Volker Lendecke <[email protected]>
Date:   Wed Feb 12 12:48:19 2014 +0000

    dbwrap: Slightly simplify dbwrap_watch_record_stored
    
    We have messaging_send_buf, so there's no point to use an explicit
    DATA_BLOB here.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Tue Feb 25 23:27:21 CET 2014 on sn-devel-104

commit 64bae74f565e7f07a408effb2665eba80fde5370
Author: Jose A. Rivera <[email protected]>
Date:   Thu Dec 12 16:06:36 2013 -0600

    vfs_glusterfs: Remove "integer fd" code and store the glfs pointers.
    
    Change-Id: I74347199e54be0d1dc031985534da1e56fd3e280
    Signed-off-by: Jose A. Rivera <[email protected]>
    Reviewed-by: Christopher R. Hertel <[email protected]>
    Reviewed-by: Ira Cooper <[email protected]>

commit 86aa43c73ce9fd16892f0489ddf41bd7fef4eaba
Author: Christopher R. Hertel <[email protected]>
Date:   Thu Dec 12 12:29:20 2013 -0600

    vfs_glusterfs: smb_stat_ex_from_stat commenting and cleanup.
    
    Change-Id: If1b54e62b4fc2240aa17e5d1eae8f279f2fdfc42
    Signed-off-by: Christopher R. Hertel <[email protected]>
    Reviewed-by: Jose A. Rivera <[email protected]>
    Reviewed-by: Ira Cooper <[email protected]>

commit 910a56a7cb10a1928e6a3edaa5eb15d086460425
Author: Christopher R. Hertel <[email protected]>
Date:   Thu Dec 12 12:27:10 2013 -0600

    vfs_glusterfs: Comment the top of the file.
    
    Change-Id: I98b512da2e0e56f061247a7c48ce576287b43827
    Signed-off-by: Christopher R. Hertel <[email protected]>
    Reviewed-by: Jose A. Rivera <[email protected]>
    Reviewed-by: Ira Cooper <[email protected]>

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

Summary of changes:
 source3/lib/dbwrap/dbwrap_watch.c |    7 +-
 source3/modules/vfs_glusterfs.c   |  169 +++++++++++++------------------------
 2 files changed, 60 insertions(+), 116 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap_watch.c 
b/source3/lib/dbwrap/dbwrap_watch.c
index ba4381e..4f3a2b3 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -307,7 +307,6 @@ static void dbwrap_watch_record_stored(struct db_context 
*db,
        struct server_id *ids = NULL;
        size_t num_ids = 0;
        TDB_DATA w_key = { 0, };
-       DATA_BLOB w_blob;
        NTSTATUS status;
        uint32_t i;
 
@@ -326,12 +325,10 @@ static void dbwrap_watch_record_stored(struct db_context 
*db,
                DEBUG(1, ("dbwrap_record_watchers_key failed\n"));
                goto done;
        }
-       w_blob.data = w_key.dptr;
-       w_blob.length = w_key.dsize;
 
        for (i=0; i<num_ids; i++) {
-               status = messaging_send(msg, ids[i], MSG_DBWRAP_MODIFIED,
-                                       &w_blob);
+               status = messaging_send_buf(msg, ids[i], MSG_DBWRAP_MODIFIED,
+                                           w_key.dptr, w_key.dsize);
                if (!NT_STATUS_IS_OK(status)) {
                        char *str = procid_str_static(&ids[i]);
                        DEBUG(1, ("messaging_send to %s failed: %s\n",
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 9bcd0cb..ba2d8e8 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -19,6 +19,24 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+/**
+ * @file   vfs_glusterfs.c
+ * @author Anand Avati <[email protected]>
+ * @date   May 2013
+ * @brief  Samba VFS module for glusterfs
+ *
+ * @todo
+ *   - AIO support\n
+ *     See, for example \c vfs_aio_linux.c in the \c sourc3/modules directory
+ *   - sendfile/recvfile support
+ *
+ * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
+ * This is a "bottom" vfs module (not something to be stacked on top of
+ * another module), and translates (most) calls to the closest actions
+ * available in libgfapi.
+ *
+ */
+
 #include "includes.h"
 #include "smbd/smbd.h"
 #include <stdio.h>
@@ -27,82 +45,9 @@
 
 #define DEFAULT_VOLFILE_SERVER "localhost"
 
-/*
-  TODO
-  ----
-  Short term:
-  - AIO support
-  - sendfile/recvfile support
-*/
-
-/* Helpers to provide 'integer' fds */
-
-/* This is global. gfapi's FD operations do not
-   require filesystem context.
-*/
-
-static glfs_fd_t **glfd_fd;
-static int glfd_fd_size;
-static int glfd_fd_used;
-
-static int glfd_fd_store(glfs_fd_t *glfd)
-{
-       int i;
-       void *tmp;
-
-       if (glfd_fd_size == glfd_fd_used) {
-               if (glfd_fd_size >= INT_MAX - 1) {
-                       errno = ENOMEM;
-                       return -1;
-               }
-
-               tmp = talloc_realloc(glfd_fd, glfd_fd, glfs_fd_t *,
-                                    glfd_fd_size + 1);
-               if (tmp == NULL) {
-                       errno = ENOMEM;
-                       return -1;
-               }
-
-               glfd_fd = tmp;
-               glfd_fd[glfd_fd_size] = 0;
-               glfd_fd_size++;
-       }
-
-       for (i = 0; i < glfd_fd_size; i++) {
-               if (glfd_fd[i] == NULL) {
-                       break;
-               }
-       }
-       glfd_fd_used++;
-       glfd_fd[i] = glfd;
-       return i;
-}
-
-static glfs_fd_t *glfd_fd_get(int i)
-{
-       if (i < 0 || i >= glfd_fd_size) {
-               return NULL;
-       }
-       return glfd_fd[i];
-}
-
-static glfs_fd_t *glfd_fd_clear(int i)
-{
-       glfs_fd_t *glfd = NULL;
-
-       if (i < 0 || i >= glfd_fd_size) {
-               return NULL;
-       }
-
-       glfd = glfd_fd[i];
-
-       glfd_fd[i] = 0;
-       glfd_fd_used--;
-       return glfd;
-}
-
-/* Helper to convert stat to stat_ex */
-
+/**
+ * Helper to convert struct stat to struct stat_ex.
+ */
 static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
 {
        ZERO_STRUCTP(dst);
@@ -116,23 +61,17 @@ static void smb_stat_ex_from_stat(struct stat_ex *dst, 
const struct stat *src)
        dst->st_ex_rdev = src->st_rdev;
        dst->st_ex_size = src->st_size;
        dst->st_ex_atime.tv_sec = src->st_atime;
-#ifdef STAT_HAVE_NSEC
-       dst->st_ex_atime.tv_nsec = src->st_atime_nsec;
-#endif
        dst->st_ex_mtime.tv_sec = src->st_mtime;
-#ifdef STAT_HAVE_NSEC
-       dst->st_ex_mtime.tv_nsec = src->st_mtime_nsec;
-#endif
        dst->st_ex_ctime.tv_sec = src->st_ctime;
-#ifdef STAT_HAVE_NSEC
-       dst->st_ex_ctime.tv_nsec = src->st_ctime_nsec;
-#endif
        dst->st_ex_btime.tv_sec = src->st_mtime;
+       dst->st_ex_blksize = src->st_blksize;
+       dst->st_ex_blocks = src->st_blocks;
 #ifdef STAT_HAVE_NSEC
+       dst->st_ex_atime.tv_nsec = src->st_atime_nsec;
+       dst->st_ex_mtime.tv_nsec = src->st_mtime_nsec;
+       dst->st_ex_ctime.tv_nsec = src->st_ctime_nsec;
        dst->st_ex_btime.tv_nsec = src->st_mtime_nsec;
 #endif
-       dst->st_ex_blksize = src->st_blksize;
-       dst->st_ex_blocks = src->st_blocks;
 }
 
 /* pre-opened glfs_t */
@@ -407,7 +346,7 @@ static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct 
*handle,
                                  files_struct *fsp, const char *mask,
                                  uint32 attributes)
 {
-       return (DIR *) glfd_fd_get(fsp->fh->fd);
+       return (DIR *) *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
 }
 
 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
@@ -479,6 +418,7 @@ static int vfs_gluster_open(struct vfs_handle_struct 
*handle,
                            int flags, mode_t mode)
 {
        glfs_fd_t *glfd;
+       glfs_fd_t **p_tmp;
 
        if (flags & O_DIRECTORY) {
                glfd = glfs_opendir(handle->data, smb_fname->base_name);
@@ -492,26 +432,33 @@ static int vfs_gluster_open(struct vfs_handle_struct 
*handle,
        if (glfd == NULL) {
                return -1;
        }
-       return glfd_fd_store(glfd);
+       p_tmp = (glfs_fd_t **)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;
 }
 
 static int vfs_gluster_close(struct vfs_handle_struct *handle,
                             files_struct *fsp)
 {
-       return glfs_close(glfd_fd_clear(fsp->fh->fd));
+       glfs_fd_t *glfd;
+       glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       VFS_REMOVE_FSP_EXTENSION(handle, fsp);
+       return glfs_close(glfd);
 }
 
 static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
                                files_struct *fsp, void *data, size_t n)
 {
-       return glfs_read(glfd_fd_get(fsp->fh->fd), data, n, 0);
+       return glfs_read(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, 0);
 }
 
 static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
                                 files_struct *fsp, void *data, size_t n,
                                 off_t offset)
 {
-       return glfs_pread(glfd_fd_get(fsp->fh->fd), data, n, offset, 0);
+       return glfs_pread(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, offset, 0);
 }
 
 static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
@@ -533,14 +480,14 @@ static ssize_t vfs_gluster_pread_recv(struct tevent_req 
*req, int *err)
 static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
                                 files_struct *fsp, const void *data, size_t n)
 {
-       return glfs_write(glfd_fd_get(fsp->fh->fd), data, n, 0);
+       return glfs_write(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, 0);
 }
 
 static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
                                  files_struct *fsp, const void *data,
                                  size_t n, off_t offset)
 {
-       return glfs_pwrite(glfd_fd_get(fsp->fh->fd), data, n, offset, 0);
+       return glfs_pwrite(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, offset, 0);
 }
 
 static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
@@ -563,7 +510,7 @@ static ssize_t vfs_gluster_pwrite_recv(struct tevent_req 
*req, int *err)
 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
                               files_struct *fsp, off_t offset, int whence)
 {
-       return glfs_lseek(glfd_fd_get(fsp->fh->fd), offset, whence);
+       return glfs_lseek(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
offset, whence);
 }
 
 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
@@ -594,7 +541,7 @@ static int vfs_gluster_rename(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
                             files_struct *fsp)
 {
-       return glfs_fsync(glfd_fd_get(fsp->fh->fd));
+       return glfs_fsync(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp));
 }
 
 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
@@ -635,7 +582,7 @@ static int vfs_gluster_fstat(struct vfs_handle_struct 
*handle,
        struct stat st;
        int ret;
 
-       ret = glfs_fstat(glfd_fd_get(fsp->fh->fd), &st);
+       ret = glfs_fstat(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
&st);
        if (ret == 0) {
                smb_stat_ex_from_stat(sbuf, &st);
        }
@@ -685,7 +632,7 @@ static int vfs_gluster_chmod(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
                              files_struct *fsp, mode_t mode)
 {
-       return glfs_fchmod(glfd_fd_get(fsp->fh->fd), mode);
+       return glfs_fchmod(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
mode);
 }
 
 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
@@ -697,7 +644,7 @@ static int vfs_gluster_chown(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
                              files_struct *fsp, uid_t uid, gid_t gid)
 {
-       return glfs_fchown(glfd_fd_get(fsp->fh->fd), uid, gid);
+       return glfs_fchown(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
uid, gid);
 }
 
 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
@@ -763,7 +710,7 @@ static int vfs_gluster_ntimes(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
                                 files_struct *fsp, off_t offset)
 {
-       return glfs_ftruncate(glfd_fd_get(fsp->fh->fd), offset);
+       return glfs_ftruncate(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), offset);
 }
 
 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
@@ -794,7 +741,7 @@ static bool vfs_gluster_lock(struct vfs_handle_struct 
*handle,
        flock.l_len = count;
        flock.l_pid = 0;
 
-       ret = glfs_posix_lock(glfd_fd_get(fsp->fh->fd), op, &flock);
+       ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), op, &flock);
 
        if (op == F_GETLK) {
                /* lock query, true if someone else has locked */
@@ -841,7 +788,7 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct 
*handle,
        flock.l_len = *pcount;
        flock.l_pid = 0;
 
-       ret = glfs_posix_lock(glfd_fd_get(fsp->fh->fd), F_GETLK, &flock);
+       ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), F_GETLK, &flock);
 
        if (ret == -1) {
                return false;
@@ -949,7 +896,7 @@ static ssize_t vfs_gluster_fgetxattr(struct 
vfs_handle_struct *handle,
                                     files_struct *fsp, const char *name,
                                     void *value, size_t size)
 {
-       return glfs_fgetxattr(glfd_fd_get(fsp->fh->fd), name, value, size);
+       return glfs_fgetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name, value, size);
 }
 
 static ssize_t vfs_gluster_listxattr(struct vfs_handle_struct *handle,
@@ -962,7 +909,7 @@ static ssize_t vfs_gluster_flistxattr(struct 
vfs_handle_struct *handle,
                                      files_struct *fsp, char *list,
                                      size_t size)
 {
-       return glfs_flistxattr(glfd_fd_get(fsp->fh->fd), list, size);
+       return glfs_flistxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), list, size);
 }
 
 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
@@ -974,7 +921,7 @@ static int vfs_gluster_removexattr(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
                                    files_struct *fsp, const char *name)
 {
-       return glfs_fremovexattr(glfd_fd_get(fsp->fh->fd), name);
+       return glfs_fremovexattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name);
 }
 
 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
@@ -988,7 +935,7 @@ static int vfs_gluster_fsetxattr(struct vfs_handle_struct 
*handle,
                                 files_struct *fsp, const char *name,
                                 const void *value, size_t size, int flags)
 {
-       return glfs_fsetxattr(glfd_fd_get(fsp->fh->fd), name, value, size,
+       return glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name, value, size,
                              flags);
 }
 
@@ -1365,16 +1312,16 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct 
vfs_handle_struct *handle,
        struct smb_acl_t *result;
        int ret;
        char *buf;
+       glfs_fd_t *glfd;
 
-       ret = glfs_fgetxattr(glfd_fd_get(fsp->fh->fd),
-                            "system.posix_acl_access", 0, 0);
+       glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       ret = glfs_fgetxattr(glfd, "system.posix_acl_access", 0, 0);
        if (ret <= 0) {
                return NULL;
        }
 
        buf = alloca(ret);
-       ret = glfs_fgetxattr(glfd_fd_get(fsp->fh->fd),
-                            "system.posix_acl_access", buf, ret);
+       ret = glfs_fgetxattr(glfd, "system.posix_acl_access", buf, ret);
        if (ret <= 0) {
                return NULL;
        }
@@ -1435,7 +1382,7 @@ static int vfs_gluster_sys_acl_set_fd(struct 
vfs_handle_struct *handle,
                return -1;
        }
 
-       ret = glfs_fsetxattr(glfd_fd_get(fsp->fh->fd),
+       ret = glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp),
                             "system.posix_acl_access", buf, size, 0);
        return ret;
 }


-- 
Samba Shared Repository

Reply via email to