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
)
599 caps
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
601 #ifdef HAVE_GFAPI_VER_6
602 caps
|= FILE_SUPPORTS_SPARSE_FILES
;
605 #ifdef STAT_HAVE_NSEC
606 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
612 static glfs_fd_t
*vfs_gluster_fetch_glfd(struct vfs_handle_struct
*handle
,
613 const files_struct
*fsp
)
615 glfs_fd_t
**glfd
= (glfs_fd_t
**)VFS_FETCH_FSP_EXTENSION(handle
, fsp
);
617 DBG_INFO("Failed to fetch fsp extension\n");
621 DBG_INFO("Empty glfs_fd_t pointer\n");
628 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct
*handle
,
629 files_struct
*fsp
, const char *mask
,
632 glfs_fd_t
*glfd
= NULL
;
634 glfd
= glfs_opendir(handle
->data
, fsp
->fsp_name
->base_name
);
642 static int vfs_gluster_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
646 START_PROFILE(syscall_closedir
);
647 ret
= glfs_closedir((void *)dirp
);
648 END_PROFILE(syscall_closedir
);
653 static struct dirent
*vfs_gluster_readdir(struct vfs_handle_struct
*handle
,
654 struct files_struct
*dirfsp
,
657 static char direntbuf
[512];
659 struct dirent
*dirent
= 0;
661 START_PROFILE(syscall_readdir
);
663 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
665 if ((ret
< 0) || (dirent
== NULL
)) {
666 END_PROFILE(syscall_readdir
);
670 END_PROFILE(syscall_readdir
);
674 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
676 START_PROFILE(syscall_rewinddir
);
677 glfs_seekdir((void *)dirp
, 0);
678 END_PROFILE(syscall_rewinddir
);
681 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
682 struct files_struct
*dirfsp
,
683 const struct smb_filename
*smb_fname
,
688 #ifdef HAVE_GFAPI_VER_7_11
689 glfs_fd_t
*pglfd
= NULL
;
691 START_PROFILE(syscall_mkdirat
);
693 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
695 END_PROFILE(syscall_mkdirat
);
696 DBG_ERR("Failed to fetch gluster fd\n");
700 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
702 struct smb_filename
*full_fname
= NULL
;
704 START_PROFILE(syscall_mkdirat
);
706 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
709 if (full_fname
== NULL
) {
710 END_PROFILE(syscall_mkdirat
);
714 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
716 TALLOC_FREE(full_fname
);
719 END_PROFILE(syscall_mkdirat
);
724 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
725 const struct files_struct
*dirfsp
,
726 const struct smb_filename
*smb_fname
,
728 const struct vfs_open_how
*how
)
730 int flags
= how
->flags
;
731 struct smb_filename
*full_fname
= NULL
;
732 bool have_opath
= false;
733 bool became_root
= false;
734 glfs_fd_t
*glfd
= NULL
;
735 glfs_fd_t
*pglfd
= NULL
;
738 START_PROFILE(syscall_openat
);
740 if (how
->resolve
!= 0) {
741 END_PROFILE(syscall_openat
);
746 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
748 END_PROFILE(syscall_openat
);
755 if (fsp
->fsp_flags
.is_pathref
) {
760 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
763 if (full_fname
== NULL
) {
764 END_PROFILE(syscall_openat
);
768 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
773 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
774 #ifdef HAVE_GFAPI_VER_7_11
776 * Fetch Gluster fd for parent directory using dirfsp
777 * before calling glfs_openat();
779 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
781 END_PROFILE(syscall_openat
);
782 DBG_ERR("Failed to fetch gluster fd\n");
786 glfd
= glfs_openat(pglfd
,
787 smb_fname
->base_name
,
792 * Replace smb_fname with full_path constructed above.
794 smb_fname
= full_fname
;
800 * smb_fname can either be a full_path or the same one
801 * as received from the caller. In the latter case we
802 * are operating at current working directory.
804 if (flags
& O_CREAT
) {
805 glfd
= glfs_creat(handle
->data
,
806 smb_fname
->base_name
,
810 glfd
= glfs_open(handle
->data
,
811 smb_fname
->base_name
,
820 TALLOC_FREE(full_fname
);
822 fsp
->fsp_flags
.have_proc_fds
= false;
825 END_PROFILE(syscall_openat
);
826 /* no extension destroy_fn, so no need to save errno */
827 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
833 END_PROFILE(syscall_openat
);
834 /* An arbitrary value for error reporting, so you know its us. */
838 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
842 glfs_fd_t
*glfd
= NULL
;
844 START_PROFILE(syscall_close
);
846 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
848 END_PROFILE(syscall_close
);
849 DBG_ERR("Failed to fetch gluster fd\n");
853 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
855 ret
= glfs_close(glfd
);
856 END_PROFILE(syscall_close
);
861 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
862 files_struct
*fsp
, void *data
, size_t n
,
866 glfs_fd_t
*glfd
= NULL
;
868 START_PROFILE_BYTES(syscall_pread
, n
);
870 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
872 END_PROFILE_BYTES(syscall_pread
);
873 DBG_ERR("Failed to fetch gluster fd\n");
877 #ifdef HAVE_GFAPI_VER_7_6
878 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
880 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
882 END_PROFILE_BYTES(syscall_pread
);
887 struct vfs_gluster_pread_state
{
894 struct vfs_aio_state vfs_aio_state
;
895 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
898 static void vfs_gluster_pread_do(void *private_data
);
899 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
900 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
902 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
903 *handle
, TALLOC_CTX
*mem_ctx
,
904 struct tevent_context
*ev
,
906 void *data
, size_t n
,
909 struct vfs_gluster_pread_state
*state
;
910 struct tevent_req
*req
, *subreq
;
912 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
914 DBG_ERR("Failed to fetch gluster fd\n");
918 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
927 state
->offset
= offset
;
929 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
930 state
->profile_bytes
, n
);
931 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
933 subreq
= pthreadpool_tevent_job_send(
934 state
, ev
, handle
->conn
->sconn
->pool
,
935 vfs_gluster_pread_do
, state
);
936 if (tevent_req_nomem(subreq
, req
)) {
937 return tevent_req_post(req
, ev
);
939 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
941 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
946 static void vfs_gluster_pread_do(void *private_data
)
948 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
949 private_data
, struct vfs_gluster_pread_state
);
950 struct timespec start_time
;
951 struct timespec end_time
;
953 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
955 PROFILE_TIMESTAMP(&start_time
);
958 #ifdef HAVE_GFAPI_VER_7_6
959 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
960 state
->offset
, 0, NULL
);
962 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
965 } while ((state
->ret
== -1) && (errno
== EINTR
));
967 if (state
->ret
== -1) {
968 state
->vfs_aio_state
.error
= errno
;
971 PROFILE_TIMESTAMP(&end_time
);
973 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
975 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
978 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
983 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
985 struct tevent_req
*req
= tevent_req_callback_data(
986 subreq
, struct tevent_req
);
987 struct vfs_gluster_pread_state
*state
= tevent_req_data(
988 req
, struct vfs_gluster_pread_state
);
991 ret
= pthreadpool_tevent_job_recv(subreq
);
993 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
994 talloc_set_destructor(state
, NULL
);
997 tevent_req_error(req
, ret
);
1001 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1002 * means the lower level pthreadpool failed to create a new
1003 * thread. Fallback to sync processing in that case to allow
1004 * some progress for the client.
1006 vfs_gluster_pread_do(state
);
1009 tevent_req_done(req
);
1012 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1013 struct vfs_aio_state
*vfs_aio_state
)
1015 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1016 req
, struct vfs_gluster_pread_state
);
1018 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1022 *vfs_aio_state
= state
->vfs_aio_state
;
1026 struct vfs_gluster_pwrite_state
{
1033 struct vfs_aio_state vfs_aio_state
;
1034 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1037 static void vfs_gluster_pwrite_do(void *private_data
);
1038 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1039 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1041 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1042 *handle
, TALLOC_CTX
*mem_ctx
,
1043 struct tevent_context
*ev
,
1045 const void *data
, size_t n
,
1048 struct tevent_req
*req
, *subreq
;
1049 struct vfs_gluster_pwrite_state
*state
;
1051 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1053 DBG_ERR("Failed to fetch gluster fd\n");
1057 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1066 state
->offset
= offset
;
1068 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1069 state
->profile_bytes
, n
);
1070 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1072 subreq
= pthreadpool_tevent_job_send(
1073 state
, ev
, handle
->conn
->sconn
->pool
,
1074 vfs_gluster_pwrite_do
, state
);
1075 if (tevent_req_nomem(subreq
, req
)) {
1076 return tevent_req_post(req
, ev
);
1078 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1080 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1085 static void vfs_gluster_pwrite_do(void *private_data
)
1087 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1088 private_data
, struct vfs_gluster_pwrite_state
);
1089 struct timespec start_time
;
1090 struct timespec end_time
;
1092 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1094 PROFILE_TIMESTAMP(&start_time
);
1097 #ifdef HAVE_GFAPI_VER_7_6
1098 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1099 state
->offset
, 0, NULL
, NULL
);
1101 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1104 } while ((state
->ret
== -1) && (errno
== EINTR
));
1106 if (state
->ret
== -1) {
1107 state
->vfs_aio_state
.error
= errno
;
1110 PROFILE_TIMESTAMP(&end_time
);
1112 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1114 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1117 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1122 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1124 struct tevent_req
*req
= tevent_req_callback_data(
1125 subreq
, struct tevent_req
);
1126 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1127 req
, struct vfs_gluster_pwrite_state
);
1130 ret
= pthreadpool_tevent_job_recv(subreq
);
1131 TALLOC_FREE(subreq
);
1132 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1133 talloc_set_destructor(state
, NULL
);
1135 if (ret
!= EAGAIN
) {
1136 tevent_req_error(req
, ret
);
1140 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1141 * means the lower level pthreadpool failed to create a new
1142 * thread. Fallback to sync processing in that case to allow
1143 * some progress for the client.
1145 vfs_gluster_pwrite_do(state
);
1148 tevent_req_done(req
);
1151 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1152 struct vfs_aio_state
*vfs_aio_state
)
1154 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1155 req
, struct vfs_gluster_pwrite_state
);
1157 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1161 *vfs_aio_state
= state
->vfs_aio_state
;
1166 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1167 files_struct
*fsp
, const void *data
,
1168 size_t n
, off_t offset
)
1171 glfs_fd_t
*glfd
= NULL
;
1173 START_PROFILE_BYTES(syscall_pwrite
, n
);
1175 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1177 END_PROFILE_BYTES(syscall_pwrite
);
1178 DBG_ERR("Failed to fetch gluster fd\n");
1182 #ifdef HAVE_GFAPI_VER_7_6
1183 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1185 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1187 END_PROFILE_BYTES(syscall_pwrite
);
1192 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1193 files_struct
*fsp
, off_t offset
, int whence
)
1196 glfs_fd_t
*glfd
= NULL
;
1198 START_PROFILE(syscall_lseek
);
1200 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1202 END_PROFILE(syscall_lseek
);
1203 DBG_ERR("Failed to fetch gluster fd\n");
1207 ret
= glfs_lseek(glfd
, offset
, whence
);
1208 END_PROFILE(syscall_lseek
);
1213 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1214 files_struct
*fromfsp
,
1215 const DATA_BLOB
*hdr
,
1216 off_t offset
, size_t n
)
1222 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1223 int fromfd
, files_struct
*tofsp
,
1224 off_t offset
, size_t n
)
1230 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1231 files_struct
*srcfsp
,
1232 const struct smb_filename
*smb_fname_src
,
1233 files_struct
*dstfsp
,
1234 const struct smb_filename
*smb_fname_dst
,
1235 const struct vfs_rename_how
*how
)
1239 #ifdef HAVE_GFAPI_VER_7_11
1240 glfs_fd_t
*src_pglfd
= NULL
;
1241 glfs_fd_t
*dst_pglfd
= NULL
;
1243 START_PROFILE(syscall_renameat
);
1245 if (how
->flags
!= 0) {
1246 END_PROFILE(syscall_renameat
);
1251 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1252 if (src_pglfd
== NULL
) {
1253 END_PROFILE(syscall_renameat
);
1254 DBG_ERR("Failed to fetch gluster fd\n");
1258 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1259 if (dst_pglfd
== NULL
) {
1260 END_PROFILE(syscall_renameat
);
1261 DBG_ERR("Failed to fetch gluster fd\n");
1265 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1266 dst_pglfd
, smb_fname_dst
->base_name
);
1268 struct smb_filename
*full_fname_src
= NULL
;
1269 struct smb_filename
*full_fname_dst
= NULL
;
1271 START_PROFILE(syscall_renameat
);
1273 if (how
->flags
!= 0) {
1274 END_PROFILE(syscall_renameat
);
1279 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1282 if (full_fname_src
== NULL
) {
1283 END_PROFILE(syscall_renameat
);
1288 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1291 if (full_fname_dst
== NULL
) {
1292 END_PROFILE(syscall_renameat
);
1293 TALLOC_FREE(full_fname_src
);
1297 ret
= glfs_rename(handle
->data
,
1298 full_fname_src
->base_name
,
1299 full_fname_dst
->base_name
);
1301 TALLOC_FREE(full_fname_src
);
1302 TALLOC_FREE(full_fname_dst
);
1305 END_PROFILE(syscall_renameat
);
1310 struct vfs_gluster_fsync_state
{
1314 struct vfs_aio_state vfs_aio_state
;
1315 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1318 static void vfs_gluster_fsync_do(void *private_data
);
1319 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1320 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1322 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1323 *handle
, TALLOC_CTX
*mem_ctx
,
1324 struct tevent_context
*ev
,
1327 struct tevent_req
*req
, *subreq
;
1328 struct vfs_gluster_fsync_state
*state
;
1330 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1332 DBG_ERR("Failed to fetch gluster fd\n");
1336 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1344 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1345 state
->profile_bytes
, 0);
1346 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1348 subreq
= pthreadpool_tevent_job_send(
1349 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1350 if (tevent_req_nomem(subreq
, req
)) {
1351 return tevent_req_post(req
, ev
);
1353 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1355 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1360 static void vfs_gluster_fsync_do(void *private_data
)
1362 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1363 private_data
, struct vfs_gluster_fsync_state
);
1364 struct timespec start_time
;
1365 struct timespec end_time
;
1367 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1369 PROFILE_TIMESTAMP(&start_time
);
1372 #ifdef HAVE_GFAPI_VER_7_6
1373 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1375 state
->ret
= glfs_fsync(state
->fd
);
1377 } while ((state
->ret
== -1) && (errno
== EINTR
));
1379 if (state
->ret
== -1) {
1380 state
->vfs_aio_state
.error
= errno
;
1383 PROFILE_TIMESTAMP(&end_time
);
1385 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1387 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1390 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1395 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1397 struct tevent_req
*req
= tevent_req_callback_data(
1398 subreq
, struct tevent_req
);
1399 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1400 req
, struct vfs_gluster_fsync_state
);
1403 ret
= pthreadpool_tevent_job_recv(subreq
);
1404 TALLOC_FREE(subreq
);
1405 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1406 talloc_set_destructor(state
, NULL
);
1408 if (ret
!= EAGAIN
) {
1409 tevent_req_error(req
, ret
);
1413 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1414 * means the lower level pthreadpool failed to create a new
1415 * thread. Fallback to sync processing in that case to allow
1416 * some progress for the client.
1418 vfs_gluster_fsync_do(state
);
1421 tevent_req_done(req
);
1424 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1425 struct vfs_aio_state
*vfs_aio_state
)
1427 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1428 req
, struct vfs_gluster_fsync_state
);
1430 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1434 *vfs_aio_state
= state
->vfs_aio_state
;
1438 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1439 struct smb_filename
*smb_fname
)
1444 START_PROFILE(syscall_stat
);
1445 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1447 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1449 if (ret
< 0 && errno
!= ENOENT
) {
1450 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1451 smb_fname
->base_name
, strerror(errno
)));
1453 END_PROFILE(syscall_stat
);
1458 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1459 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1463 glfs_fd_t
*glfd
= NULL
;
1465 START_PROFILE(syscall_fstat
);
1467 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1469 END_PROFILE(syscall_fstat
);
1470 DBG_ERR("Failed to fetch gluster fd\n");
1474 ret
= glfs_fstat(glfd
, &st
);
1476 smb_stat_ex_from_stat(sbuf
, &st
);
1479 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1480 fsp_get_io_fd(fsp
), strerror(errno
)));
1482 END_PROFILE(syscall_fstat
);
1487 static int vfs_gluster_fstatat(struct vfs_handle_struct
*handle
,
1488 const struct files_struct
*dirfsp
,
1489 const struct smb_filename
*smb_fname
,
1490 SMB_STRUCT_STAT
*sbuf
,
1496 #ifdef HAVE_GFAPI_VER_7_11
1497 glfs_fd_t
*pglfd
= NULL
;
1499 START_PROFILE(syscall_fstatat
);
1501 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1502 if (pglfd
== NULL
) {
1503 END_PROFILE(syscall_fstatat
);
1504 DBG_ERR("Failed to fetch gluster fd\n");
1508 ret
= glfs_fstatat(pglfd
, smb_fname
->base_name
, &st
, flags
);
1510 struct smb_filename
*full_fname
= NULL
;
1512 START_PROFILE(syscall_fstatat
);
1514 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1517 if (full_fname
== NULL
) {
1518 END_PROFILE(syscall_fstatat
);
1522 ret
= glfs_stat(handle
->data
, full_fname
->base_name
, &st
);
1524 TALLOC_FREE(full_fname
->base_name
);
1528 smb_stat_ex_from_stat(sbuf
, &st
);
1531 END_PROFILE(syscall_fstatat
);
1536 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1537 struct smb_filename
*smb_fname
)
1542 START_PROFILE(syscall_lstat
);
1543 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1545 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1547 if (ret
< 0 && errno
!= ENOENT
) {
1548 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1549 smb_fname
->base_name
, strerror(errno
)));
1551 END_PROFILE(syscall_lstat
);
1556 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1558 const SMB_STRUCT_STAT
*sbuf
)
1562 START_PROFILE(syscall_get_alloc_size
);
1563 ret
= sbuf
->st_ex_blocks
* 512;
1564 END_PROFILE(syscall_get_alloc_size
);
1569 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1570 struct files_struct
*dirfsp
,
1571 const struct smb_filename
*smb_fname
,
1576 #ifdef HAVE_GFAPI_VER_7_11
1577 glfs_fd_t
*pglfd
= NULL
;
1579 START_PROFILE(syscall_unlinkat
);
1581 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1582 if (pglfd
== NULL
) {
1583 END_PROFILE(syscall_unlinkat
);
1584 DBG_ERR("Failed to fetch gluster fd\n");
1588 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1590 struct smb_filename
*full_fname
= NULL
;
1592 START_PROFILE(syscall_unlinkat
);
1594 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1597 if (full_fname
== NULL
) {
1598 END_PROFILE(syscall_unlinkat
);
1602 if (flags
& AT_REMOVEDIR
) {
1603 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1605 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1608 TALLOC_FREE(full_fname
);
1611 END_PROFILE(syscall_unlinkat
);
1616 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1617 files_struct
*fsp
, mode_t mode
)
1620 glfs_fd_t
*glfd
= NULL
;
1622 START_PROFILE(syscall_fchmod
);
1624 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1626 END_PROFILE(syscall_fchmod
);
1627 DBG_ERR("Failed to fetch gluster fd\n");
1631 if (!fsp
->fsp_flags
.is_pathref
) {
1633 * We can use an io_fd to remove xattrs.
1635 ret
= glfs_fchmod(glfd
, mode
);
1638 * This is no longer a handle based call.
1640 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1642 END_PROFILE(syscall_fchmod
);
1647 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1648 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1651 glfs_fd_t
*glfd
= NULL
;
1653 START_PROFILE(syscall_fchown
);
1655 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1657 END_PROFILE(syscall_fchown
);
1658 DBG_ERR("Failed to fetch gluster fd\n");
1662 ret
= glfs_fchown(glfd
, uid
, gid
);
1663 END_PROFILE(syscall_fchown
);
1668 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1669 const struct smb_filename
*smb_fname
,
1675 START_PROFILE(syscall_lchown
);
1676 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1677 END_PROFILE(syscall_lchown
);
1682 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1683 const struct smb_filename
*smb_fname
)
1687 START_PROFILE(syscall_chdir
);
1688 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1689 END_PROFILE(syscall_chdir
);
1694 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1697 char cwd
[PATH_MAX
] = { '\0' };
1699 struct smb_filename
*smb_fname
= NULL
;
1701 START_PROFILE(syscall_getwd
);
1703 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1704 END_PROFILE(syscall_getwd
);
1709 smb_fname
= synthetic_smb_fname(ctx
,
1718 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1720 struct smb_file_time
*ft
)
1723 struct timespec times
[2];
1724 glfs_fd_t
*glfd
= NULL
;
1726 START_PROFILE(syscall_fntimes
);
1728 if (is_omit_timespec(&ft
->atime
)) {
1729 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1730 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1732 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1733 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1736 if (is_omit_timespec(&ft
->mtime
)) {
1737 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1738 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1740 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1741 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1744 if ((timespec_compare(×
[0],
1745 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1746 (timespec_compare(×
[1],
1747 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1748 END_PROFILE(syscall_fntimes
);
1752 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1754 END_PROFILE(syscall_fntimes
);
1755 DBG_ERR("Failed to fetch gluster fd\n");
1759 if (!fsp
->fsp_flags
.is_pathref
) {
1760 ret
= glfs_futimens(glfd
, times
);
1762 ret
= glfs_utimens(handle
->data
,
1763 fsp
->fsp_name
->base_name
,
1766 END_PROFILE(syscall_fntimes
);
1771 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1772 files_struct
*fsp
, off_t offset
)
1775 glfs_fd_t
*glfd
= NULL
;
1777 START_PROFILE(syscall_ftruncate
);
1779 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1781 END_PROFILE(syscall_ftruncate
);
1782 DBG_ERR("Failed to fetch gluster fd\n");
1786 #ifdef HAVE_GFAPI_VER_7_6
1787 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1789 ret
= glfs_ftruncate(glfd
, offset
);
1791 END_PROFILE(syscall_ftruncate
);
1796 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1797 struct files_struct
*fsp
,
1799 off_t offset
, off_t len
)
1802 #ifdef HAVE_GFAPI_VER_6
1803 glfs_fd_t
*glfd
= NULL
;
1804 int keep_size
, punch_hole
;
1806 START_PROFILE(syscall_fallocate
);
1808 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1810 END_PROFILE(syscall_fallocate
);
1811 DBG_ERR("Failed to fetch gluster fd\n");
1815 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1816 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1818 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1820 END_PROFILE(syscall_fallocate
);
1826 ret
= glfs_discard(glfd
, offset
, len
);
1828 DBG_DEBUG("glfs_discard failed: %s\n",
1833 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1834 END_PROFILE(syscall_fallocate
);
1842 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1844 const struct smb_filename
*smb_fname
)
1846 char *result
= NULL
;
1847 struct smb_filename
*result_fname
= NULL
;
1848 char *resolved_path
= NULL
;
1850 START_PROFILE(syscall_realpath
);
1852 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1853 if (resolved_path
== NULL
) {
1854 END_PROFILE(syscall_realpath
);
1859 result
= glfs_realpath(handle
->data
,
1860 smb_fname
->base_name
,
1862 if (result
!= NULL
) {
1863 result_fname
= synthetic_smb_fname(ctx
,
1871 SAFE_FREE(resolved_path
);
1872 END_PROFILE(syscall_realpath
);
1874 return result_fname
;
1877 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1878 files_struct
*fsp
, int op
, off_t offset
,
1879 off_t count
, int type
)
1881 struct flock flock
= { 0, };
1883 glfs_fd_t
*glfd
= NULL
;
1886 START_PROFILE(syscall_fcntl_lock
);
1888 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1890 DBG_ERR("Failed to fetch gluster fd\n");
1895 flock
.l_type
= type
;
1896 flock
.l_whence
= SEEK_SET
;
1897 flock
.l_start
= offset
;
1898 flock
.l_len
= count
;
1901 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1903 if (op
== F_GETLK
) {
1904 /* lock query, true if someone else has locked */
1906 (flock
.l_type
!= F_UNLCK
) &&
1907 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1923 END_PROFILE(syscall_fcntl_lock
);
1928 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1930 uint32_t share_access
,
1931 uint32_t access_mask
)
1937 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1938 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1941 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1942 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1944 if (cmd
== F_GETFL
) {
1946 } else if (cmd
== F_SETFL
) {
1947 va_list dup_cmd_arg
;
1950 va_copy(dup_cmd_arg
, cmd_arg
);
1951 opt
= va_arg(dup_cmd_arg
, int);
1952 va_end(dup_cmd_arg
);
1956 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1959 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1965 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1966 files_struct
*fsp
, int leasetype
)
1972 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1973 files_struct
*fsp
, off_t
*poffset
,
1974 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1976 struct flock flock
= { 0, };
1978 glfs_fd_t
*glfd
= NULL
;
1980 START_PROFILE(syscall_fcntl_getlock
);
1982 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1984 END_PROFILE(syscall_fcntl_getlock
);
1985 DBG_ERR("Failed to fetch gluster fd\n");
1989 flock
.l_type
= *ptype
;
1990 flock
.l_whence
= SEEK_SET
;
1991 flock
.l_start
= *poffset
;
1992 flock
.l_len
= *pcount
;
1995 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
1998 END_PROFILE(syscall_fcntl_getlock
);
2002 *ptype
= flock
.l_type
;
2003 *poffset
= flock
.l_start
;
2004 *pcount
= flock
.l_len
;
2005 *ppid
= flock
.l_pid
;
2006 END_PROFILE(syscall_fcntl_getlock
);
2011 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
2012 const struct smb_filename
*link_target
,
2013 struct files_struct
*dirfsp
,
2014 const struct smb_filename
*new_smb_fname
)
2018 #ifdef HAVE_GFAPI_VER_7_11
2019 glfs_fd_t
*pglfd
= NULL
;
2021 START_PROFILE(syscall_symlinkat
);
2023 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2024 if (pglfd
== NULL
) {
2025 END_PROFILE(syscall_symlinkat
);
2026 DBG_ERR("Failed to fetch gluster fd\n");
2030 ret
= glfs_symlinkat(link_target
->base_name
,
2032 new_smb_fname
->base_name
);
2034 struct smb_filename
*full_fname
= NULL
;
2036 START_PROFILE(syscall_symlinkat
);
2038 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2041 if (full_fname
== NULL
) {
2042 END_PROFILE(syscall_symlinkat
);
2046 ret
= glfs_symlink(handle
->data
,
2047 link_target
->base_name
,
2048 full_fname
->base_name
);
2050 TALLOC_FREE(full_fname
);
2053 END_PROFILE(syscall_symlinkat
);
2058 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2059 const struct files_struct
*dirfsp
,
2060 const struct smb_filename
*smb_fname
,
2066 #ifdef HAVE_GFAPI_VER_7_11
2067 glfs_fd_t
*pglfd
= NULL
;
2069 START_PROFILE(syscall_readlinkat
);
2071 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2072 if (pglfd
== NULL
) {
2073 END_PROFILE(syscall_readlinkat
);
2074 DBG_ERR("Failed to fetch gluster fd\n");
2078 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2080 struct smb_filename
*full_fname
= NULL
;
2082 START_PROFILE(syscall_readlinkat
);
2084 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2087 if (full_fname
== NULL
) {
2088 END_PROFILE(syscall_readlinkat
);
2092 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2094 TALLOC_FREE(full_fname
);
2097 END_PROFILE(syscall_readlinkat
);
2102 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2103 files_struct
*srcfsp
,
2104 const struct smb_filename
*old_smb_fname
,
2105 files_struct
*dstfsp
,
2106 const struct smb_filename
*new_smb_fname
,
2111 #ifdef HAVE_GFAPI_VER_7_11
2112 glfs_fd_t
*src_pglfd
= NULL
;
2113 glfs_fd_t
*dst_pglfd
= NULL
;
2115 START_PROFILE(syscall_linkat
);
2117 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
2118 if (src_pglfd
== NULL
) {
2119 END_PROFILE(syscall_linkat
);
2120 DBG_ERR("Failed to fetch gluster fd\n");
2124 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
2125 if (dst_pglfd
== NULL
) {
2126 END_PROFILE(syscall_linkat
);
2127 DBG_ERR("Failed to fetch gluster fd\n");
2131 ret
= glfs_linkat(src_pglfd
,
2132 old_smb_fname
->base_name
,
2134 new_smb_fname
->base_name
,
2137 struct smb_filename
*full_fname_old
= NULL
;
2138 struct smb_filename
*full_fname_new
= NULL
;
2140 START_PROFILE(syscall_linkat
);
2142 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2145 if (full_fname_old
== NULL
) {
2146 END_PROFILE(syscall_linkat
);
2150 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2153 if (full_fname_new
== NULL
) {
2154 END_PROFILE(syscall_linkat
);
2155 TALLOC_FREE(full_fname_old
);
2159 ret
= glfs_link(handle
->data
,
2160 full_fname_old
->base_name
,
2161 full_fname_new
->base_name
);
2163 TALLOC_FREE(full_fname_old
);
2164 TALLOC_FREE(full_fname_new
);
2167 END_PROFILE(syscall_linkat
);
2172 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2173 files_struct
*dirfsp
,
2174 const struct smb_filename
*smb_fname
,
2180 #ifdef HAVE_GFAPI_VER_7_11
2181 glfs_fd_t
*pglfd
= NULL
;
2183 START_PROFILE(syscall_mknodat
);
2185 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2186 if (pglfd
== NULL
) {
2187 END_PROFILE(syscall_mknodat
);
2188 DBG_ERR("Failed to fetch gluster fd\n");
2192 ret
= glfs_mknodat(pglfd
, smb_fname
->base_name
, mode
, dev
);
2194 struct smb_filename
*full_fname
= NULL
;
2196 START_PROFILE(syscall_mknodat
);
2198 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2201 if (full_fname
== NULL
) {
2202 END_PROFILE(syscall_mknodat
);
2206 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2208 TALLOC_FREE(full_fname
);
2211 END_PROFILE(syscall_mknodat
);
2216 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2217 struct files_struct
*fsp
,
2224 static NTSTATUS
vfs_gluster_get_real_filename_at(
2225 struct vfs_handle_struct
*handle
,
2226 struct files_struct
*dirfsp
,
2228 TALLOC_CTX
*mem_ctx
,
2232 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2233 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2235 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2236 return NT_STATUS_OBJECT_NAME_INVALID
;
2239 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2240 "glusterfs.get_real_filename:%s", name
);
2242 ret
= glfs_getxattr(handle
->data
,
2243 dirfsp
->fsp_name
->base_name
,
2246 GLUSTER_NAME_MAX
+ 1);
2248 if (errno
== ENOATTR
) {
2251 return map_nt_error_from_unix(errno
);
2254 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2255 if (found_name
[0] == NULL
) {
2256 return NT_STATUS_NO_MEMORY
;
2259 return NT_STATUS_OK
;
2262 static const char *vfs_gluster_connectpath(
2263 struct vfs_handle_struct
*handle
,
2264 const struct files_struct
*dirfsp
,
2265 const struct smb_filename
*smb_fname
)
2267 return handle
->conn
->connectpath
;
2272 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2273 files_struct
*fsp
, const char *name
,
2274 void *value
, size_t size
)
2276 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2278 DBG_ERR("Failed to fetch gluster fd\n");
2282 if (!fsp
->fsp_flags
.is_pathref
) {
2284 * We can use an io_fd to retrieve xattr value.
2286 return glfs_fgetxattr(glfd
, name
, value
, size
);
2290 * This is no longer a handle based call.
2292 return glfs_getxattr(handle
->data
,
2293 fsp
->fsp_name
->base_name
,
2299 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2300 files_struct
*fsp
, char *list
,
2303 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2305 DBG_ERR("Failed to fetch gluster fd\n");
2308 if (!fsp
->fsp_flags
.is_pathref
) {
2310 * We can use an io_fd to list xattrs.
2312 return glfs_flistxattr(glfd
, list
, size
);
2315 * This is no longer a handle based call.
2317 return glfs_listxattr(handle
->data
,
2318 fsp
->fsp_name
->base_name
,
2324 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2325 files_struct
*fsp
, const char *name
)
2327 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2329 DBG_ERR("Failed to fetch gluster fd\n");
2332 if (!fsp
->fsp_flags
.is_pathref
) {
2334 * We can use an io_fd to remove xattrs.
2336 return glfs_fremovexattr(glfd
, name
);
2339 * This is no longer a handle based call.
2341 return glfs_removexattr(handle
->data
,
2342 fsp
->fsp_name
->base_name
,
2347 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2348 files_struct
*fsp
, const char *name
,
2349 const void *value
, size_t size
, int flags
)
2351 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2353 DBG_ERR("Failed to fetch gluster fd\n");
2357 if (!fsp
->fsp_flags
.is_pathref
) {
2359 * We can use an io_fd to set xattrs.
2361 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2364 * This is no longer a handle based call.
2366 return glfs_setxattr(handle
->data
,
2367 fsp
->fsp_name
->base_name
,
2375 /* AIO Operations */
2377 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2383 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2384 struct files_struct
*dirfsp
,
2385 const struct smb_filename
*smb_fname
,
2386 const struct referral
*reflist
,
2387 size_t referral_count
)
2389 TALLOC_CTX
*frame
= talloc_stackframe();
2390 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2392 char *msdfs_link
= NULL
;
2393 #ifdef HAVE_GFAPI_VER_7_11
2394 glfs_fd_t
*pglfd
= NULL
;
2396 struct smb_filename
*full_fname
= NULL
;
2399 /* Form the msdfs_link contents */
2400 msdfs_link
= msdfs_link_string(frame
,
2403 if (msdfs_link
== NULL
) {
2407 #ifdef HAVE_GFAPI_VER_7_11
2408 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2409 if (pglfd
== NULL
) {
2410 DBG_ERR("Failed to fetch gluster fd\n");
2411 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2415 ret
= glfs_symlinkat(msdfs_link
, pglfd
, smb_fname
->base_name
);
2417 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2420 if (full_fname
== NULL
) {
2424 ret
= glfs_symlink(handle
->data
, msdfs_link
, full_fname
->base_name
);
2426 TALLOC_FREE(full_fname
);
2429 status
= NT_STATUS_OK
;
2431 status
= map_nt_error_from_unix(errno
);
2441 * Read and return the contents of a DFS redirect given a
2442 * pathname. A caller can pass in NULL for ppreflist and
2443 * preferral_count but still determine if this was a
2444 * DFS redirect point by getting NT_STATUS_OK back
2445 * without incurring the overhead of reading and parsing
2446 * the referral contents.
2449 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2450 TALLOC_CTX
*mem_ctx
,
2451 struct files_struct
*dirfsp
,
2452 struct smb_filename
*smb_fname
,
2453 struct referral
**ppreflist
,
2454 size_t *preferral_count
)
2456 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2458 char *link_target
= NULL
;
2461 #if defined(HAVE_BROKEN_READLINK)
2462 char link_target_buf
[PATH_MAX
];
2464 char link_target_buf
[7];
2467 struct smb_filename
*full_fname
= NULL
;
2469 #ifdef HAVE_GFAPI_VER_7_11
2470 glfs_fd_t
*pglfd
= NULL
;
2473 if (is_named_stream(smb_fname
)) {
2474 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2478 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2480 * We're only checking if this is a DFS
2481 * redirect. We don't need to return data.
2483 bufsize
= sizeof(link_target_buf
);
2484 link_target
= link_target_buf
;
2487 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2493 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2496 if (full_fname
== NULL
) {
2497 status
= NT_STATUS_NO_MEMORY
;
2501 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2503 status
= map_nt_error_from_unix(errno
);
2507 #ifdef HAVE_GFAPI_VER_7_11
2508 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2509 if (pglfd
== NULL
) {
2510 DBG_ERR("Failed to fetch gluster fd\n");
2511 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2514 referral_len
= glfs_readlinkat(pglfd
,
2515 smb_fname
->base_name
,
2519 referral_len
= glfs_readlink(handle
->data
,
2520 full_fname
->base_name
,
2524 if (referral_len
< 0) {
2525 if (errno
== EINVAL
) {
2526 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2527 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2529 status
= map_nt_error_from_unix(errno
);
2530 DBG_ERR("Error reading "
2531 "msdfs link %s: %s\n",
2532 full_fname
->base_name
,
2537 link_target
[referral_len
] = '\0';
2539 DBG_INFO("%s -> %s\n",
2540 full_fname
->base_name
,
2543 if (!strnequal(link_target
, "msdfs:", 6)) {
2544 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2548 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2549 /* Early return for checking if this is a DFS link. */
2550 TALLOC_FREE(full_fname
);
2551 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2552 return NT_STATUS_OK
;
2555 ok
= parse_msdfs_symlink(mem_ctx
,
2556 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2562 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2563 status
= NT_STATUS_OK
;
2565 status
= NT_STATUS_NO_MEMORY
;
2570 if (link_target
!= link_target_buf
) {
2571 TALLOC_FREE(link_target
);
2573 TALLOC_FREE(full_fname
);
2577 static struct vfs_fn_pointers glusterfs_fns
= {
2579 /* Disk Operations */
2581 .connect_fn
= vfs_gluster_connect
,
2582 .disconnect_fn
= vfs_gluster_disconnect
,
2583 .disk_free_fn
= vfs_gluster_disk_free
,
2584 .get_quota_fn
= vfs_gluster_get_quota
,
2585 .set_quota_fn
= vfs_gluster_set_quota
,
2586 .statvfs_fn
= vfs_gluster_statvfs
,
2587 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2589 .get_dfs_referrals_fn
= NULL
,
2591 /* Directory Operations */
2593 .fdopendir_fn
= vfs_gluster_fdopendir
,
2594 .readdir_fn
= vfs_gluster_readdir
,
2595 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2596 .mkdirat_fn
= vfs_gluster_mkdirat
,
2597 .closedir_fn
= vfs_gluster_closedir
,
2599 /* File Operations */
2601 .openat_fn
= vfs_gluster_openat
,
2602 .create_file_fn
= NULL
,
2603 .close_fn
= vfs_gluster_close
,
2604 .pread_fn
= vfs_gluster_pread
,
2605 .pread_send_fn
= vfs_gluster_pread_send
,
2606 .pread_recv_fn
= vfs_gluster_pread_recv
,
2607 .pwrite_fn
= vfs_gluster_pwrite
,
2608 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2609 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2610 .lseek_fn
= vfs_gluster_lseek
,
2611 .sendfile_fn
= vfs_gluster_sendfile
,
2612 .recvfile_fn
= vfs_gluster_recvfile
,
2613 .renameat_fn
= vfs_gluster_renameat
,
2614 .fsync_send_fn
= vfs_gluster_fsync_send
,
2615 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2617 .stat_fn
= vfs_gluster_stat
,
2618 .fstat_fn
= vfs_gluster_fstat
,
2619 .fstatat_fn
= vfs_gluster_fstatat
,
2620 .lstat_fn
= vfs_gluster_lstat
,
2621 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2622 .unlinkat_fn
= vfs_gluster_unlinkat
,
2624 .fchmod_fn
= vfs_gluster_fchmod
,
2625 .fchown_fn
= vfs_gluster_fchown
,
2626 .lchown_fn
= vfs_gluster_lchown
,
2627 .chdir_fn
= vfs_gluster_chdir
,
2628 .getwd_fn
= vfs_gluster_getwd
,
2629 .fntimes_fn
= vfs_gluster_fntimes
,
2630 .ftruncate_fn
= vfs_gluster_ftruncate
,
2631 .fallocate_fn
= vfs_gluster_fallocate
,
2632 .lock_fn
= vfs_gluster_lock
,
2633 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2634 .fcntl_fn
= vfs_gluster_fcntl
,
2635 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2636 .getlock_fn
= vfs_gluster_getlock
,
2637 .symlinkat_fn
= vfs_gluster_symlinkat
,
2638 .readlinkat_fn
= vfs_gluster_readlinkat
,
2639 .linkat_fn
= vfs_gluster_linkat
,
2640 .mknodat_fn
= vfs_gluster_mknodat
,
2641 .realpath_fn
= vfs_gluster_realpath
,
2642 .fchflags_fn
= vfs_gluster_fchflags
,
2643 .file_id_create_fn
= NULL
,
2644 .fstreaminfo_fn
= NULL
,
2645 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2646 .connectpath_fn
= vfs_gluster_connectpath
,
2647 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2648 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2650 .brl_lock_windows_fn
= NULL
,
2651 .brl_unlock_windows_fn
= NULL
,
2652 .strict_lock_check_fn
= NULL
,
2653 .translate_name_fn
= NULL
,
2656 /* NT ACL Operations */
2657 .fget_nt_acl_fn
= NULL
,
2658 .fset_nt_acl_fn
= NULL
,
2659 .audit_file_fn
= NULL
,
2661 /* Posix ACL Operations */
2662 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2663 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2664 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2665 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2668 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2669 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2670 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2671 .flistxattr_fn
= vfs_gluster_flistxattr
,
2672 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2673 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2675 /* AIO Operations */
2676 .aio_force_fn
= vfs_gluster_aio_force
,
2678 /* Durable handle Operations */
2679 .durable_cookie_fn
= NULL
,
2680 .durable_disconnect_fn
= NULL
,
2681 .durable_reconnect_fn
= NULL
,
2685 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2687 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2688 "glusterfs", &glusterfs_fns
);