The branch, v4-17-test has been updated
       via  ffe95221aab vfs_glusterfs: Implement SMB_VFS_FSTATAT
       via  d5831b0f098 vfs_glusterfs: Use glfs_fgetxattr() for 
SMB_VFS_GET_REAL_FILENAME_AT
       via  9d11c39a2b8 vfs_glusterfs: Use glfs_readlinkat() for 
SMB_VFS_READ_DFS_PATHAT
       via  5e26c570b7c vfs_glusterfs: Use glfs_symlinkat() for 
SMB_VFS_CREATE_DFS_PATHAT
       via  5e155ea4505 vfs_glusterfs: Use glfs_mknodat() for SMB_VFS_MKNODAT
       via  1d74f92deb4 vfs_glusterfs: Use glfs_linkat() for SMB_VFS_LINKAT
       via  894338eddbb vfs_glusterfs: Use glfs_readlinkat() for 
SMB_VFS_READLINKAT
       via  41eb80482b3 vfs_glusterfs: Use glfs_symlinkat() for 
SMB_VFS_SYMLINKAT
       via  c9b0459a175 vfs_glusterfs: Use glfs_unlinkat() for SMB_VFS_UNLINKAT
       via  618c868642d vfs_glusterfs: Use glfs_renameat() for SMB_VFS_RENAMEAT
       via  a41e308cf08 vfs_glusterfs: Use glfs_mkdirat() for SMB_VFS_MKDIRAT
       via  e0375100d79 vfs_glusterfs: Use glfs_openat() for SMB_VFS_OPENAT
       via  a8eab509154 source3/wscript: Detect glusterfs-api with *at() calls 
support
       via  9f04cb8f58d vfs_glusterfs: Accept fsp with const qualifier
      from  fbd69dab91c VERSION: Bump version up to Samba 4.17.0rc4...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-17-test


- Log -----------------------------------------------------------------
commit ffe95221aab1db375de704b366971ef99398577d
Author: Anoop C S <anoo...@samba.org>
Date:   Wed Aug 24 15:01:31 2022 +0530

    vfs_glusterfs: Implement SMB_VFS_FSTATAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Fri Aug 26 17:33:15 UTC 2022 on sn-devel-184
    
    (cherry picked from commit b7c460b902800c0156385b2edb82efb07f561c51)
    
    Autobuild-User(v4-17-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-17-test): Tue Aug 30 10:45:43 UTC 2022 on sn-devel-184

commit d5831b0f09803db0309c013e3499ff0fa95c0c8c
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:16:08 2022 +0530

    vfs_glusterfs: Use glfs_fgetxattr() for SMB_VFS_GET_REAL_FILENAME_AT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 65f4c4e31e4cc60eb9ebca3858275a29f43d5e12)

commit 9d11c39a2b8d2c508d448f08e718009d9a5e44e7
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 13:08:42 2022 +0530

    vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READ_DFS_PATHAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 55548d7405ceca1d20e788a459e685c56f2ff139)

commit 5e26c570b7cb09f5e3e9ecd58bed7e01f4bc4808
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:51:16 2022 +0530

    vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_CREATE_DFS_PATHAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 310a908098b4ff3130a61594c15e91d5e561f357)

commit 5e155ea4505adcb839fdf92f3083c7b7a43e3131
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:15:10 2022 +0530

    vfs_glusterfs: Use glfs_mknodat() for SMB_VFS_MKNODAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit a4235200383fa4dc2f376ce042ed067a45f105d5)

commit 1d74f92deb43b7843ce44c79209965e13fd580f0
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:14:29 2022 +0530

    vfs_glusterfs: Use glfs_linkat() for SMB_VFS_LINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 21654af5a5a062d831f7cb1efec1f1b1eb333bd2)

commit 894338eddbbcacced2908da4aa0fd3d11d3e096c
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:13:33 2022 +0530

    vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 58b6cdabc0c3d788b407d3bfa46570311e910180)

commit 41eb80482b34ec91306ca73a43ee21d3898b2c55
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:12:43 2022 +0530

    vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_SYMLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit b2746eb5fa64e0ec58e99eed5be10c98ea4e1c1e)

