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 "lib/util/util_file.h"
45 #include "smbd/globals.h"
46 #include "lib/util/sys_rw.h"
47 #include "smbprofile.h"
48 #include "modules/posixacl_xattr.h"
49 #include "lib/pthreadpool/pthreadpool_tevent.h"
51 #define DEFAULT_VOLFILE_SERVER "localhost"
52 #define GLUSTER_NAME_MAX 255
55 * Helper to convert struct stat to struct stat_ex.
57 static void smb_stat_ex_from_stat(struct stat_ex
*dst
, const struct stat
*src
)
61 dst
->st_ex_dev
= src
->st_dev
;
62 dst
->st_ex_ino
= src
->st_ino
;
63 dst
->st_ex_mode
= src
->st_mode
;
64 dst
->st_ex_nlink
= src
->st_nlink
;
65 dst
->st_ex_uid
= src
->st_uid
;
66 dst
->st_ex_gid
= src
->st_gid
;
67 dst
->st_ex_rdev
= src
->st_rdev
;
68 dst
->st_ex_size
= src
->st_size
;
69 dst
->st_ex_atime
.tv_sec
= src
->st_atime
;
70 dst
->st_ex_mtime
.tv_sec
= src
->st_mtime
;
71 dst
->st_ex_ctime
.tv_sec
= src
->st_ctime
;
72 dst
->st_ex_btime
.tv_sec
= src
->st_mtime
;
73 dst
->st_ex_blksize
= src
->st_blksize
;
74 dst
->st_ex_blocks
= src
->st_blocks
;
76 dst
->st_ex_atime
.tv_nsec
= src
->st_atime_nsec
;
77 dst
->st_ex_mtime
.tv_nsec
= src
->st_mtime_nsec
;
78 dst
->st_ex_ctime
.tv_nsec
= src
->st_ctime_nsec
;
79 dst
->st_ex_btime
.tv_nsec
= src
->st_mtime_nsec
;
83 /* pre-opened glfs_t */
85 static struct glfs_preopened
{
90 struct glfs_preopened
*next
, *prev
;
94 static int glfs_set_preopened(const char *volume
, const char *connectpath
, glfs_t
*fs
)
96 struct glfs_preopened
*entry
= NULL
;
98 entry
= talloc_zero(NULL
, struct glfs_preopened
);
104 entry
->volume
= talloc_strdup(entry
, volume
);
105 if (!entry
->volume
) {
111 entry
->connectpath
= talloc_strdup(entry
, connectpath
);
112 if (entry
->connectpath
== NULL
) {
121 DLIST_ADD(glfs_preopened
, entry
);
126 static glfs_t
*glfs_find_preopened(const char *volume
, const char *connectpath
)
128 struct glfs_preopened
*entry
= NULL
;
130 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
131 if (strcmp(entry
->volume
, volume
) == 0 &&
132 strcmp(entry
->connectpath
, connectpath
) == 0)
142 static void glfs_clear_preopened(glfs_t
*fs
)
144 struct glfs_preopened
*entry
= NULL
;
146 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
147 if (entry
->fs
== fs
) {
151 DLIST_REMOVE(glfs_preopened
, entry
);
153 glfs_fini(entry
->fs
);
160 static int vfs_gluster_set_volfile_servers(glfs_t
*fs
,
161 const char *volfile_servers
)
164 size_t server_count
= 0;
165 size_t server_success
= 0;
167 TALLOC_CTX
*frame
= talloc_stackframe();
169 DBG_INFO("servers list %s\n", volfile_servers
);
171 while (next_token_talloc(frame
, &volfile_servers
, &server
, " \t")) {
172 char *transport
= NULL
;
177 DBG_INFO("server %zu %s\n", server_count
, server
);
179 /* Determine the transport type */
180 if (strncmp(server
, "unix+", 5) == 0) {
182 transport
= talloc_strdup(frame
, "unix");
187 host
= talloc_strdup(frame
, server
+ 5);
194 char *port_index
= NULL
;
196 if (strncmp(server
, "tcp+", 4) == 0) {
200 /* IPv6 is enclosed in []
201 * ':' before ']' is part of IPv6
202 * ':' after ']' indicates port
205 if (server
[0] == '[') {
207 p
= index(server
, ']');
216 port_index
= index(p
, ':');
218 if (port_index
== NULL
) {
221 port
= atoi(port_index
+ 1);
222 port_index
[0] = '\0';
224 transport
= talloc_strdup(frame
, "tcp");
229 host
= talloc_strdup(frame
, server
);
236 DBG_INFO("Calling set volfile server with params "
237 "transport=%s, host=%s, port=%d\n", transport
,
240 ret
= glfs_set_volfile_server(fs
, transport
, host
, port
);
242 DBG_WARNING("Failed to set volfile_server "
243 "transport=%s, host=%s, port=%d (%s)\n",
244 transport
, host
, port
, strerror(errno
));
251 if (server_count
== 0) {
253 } else if (server_success
< server_count
) {
254 DBG_WARNING("Failed to set %zu out of %zu servers parsed\n",
255 server_count
- server_success
, server_count
);
263 /* Disk Operations */
265 static int check_for_write_behind_translator(TALLOC_CTX
*mem_ctx
,
274 bool write_behind_present
= false;
278 ret
= glfs_get_volfile(fs
, NULL
, 0);
280 DBG_ERR("%s: Failed to get volfile for "
281 "volume (%s): No volfile\n",
287 DBG_ERR("%s: Invalid return %d for glfs_get_volfile for "
288 "volume (%s): No volfile\n",
297 buf
= talloc_zero_array(mem_ctx
, char, newlen
);
302 ret
= glfs_get_volfile(fs
, buf
, newlen
);
305 DBG_ERR("%s: Failed to get volfile for volume (%s)\n",
306 volume
, strerror(errno
));
310 option
= talloc_asprintf(mem_ctx
, "volume %s-write-behind", volume
);
311 if (option
== NULL
) {
317 * file_lines_parse() plays horrible tricks with
318 * the passed-in talloc pointers and the hierarchy
319 * which makes freeing hard to get right.
321 * As we know mem_ctx is freed by the caller, after
322 * this point don't free on exit and let the caller
323 * handle it. This violates good Samba coding practice
324 * but we know we're not leaking here.
327 lines
= file_lines_parse(buf
,
331 if (lines
== NULL
|| numlines
<= 0) {
334 /* On success, buf is now a talloc child of lines !! */
336 for (i
=0; i
< numlines
; i
++) {
337 if (strequal(lines
[i
], option
)) {
338 write_behind_present
= true;
343 if (write_behind_present
) {
344 DBG_ERR("Write behind translator is enabled for "
345 "volume (%s), refusing to connect! "
346 "Please turn off the write behind translator by calling "
347 "'gluster volume set %s performance.write-behind off' "
348 "on the commandline. "
349 "Check the vfs_glusterfs(8) manpage for "
350 "further details.\n",
358 static int vfs_gluster_connect(struct vfs_handle_struct
*handle
,
362 const struct loadparm_substitution
*lp_sub
=
363 loadparm_s3_global_substitution();
364 const char *volfile_servers
;
371 bool write_behind_pass_through_set
= false;
373 tmp_ctx
= talloc_new(NULL
);
374 if (tmp_ctx
== NULL
) {
378 logfile
= lp_parm_substituted_string(tmp_ctx
,
385 loglevel
= lp_parm_int(SNUM(handle
->conn
), "glusterfs", "loglevel", -1);
387 volfile_servers
= lp_parm_substituted_string(tmp_ctx
,
393 if (volfile_servers
== NULL
) {
394 volfile_servers
= DEFAULT_VOLFILE_SERVER
;
397 volume
= lp_parm_const_string(SNUM(handle
->conn
), "glusterfs", "volume",
399 if (volume
== NULL
) {
403 fs
= glfs_find_preopened(volume
, handle
->conn
->connectpath
);
408 fs
= glfs_new(volume
);
414 ret
= vfs_gluster_set_volfile_servers(fs
, volfile_servers
);
416 DBG_ERR("Failed to set volfile_servers from list %s\n",
421 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-posix-acl",
424 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
428 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-selinux",
431 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
435 ret
= glfs_set_xlator_option(fs
, "*-snapview-client",
436 "snapdir-entry-path",
437 handle
->conn
->connectpath
);
439 DEBUG(0, ("%s: Failed to set xlator option:"
440 " snapdir-entry-path\n", volume
));
444 #ifdef HAVE_GFAPI_VER_7_9
445 ret
= glfs_set_xlator_option(fs
, "*-write-behind", "pass-through",
448 DBG_ERR("%s: Failed to set xlator option: pass-through\n",
452 write_behind_pass_through_set
= true;
455 ret
= glfs_set_logging(fs
, logfile
, loglevel
);
457 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
458 volume
, logfile
, loglevel
));
464 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
465 volume
, strerror(errno
)));
469 if (!write_behind_pass_through_set
) {
470 ret
= check_for_write_behind_translator(tmp_ctx
, fs
, volume
);
476 ret
= glfs_set_preopened(volume
, handle
->conn
->connectpath
, fs
);
478 DEBUG(0, ("%s: Failed to register volume (%s)\n",
479 volume
, strerror(errno
)));
484 * The shadow_copy2 module will fail to export subdirectories
485 * of a gluster volume unless we specify the mount point,
486 * because the detection fails if the file system is not
488 * https://bugzilla.samba.org/show_bug.cgi?id=13091
490 lp_do_parameter(SNUM(handle
->conn
), "shadow:mountpoint", "/");
493 * Unless we have an async implementation of getxattrat turn this off.
495 lp_do_parameter(SNUM(handle
->conn
), "smbd async dosmode", "false");
502 DBG_ERR("%s: Initialized volume from servers %s\n",
503 volume
, volfile_servers
);
506 talloc_free(tmp_ctx
);
510 static void vfs_gluster_disconnect(struct vfs_handle_struct
*handle
)
516 glfs_clear_preopened(fs
);
519 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct
*handle
,
520 const struct smb_filename
*smb_fname
,
525 struct statvfs statvfs
= { 0, };
528 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
533 if (bsize_p
!= NULL
) {
534 *bsize_p
= (uint64_t)statvfs
.f_bsize
; /* Block size */
536 if (dfree_p
!= NULL
) {
537 *dfree_p
= (uint64_t)statvfs
.f_bavail
; /* Available Block units */
539 if (dsize_p
!= NULL
) {
540 *dsize_p
= (uint64_t)statvfs
.f_blocks
; /* Total Block units */
543 return (uint64_t)statvfs
.f_bavail
;
546 static int vfs_gluster_get_quota(struct vfs_handle_struct
*handle
,
547 const struct smb_filename
*smb_fname
,
548 enum SMB_QUOTA_TYPE qtype
,
557 vfs_gluster_set_quota(struct vfs_handle_struct
*handle
,
558 enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
564 static int vfs_gluster_statvfs(struct vfs_handle_struct
*handle
,
565 const struct smb_filename
*smb_fname
,
566 struct vfs_statvfs_struct
*vfs_statvfs
)
568 struct statvfs statvfs
= { 0, };
571 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
573 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
574 smb_fname
->base_name
, strerror(errno
)));
578 ZERO_STRUCTP(vfs_statvfs
);
580 vfs_statvfs
->OptimalTransferSize
= statvfs
.f_frsize
;
581 vfs_statvfs
->BlockSize
= statvfs
.f_bsize
;
582 vfs_statvfs
->TotalBlocks
= statvfs
.f_blocks
;
583 vfs_statvfs
->BlocksAvail
= statvfs
.f_bfree
;
584 vfs_statvfs
->UserBlocksAvail
= statvfs
.f_bavail
;
585 vfs_statvfs
->TotalFileNodes
= statvfs
.f_files
;
586 vfs_statvfs
->FreeFileNodes
= statvfs
.f_ffree
;
587 vfs_statvfs
->FsIdentifier
= statvfs
.f_fsid
;
588 vfs_statvfs
->FsCapabilities
=
589 FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
594 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct
*handle
,
595 enum timestamp_set_resolution
*p_ts_res
)
597 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
599 #ifdef HAVE_GFAPI_VER_6
600 caps
|= FILE_SUPPORTS_SPARSE_FILES
;
603 #ifdef STAT_HAVE_NSEC
604 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
610 static glfs_fd_t
*vfs_gluster_fetch_glfd(struct vfs_handle_struct
*handle
,
611 const files_struct
*fsp
)
613 glfs_fd_t
**glfd
= (glfs_fd_t
**)VFS_FETCH_FSP_EXTENSION(handle
, fsp
);
615 DBG_INFO("Failed to fetch fsp extension\n");
619 DBG_INFO("Empty glfs_fd_t pointer\n");
626 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct
*handle
,
627 files_struct
*fsp
, const char *mask
,
630 glfs_fd_t
*glfd
= NULL
;
632 glfd
= glfs_opendir(handle
->data
, fsp
->fsp_name
->base_name
);
640 static int vfs_gluster_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
644 START_PROFILE(syscall_closedir
);
645 ret
= glfs_closedir((void *)dirp
);
646 END_PROFILE(syscall_closedir
);
651 static struct dirent
*vfs_gluster_readdir(struct vfs_handle_struct
*handle
,
652 struct files_struct
*dirfsp
,
655 static char direntbuf
[512];
657 struct dirent
*dirent
= 0;
659 START_PROFILE(syscall_readdir
);
661 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
663 if ((ret
< 0) || (dirent
== NULL
)) {
664 END_PROFILE(syscall_readdir
);
668 END_PROFILE(syscall_readdir
);
672 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
674 START_PROFILE(syscall_rewinddir
);
675 glfs_seekdir((void *)dirp
, 0);
676 END_PROFILE(syscall_rewinddir
);
679 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
680 struct files_struct
*dirfsp
,
681 const struct smb_filename
*smb_fname
,
686 #ifdef HAVE_GFAPI_VER_7_11
687 glfs_fd_t
*pglfd
= NULL
;
689 START_PROFILE(syscall_mkdirat
);
691 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
693 END_PROFILE(syscall_mkdirat
);
694 DBG_ERR("Failed to fetch gluster fd\n");
698 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
700 struct smb_filename
*full_fname
= NULL
;
702 START_PROFILE(syscall_mkdirat
);
704 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
707 if (full_fname
== NULL
) {
708 END_PROFILE(syscall_mkdirat
);
712 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
714 TALLOC_FREE(full_fname
);
717 END_PROFILE(syscall_mkdirat
);
722 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
723 const struct files_struct
*dirfsp
,
724 const struct smb_filename
*smb_fname
,
726 const struct vfs_open_how
*how
)
728 int flags
= how
->flags
;
729 struct smb_filename
*full_fname
= NULL
;
730 bool have_opath
= false;
731 bool became_root
= false;
732 glfs_fd_t
*glfd
= NULL
;
733 glfs_fd_t
*pglfd
= NULL
;
736 START_PROFILE(syscall_openat
);
738 if (how
->resolve
!= 0) {
739 END_PROFILE(syscall_openat
);
744 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
746 END_PROFILE(syscall_openat
);
753 if (fsp
->fsp_flags
.is_pathref
) {
758 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
761 if (full_fname
== NULL
) {
762 END_PROFILE(syscall_openat
);
766 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
771 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
772 #ifdef HAVE_GFAPI_VER_7_11
774 * Fetch Gluster fd for parent directory using dirfsp
775 * before calling glfs_openat();
777 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
779 END_PROFILE(syscall_openat
);
780 DBG_ERR("Failed to fetch gluster fd\n");
784 glfd
= glfs_openat(pglfd
,
785 smb_fname
->base_name
,
790 * Replace smb_fname with full_path constructed above.
792 smb_fname
= full_fname
;
798 * smb_fname can either be a full_path or the same one
799 * as received from the caller. In the latter case we
800 * are operating at current working directory.
802 if (flags
& O_CREAT
) {
803 glfd
= glfs_creat(handle
->data
,
804 smb_fname
->base_name
,
808 glfd
= glfs_open(handle
->data
,
809 smb_fname
->base_name
,
818 TALLOC_FREE(full_fname
);
820 fsp
->fsp_flags
.have_proc_fds
= false;
823 END_PROFILE(syscall_openat
);
824 /* no extension destroy_fn, so no need to save errno */
825 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
831 END_PROFILE(syscall_openat
);
832 /* An arbitrary value for error reporting, so you know its us. */
836 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
840 glfs_fd_t
*glfd
= NULL
;
842 START_PROFILE(syscall_close
);
844 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
846 END_PROFILE(syscall_close
);
847 DBG_ERR("Failed to fetch gluster fd\n");
851 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
853 ret
= glfs_close(glfd
);
854 END_PROFILE(syscall_close
);
859 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
860 files_struct
*fsp
, void *data
, size_t n
,
864 glfs_fd_t
*glfd
= NULL
;
866 START_PROFILE_BYTES(syscall_pread
, n
);
868 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
870 END_PROFILE_BYTES(syscall_pread
);
871 DBG_ERR("Failed to fetch gluster fd\n");
875 #ifdef HAVE_GFAPI_VER_7_6
876 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
878 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
880 END_PROFILE_BYTES(syscall_pread
);
885 struct vfs_gluster_pread_state
{
892 struct vfs_aio_state vfs_aio_state
;
893 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
896 static void vfs_gluster_pread_do(void *private_data
);
897 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
898 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
900 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
901 *handle
, TALLOC_CTX
*mem_ctx
,
902 struct tevent_context
*ev
,
904 void *data
, size_t n
,
907 struct vfs_gluster_pread_state
*state
;
908 struct tevent_req
*req
, *subreq
;
910 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
912 DBG_ERR("Failed to fetch gluster fd\n");
916 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
925 state
->offset
= offset
;
927 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
928 state
->profile_bytes
, n
);
929 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
931 subreq
= pthreadpool_tevent_job_send(
932 state
, ev
, handle
->conn
->sconn
->pool
,
933 vfs_gluster_pread_do
, state
);
934 if (tevent_req_nomem(subreq
, req
)) {
935 return tevent_req_post(req
, ev
);
937 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
939 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
944 static void vfs_gluster_pread_do(void *private_data
)
946 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
947 private_data
, struct vfs_gluster_pread_state
);
948 struct timespec start_time
;
949 struct timespec end_time
;
951 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
953 PROFILE_TIMESTAMP(&start_time
);
956 #ifdef HAVE_GFAPI_VER_7_6
957 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
958 state
->offset
, 0, NULL
);
960 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
963 } while ((state
->ret
== -1) && (errno
== EINTR
));
965 if (state
->ret
== -1) {
966 state
->vfs_aio_state
.error
= errno
;
969 PROFILE_TIMESTAMP(&end_time
);
971 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
973 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
976 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
981 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
983 struct tevent_req
*req
= tevent_req_callback_data(
984 subreq
, struct tevent_req
);
985 struct vfs_gluster_pread_state
*state
= tevent_req_data(
986 req
, struct vfs_gluster_pread_state
);
989 ret
= pthreadpool_tevent_job_recv(subreq
);
991 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
992 talloc_set_destructor(state
, NULL
);
995 tevent_req_error(req
, ret
);
999 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1000 * means the lower level pthreadpool failed to create a new
1001 * thread. Fallback to sync processing in that case to allow
1002 * some progress for the client.
1004 vfs_gluster_pread_do(state
);
1007 tevent_req_done(req
);
1010 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1011 struct vfs_aio_state
*vfs_aio_state
)
1013 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1014 req
, struct vfs_gluster_pread_state
);
1016 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1020 *vfs_aio_state
= state
->vfs_aio_state
;
1024 struct vfs_gluster_pwrite_state
{
1031 struct vfs_aio_state vfs_aio_state
;
1032 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1035 static void vfs_gluster_pwrite_do(void *private_data
);
1036 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1037 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1039 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1040 *handle
, TALLOC_CTX
*mem_ctx
,
1041 struct tevent_context
*ev
,
1043 const void *data
, size_t n
,
1046 struct tevent_req
*req
, *subreq
;
1047 struct vfs_gluster_pwrite_state
*state
;
1049 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1051 DBG_ERR("Failed to fetch gluster fd\n");
1055 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1064 state
->offset
= offset
;
1066 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1067 state
->profile_bytes
, n
);
1068 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1070 subreq
= pthreadpool_tevent_job_send(
1071 state
, ev
, handle
->conn
->sconn
->pool
,
1072 vfs_gluster_pwrite_do
, state
);
1073 if (tevent_req_nomem(subreq
, req
)) {
1074 return tevent_req_post(req
, ev
);
1076 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1078 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1083 static void vfs_gluster_pwrite_do(void *private_data
)
1085 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1086 private_data
, struct vfs_gluster_pwrite_state
);
1087 struct timespec start_time
;
1088 struct timespec end_time
;
1090 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1092 PROFILE_TIMESTAMP(&start_time
);
1095 #ifdef HAVE_GFAPI_VER_7_6
1096 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1097 state
->offset
, 0, NULL
, NULL
);
1099 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1102 } while ((state
->ret
== -1) && (errno
== EINTR
));
1104 if (state
->ret
== -1) {
1105 state
->vfs_aio_state
.error
= errno
;
1108 PROFILE_TIMESTAMP(&end_time
);
1110 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1112 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1115 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1120 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1122 struct tevent_req
*req
= tevent_req_callback_data(
1123 subreq
, struct tevent_req
);
1124 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1125 req
, struct vfs_gluster_pwrite_state
);
1128 ret
= pthreadpool_tevent_job_recv(subreq
);
1129 TALLOC_FREE(subreq
);
1130 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1131 talloc_set_destructor(state
, NULL
);
1133 if (ret
!= EAGAIN
) {
1134 tevent_req_error(req
, ret
);
1138 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1139 * means the lower level pthreadpool failed to create a new
1140 * thread. Fallback to sync processing in that case to allow
1141 * some progress for the client.
1143 vfs_gluster_pwrite_do(state
);
1146 tevent_req_done(req
);
1149 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1150 struct vfs_aio_state
*vfs_aio_state
)
1152 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1153 req
, struct vfs_gluster_pwrite_state
);
1155 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1159 *vfs_aio_state
= state
->vfs_aio_state
;
1164 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1165 files_struct
*fsp
, const void *data
,
1166 size_t n
, off_t offset
)
1169 glfs_fd_t
*glfd
= NULL
;
1171 START_PROFILE_BYTES(syscall_pwrite
, n
);
1173 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1175 END_PROFILE_BYTES(syscall_pwrite
);
1176 DBG_ERR("Failed to fetch gluster fd\n");
1180 #ifdef HAVE_GFAPI_VER_7_6
1181 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1183 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1185 END_PROFILE_BYTES(syscall_pwrite
);
1190 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1191 files_struct
*fsp
, off_t offset
, int whence
)
1194 glfs_fd_t
*glfd
= NULL
;
1196 START_PROFILE(syscall_lseek
);
1198 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1200 END_PROFILE(syscall_lseek
);
1201 DBG_ERR("Failed to fetch gluster fd\n");
1205 ret
= glfs_lseek(glfd
, offset
, whence
);
1206 END_PROFILE(syscall_lseek
);
1211 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1212 files_struct
*fromfsp
,
1213 const DATA_BLOB
*hdr
,
1214 off_t offset
, size_t n
)
1220 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1221 int fromfd
, files_struct
*tofsp
,
1222 off_t offset
, size_t n
)
1228 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1229 files_struct
*srcfsp
,
1230 const struct smb_filename
*smb_fname_src
,
1231 files_struct
*dstfsp
,
1232 const struct smb_filename
*smb_fname_dst
)
1236 #ifdef HAVE_GFAPI_VER_7_11
1237 glfs_fd_t
*src_pglfd
= NULL
;
1238 glfs_fd_t
*dst_pglfd
= NULL
;
1240 START_PROFILE(syscall_renameat
);
1242 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1243 if (src_pglfd
== NULL
) {
1244 END_PROFILE(syscall_renameat
);
1245 DBG_ERR("Failed to fetch gluster fd\n");
1249 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1250 if (dst_pglfd
== NULL
) {
1251 END_PROFILE(syscall_renameat
);
1252 DBG_ERR("Failed to fetch gluster fd\n");
1256 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1257 dst_pglfd
, smb_fname_dst
->base_name
);
1259 struct smb_filename
*full_fname_src
= NULL
;
1260 struct smb_filename
*full_fname_dst
= NULL
;
1262 START_PROFILE(syscall_renameat
);
1264 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1267 if (full_fname_src
== NULL
) {
1268 END_PROFILE(syscall_renameat
);
1273 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1276 if (full_fname_dst
== NULL
) {
1277 END_PROFILE(syscall_renameat
);
1278 TALLOC_FREE(full_fname_src
);
1282 ret
= glfs_rename(handle
->data
,
1283 full_fname_src
->base_name
,
1284 full_fname_dst
->base_name
);
1286 TALLOC_FREE(full_fname_src
);
1287 TALLOC_FREE(full_fname_dst
);
1290 END_PROFILE(syscall_renameat
);
1295 struct vfs_gluster_fsync_state
{
1299 struct vfs_aio_state vfs_aio_state
;
1300 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1303 static void vfs_gluster_fsync_do(void *private_data
);
1304 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1305 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1307 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1308 *handle
, TALLOC_CTX
*mem_ctx
,
1309 struct tevent_context
*ev
,
1312 struct tevent_req
*req
, *subreq
;
1313 struct vfs_gluster_fsync_state
*state
;
1315 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1317 DBG_ERR("Failed to fetch gluster fd\n");
1321 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1329 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1330 state
->profile_bytes
, 0);
1331 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1333 subreq
= pthreadpool_tevent_job_send(
1334 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1335 if (tevent_req_nomem(subreq
, req
)) {
1336 return tevent_req_post(req
, ev
);
1338 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1340 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1345 static void vfs_gluster_fsync_do(void *private_data
)
1347 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1348 private_data
, struct vfs_gluster_fsync_state
);
1349 struct timespec start_time
;
1350 struct timespec end_time
;
1352 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1354 PROFILE_TIMESTAMP(&start_time
);
1357 #ifdef HAVE_GFAPI_VER_7_6
1358 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1360 state
->ret
= glfs_fsync(state
->fd
);
1362 } while ((state
->ret
== -1) && (errno
== EINTR
));
1364 if (state
->ret
== -1) {
1365 state
->vfs_aio_state
.error
= errno
;
1368 PROFILE_TIMESTAMP(&end_time
);
1370 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1372 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1375 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1380 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1382 struct tevent_req
*req
= tevent_req_callback_data(
1383 subreq
, struct tevent_req
);
1384 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1385 req
, struct vfs_gluster_fsync_state
);
1388 ret
= pthreadpool_tevent_job_recv(subreq
);
1389 TALLOC_FREE(subreq
);
1390 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1391 talloc_set_destructor(state
, NULL
);
1393 if (ret
!= EAGAIN
) {
1394 tevent_req_error(req
, ret
);
1398 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1399 * means the lower level pthreadpool failed to create a new
1400 * thread. Fallback to sync processing in that case to allow
1401 * some progress for the client.
1403 vfs_gluster_fsync_do(state
);
1406 tevent_req_done(req
);
1409 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1410 struct vfs_aio_state
*vfs_aio_state
)
1412 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1413 req
, struct vfs_gluster_fsync_state
);
1415 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1419 *vfs_aio_state
= state
->vfs_aio_state
;
1423 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1424 struct smb_filename
*smb_fname
)
1429 START_PROFILE(syscall_stat
);
1430 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1432 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1434 if (ret
< 0 && errno
!= ENOENT
) {
1435 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1436 smb_fname
->base_name
, strerror(errno
)));
1438 END_PROFILE(syscall_stat
);
1443 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1444 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1448 glfs_fd_t
*glfd
= NULL
;
1450 START_PROFILE(syscall_fstat
);
1452 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1454 END_PROFILE(syscall_fstat
);
1455 DBG_ERR("Failed to fetch gluster fd\n");
1459 ret
= glfs_fstat(glfd
, &st
);
1461 smb_stat_ex_from_stat(sbuf
, &st
);
1464 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1465 fsp_get_io_fd(fsp
), strerror(errno
)));
1467 END_PROFILE(syscall_fstat
);
1472 static int vfs_gluster_fstatat(struct vfs_handle_struct
*handle
,
1473 const struct files_struct
*dirfsp
,
1474 const struct smb_filename
*smb_fname
,
1475 SMB_STRUCT_STAT
*sbuf
,
1481 #ifdef HAVE_GFAPI_VER_7_11
1482 glfs_fd_t
*pglfd
= NULL
;
1484 START_PROFILE(syscall_fstatat
);
1486 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1487 if (pglfd
== NULL
) {
1488 END_PROFILE(syscall_fstatat
);
1489 DBG_ERR("Failed to fetch gluster fd\n");
1493 ret
= glfs_fstatat(pglfd
, smb_fname
->base_name
, &st
, flags
);
1495 struct smb_filename
*full_fname
= NULL
;
1497 START_PROFILE(syscall_fstatat
);
1499 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1502 if (full_fname
== NULL
) {
1503 END_PROFILE(syscall_fstatat
);
1507 ret
= glfs_stat(handle
->data
, full_fname
->base_name
, &st
);
1509 TALLOC_FREE(full_fname
->base_name
);
1513 smb_stat_ex_from_stat(sbuf
, &st
);
1516 END_PROFILE(syscall_fstatat
);
1521 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1522 struct smb_filename
*smb_fname
)
1527 START_PROFILE(syscall_lstat
);
1528 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1530 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1532 if (ret
< 0 && errno
!= ENOENT
) {
1533 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1534 smb_fname
->base_name
, strerror(errno
)));
1536 END_PROFILE(syscall_lstat
);
1541 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1543 const SMB_STRUCT_STAT
*sbuf
)
1547 START_PROFILE(syscall_get_alloc_size
);
1548 ret
= sbuf
->st_ex_blocks
* 512;
1549 END_PROFILE(syscall_get_alloc_size
);
1554 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1555 struct files_struct
*dirfsp
,
1556 const struct smb_filename
*smb_fname
,
1561 #ifdef HAVE_GFAPI_VER_7_11
1562 glfs_fd_t
*pglfd
= NULL
;
1564 START_PROFILE(syscall_unlinkat
);
1566 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1567 if (pglfd
== NULL
) {
1568 END_PROFILE(syscall_unlinkat
);
1569 DBG_ERR("Failed to fetch gluster fd\n");
1573 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1575 struct smb_filename
*full_fname
= NULL
;
1577 START_PROFILE(syscall_unlinkat
);
1579 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1582 if (full_fname
== NULL
) {
1583 END_PROFILE(syscall_unlinkat
);
1587 if (flags
& AT_REMOVEDIR
) {
1588 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1590 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1593 TALLOC_FREE(full_fname
);
1596 END_PROFILE(syscall_unlinkat
);
1601 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1602 files_struct
*fsp
, mode_t mode
)
1605 glfs_fd_t
*glfd
= NULL
;
1607 START_PROFILE(syscall_fchmod
);
1609 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1611 END_PROFILE(syscall_fchmod
);
1612 DBG_ERR("Failed to fetch gluster fd\n");
1616 if (!fsp
->fsp_flags
.is_pathref
) {
1618 * We can use an io_fd to remove xattrs.
1620 ret
= glfs_fchmod(glfd
, mode
);
1623 * This is no longer a handle based call.
1625 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1627 END_PROFILE(syscall_fchmod
);
1632 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1633 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1636 glfs_fd_t
*glfd
= NULL
;
1638 START_PROFILE(syscall_fchown
);
1640 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1642 END_PROFILE(syscall_fchown
);
1643 DBG_ERR("Failed to fetch gluster fd\n");
1647 ret
= glfs_fchown(glfd
, uid
, gid
);
1648 END_PROFILE(syscall_fchown
);
1653 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1654 const struct smb_filename
*smb_fname
,
1660 START_PROFILE(syscall_lchown
);
1661 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1662 END_PROFILE(syscall_lchown
);
1667 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1668 const struct smb_filename
*smb_fname
)
1672 START_PROFILE(syscall_chdir
);
1673 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1674 END_PROFILE(syscall_chdir
);
1679 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1682 char cwd
[PATH_MAX
] = { '\0' };
1684 struct smb_filename
*smb_fname
= NULL
;
1686 START_PROFILE(syscall_getwd
);
1688 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1689 END_PROFILE(syscall_getwd
);
1694 smb_fname
= synthetic_smb_fname(ctx
,
1703 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1705 struct smb_file_time
*ft
)
1708 struct timespec times
[2];
1709 glfs_fd_t
*glfd
= NULL
;
1711 START_PROFILE(syscall_fntimes
);
1713 if (is_omit_timespec(&ft
->atime
)) {
1714 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1715 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1717 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1718 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1721 if (is_omit_timespec(&ft
->mtime
)) {
1722 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1723 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1725 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1726 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1729 if ((timespec_compare(×
[0],
1730 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1731 (timespec_compare(×
[1],
1732 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1733 END_PROFILE(syscall_fntimes
);
1737 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1739 END_PROFILE(syscall_fntimes
);
1740 DBG_ERR("Failed to fetch gluster fd\n");
1744 if (!fsp
->fsp_flags
.is_pathref
) {
1745 ret
= glfs_futimens(glfd
, times
);
1747 ret
= glfs_utimens(handle
->data
,
1748 fsp
->fsp_name
->base_name
,
1751 END_PROFILE(syscall_fntimes
);
1756 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1757 files_struct
*fsp
, off_t offset
)
1760 glfs_fd_t
*glfd
= NULL
;
1762 START_PROFILE(syscall_ftruncate
);
1764 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1766 END_PROFILE(syscall_ftruncate
);
1767 DBG_ERR("Failed to fetch gluster fd\n");
1771 #ifdef HAVE_GFAPI_VER_7_6
1772 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1774 ret
= glfs_ftruncate(glfd
, offset
);
1776 END_PROFILE(syscall_ftruncate
);
1781 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1782 struct files_struct
*fsp
,
1784 off_t offset
, off_t len
)
1787 #ifdef HAVE_GFAPI_VER_6
1788 glfs_fd_t
*glfd
= NULL
;
1789 int keep_size
, punch_hole
;
1791 START_PROFILE(syscall_fallocate
);
1793 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1795 END_PROFILE(syscall_fallocate
);
1796 DBG_ERR("Failed to fetch gluster fd\n");
1800 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1801 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1803 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1805 END_PROFILE(syscall_fallocate
);
1811 ret
= glfs_discard(glfd
, offset
, len
);
1813 DBG_DEBUG("glfs_discard failed: %s\n",
1818 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1819 END_PROFILE(syscall_fallocate
);
1827 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1829 const struct smb_filename
*smb_fname
)
1831 char *result
= NULL
;
1832 struct smb_filename
*result_fname
= NULL
;
1833 char *resolved_path
= NULL
;
1835 START_PROFILE(syscall_realpath
);
1837 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1838 if (resolved_path
== NULL
) {
1839 END_PROFILE(syscall_realpath
);
1844 result
= glfs_realpath(handle
->data
,
1845 smb_fname
->base_name
,
1847 if (result
!= NULL
) {
1848 result_fname
= synthetic_smb_fname(ctx
,
1856 SAFE_FREE(resolved_path
);
1857 END_PROFILE(syscall_realpath
);
1859 return result_fname
;
1862 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1863 files_struct
*fsp
, int op
, off_t offset
,
1864 off_t count
, int type
)
1866 struct flock flock
= { 0, };
1868 glfs_fd_t
*glfd
= NULL
;
1871 START_PROFILE(syscall_fcntl_lock
);
1873 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1875 DBG_ERR("Failed to fetch gluster fd\n");
1880 flock
.l_type
= type
;
1881 flock
.l_whence
= SEEK_SET
;
1882 flock
.l_start
= offset
;
1883 flock
.l_len
= count
;
1886 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1888 if (op
== F_GETLK
) {
1889 /* lock query, true if someone else has locked */
1891 (flock
.l_type
!= F_UNLCK
) &&
1892 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1908 END_PROFILE(syscall_fcntl_lock
);
1913 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1915 uint32_t share_access
,
1916 uint32_t access_mask
)
1922 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1923 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1926 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1927 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1929 if (cmd
== F_GETFL
) {
1931 } else if (cmd
== F_SETFL
) {
1932 va_list dup_cmd_arg
;
1935 va_copy(dup_cmd_arg
, cmd_arg
);
1936 opt
= va_arg(dup_cmd_arg
, int);
1937 va_end(dup_cmd_arg
);
1941 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1944 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1950 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1951 files_struct
*fsp
, int leasetype
)
1957 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1958 files_struct
*fsp
, off_t
*poffset
,
1959 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1961 struct flock flock
= { 0, };
1963 glfs_fd_t
*glfd
= NULL
;
1965 START_PROFILE(syscall_fcntl_getlock
);
1967 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1969 END_PROFILE(syscall_fcntl_getlock
);
1970 DBG_ERR("Failed to fetch gluster fd\n");
1974 flock
.l_type
= *ptype
;
1975 flock
.l_whence
= SEEK_SET
;
1976 flock
.l_start
= *poffset
;
1977 flock
.l_len
= *pcount
;
1980 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
1983 END_PROFILE(syscall_fcntl_getlock
);
1987 *ptype
= flock
.l_type
;
1988 *poffset
= flock
.l_start
;
1989 *pcount
= flock
.l_len
;
1990 *ppid
= flock
.l_pid
;
1991 END_PROFILE(syscall_fcntl_getlock
);
1996 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
1997 const struct smb_filename
*link_target
,
1998 struct files_struct
*dirfsp
,
1999 const struct smb_filename
*new_smb_fname
)
2003 #ifdef HAVE_GFAPI_VER_7_11
2004 glfs_fd_t
*pglfd
= NULL
;
2006 START_PROFILE(syscall_symlinkat
);
2008 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2009 if (pglfd
== NULL
) {
2010 END_PROFILE(syscall_symlinkat
);
2011 DBG_ERR("Failed to fetch gluster fd\n");
2015 ret
= glfs_symlinkat(link_target
->base_name
,
2017 new_smb_fname
->base_name
);
2019 struct smb_filename
*full_fname
= NULL
;
2021 START_PROFILE(syscall_symlinkat
);
2023 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2026 if (full_fname
== NULL
) {
2027 END_PROFILE(syscall_symlinkat
);
2031 ret
= glfs_symlink(handle
->data
,
2032 link_target
->base_name
,
2033 full_fname
->base_name
);
2035 TALLOC_FREE(full_fname
);
2038 END_PROFILE(syscall_symlinkat
);
2043 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2044 const struct files_struct
*dirfsp
,
2045 const struct smb_filename
*smb_fname
,
2051 #ifdef HAVE_GFAPI_VER_7_11
2052 glfs_fd_t
*pglfd
= NULL
;
2054 START_PROFILE(syscall_readlinkat
);
2056 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2057 if (pglfd
== NULL
) {
2058 END_PROFILE(syscall_readlinkat
);
2059 DBG_ERR("Failed to fetch gluster fd\n");
2063 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2065 struct smb_filename
*full_fname
= NULL
;
2067 START_PROFILE(syscall_readlinkat
);
2069 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2072 if (full_fname
== NULL
) {
2073 END_PROFILE(syscall_readlinkat
);
2077 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2079 TALLOC_FREE(full_fname
);
2082 END_PROFILE(syscall_readlinkat
);
2087 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2088 files_struct
*srcfsp
,
2089 const struct smb_filename
*old_smb_fname
,
2090 files_struct
*dstfsp
,
2091 const struct smb_filename
*new_smb_fname
,
2096 #ifdef HAVE_GFAPI_VER_7_11
2097 glfs_fd_t
*src_pglfd
= NULL
;
2098 glfs_fd_t
*dst_pglfd
= NULL
;
2100 START_PROFILE(syscall_linkat
);
2102 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
2103 if (src_pglfd
== NULL
) {
2104 END_PROFILE(syscall_linkat
);
2105 DBG_ERR("Failed to fetch gluster fd\n");
2109 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
2110 if (dst_pglfd
== NULL
) {
2111 END_PROFILE(syscall_linkat
);
2112 DBG_ERR("Failed to fetch gluster fd\n");
2116 ret
= glfs_linkat(src_pglfd
,
2117 old_smb_fname
->base_name
,
2119 new_smb_fname
->base_name
,
2122 struct smb_filename
*full_fname_old
= NULL
;
2123 struct smb_filename
*full_fname_new
= NULL
;
2125 START_PROFILE(syscall_linkat
);
2127 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2130 if (full_fname_old
== NULL
) {
2131 END_PROFILE(syscall_linkat
);
2135 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2138 if (full_fname_new
== NULL
) {
2139 END_PROFILE(syscall_linkat
);
2140 TALLOC_FREE(full_fname_old
);
2144 ret
= glfs_link(handle
->data
,
2145 full_fname_old
->base_name
,
2146 full_fname_new
->base_name
);
2148 TALLOC_FREE(full_fname_old
);
2149 TALLOC_FREE(full_fname_new
);
2152 END_PROFILE(syscall_linkat
);
2157 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2158 files_struct
*dirfsp
,
2159 const struct smb_filename
*smb_fname
,
2165 #ifdef HAVE_GFAPI_VER_7_11
2166 glfs_fd_t
*pglfd
= NULL
;
2168 START_PROFILE(syscall_mknodat
);
2170 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2171 if (pglfd
== NULL
) {
2172 END_PROFILE(syscall_mknodat
);
2173 DBG_ERR("Failed to fetch gluster fd\n");
2177 ret
= glfs_mknodat(pglfd
, smb_fname
->base_name
, mode
, dev
);
2179 struct smb_filename
*full_fname
= NULL
;
2181 START_PROFILE(syscall_mknodat
);
2183 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2186 if (full_fname
== NULL
) {
2187 END_PROFILE(syscall_mknodat
);
2191 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2193 TALLOC_FREE(full_fname
);
2196 END_PROFILE(syscall_mknodat
);
2201 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2202 struct files_struct
*fsp
,
2209 static NTSTATUS
vfs_gluster_get_real_filename_at(
2210 struct vfs_handle_struct
*handle
,
2211 struct files_struct
*dirfsp
,
2213 TALLOC_CTX
*mem_ctx
,
2217 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2218 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2220 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2221 return NT_STATUS_OBJECT_NAME_INVALID
;
2224 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2225 "glusterfs.get_real_filename:%s", name
);
2227 ret
= glfs_getxattr(handle
->data
,
2228 dirfsp
->fsp_name
->base_name
,
2231 GLUSTER_NAME_MAX
+ 1);
2233 if (errno
== ENOATTR
) {
2236 return map_nt_error_from_unix(errno
);
2239 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2240 if (found_name
[0] == NULL
) {
2241 return NT_STATUS_NO_MEMORY
;
2244 return NT_STATUS_OK
;
2247 static const char *vfs_gluster_connectpath(
2248 struct vfs_handle_struct
*handle
,
2249 const struct files_struct
*dirfsp
,
2250 const struct smb_filename
*smb_fname
)
2252 return handle
->conn
->connectpath
;
2257 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2258 files_struct
*fsp
, const char *name
,
2259 void *value
, size_t size
)
2261 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2263 DBG_ERR("Failed to fetch gluster fd\n");
2267 if (!fsp
->fsp_flags
.is_pathref
) {
2269 * We can use an io_fd to retrieve xattr value.
2271 return glfs_fgetxattr(glfd
, name
, value
, size
);
2275 * This is no longer a handle based call.
2277 return glfs_getxattr(handle
->data
,
2278 fsp
->fsp_name
->base_name
,
2284 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2285 files_struct
*fsp
, char *list
,
2288 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2290 DBG_ERR("Failed to fetch gluster fd\n");
2293 if (!fsp
->fsp_flags
.is_pathref
) {
2295 * We can use an io_fd to list xattrs.
2297 return glfs_flistxattr(glfd
, list
, size
);
2300 * This is no longer a handle based call.
2302 return glfs_listxattr(handle
->data
,
2303 fsp
->fsp_name
->base_name
,
2309 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2310 files_struct
*fsp
, const char *name
)
2312 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2314 DBG_ERR("Failed to fetch gluster fd\n");
2317 if (!fsp
->fsp_flags
.is_pathref
) {
2319 * We can use an io_fd to remove xattrs.
2321 return glfs_fremovexattr(glfd
, name
);
2324 * This is no longer a handle based call.
2326 return glfs_removexattr(handle
->data
,
2327 fsp
->fsp_name
->base_name
,
2332 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2333 files_struct
*fsp
, const char *name
,
2334 const void *value
, size_t size
, int flags
)
2336 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2338 DBG_ERR("Failed to fetch gluster fd\n");
2342 if (!fsp
->fsp_flags
.is_pathref
) {
2344 * We can use an io_fd to set xattrs.
2346 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2349 * This is no longer a handle based call.
2351 return glfs_setxattr(handle
->data
,
2352 fsp
->fsp_name
->base_name
,
2360 /* AIO Operations */
2362 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2368 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2369 struct files_struct
*dirfsp
,
2370 const struct smb_filename
*smb_fname
,
2371 const struct referral
*reflist
,
2372 size_t referral_count
)
2374 TALLOC_CTX
*frame
= talloc_stackframe();
2375 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2377 char *msdfs_link
= NULL
;
2378 #ifdef HAVE_GFAPI_VER_7_11
2379 glfs_fd_t
*pglfd
= NULL
;
2381 struct smb_filename
*full_fname
= NULL
;
2384 /* Form the msdfs_link contents */
2385 msdfs_link
= msdfs_link_string(frame
,
2388 if (msdfs_link
== NULL
) {
2392 #ifdef HAVE_GFAPI_VER_7_11
2393 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2394 if (pglfd
== NULL
) {
2395 DBG_ERR("Failed to fetch gluster fd\n");
2396 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2400 ret
= glfs_symlinkat(msdfs_link
, pglfd
, smb_fname
->base_name
);
2402 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2405 if (full_fname
== NULL
) {
2409 ret
= glfs_symlink(handle
->data
, msdfs_link
, full_fname
->base_name
);
2411 TALLOC_FREE(full_fname
);
2414 status
= NT_STATUS_OK
;
2416 status
= map_nt_error_from_unix(errno
);
2426 * Read and return the contents of a DFS redirect given a
2427 * pathname. A caller can pass in NULL for ppreflist and
2428 * preferral_count but still determine if this was a
2429 * DFS redirect point by getting NT_STATUS_OK back
2430 * without incurring the overhead of reading and parsing
2431 * the referral contents.
2434 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2435 TALLOC_CTX
*mem_ctx
,
2436 struct files_struct
*dirfsp
,
2437 struct smb_filename
*smb_fname
,
2438 struct referral
**ppreflist
,
2439 size_t *preferral_count
)
2441 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2443 char *link_target
= NULL
;
2446 #if defined(HAVE_BROKEN_READLINK)
2447 char link_target_buf
[PATH_MAX
];
2449 char link_target_buf
[7];
2452 struct smb_filename
*full_fname
= NULL
;
2454 #ifdef HAVE_GFAPI_VER_7_11
2455 glfs_fd_t
*pglfd
= NULL
;
2458 if (is_named_stream(smb_fname
)) {
2459 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2463 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2465 * We're only checking if this is a DFS
2466 * redirect. We don't need to return data.
2468 bufsize
= sizeof(link_target_buf
);
2469 link_target
= link_target_buf
;
2472 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2478 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2481 if (full_fname
== NULL
) {
2482 status
= NT_STATUS_NO_MEMORY
;
2486 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2488 status
= map_nt_error_from_unix(errno
);
2492 #ifdef HAVE_GFAPI_VER_7_11
2493 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2494 if (pglfd
== NULL
) {
2495 DBG_ERR("Failed to fetch gluster fd\n");
2496 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2499 referral_len
= glfs_readlinkat(pglfd
,
2500 smb_fname
->base_name
,
2504 referral_len
= glfs_readlink(handle
->data
,
2505 full_fname
->base_name
,
2509 if (referral_len
< 0) {
2510 if (errno
== EINVAL
) {
2511 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2512 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2514 status
= map_nt_error_from_unix(errno
);
2515 DBG_ERR("Error reading "
2516 "msdfs link %s: %s\n",
2517 full_fname
->base_name
,
2522 link_target
[referral_len
] = '\0';
2524 DBG_INFO("%s -> %s\n",
2525 full_fname
->base_name
,
2528 if (!strnequal(link_target
, "msdfs:", 6)) {
2529 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2533 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2534 /* Early return for checking if this is a DFS link. */
2535 TALLOC_FREE(full_fname
);
2536 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2537 return NT_STATUS_OK
;
2540 ok
= parse_msdfs_symlink(mem_ctx
,
2541 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2547 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2548 status
= NT_STATUS_OK
;
2550 status
= NT_STATUS_NO_MEMORY
;
2555 if (link_target
!= link_target_buf
) {
2556 TALLOC_FREE(link_target
);
2558 TALLOC_FREE(full_fname
);
2562 static struct vfs_fn_pointers glusterfs_fns
= {
2564 /* Disk Operations */
2566 .connect_fn
= vfs_gluster_connect
,
2567 .disconnect_fn
= vfs_gluster_disconnect
,
2568 .disk_free_fn
= vfs_gluster_disk_free
,
2569 .get_quota_fn
= vfs_gluster_get_quota
,
2570 .set_quota_fn
= vfs_gluster_set_quota
,
2571 .statvfs_fn
= vfs_gluster_statvfs
,
2572 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2574 .get_dfs_referrals_fn
= NULL
,
2576 /* Directory Operations */
2578 .fdopendir_fn
= vfs_gluster_fdopendir
,
2579 .readdir_fn
= vfs_gluster_readdir
,
2580 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2581 .mkdirat_fn
= vfs_gluster_mkdirat
,
2582 .closedir_fn
= vfs_gluster_closedir
,
2584 /* File Operations */
2586 .openat_fn
= vfs_gluster_openat
,
2587 .create_file_fn
= NULL
,
2588 .close_fn
= vfs_gluster_close
,
2589 .pread_fn
= vfs_gluster_pread
,
2590 .pread_send_fn
= vfs_gluster_pread_send
,
2591 .pread_recv_fn
= vfs_gluster_pread_recv
,
2592 .pwrite_fn
= vfs_gluster_pwrite
,
2593 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2594 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2595 .lseek_fn
= vfs_gluster_lseek
,
2596 .sendfile_fn
= vfs_gluster_sendfile
,
2597 .recvfile_fn
= vfs_gluster_recvfile
,
2598 .renameat_fn
= vfs_gluster_renameat
,
2599 .fsync_send_fn
= vfs_gluster_fsync_send
,
2600 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2602 .stat_fn
= vfs_gluster_stat
,
2603 .fstat_fn
= vfs_gluster_fstat
,
2604 .fstatat_fn
= vfs_gluster_fstatat
,
2605 .lstat_fn
= vfs_gluster_lstat
,
2606 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2607 .unlinkat_fn
= vfs_gluster_unlinkat
,
2609 .fchmod_fn
= vfs_gluster_fchmod
,
2610 .fchown_fn
= vfs_gluster_fchown
,
2611 .lchown_fn
= vfs_gluster_lchown
,
2612 .chdir_fn
= vfs_gluster_chdir
,
2613 .getwd_fn
= vfs_gluster_getwd
,
2614 .fntimes_fn
= vfs_gluster_fntimes
,
2615 .ftruncate_fn
= vfs_gluster_ftruncate
,
2616 .fallocate_fn
= vfs_gluster_fallocate
,
2617 .lock_fn
= vfs_gluster_lock
,
2618 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2619 .fcntl_fn
= vfs_gluster_fcntl
,
2620 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2621 .getlock_fn
= vfs_gluster_getlock
,
2622 .symlinkat_fn
= vfs_gluster_symlinkat
,
2623 .readlinkat_fn
= vfs_gluster_readlinkat
,
2624 .linkat_fn
= vfs_gluster_linkat
,
2625 .mknodat_fn
= vfs_gluster_mknodat
,
2626 .realpath_fn
= vfs_gluster_realpath
,
2627 .fchflags_fn
= vfs_gluster_fchflags
,
2628 .file_id_create_fn
= NULL
,
2629 .fstreaminfo_fn
= NULL
,
2630 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2631 .connectpath_fn
= vfs_gluster_connectpath
,
2632 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2633 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2635 .brl_lock_windows_fn
= NULL
,
2636 .brl_unlock_windows_fn
= NULL
,
2637 .strict_lock_check_fn
= NULL
,
2638 .translate_name_fn
= NULL
,
2641 /* NT ACL Operations */
2642 .fget_nt_acl_fn
= NULL
,
2643 .fset_nt_acl_fn
= NULL
,
2644 .audit_file_fn
= NULL
,
2646 /* Posix ACL Operations */
2647 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2648 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2649 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2650 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2653 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2654 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2655 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2656 .flistxattr_fn
= vfs_gluster_flistxattr
,
2657 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2658 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2660 /* AIO Operations */
2661 .aio_force_fn
= vfs_gluster_aio_force
,
2663 /* Durable handle Operations */
2664 .durable_cookie_fn
= NULL
,
2665 .durable_disconnect_fn
= NULL
,
2666 .durable_reconnect_fn
= NULL
,
2670 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2672 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2673 "glusterfs", &glusterfs_fns
);