2 Unix SMB/CIFS implementation.
4 Wrap GlusterFS GFAPI calls in vfs functions.
6 Copyright (c) 2013 Anand Avati <avati@redhat.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @file vfs_glusterfs.c
24 * @author Anand Avati <avati@redhat.com>
26 * @brief Samba VFS module for glusterfs
29 * - sendfile/recvfile support
31 * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
32 * This is a "bottom" vfs module (not something to be stacked on top of
33 * another module), and translates (most) calls to the closest actions
34 * available in libgfapi.
39 #include "smbd/smbd.h"
41 #include <glusterfs/api/glfs.h>
42 #include "lib/util/dlinklist.h"
43 #include "lib/util/tevent_unix.h"
44 #include "smbd/globals.h"
45 #include "lib/util/sys_rw.h"
46 #include "smbprofile.h"
47 #include "modules/posixacl_xattr.h"
48 #include "lib/pthreadpool/pthreadpool_tevent.h"
50 #define DEFAULT_VOLFILE_SERVER "localhost"
51 #define GLUSTER_NAME_MAX 255
54 * Helper to convert struct stat to struct stat_ex.
56 static void smb_stat_ex_from_stat(struct stat_ex
*dst
, const struct stat
*src
)
60 dst
->st_ex_dev
= src
->st_dev
;
61 dst
->st_ex_ino
= src
->st_ino
;
62 dst
->st_ex_mode
= src
->st_mode
;
63 dst
->st_ex_nlink
= src
->st_nlink
;
64 dst
->st_ex_uid
= src
->st_uid
;
65 dst
->st_ex_gid
= src
->st_gid
;
66 dst
->st_ex_rdev
= src
->st_rdev
;
67 dst
->st_ex_size
= src
->st_size
;
68 dst
->st_ex_atime
.tv_sec
= src
->st_atime
;
69 dst
->st_ex_mtime
.tv_sec
= src
->st_mtime
;
70 dst
->st_ex_ctime
.tv_sec
= src
->st_ctime
;
71 dst
->st_ex_btime
.tv_sec
= src
->st_mtime
;
72 dst
->st_ex_blksize
= src
->st_blksize
;
73 dst
->st_ex_blocks
= src
->st_blocks
;
75 dst
->st_ex_atime
.tv_nsec
= src
->st_atime_nsec
;
76 dst
->st_ex_mtime
.tv_nsec
= src
->st_mtime_nsec
;
77 dst
->st_ex_ctime
.tv_nsec
= src
->st_ctime_nsec
;
78 dst
->st_ex_btime
.tv_nsec
= src
->st_mtime_nsec
;
82 /* pre-opened glfs_t */
84 static struct glfs_preopened
{
89 struct glfs_preopened
*next
, *prev
;
93 static int glfs_set_preopened(const char *volume
, const char *connectpath
, glfs_t
*fs
)
95 struct glfs_preopened
*entry
= NULL
;
97 entry
= talloc_zero(NULL
, struct glfs_preopened
);
103 entry
->volume
= talloc_strdup(entry
, volume
);
104 if (!entry
->volume
) {
110 entry
->connectpath
= talloc_strdup(entry
, connectpath
);
111 if (entry
->connectpath
== NULL
) {
120 DLIST_ADD(glfs_preopened
, entry
);
125 static glfs_t
*glfs_find_preopened(const char *volume
, const char *connectpath
)
127 struct glfs_preopened
*entry
= NULL
;
129 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
130 if (strcmp(entry
->volume
, volume
) == 0 &&
131 strcmp(entry
->connectpath
, connectpath
) == 0)
141 static void glfs_clear_preopened(glfs_t
*fs
)
143 struct glfs_preopened
*entry
= NULL
;
145 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
146 if (entry
->fs
== fs
) {
150 DLIST_REMOVE(glfs_preopened
, entry
);
152 glfs_fini(entry
->fs
);
158 static int vfs_gluster_set_volfile_servers(glfs_t
*fs
,
159 const char *volfile_servers
)
162 size_t server_count
= 0;
163 size_t server_success
= 0;
165 TALLOC_CTX
*frame
= talloc_stackframe();
167 DBG_INFO("servers list %s\n", volfile_servers
);
169 while (next_token_talloc(frame
, &volfile_servers
, &server
, " \t")) {
170 char *transport
= NULL
;
175 DBG_INFO("server %zu %s\n", server_count
, server
);
177 /* Determine the transport type */
178 if (strncmp(server
, "unix+", 5) == 0) {
180 transport
= talloc_strdup(frame
, "unix");
185 host
= talloc_strdup(frame
, server
+ 5);
192 char *port_index
= NULL
;
194 if (strncmp(server
, "tcp+", 4) == 0) {
198 /* IPv6 is enclosed in []
199 * ':' before ']' is part of IPv6
200 * ':' after ']' indicates port
203 if (server
[0] == '[') {
205 p
= index(server
, ']');
214 port_index
= index(p
, ':');
216 if (port_index
== NULL
) {
219 port
= atoi(port_index
+ 1);
220 port_index
[0] = '\0';
222 transport
= talloc_strdup(frame
, "tcp");
227 host
= talloc_strdup(frame
, server
);
234 DBG_INFO("Calling set volfile server with params "
235 "transport=%s, host=%s, port=%d\n", transport
,
238 ret
= glfs_set_volfile_server(fs
, transport
, host
, port
);
240 DBG_WARNING("Failed to set volfile_server "
241 "transport=%s, host=%s, port=%d (%s)\n",
242 transport
, host
, port
, strerror(errno
));
249 if (server_count
== 0) {
251 } else if (server_success
< server_count
) {
252 DBG_WARNING("Failed to set %zu out of %zu servers parsed\n",
253 server_count
- server_success
, server_count
);
261 /* Disk Operations */
263 static int check_for_write_behind_translator(TALLOC_CTX
*mem_ctx
,
272 bool write_behind_present
= false;
276 ret
= glfs_get_volfile(fs
, NULL
, 0);
278 DBG_ERR("%s: Failed to get volfile for "
279 "volume (%s): No volfile\n",
285 DBG_ERR("%s: Invalid return %d for glfs_get_volfile for "
286 "volume (%s): No volfile\n",
295 buf
= talloc_zero_array(mem_ctx
, char, newlen
);
300 ret
= glfs_get_volfile(fs
, buf
, newlen
);
303 DBG_ERR("%s: Failed to get volfile for volume (%s)\n",
304 volume
, strerror(errno
));
308 option
= talloc_asprintf(mem_ctx
, "volume %s-write-behind", volume
);
309 if (option
== NULL
) {
315 * file_lines_parse() plays horrible tricks with
316 * the passed-in talloc pointers and the hierarcy
317 * which makes freeing hard to get right.
319 * As we know mem_ctx is freed by the caller, after
320 * this point don't free on exit and let the caller
321 * handle it. This violates good Samba coding practice
322 * but we know we're not leaking here.
325 lines
= file_lines_parse(buf
,
329 if (lines
== NULL
|| numlines
<= 0) {
332 /* On success, buf is now a talloc child of lines !! */
334 for (i
=0; i
< numlines
; i
++) {
335 if (strequal(lines
[i
], option
)) {
336 write_behind_present
= true;
341 if (write_behind_present
) {
342 DBG_ERR("Write behind translator is enabled for "
343 "volume (%s), refusing to connect! "
344 "Please turn off the write behind translator by calling "
345 "'gluster volume set %s performance.write-behind off' "
346 "on the commandline. "
347 "Check the vfs_glusterfs(8) manpage for "
348 "further details.\n",
356 static int vfs_gluster_connect(struct vfs_handle_struct
*handle
,
360 const struct loadparm_substitution
*lp_sub
=
361 loadparm_s3_global_substitution();
362 const char *volfile_servers
;
369 bool write_behind_pass_through_set
= false;
371 tmp_ctx
= talloc_new(NULL
);
372 if (tmp_ctx
== NULL
) {
376 logfile
= lp_parm_substituted_string(tmp_ctx
,
383 loglevel
= lp_parm_int(SNUM(handle
->conn
), "glusterfs", "loglevel", -1);
385 volfile_servers
= lp_parm_substituted_string(tmp_ctx
,
391 if (volfile_servers
== NULL
) {
392 volfile_servers
= DEFAULT_VOLFILE_SERVER
;
395 volume
= lp_parm_const_string(SNUM(handle
->conn
), "glusterfs", "volume",
397 if (volume
== NULL
) {
401 fs
= glfs_find_preopened(volume
, handle
->conn
->connectpath
);
406 fs
= glfs_new(volume
);
412 ret
= vfs_gluster_set_volfile_servers(fs
, volfile_servers
);
414 DBG_ERR("Failed to set volfile_servers from list %s\n",
419 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-posix-acl",
422 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
426 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-selinux",
429 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
433 ret
= glfs_set_xlator_option(fs
, "*-snapview-client",
434 "snapdir-entry-path",
435 handle
->conn
->connectpath
);
437 DEBUG(0, ("%s: Failed to set xlator option:"
438 " snapdir-entry-path\n", volume
));
442 #ifdef HAVE_GFAPI_VER_7_9
443 ret
= glfs_set_xlator_option(fs
, "*-write-behind", "pass-through",
446 DBG_ERR("%s: Failed to set xlator option: pass-through\n",
450 write_behind_pass_through_set
= true;
453 ret
= glfs_set_logging(fs
, logfile
, loglevel
);
455 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
456 volume
, logfile
, loglevel
));
462 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
463 volume
, strerror(errno
)));
467 if (!write_behind_pass_through_set
) {
468 ret
= check_for_write_behind_translator(tmp_ctx
, fs
, volume
);
474 ret
= glfs_set_preopened(volume
, handle
->conn
->connectpath
, fs
);
476 DEBUG(0, ("%s: Failed to register volume (%s)\n",
477 volume
, strerror(errno
)));
482 * The shadow_copy2 module will fail to export subdirectories
483 * of a gluster volume unless we specify the mount point,
484 * because the detection fails if the file system is not
486 * https://bugzilla.samba.org/show_bug.cgi?id=13091
488 lp_do_parameter(SNUM(handle
->conn
), "shadow:mountpoint", "/");
491 * Unless we have an async implementation of getxattrat turn this off.
493 lp_do_parameter(SNUM(handle
->conn
), "smbd async dosmode", "false");
500 DBG_ERR("%s: Initialized volume from servers %s\n",
501 volume
, volfile_servers
);
504 talloc_free(tmp_ctx
);
508 static void vfs_gluster_disconnect(struct vfs_handle_struct
*handle
)
514 glfs_clear_preopened(fs
);
517 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct
*handle
,
518 const struct smb_filename
*smb_fname
,
523 struct statvfs statvfs
= { 0, };
526 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
531 if (bsize_p
!= NULL
) {
532 *bsize_p
= (uint64_t)statvfs
.f_bsize
; /* Block size */
534 if (dfree_p
!= NULL
) {
535 *dfree_p
= (uint64_t)statvfs
.f_bavail
; /* Available Block units */
537 if (dsize_p
!= NULL
) {
538 *dsize_p
= (uint64_t)statvfs
.f_blocks
; /* Total Block units */
541 return (uint64_t)statvfs
.f_bavail
;
544 static int vfs_gluster_get_quota(struct vfs_handle_struct
*handle
,
545 const struct smb_filename
*smb_fname
,
546 enum SMB_QUOTA_TYPE qtype
,
555 vfs_gluster_set_quota(struct vfs_handle_struct
*handle
,
556 enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
562 static int vfs_gluster_statvfs(struct vfs_handle_struct
*handle
,
563 const struct smb_filename
*smb_fname
,
564 struct vfs_statvfs_struct
*vfs_statvfs
)
566 struct statvfs statvfs
= { 0, };
569 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
571 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
572 smb_fname
->base_name
, strerror(errno
)));
576 ZERO_STRUCTP(vfs_statvfs
);
578 vfs_statvfs
->OptimalTransferSize
= statvfs
.f_frsize
;
579 vfs_statvfs
->BlockSize
= statvfs
.f_bsize
;
580 vfs_statvfs
->TotalBlocks
= statvfs
.f_blocks
;
581 vfs_statvfs
->BlocksAvail
= statvfs
.f_bfree
;
582 vfs_statvfs
->UserBlocksAvail
= statvfs
.f_bavail
;
583 vfs_statvfs
->TotalFileNodes
= statvfs
.f_files
;
584 vfs_statvfs
->FreeFileNodes
= statvfs
.f_ffree
;
585 vfs_statvfs
->FsIdentifier
= statvfs
.f_fsid
;
586 vfs_statvfs
->FsCapabilities
=
587 FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
592 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct
*handle
,
593 enum timestamp_set_resolution
*p_ts_res
)
595 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
597 #ifdef HAVE_GFAPI_VER_6
598 caps
|= FILE_SUPPORTS_SPARSE_FILES
;
601 #ifdef STAT_HAVE_NSEC
602 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
608 static glfs_fd_t
*vfs_gluster_fetch_glfd(struct vfs_handle_struct
*handle
,
609 const files_struct
*fsp
)
611 glfs_fd_t
**glfd
= (glfs_fd_t
**)VFS_FETCH_FSP_EXTENSION(handle
, fsp
);
613 DBG_INFO("Failed to fetch fsp extension\n");
617 DBG_INFO("Empty glfs_fd_t pointer\n");
624 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct
*handle
,
625 files_struct
*fsp
, const char *mask
,
628 glfs_fd_t
*glfd
= NULL
;
629 struct smb_filename
*full_fname
= NULL
;
630 struct smb_filename
*smb_fname_dot
= NULL
;
632 smb_fname_dot
= synthetic_smb_fname(fsp
->fsp_name
,
639 if (smb_fname_dot
== NULL
) {
643 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
646 if (full_fname
== NULL
) {
647 TALLOC_FREE(smb_fname_dot
);
651 glfd
= glfs_opendir(handle
->data
, full_fname
->base_name
);
653 TALLOC_FREE(full_fname
);
654 TALLOC_FREE(smb_fname_dot
);
658 TALLOC_FREE(full_fname
);
659 TALLOC_FREE(smb_fname_dot
);
664 static int vfs_gluster_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
668 START_PROFILE(syscall_closedir
);
669 ret
= glfs_closedir((void *)dirp
);
670 END_PROFILE(syscall_closedir
);
675 static struct dirent
*vfs_gluster_readdir(struct vfs_handle_struct
*handle
,
676 struct files_struct
*dirfsp
,
678 SMB_STRUCT_STAT
*sbuf
)
680 static char direntbuf
[512];
683 struct dirent
*dirent
= 0;
685 START_PROFILE(syscall_readdir
);
687 ret
= glfs_readdirplus_r((void *)dirp
, &stat
, (void *)direntbuf
,
690 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
693 if ((ret
< 0) || (dirent
== NULL
)) {
694 END_PROFILE(syscall_readdir
);
699 SET_STAT_INVALID(*sbuf
);
700 if (!S_ISLNK(stat
.st_mode
)) {
701 smb_stat_ex_from_stat(sbuf
, &stat
);
705 END_PROFILE(syscall_readdir
);
709 static long vfs_gluster_telldir(struct vfs_handle_struct
*handle
, DIR *dirp
)
713 START_PROFILE(syscall_telldir
);
714 ret
= glfs_telldir((void *)dirp
);
715 END_PROFILE(syscall_telldir
);
720 static void vfs_gluster_seekdir(struct vfs_handle_struct
*handle
, DIR *dirp
,
723 START_PROFILE(syscall_seekdir
);
724 glfs_seekdir((void *)dirp
, offset
);
725 END_PROFILE(syscall_seekdir
);
728 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
730 START_PROFILE(syscall_rewinddir
);
731 glfs_seekdir((void *)dirp
, 0);
732 END_PROFILE(syscall_rewinddir
);
735 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
736 struct files_struct
*dirfsp
,
737 const struct smb_filename
*smb_fname
,
742 #ifdef HAVE_GFAPI_VER_7_11
743 glfs_fd_t
*pglfd
= NULL
;
745 START_PROFILE(syscall_mkdirat
);
747 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
749 END_PROFILE(syscall_mkdirat
);
750 DBG_ERR("Failed to fetch gluster fd\n");
754 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
756 struct smb_filename
*full_fname
= NULL
;
758 START_PROFILE(syscall_mkdirat
);
760 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
763 if (full_fname
== NULL
) {
764 END_PROFILE(syscall_mkdirat
);
768 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
770 TALLOC_FREE(full_fname
);
773 END_PROFILE(syscall_mkdirat
);
778 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
779 const struct files_struct
*dirfsp
,
780 const struct smb_filename
*smb_fname
,
782 const struct vfs_open_how
*how
)
784 int flags
= how
->flags
;
785 struct smb_filename
*full_fname
= NULL
;
786 bool have_opath
= false;
787 bool became_root
= false;
789 glfs_fd_t
*pglfd
= NULL
;
792 START_PROFILE(syscall_openat
);
794 if (how
->resolve
!= 0) {
795 END_PROFILE(syscall_openat
);
800 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
802 END_PROFILE(syscall_openat
);
809 if (fsp
->fsp_flags
.is_pathref
) {
814 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
817 if (full_fname
== NULL
) {
818 END_PROFILE(syscall_openat
);
822 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
828 * O_CREAT flag in open is handled differently in a way which is *NOT*
829 * safe against symlink race situations. We use glfs_creat() instead
830 * for correctness as glfs_openat() is broken with O_CREAT present
833 if (flags
& O_CREAT
) {
834 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
836 * Replace smb_fname with full_path constructed above.
838 smb_fname
= full_fname
;
842 * smb_fname can either be a full_path or the same one
843 * as received from the caller. In the latter case we
844 * are operating at current working directory.
846 glfd
= glfs_creat(handle
->data
,
847 smb_fname
->base_name
,
851 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
852 #ifdef HAVE_GFAPI_VER_7_11
854 * Fetch Gluster fd for parent directory using dirfsp
855 * before calling glfs_openat();
857 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
859 END_PROFILE(syscall_openat
);
860 DBG_ERR("Failed to fetch gluster fd\n");
864 glfd
= glfs_openat(pglfd
,
865 smb_fname
->base_name
,
870 * Replace smb_fname with full_path constructed above.
872 smb_fname
= full_fname
;
878 * smb_fname can either be a full_path or the same one
879 * as received from the caller. In the latter case we
880 * are operating at current working directory.
882 glfd
= glfs_open(handle
->data
,
883 smb_fname
->base_name
,
892 TALLOC_FREE(full_fname
);
894 fsp
->fsp_flags
.have_proc_fds
= false;
897 END_PROFILE(syscall_openat
);
898 /* no extension destroy_fn, so no need to save errno */
899 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
905 END_PROFILE(syscall_openat
);
906 /* An arbitrary value for error reporting, so you know its us. */
910 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
914 glfs_fd_t
*glfd
= NULL
;
916 START_PROFILE(syscall_close
);
918 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
920 END_PROFILE(syscall_close
);
921 DBG_ERR("Failed to fetch gluster fd\n");
925 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
927 ret
= glfs_close(glfd
);
928 END_PROFILE(syscall_close
);
933 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
934 files_struct
*fsp
, void *data
, size_t n
,
938 glfs_fd_t
*glfd
= NULL
;
940 START_PROFILE_BYTES(syscall_pread
, n
);
942 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
944 END_PROFILE_BYTES(syscall_pread
);
945 DBG_ERR("Failed to fetch gluster fd\n");
949 #ifdef HAVE_GFAPI_VER_7_6
950 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
952 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
954 END_PROFILE_BYTES(syscall_pread
);
959 struct vfs_gluster_pread_state
{
966 struct vfs_aio_state vfs_aio_state
;
967 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
970 static void vfs_gluster_pread_do(void *private_data
);
971 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
972 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
974 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
975 *handle
, TALLOC_CTX
*mem_ctx
,
976 struct tevent_context
*ev
,
978 void *data
, size_t n
,
981 struct vfs_gluster_pread_state
*state
;
982 struct tevent_req
*req
, *subreq
;
984 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
986 DBG_ERR("Failed to fetch gluster fd\n");
990 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
999 state
->offset
= offset
;
1001 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
1002 state
->profile_bytes
, n
);
1003 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1005 subreq
= pthreadpool_tevent_job_send(
1006 state
, ev
, handle
->conn
->sconn
->pool
,
1007 vfs_gluster_pread_do
, state
);
1008 if (tevent_req_nomem(subreq
, req
)) {
1009 return tevent_req_post(req
, ev
);
1011 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
1013 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
1018 static void vfs_gluster_pread_do(void *private_data
)
1020 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
1021 private_data
, struct vfs_gluster_pread_state
);
1022 struct timespec start_time
;
1023 struct timespec end_time
;
1025 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1027 PROFILE_TIMESTAMP(&start_time
);
1030 #ifdef HAVE_GFAPI_VER_7_6
1031 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
1032 state
->offset
, 0, NULL
);
1034 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
1037 } while ((state
->ret
== -1) && (errno
== EINTR
));
1039 if (state
->ret
== -1) {
1040 state
->vfs_aio_state
.error
= errno
;
1043 PROFILE_TIMESTAMP(&end_time
);
1045 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1047 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1050 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
1055 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
1057 struct tevent_req
*req
= tevent_req_callback_data(
1058 subreq
, struct tevent_req
);
1059 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1060 req
, struct vfs_gluster_pread_state
);
1063 ret
= pthreadpool_tevent_job_recv(subreq
);
1064 TALLOC_FREE(subreq
);
1065 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1066 talloc_set_destructor(state
, NULL
);
1068 if (ret
!= EAGAIN
) {
1069 tevent_req_error(req
, ret
);
1073 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1074 * means the lower level pthreadpool failed to create a new
1075 * thread. Fallback to sync processing in that case to allow
1076 * some progress for the client.
1078 vfs_gluster_pread_do(state
);
1081 tevent_req_done(req
);
1084 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1085 struct vfs_aio_state
*vfs_aio_state
)
1087 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1088 req
, struct vfs_gluster_pread_state
);
1090 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1094 *vfs_aio_state
= state
->vfs_aio_state
;
1098 struct vfs_gluster_pwrite_state
{
1105 struct vfs_aio_state vfs_aio_state
;
1106 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1109 static void vfs_gluster_pwrite_do(void *private_data
);
1110 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1111 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1113 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1114 *handle
, TALLOC_CTX
*mem_ctx
,
1115 struct tevent_context
*ev
,
1117 const void *data
, size_t n
,
1120 struct tevent_req
*req
, *subreq
;
1121 struct vfs_gluster_pwrite_state
*state
;
1123 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1125 DBG_ERR("Failed to fetch gluster fd\n");
1129 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1138 state
->offset
= offset
;
1140 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1141 state
->profile_bytes
, n
);
1142 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1144 subreq
= pthreadpool_tevent_job_send(
1145 state
, ev
, handle
->conn
->sconn
->pool
,
1146 vfs_gluster_pwrite_do
, state
);
1147 if (tevent_req_nomem(subreq
, req
)) {
1148 return tevent_req_post(req
, ev
);
1150 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1152 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1157 static void vfs_gluster_pwrite_do(void *private_data
)
1159 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1160 private_data
, struct vfs_gluster_pwrite_state
);
1161 struct timespec start_time
;
1162 struct timespec end_time
;
1164 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1166 PROFILE_TIMESTAMP(&start_time
);
1169 #ifdef HAVE_GFAPI_VER_7_6
1170 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1171 state
->offset
, 0, NULL
, NULL
);
1173 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1176 } while ((state
->ret
== -1) && (errno
== EINTR
));
1178 if (state
->ret
== -1) {
1179 state
->vfs_aio_state
.error
= errno
;
1182 PROFILE_TIMESTAMP(&end_time
);
1184 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1186 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1189 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1194 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1196 struct tevent_req
*req
= tevent_req_callback_data(
1197 subreq
, struct tevent_req
);
1198 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1199 req
, struct vfs_gluster_pwrite_state
);
1202 ret
= pthreadpool_tevent_job_recv(subreq
);
1203 TALLOC_FREE(subreq
);
1204 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1205 talloc_set_destructor(state
, NULL
);
1207 if (ret
!= EAGAIN
) {
1208 tevent_req_error(req
, ret
);
1212 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1213 * means the lower level pthreadpool failed to create a new
1214 * thread. Fallback to sync processing in that case to allow
1215 * some progress for the client.
1217 vfs_gluster_pwrite_do(state
);
1220 tevent_req_done(req
);
1223 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1224 struct vfs_aio_state
*vfs_aio_state
)
1226 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1227 req
, struct vfs_gluster_pwrite_state
);
1229 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1233 *vfs_aio_state
= state
->vfs_aio_state
;
1238 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1239 files_struct
*fsp
, const void *data
,
1240 size_t n
, off_t offset
)
1243 glfs_fd_t
*glfd
= NULL
;
1245 START_PROFILE_BYTES(syscall_pwrite
, n
);
1247 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1249 END_PROFILE_BYTES(syscall_pwrite
);
1250 DBG_ERR("Failed to fetch gluster fd\n");
1254 #ifdef HAVE_GFAPI_VER_7_6
1255 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1257 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1259 END_PROFILE_BYTES(syscall_pwrite
);
1264 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1265 files_struct
*fsp
, off_t offset
, int whence
)
1268 glfs_fd_t
*glfd
= NULL
;
1270 START_PROFILE(syscall_lseek
);
1272 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1274 END_PROFILE(syscall_lseek
);
1275 DBG_ERR("Failed to fetch gluster fd\n");
1279 ret
= glfs_lseek(glfd
, offset
, whence
);
1280 END_PROFILE(syscall_lseek
);
1285 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1286 files_struct
*fromfsp
,
1287 const DATA_BLOB
*hdr
,
1288 off_t offset
, size_t n
)
1294 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1295 int fromfd
, files_struct
*tofsp
,
1296 off_t offset
, size_t n
)
1302 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1303 files_struct
*srcfsp
,
1304 const struct smb_filename
*smb_fname_src
,
1305 files_struct
*dstfsp
,
1306 const struct smb_filename
*smb_fname_dst
)
1310 #ifdef HAVE_GFAPI_VER_7_11
1311 glfs_fd_t
*src_pglfd
= NULL
;
1312 glfs_fd_t
*dst_pglfd
= NULL
;
1314 START_PROFILE(syscall_renameat
);
1316 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1317 if (src_pglfd
== NULL
) {
1318 END_PROFILE(syscall_renameat
);
1319 DBG_ERR("Failed to fetch gluster fd\n");
1323 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1324 if (dst_pglfd
== NULL
) {
1325 END_PROFILE(syscall_renameat
);
1326 DBG_ERR("Failed to fetch gluster fd\n");
1330 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1331 dst_pglfd
, smb_fname_dst
->base_name
);
1333 struct smb_filename
*full_fname_src
= NULL
;
1334 struct smb_filename
*full_fname_dst
= NULL
;
1336 START_PROFILE(syscall_renameat
);
1338 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1341 if (full_fname_src
== NULL
) {
1342 END_PROFILE(syscall_renameat
);
1347 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1350 if (full_fname_dst
== NULL
) {
1351 END_PROFILE(syscall_renameat
);
1352 TALLOC_FREE(full_fname_src
);
1356 ret
= glfs_rename(handle
->data
,
1357 full_fname_src
->base_name
,
1358 full_fname_dst
->base_name
);
1360 TALLOC_FREE(full_fname_src
);
1361 TALLOC_FREE(full_fname_dst
);
1364 END_PROFILE(syscall_renameat
);
1369 struct vfs_gluster_fsync_state
{
1373 struct vfs_aio_state vfs_aio_state
;
1374 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1377 static void vfs_gluster_fsync_do(void *private_data
);
1378 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1379 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1381 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1382 *handle
, TALLOC_CTX
*mem_ctx
,
1383 struct tevent_context
*ev
,
1386 struct tevent_req
*req
, *subreq
;
1387 struct vfs_gluster_fsync_state
*state
;
1389 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1391 DBG_ERR("Failed to fetch gluster fd\n");
1395 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1403 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1404 state
->profile_bytes
, 0);
1405 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1407 subreq
= pthreadpool_tevent_job_send(
1408 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1409 if (tevent_req_nomem(subreq
, req
)) {
1410 return tevent_req_post(req
, ev
);
1412 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1414 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1419 static void vfs_gluster_fsync_do(void *private_data
)
1421 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1422 private_data
, struct vfs_gluster_fsync_state
);
1423 struct timespec start_time
;
1424 struct timespec end_time
;
1426 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1428 PROFILE_TIMESTAMP(&start_time
);
1431 #ifdef HAVE_GFAPI_VER_7_6
1432 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1434 state
->ret
= glfs_fsync(state
->fd
);
1436 } while ((state
->ret
== -1) && (errno
== EINTR
));
1438 if (state
->ret
== -1) {
1439 state
->vfs_aio_state
.error
= errno
;
1442 PROFILE_TIMESTAMP(&end_time
);
1444 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1446 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1449 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1454 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1456 struct tevent_req
*req
= tevent_req_callback_data(
1457 subreq
, struct tevent_req
);
1458 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1459 req
, struct vfs_gluster_fsync_state
);
1462 ret
= pthreadpool_tevent_job_recv(subreq
);
1463 TALLOC_FREE(subreq
);
1464 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1465 talloc_set_destructor(state
, NULL
);
1467 if (ret
!= EAGAIN
) {
1468 tevent_req_error(req
, ret
);
1472 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1473 * means the lower level pthreadpool failed to create a new
1474 * thread. Fallback to sync processing in that case to allow
1475 * some progress for the client.
1477 vfs_gluster_fsync_do(state
);
1480 tevent_req_done(req
);
1483 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1484 struct vfs_aio_state
*vfs_aio_state
)
1486 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1487 req
, struct vfs_gluster_fsync_state
);
1489 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1493 *vfs_aio_state
= state
->vfs_aio_state
;
1497 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1498 struct smb_filename
*smb_fname
)
1503 START_PROFILE(syscall_stat
);
1504 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1506 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1508 if (ret
< 0 && errno
!= ENOENT
) {
1509 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1510 smb_fname
->base_name
, strerror(errno
)));
1512 END_PROFILE(syscall_stat
);
1517 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1518 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1522 glfs_fd_t
*glfd
= NULL
;
1524 START_PROFILE(syscall_fstat
);
1526 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1528 END_PROFILE(syscall_fstat
);
1529 DBG_ERR("Failed to fetch gluster fd\n");
1533 ret
= glfs_fstat(glfd
, &st
);
1535 smb_stat_ex_from_stat(sbuf
, &st
);
1538 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1539 fsp_get_io_fd(fsp
), strerror(errno
)));
1541 END_PROFILE(syscall_fstat
);
1546 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1547 struct smb_filename
*smb_fname
)
1552 START_PROFILE(syscall_lstat
);
1553 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1555 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1557 if (ret
< 0 && errno
!= ENOENT
) {
1558 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1559 smb_fname
->base_name
, strerror(errno
)));
1561 END_PROFILE(syscall_lstat
);
1566 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1568 const SMB_STRUCT_STAT
*sbuf
)
1572 START_PROFILE(syscall_get_alloc_size
);
1573 ret
= sbuf
->st_ex_blocks
* 512;
1574 END_PROFILE(syscall_get_alloc_size
);
1579 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1580 struct files_struct
*dirfsp
,
1581 const struct smb_filename
*smb_fname
,
1586 #ifdef HAVE_GFAPI_VER_7_11
1587 glfs_fd_t
*pglfd
= NULL
;
1589 START_PROFILE(syscall_unlinkat
);
1591 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1592 if (pglfd
== NULL
) {
1593 END_PROFILE(syscall_unlinkat
);
1594 DBG_ERR("Failed to fetch gluster fd\n");
1598 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1600 struct smb_filename
*full_fname
= NULL
;
1602 START_PROFILE(syscall_unlinkat
);
1604 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1607 if (full_fname
== NULL
) {
1608 END_PROFILE(syscall_unlinkat
);
1612 if (flags
& AT_REMOVEDIR
) {
1613 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1615 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1618 TALLOC_FREE(full_fname
);
1621 END_PROFILE(syscall_unlinkat
);
1626 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1627 files_struct
*fsp
, mode_t mode
)
1630 glfs_fd_t
*glfd
= NULL
;
1632 START_PROFILE(syscall_fchmod
);
1634 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1636 END_PROFILE(syscall_fchmod
);
1637 DBG_ERR("Failed to fetch gluster fd\n");
1641 if (!fsp
->fsp_flags
.is_pathref
) {
1643 * We can use an io_fd to remove xattrs.
1645 ret
= glfs_fchmod(glfd
, mode
);
1648 * This is no longer a handle based call.
1650 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1652 END_PROFILE(syscall_fchmod
);
1657 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1658 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1661 glfs_fd_t
*glfd
= NULL
;
1663 START_PROFILE(syscall_fchown
);
1665 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1667 END_PROFILE(syscall_fchown
);
1668 DBG_ERR("Failed to fetch gluster fd\n");
1672 ret
= glfs_fchown(glfd
, uid
, gid
);
1673 END_PROFILE(syscall_fchown
);
1678 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1679 const struct smb_filename
*smb_fname
,
1685 START_PROFILE(syscall_lchown
);
1686 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1687 END_PROFILE(syscall_lchown
);
1692 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1693 const struct smb_filename
*smb_fname
)
1697 START_PROFILE(syscall_chdir
);
1698 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1699 END_PROFILE(syscall_chdir
);
1704 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1707 char cwd
[PATH_MAX
] = { '\0' };
1709 struct smb_filename
*smb_fname
= NULL
;
1711 START_PROFILE(syscall_getwd
);
1713 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1714 END_PROFILE(syscall_getwd
);
1719 smb_fname
= synthetic_smb_fname(ctx
,
1728 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1730 struct smb_file_time
*ft
)
1733 struct timespec times
[2];
1734 glfs_fd_t
*glfd
= NULL
;
1736 START_PROFILE(syscall_fntimes
);
1738 if (is_omit_timespec(&ft
->atime
)) {
1739 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1740 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1742 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1743 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1746 if (is_omit_timespec(&ft
->mtime
)) {
1747 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1748 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1750 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1751 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1754 if ((timespec_compare(×
[0],
1755 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1756 (timespec_compare(×
[1],
1757 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1758 END_PROFILE(syscall_fntimes
);
1762 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1764 END_PROFILE(syscall_fntimes
);
1765 DBG_ERR("Failed to fetch gluster fd\n");
1769 ret
= glfs_futimens(glfd
, times
);
1770 END_PROFILE(syscall_fntimes
);
1775 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1776 files_struct
*fsp
, off_t offset
)
1779 glfs_fd_t
*glfd
= NULL
;
1781 START_PROFILE(syscall_ftruncate
);
1783 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1785 END_PROFILE(syscall_ftruncate
);
1786 DBG_ERR("Failed to fetch gluster fd\n");
1790 #ifdef HAVE_GFAPI_VER_7_6
1791 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1793 ret
= glfs_ftruncate(glfd
, offset
);
1795 END_PROFILE(syscall_ftruncate
);
1800 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1801 struct files_struct
*fsp
,
1803 off_t offset
, off_t len
)
1806 #ifdef HAVE_GFAPI_VER_6
1807 glfs_fd_t
*glfd
= NULL
;
1808 int keep_size
, punch_hole
;
1810 START_PROFILE(syscall_fallocate
);
1812 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1814 END_PROFILE(syscall_fallocate
);
1815 DBG_ERR("Failed to fetch gluster fd\n");
1819 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1820 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1822 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1824 END_PROFILE(syscall_fallocate
);
1830 ret
= glfs_discard(glfd
, offset
, len
);
1832 DBG_DEBUG("glfs_discard failed: %s\n",
1837 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1838 END_PROFILE(syscall_fallocate
);
1846 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1848 const struct smb_filename
*smb_fname
)
1850 char *result
= NULL
;
1851 struct smb_filename
*result_fname
= NULL
;
1852 char *resolved_path
= NULL
;
1854 START_PROFILE(syscall_realpath
);
1856 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1857 if (resolved_path
== NULL
) {
1858 END_PROFILE(syscall_realpath
);
1863 result
= glfs_realpath(handle
->data
,
1864 smb_fname
->base_name
,
1866 if (result
!= NULL
) {
1867 result_fname
= synthetic_smb_fname(ctx
,
1875 SAFE_FREE(resolved_path
);
1876 END_PROFILE(syscall_realpath
);
1878 return result_fname
;
1881 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1882 files_struct
*fsp
, int op
, off_t offset
,
1883 off_t count
, int type
)
1885 struct flock flock
= { 0, };
1887 glfs_fd_t
*glfd
= NULL
;
1890 START_PROFILE(syscall_fcntl_lock
);
1892 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1894 DBG_ERR("Failed to fetch gluster fd\n");
1899 flock
.l_type
= type
;
1900 flock
.l_whence
= SEEK_SET
;
1901 flock
.l_start
= offset
;
1902 flock
.l_len
= count
;
1905 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1907 if (op
== F_GETLK
) {
1908 /* lock query, true if someone else has locked */
1910 (flock
.l_type
!= F_UNLCK
) &&
1911 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1927 END_PROFILE(syscall_fcntl_lock
);
1932 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1934 uint32_t share_access
,
1935 uint32_t access_mask
)
1941 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1942 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1945 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1946 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1948 if (cmd
== F_GETFL
) {
1950 } else if (cmd
== F_SETFL
) {
1951 va_list dup_cmd_arg
;
1954 va_copy(dup_cmd_arg
, cmd_arg
);
1955 opt
= va_arg(dup_cmd_arg
, int);
1956 va_end(dup_cmd_arg
);
1960 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1963 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1969 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1970 files_struct
*fsp
, int leasetype
)
1976 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1977 files_struct
*fsp
, off_t
*poffset
,
1978 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1980 struct flock flock
= { 0, };
1982 glfs_fd_t
*glfd
= NULL
;
1984 START_PROFILE(syscall_fcntl_getlock
);
1986 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1988 END_PROFILE(syscall_fcntl_getlock
);
1989 DBG_ERR("Failed to fetch gluster fd\n");
1993 flock
.l_type
= *ptype
;
1994 flock
.l_whence
= SEEK_SET
;
1995 flock
.l_start
= *poffset
;
1996 flock
.l_len
= *pcount
;
1999 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
2002 END_PROFILE(syscall_fcntl_getlock
);
2006 *ptype
= flock
.l_type
;
2007 *poffset
= flock
.l_start
;
2008 *pcount
= flock
.l_len
;
2009 *ppid
= flock
.l_pid
;
2010 END_PROFILE(syscall_fcntl_getlock
);
2015 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
2016 const struct smb_filename
*link_target
,
2017 struct files_struct
*dirfsp
,
2018 const struct smb_filename
*new_smb_fname
)
2022 #ifdef HAVE_GFAPI_VER_7_11
2023 glfs_fd_t
*pglfd
= NULL
;
2025 START_PROFILE(syscall_symlinkat
);
2027 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2028 if (pglfd
== NULL
) {
2029 END_PROFILE(syscall_symlinkat
);
2030 DBG_ERR("Failed to fetch gluster fd\n");
2034 ret
= glfs_symlinkat(link_target
->base_name
,
2036 new_smb_fname
->base_name
);
2038 struct smb_filename
*full_fname
= NULL
;
2040 START_PROFILE(syscall_symlinkat
);
2042 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2045 if (full_fname
== NULL
) {
2046 END_PROFILE(syscall_symlinkat
);
2050 ret
= glfs_symlink(handle
->data
,
2051 link_target
->base_name
,
2052 full_fname
->base_name
);
2054 TALLOC_FREE(full_fname
);
2057 END_PROFILE(syscall_symlinkat
);
2062 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2063 const struct files_struct
*dirfsp
,
2064 const struct smb_filename
*smb_fname
,
2070 #ifdef HAVE_GFAPI_VER_7_11
2071 glfs_fd_t
*pglfd
= NULL
;
2073 START_PROFILE(syscall_readlinkat
);
2075 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2076 if (pglfd
== NULL
) {
2077 END_PROFILE(syscall_readlinkat
);
2078 DBG_ERR("Failed to fetch gluster fd\n");
2082 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2084 struct smb_filename
*full_fname
= NULL
;
2086 START_PROFILE(syscall_readlinkat
);
2088 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2091 if (full_fname
== NULL
) {
2092 END_PROFILE(syscall_readlinkat
);
2096 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2098 TALLOC_FREE(full_fname
);
2101 END_PROFILE(syscall_readlinkat
);
2106 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2107 files_struct
*srcfsp
,
2108 const struct smb_filename
*old_smb_fname
,
2109 files_struct
*dstfsp
,
2110 const struct smb_filename
*new_smb_fname
,
2114 struct smb_filename
*full_fname_old
= NULL
;
2115 struct smb_filename
*full_fname_new
= NULL
;
2117 START_PROFILE(syscall_linkat
);
2119 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2122 if (full_fname_old
== NULL
) {
2123 END_PROFILE(syscall_linkat
);
2126 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2129 if (full_fname_new
== NULL
) {
2130 TALLOC_FREE(full_fname_old
);
2131 END_PROFILE(syscall_linkat
);
2135 ret
= glfs_link(handle
->data
,
2136 full_fname_old
->base_name
,
2137 full_fname_new
->base_name
);
2139 TALLOC_FREE(full_fname_old
);
2140 TALLOC_FREE(full_fname_new
);
2141 END_PROFILE(syscall_linkat
);
2146 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2147 files_struct
*dirfsp
,
2148 const struct smb_filename
*smb_fname
,
2152 struct smb_filename
*full_fname
= NULL
;
2155 START_PROFILE(syscall_mknodat
);
2157 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2160 if (full_fname
== NULL
) {
2161 END_PROFILE(syscall_mknodat
);
2165 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2167 TALLOC_FREE(full_fname
);
2169 END_PROFILE(syscall_mknodat
);
2174 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2175 struct files_struct
*fsp
,
2182 static NTSTATUS
vfs_gluster_get_real_filename_at(
2183 struct vfs_handle_struct
*handle
,
2184 struct files_struct
*dirfsp
,
2186 TALLOC_CTX
*mem_ctx
,
2190 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2191 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2192 NTSTATUS status
= NT_STATUS_OK
;
2193 struct smb_filename
*smb_fname_dot
= NULL
;
2194 struct smb_filename
*full_fname
= NULL
;
2196 smb_fname_dot
= synthetic_smb_fname(mem_ctx
,
2202 if (smb_fname_dot
== NULL
) {
2203 return NT_STATUS_NO_MEMORY
;
2206 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2209 if (full_fname
== NULL
) {
2210 TALLOC_FREE(smb_fname_dot
);
2211 return NT_STATUS_NO_MEMORY
;
2214 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2215 status
= NT_STATUS_OBJECT_NAME_INVALID
;
2219 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2220 "glusterfs.get_real_filename:%s", name
);
2222 ret
= glfs_getxattr(handle
->data
, full_fname
->base_name
,
2223 key_buf
, val_buf
, GLUSTER_NAME_MAX
+ 1);
2225 if (errno
== ENOATTR
) {
2228 status
= map_nt_error_from_unix(errno
);
2232 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2233 if (found_name
[0] == NULL
) {
2234 status
= NT_STATUS_NO_MEMORY
;
2239 TALLOC_FREE(smb_fname_dot
);
2240 TALLOC_FREE(full_fname
);
2245 static const char *vfs_gluster_connectpath(struct vfs_handle_struct
*handle
,
2246 const struct smb_filename
*smb_fname
)
2248 return handle
->conn
->connectpath
;
2253 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2254 files_struct
*fsp
, const char *name
,
2255 void *value
, size_t size
)
2257 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2259 DBG_ERR("Failed to fetch gluster fd\n");
2263 return glfs_fgetxattr(glfd
, name
, value
, size
);
2266 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2267 files_struct
*fsp
, char *list
,
2270 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2272 DBG_ERR("Failed to fetch gluster fd\n");
2275 if (!fsp
->fsp_flags
.is_pathref
) {
2277 * We can use an io_fd to list xattrs.
2279 return glfs_flistxattr(glfd
, list
, size
);
2282 * This is no longer a handle based call.
2284 return glfs_listxattr(handle
->data
,
2285 fsp
->fsp_name
->base_name
,
2291 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2292 files_struct
*fsp
, const char *name
)
2294 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2296 DBG_ERR("Failed to fetch gluster fd\n");
2299 if (!fsp
->fsp_flags
.is_pathref
) {
2301 * We can use an io_fd to remove xattrs.
2303 return glfs_fremovexattr(glfd
, name
);
2306 * This is no longer a handle based call.
2308 return glfs_removexattr(handle
->data
,
2309 fsp
->fsp_name
->base_name
,
2314 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2315 files_struct
*fsp
, const char *name
,
2316 const void *value
, size_t size
, int flags
)
2318 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2320 DBG_ERR("Failed to fetch gluster fd\n");
2324 if (!fsp
->fsp_flags
.is_pathref
) {
2326 * We can use an io_fd to set xattrs.
2328 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2331 * This is no longer a handle based call.
2333 return glfs_setxattr(handle
->data
,
2334 fsp
->fsp_name
->base_name
,
2342 /* AIO Operations */
2344 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2350 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2351 struct files_struct
*dirfsp
,
2352 const struct smb_filename
*smb_fname
,
2353 const struct referral
*reflist
,
2354 size_t referral_count
)
2356 TALLOC_CTX
*frame
= talloc_stackframe();
2357 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2359 char *msdfs_link
= NULL
;
2360 struct smb_filename
*full_fname
= NULL
;
2362 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2365 if (full_fname
== NULL
) {
2369 /* Form the msdfs_link contents */
2370 msdfs_link
= msdfs_link_string(frame
,
2373 if (msdfs_link
== NULL
) {
2377 ret
= glfs_symlink(handle
->data
,
2379 full_fname
->base_name
);
2381 status
= NT_STATUS_OK
;
2383 status
= map_nt_error_from_unix(errno
);
2393 * Read and return the contents of a DFS redirect given a
2394 * pathname. A caller can pass in NULL for ppreflist and
2395 * preferral_count but still determine if this was a
2396 * DFS redirect point by getting NT_STATUS_OK back
2397 * without incurring the overhead of reading and parsing
2398 * the referral contents.
2401 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2402 TALLOC_CTX
*mem_ctx
,
2403 struct files_struct
*dirfsp
,
2404 struct smb_filename
*smb_fname
,
2405 struct referral
**ppreflist
,
2406 size_t *preferral_count
)
2408 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2410 char *link_target
= NULL
;
2413 #if defined(HAVE_BROKEN_READLINK)
2414 char link_target_buf
[PATH_MAX
];
2416 char link_target_buf
[7];
2419 struct smb_filename
*full_fname
= NULL
;
2422 if (is_named_stream(smb_fname
)) {
2423 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2427 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2429 * We're only checking if this is a DFS
2430 * redirect. We don't need to return data.
2432 bufsize
= sizeof(link_target_buf
);
2433 link_target
= link_target_buf
;
2436 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2442 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2445 if (full_fname
== NULL
) {
2446 status
= NT_STATUS_NO_MEMORY
;
2450 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2452 status
= map_nt_error_from_unix(errno
);
2456 referral_len
= glfs_readlink(handle
->data
,
2457 full_fname
->base_name
,
2460 if (referral_len
< 0) {
2461 if (errno
== EINVAL
) {
2462 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2463 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2465 status
= map_nt_error_from_unix(errno
);
2466 DBG_ERR("Error reading "
2467 "msdfs link %s: %s\n",
2468 full_fname
->base_name
,
2473 link_target
[referral_len
] = '\0';
2475 DBG_INFO("%s -> %s\n",
2476 full_fname
->base_name
,
2479 if (!strnequal(link_target
, "msdfs:", 6)) {
2480 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2484 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2485 /* Early return for checking if this is a DFS link. */
2486 TALLOC_FREE(full_fname
);
2487 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2488 return NT_STATUS_OK
;
2491 ok
= parse_msdfs_symlink(mem_ctx
,
2492 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2498 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2499 status
= NT_STATUS_OK
;
2501 status
= NT_STATUS_NO_MEMORY
;
2506 if (link_target
!= link_target_buf
) {
2507 TALLOC_FREE(link_target
);
2509 TALLOC_FREE(full_fname
);
2513 static struct vfs_fn_pointers glusterfs_fns
= {
2515 /* Disk Operations */
2517 .connect_fn
= vfs_gluster_connect
,
2518 .disconnect_fn
= vfs_gluster_disconnect
,
2519 .disk_free_fn
= vfs_gluster_disk_free
,
2520 .get_quota_fn
= vfs_gluster_get_quota
,
2521 .set_quota_fn
= vfs_gluster_set_quota
,
2522 .statvfs_fn
= vfs_gluster_statvfs
,
2523 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2525 .get_dfs_referrals_fn
= NULL
,
2527 /* Directory Operations */
2529 .fdopendir_fn
= vfs_gluster_fdopendir
,
2530 .readdir_fn
= vfs_gluster_readdir
,
2531 .seekdir_fn
= vfs_gluster_seekdir
,
2532 .telldir_fn
= vfs_gluster_telldir
,
2533 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2534 .mkdirat_fn
= vfs_gluster_mkdirat
,
2535 .closedir_fn
= vfs_gluster_closedir
,
2537 /* File Operations */
2539 .openat_fn
= vfs_gluster_openat
,
2540 .create_file_fn
= NULL
,
2541 .close_fn
= vfs_gluster_close
,
2542 .pread_fn
= vfs_gluster_pread
,
2543 .pread_send_fn
= vfs_gluster_pread_send
,
2544 .pread_recv_fn
= vfs_gluster_pread_recv
,
2545 .pwrite_fn
= vfs_gluster_pwrite
,
2546 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2547 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2548 .lseek_fn
= vfs_gluster_lseek
,
2549 .sendfile_fn
= vfs_gluster_sendfile
,
2550 .recvfile_fn
= vfs_gluster_recvfile
,
2551 .renameat_fn
= vfs_gluster_renameat
,
2552 .fsync_send_fn
= vfs_gluster_fsync_send
,
2553 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2555 .stat_fn
= vfs_gluster_stat
,
2556 .fstat_fn
= vfs_gluster_fstat
,
2557 .lstat_fn
= vfs_gluster_lstat
,
2558 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2559 .unlinkat_fn
= vfs_gluster_unlinkat
,
2561 .fchmod_fn
= vfs_gluster_fchmod
,
2562 .fchown_fn
= vfs_gluster_fchown
,
2563 .lchown_fn
= vfs_gluster_lchown
,
2564 .chdir_fn
= vfs_gluster_chdir
,
2565 .getwd_fn
= vfs_gluster_getwd
,
2566 .fntimes_fn
= vfs_gluster_fntimes
,
2567 .ftruncate_fn
= vfs_gluster_ftruncate
,
2568 .fallocate_fn
= vfs_gluster_fallocate
,
2569 .lock_fn
= vfs_gluster_lock
,
2570 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2571 .fcntl_fn
= vfs_gluster_fcntl
,
2572 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2573 .getlock_fn
= vfs_gluster_getlock
,
2574 .symlinkat_fn
= vfs_gluster_symlinkat
,
2575 .readlinkat_fn
= vfs_gluster_readlinkat
,
2576 .linkat_fn
= vfs_gluster_linkat
,
2577 .mknodat_fn
= vfs_gluster_mknodat
,
2578 .realpath_fn
= vfs_gluster_realpath
,
2579 .fchflags_fn
= vfs_gluster_fchflags
,
2580 .file_id_create_fn
= NULL
,
2581 .fstreaminfo_fn
= NULL
,
2582 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2583 .connectpath_fn
= vfs_gluster_connectpath
,
2584 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2585 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2587 .brl_lock_windows_fn
= NULL
,
2588 .brl_unlock_windows_fn
= NULL
,
2589 .strict_lock_check_fn
= NULL
,
2590 .translate_name_fn
= NULL
,
2593 /* NT ACL Operations */
2594 .fget_nt_acl_fn
= NULL
,
2595 .fset_nt_acl_fn
= NULL
,
2596 .audit_file_fn
= NULL
,
2598 /* Posix ACL Operations */
2599 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2600 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2601 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2602 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2605 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2606 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2607 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2608 .flistxattr_fn
= vfs_gluster_flistxattr
,
2609 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2610 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2612 /* AIO Operations */
2613 .aio_force_fn
= vfs_gluster_aio_force
,
2615 /* Durable handle Operations */
2616 .durable_cookie_fn
= NULL
,
2617 .durable_disconnect_fn
= NULL
,
2618 .durable_reconnect_fn
= NULL
,
2622 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2624 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2625 "glusterfs", &glusterfs_fns
);