commit c9b0459a1755832f6279f955e1cbca2d74b08f8d
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:11:54 2022 +0530

    vfs_glusterfs: Use glfs_unlinkat() for SMB_VFS_UNLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 2fa71202ab347fd057bb9b42740e57344e2679e1)

commit 618c868642d7e09ac467e73195e6638853bd5096
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:11:02 2022 +0530

    vfs_glusterfs: Use glfs_renameat() for SMB_VFS_RENAMEAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 2b721ff22be04cea90086dde2a50f4287d075326)

commit a41e308cf080d7f202ab29c88c96fb08e604a1e3
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:10:16 2022 +0530

    vfs_glusterfs: Use glfs_mkdirat() for SMB_VFS_MKDIRAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 56c4aab11190b8d48a5b92babea7fc7e78b54b4e)

commit e0375100d798459d87d51c300f87049baf1027c2
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:07:08 2022 +0530

    vfs_glusterfs: Use glfs_openat() for SMB_VFS_OPENAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 184a9913241acd4f69128ced3370d3bf49b95f3b)

commit a8eab509154fcd0b93b193ead231a7b62f28d38d
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 12:17:33 2022 +0530

    source3/wscript: Detect glusterfs-api with *at() calls support
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 3425fa0daf9e32d09c7716692cdfdffdc09856d7)

commit 9f04cb8f58d6dbda2769a57fcc6ec0a3fb137ccd
Author: Anoop C S <anoo...@samba.org>
Date:   Fri Aug 19 11:58:34 2022 +0530

    vfs_glusterfs: Accept fsp with const qualifier
    
    This is in preparation to avoid any `const` qualifier being discarded
    warning with future changes to various *_at() calls which has `const
    file_struct` arguments.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 5f51fa9c07e194bcc3c4f39a1bfc2e01139c917b)

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

Summary of changes:
 source3/modules/vfs_glusterfs.c | 438 ++++++++++++++++++++++++++++++++--------
 source3/wscript                 |   4 +
 2 files changed, 363 insertions(+), 79 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index dd05da0f9bb..e2f9fbd8bd4 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -606,7 +606,7 @@ static uint32_t vfs_gluster_fs_capabilities(struct 
vfs_handle_struct *handle,
 }
 
 static glfs_fd_t *vfs_gluster_fetch_glfd(struct vfs_handle_struct *handle,
-                                        files_struct *fsp)
+                                        const files_struct *fsp)
 {
        glfs_fd_t **glfd = (glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
        if (glfd == NULL) {
@@ -737,9 +737,24 @@ static int vfs_gluster_mkdirat(struct vfs_handle_struct 
*handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
 {
-       struct smb_filename *full_fname = NULL;
        int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *pglfd = NULL;
+
+       START_PROFILE(syscall_mkdirat);
+
+       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+       if (pglfd == NULL) {
+               END_PROFILE(syscall_mkdirat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_mkdirat(pglfd, smb_fname->base_name, mode);
+#else
+       struct smb_filename *full_fname = NULL;
+
        START_PROFILE(syscall_mkdirat);
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
@@ -753,6 +768,7 @@ static int vfs_gluster_mkdirat(struct vfs_handle_struct 
*handle,
        ret = glfs_mkdir(handle->data, full_fname->base_name, mode);
 
        TALLOC_FREE(full_fname);
+#endif
 
        END_PROFILE(syscall_mkdirat);
 
@@ -765,9 +781,12 @@ static int vfs_gluster_openat(struct vfs_handle_struct 
*handle,
                              files_struct *fsp,
                              const struct vfs_open_how *how)
 {
-       struct smb_filename *name = NULL;
+       int flags = how->flags;
+       struct smb_filename *full_fname = NULL;
+       bool have_opath = false;
        bool became_root = false;
        glfs_fd_t *glfd;
+       glfs_fd_t *pglfd = NULL;
        glfs_fd_t **p_tmp;
 
        START_PROFILE(syscall_openat);
@@ -778,58 +797,103 @@ static int vfs_gluster_openat(struct vfs_handle_struct 
*handle,
                return -1;
        }
 
-       /*
-        * Looks like glfs API doesn't have openat().
-        */
-       if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
-               name = full_path_from_dirfsp_atname(talloc_tos(),
-                                                   dirfsp,
-                                                   smb_fname);
-               if (name == NULL) {
-                       END_PROFILE(syscall_openat);
-                       return -1;
-               }
-               smb_fname = name;
-       }
-
        p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
        if (p_tmp == NULL) {
-               TALLOC_FREE(name);
                END_PROFILE(syscall_openat);
                errno = ENOMEM;
                return -1;
        }
 
+#ifdef O_PATH
+       have_opath = true;
        if (fsp->fsp_flags.is_pathref) {
-               /*
-                * ceph doesn't support O_PATH so we have to fallback to
-                * become_root().
-                */
+               flags |= O_PATH;
+       }
+#endif
+
+       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                                 dirfsp,
+                                                 smb_fname);
+       if (full_fname == NULL) {
+               END_PROFILE(syscall_openat);
+               return -1;
+       }
+
+       if (fsp->fsp_flags.is_pathref && !have_opath) {
                become_root();
                became_root = true;
        }
 
-       if (how->flags & O_DIRECTORY) {
-               glfd = glfs_opendir(handle->data, smb_fname->base_name);
-       } else if (how->flags & O_CREAT) {
+       /*
+        * O_CREAT flag in open is handled differently in a way which is *NOT*
+        * safe against symlink race situations. We use glfs_creat() instead
+        * for correctness as glfs_openat() is broken with O_CREAT present
+        * in open flags.
+        */
+       if (flags & O_CREAT) {
+               if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+                       /*
+                        * Replace smb_fname with full_path constructed above.
+                        */
+                       smb_fname = full_fname;
+               }
+
+               /*
+                * smb_fname can either be a full_path or the same one
+                * as received from the caller. In the latter case we
+                * are operating at current working directory.
+                */
                glfd = glfs_creat(handle->data,
                                  smb_fname->base_name,
-                                 how->flags,
+                                 flags,
                                  how->mode);
        } else {
-               glfd = glfs_open(handle->data,
-                                smb_fname->base_name,
-                                how->flags);
+               if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+#ifdef HAVE_GFAPI_VER_7_11
+                       /*
+                        * Fetch Gluster fd for parent directory using dirfsp
+                        * before calling glfs_openat();
+                        */
+                       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+                       if (pglfd == NULL) {
+                               END_PROFILE(syscall_openat);
+                               DBG_ERR("Failed to fetch gluster fd\n");
+                               return -1;
+                       }
+
+                       glfd = glfs_openat(pglfd,
+                                          smb_fname->base_name,
+                                          flags,
+                                          how->mode);
+#else
+                       /*
+                        * Replace smb_fname with full_path constructed above.
+                        */
+                       smb_fname = full_fname;
+#endif
+               }
+
+               if (pglfd == NULL) {
+                       /*
+                        * smb_fname can either be a full_path or the same one
+                        * as received from the caller. In the latter case we
+                        * are operating at current working directory.
+                        */
+                       glfd = glfs_open(handle->data,
+                                        smb_fname->base_name,
+                                        flags);
+               }
        }
 
        if (became_root) {
                unbecome_root();
        }
 
+       TALLOC_FREE(full_fname);
+
        fsp->fsp_flags.have_proc_fds = false;
 
        if (glfd == NULL) {
-               TALLOC_FREE(name);
                END_PROFILE(syscall_openat);
                /* no extension destroy_fn, so no need to save errno */
                VFS_REMOVE_FSP_EXTENSION(handle, fsp);
@@ -838,7 +902,6 @@ static int vfs_gluster_openat(struct vfs_handle_struct 
*handle,
 
        *p_tmp = glfd;
 
-       TALLOC_FREE(name);
        END_PROFILE(syscall_openat);
        /* An arbitrary value for error reporting, so you know its us. */
        return 13371337;
@@ -1242,9 +1305,33 @@ static int vfs_gluster_renameat(struct vfs_handle_struct 
*handle,
                        files_struct *dstfsp,
                        const struct smb_filename *smb_fname_dst)
 {
+       int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *src_pglfd = NULL;
+       glfs_fd_t *dst_pglfd = NULL;
+
+       START_PROFILE(syscall_renameat);
+
+       src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
+       if (src_pglfd == NULL) {
+               END_PROFILE(syscall_renameat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       dst_pglfd = vfs_gluster_fetch_glfd(handle, dstfsp);
+       if (dst_pglfd == NULL) {
+               END_PROFILE(syscall_renameat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_renameat(src_pglfd, smb_fname_src->base_name,
+                           dst_pglfd, smb_fname_dst->base_name);
+#else
        struct smb_filename *full_fname_src = NULL;
        struct smb_filename *full_fname_dst = NULL;
-       int ret;
 
        START_PROFILE(syscall_renameat);
 
@@ -1252,24 +1339,28 @@ static int vfs_gluster_renameat(struct 
vfs_handle_struct *handle,
                                                      srcfsp,
                                                      smb_fname_src);
        if (full_fname_src == NULL) {
-               errno = ENOMEM;
                END_PROFILE(syscall_renameat);
+               errno = ENOMEM;
                return -1;
        }
+
        full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(),
                                                      dstfsp,
                                                      smb_fname_dst);
        if (full_fname_dst == NULL) {
+               END_PROFILE(syscall_renameat);
                TALLOC_FREE(full_fname_src);
                errno = ENOMEM;
-               END_PROFILE(syscall_renameat);
                return -1;
        }
        ret = glfs_rename(handle->data,
                          full_fname_src->base_name,
                          full_fname_dst->base_name);
+
        TALLOC_FREE(full_fname_src);
        TALLOC_FREE(full_fname_dst);
+#endif
+
        END_PROFILE(syscall_renameat);
 
        return ret;
@@ -1452,6 +1543,55 @@ static int vfs_gluster_fstat(struct vfs_handle_struct 
*handle,
        return ret;
 }
 
+static int vfs_gluster_fstatat(struct vfs_handle_struct *handle,
+                              const struct files_struct *dirfsp,
+                              const struct smb_filename *smb_fname,
+                              SMB_STRUCT_STAT *sbuf,
+                              int flags)
+{
+       struct stat st;
+       int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *pglfd = NULL;
+
+       START_PROFILE(syscall_fstatat);
+
+       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+       if (pglfd == NULL) {
+               END_PROFILE(syscall_fstatat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_fstatat(pglfd, smb_fname->base_name, &st, flags);
+#else
+       struct smb_filename *full_fname = NULL;
+
+       START_PROFILE(syscall_fstatat);
+
+       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                                 dirfsp,
+                                                 smb_fname);
+       if (full_fname == NULL) {
+               END_PROFILE(syscall_fstatat);
+               return -1;
+       }
+
+       ret = glfs_stat(handle->data, full_fname->base_name, &st);
+
+       TALLOC_FREE(full_fname->base_name);
+#endif
+
+       if (ret == 0) {
+               smb_stat_ex_from_stat(sbuf, &st);
+       }
+
+       END_PROFILE(syscall_fstatat);
+
+       return ret;
+}
+
 static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
                             struct smb_filename *smb_fname)
 {
@@ -1490,9 +1630,24 @@ static int vfs_gluster_unlinkat(struct vfs_handle_struct 
*handle,
                        const struct smb_filename *smb_fname,
                        int flags)
 {
-       struct smb_filename *full_fname = NULL;
        int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *pglfd = NULL;
+
+       START_PROFILE(syscall_unlinkat);
+
+       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+       if (pglfd == NULL) {
+               END_PROFILE(syscall_unlinkat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_unlinkat(pglfd, smb_fname->base_name, flags);
+#else
+       struct smb_filename *full_fname = NULL;
+
        START_PROFILE(syscall_unlinkat);
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
@@ -1508,7 +1663,10 @@ static int vfs_gluster_unlinkat(struct vfs_handle_struct 
*handle,
        } else {
                ret = glfs_unlink(handle->data, full_fname->base_name);
        }
+
        TALLOC_FREE(full_fname);
+#endif
+
        END_PROFILE(syscall_unlinkat);
 
        return ret;
@@ -1908,24 +2066,42 @@ static int vfs_gluster_symlinkat(struct 
vfs_handle_struct *handle,
                                struct files_struct *dirfsp,
                                const struct smb_filename *new_smb_fname)
 {
-       struct smb_filename *full_fname = NULL;
        int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *pglfd = NULL;
+
+       START_PROFILE(syscall_symlinkat);
+
+       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+       if (pglfd == NULL) {
+               END_PROFILE(syscall_symlinkat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_symlinkat(link_target->base_name,
+                            pglfd,
+                            new_smb_fname->base_name);
+#else
+       struct smb_filename *full_fname = NULL;
+
        START_PROFILE(syscall_symlinkat);
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
-                                               dirfsp,
-                                               new_smb_fname);
+                                                 dirfsp,
+                                                 new_smb_fname);
        if (full_fname == NULL) {
                END_PROFILE(syscall_symlinkat);
                return -1;
        }
 
        ret = glfs_symlink(handle->data,
-                       link_target->base_name,
-                       full_fname->base_name);
+                          link_target->base_name,
+                          full_fname->base_name);
 
        TALLOC_FREE(full_fname);
+#endif
 
        END_PROFILE(syscall_symlinkat);
 
@@ -1938,14 +2114,29 @@ static int vfs_gluster_readlinkat(struct 
vfs_handle_struct *handle,
                                char *buf,
                                size_t bufsiz)
 {
-       struct smb_filename *full_fname = NULL;
        int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *pglfd = NULL;
+
+       START_PROFILE(syscall_readlinkat);
+
+       pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+       if (pglfd == NULL) {
+               END_PROFILE(syscall_readlinkat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_readlinkat(pglfd, smb_fname->base_name, buf, bufsiz);
+#else
+       struct smb_filename *full_fname = NULL;
+
        START_PROFILE(syscall_readlinkat);
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
-                                               dirfsp,
-                                               smb_fname);
+                                                 dirfsp,
+                                                 smb_fname);
        if (full_fname == NULL) {
                END_PROFILE(syscall_readlinkat);
                return -1;
@@ -1954,6 +2145,7 @@ static int vfs_gluster_readlinkat(struct 
vfs_handle_struct *handle,
        ret = glfs_readlink(handle->data, full_fname->base_name, buf, bufsiz);
 
        TALLOC_FREE(full_fname);
+#endif
 
        END_PROFILE(syscall_readlinkat);
 
@@ -1968,24 +2160,52 @@ static int vfs_gluster_linkat(struct vfs_handle_struct 
*handle,
                                int flags)
 {
        int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+       glfs_fd_t *src_pglfd = NULL;
+       glfs_fd_t *dst_pglfd = NULL;
+
+       START_PROFILE(syscall_linkat);
+
+       src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
+       if (src_pglfd == NULL) {
+               END_PROFILE(syscall_linkat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       dst_pglfd = vfs_gluster_fetch_glfd(handle, dstfsp);
+       if (dst_pglfd == NULL) {
+               END_PROFILE(syscall_linkat);
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_linkat(src_pglfd,
+                         old_smb_fname->base_name,
+                         dst_pglfd,
+                         new_smb_fname->base_name,
+                         flags);
+#else
        struct smb_filename *full_fname_old = NULL;
        struct smb_filename *full_fname_new = NULL;
 
        START_PROFILE(syscall_linkat);
 
        full_fname_old = full_path_from_dirfsp_atname(talloc_tos(),
-                                               srcfsp,
-                                               old_smb_fname);
+                                                     srcfsp,
+                                                     old_smb_fname);
        if (full_fname_old == NULL) {
                END_PROFILE(syscall_linkat);
                return -1;
        }
+
        full_fname_new = full_path_from_dirfsp_atname(talloc_tos(),
-                                               dstfsp,
-                                               new_smb_fname);
+                                                     dstfsp,
+                                                     new_smb_fname);
        if (full_fname_new == NULL) {


-- 
Samba Shared Repository

Reply via email to