2 Unix SMB/CIFS implementation.
4 Wrap GlusterFS GFAPI calls in vfs functions.
6 Copyright (c) 2013 Anand Avati <avati@redhat.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @file vfs_glusterfs.c
24 * @author Anand Avati <avati@redhat.com>
26 * @brief Samba VFS module for glusterfs
29 * - sendfile/recvfile support
31 * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
32 * This is a "bottom" vfs module (not something to be stacked on top of
33 * another module), and translates (most) calls to the closest actions
34 * available in libgfapi.
39 #include "smbd/smbd.h"
41 #include <glusterfs/api/glfs.h>
42 #include "lib/util/dlinklist.h"
43 #include "lib/util/tevent_unix.h"
44 #include "smbd/globals.h"
45 #include "lib/util/sys_rw.h"
46 #include "smbprofile.h"
47 #include "modules/posixacl_xattr.h"
48 #include "lib/pthreadpool/pthreadpool_tevent.h"
50 #define DEFAULT_VOLFILE_SERVER "localhost"
51 #define GLUSTER_NAME_MAX 255
54 * Helper to convert struct stat to struct stat_ex.
56 static void smb_stat_ex_from_stat(struct stat_ex
*dst
, const struct stat
*src
)
60 dst
->st_ex_dev
= src
->st_dev
;
61 dst
->st_ex_ino
= src
->st_ino
;
62 dst
->st_ex_mode
= src
->st_mode
;
63 dst
->st_ex_nlink
= src
->st_nlink
;
64 dst
->st_ex_uid
= src
->st_uid
;
65 dst
->st_ex_gid
= src
->st_gid
;
66 dst
->st_ex_rdev
= src
->st_rdev
;
67 dst
->st_ex_size
= src
->st_size
;
68 dst
->st_ex_atime
.tv_sec
= src
->st_atime
;
69 dst
->st_ex_mtime
.tv_sec
= src
->st_mtime
;
70 dst
->st_ex_ctime
.tv_sec
= src
->st_ctime
;
71 dst
->st_ex_btime
.tv_sec
= src
->st_mtime
;
72 dst
->st_ex_blksize
= src
->st_blksize
;
73 dst
->st_ex_blocks
= src
->st_blocks
;
75 dst
->st_ex_atime
.tv_nsec
= src
->st_atime_nsec
;
76 dst
->st_ex_mtime
.tv_nsec
= src
->st_mtime_nsec
;
77 dst
->st_ex_ctime
.tv_nsec
= src
->st_ctime_nsec
;
78 dst
->st_ex_btime
.tv_nsec
= src
->st_mtime_nsec
;
82 /* pre-opened glfs_t */
84 static struct glfs_preopened
{
89 struct glfs_preopened
*next
, *prev
;
93 static int glfs_set_preopened(const char *volume
, const char *connectpath
, glfs_t
*fs
)
95 struct glfs_preopened
*entry
= NULL
;
97 entry
= talloc_zero(NULL
, struct glfs_preopened
);
103 entry
->volume
= talloc_strdup(entry
, volume
);
104 if (!entry
->volume
) {
110 entry
->connectpath
= talloc_strdup(entry
, connectpath
);
111 if (entry
->connectpath
== NULL
) {
120 DLIST_ADD(glfs_preopened
, entry
);
125 static glfs_t
*glfs_find_preopened(const char *volume
, const char *connectpath
)
127 struct glfs_preopened
*entry
= NULL
;
129 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
130 if (strcmp(entry
->volume
, volume
) == 0 &&
131 strcmp(entry
->connectpath
, connectpath
) == 0)
141 static void glfs_clear_preopened(glfs_t
*fs
)
143 struct glfs_preopened
*entry
= NULL
;
145 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
146 if (entry
->fs
== fs
) {
150 DLIST_REMOVE(glfs_preopened
, entry
);
152 glfs_fini(entry
->fs
);
159 static int vfs_gluster_set_volfile_servers(glfs_t
*fs
,
160 const char *volfile_servers
)
163 size_t server_count
= 0;
164 size_t server_success
= 0;
166 TALLOC_CTX
*frame
= talloc_stackframe();
168 DBG_INFO("servers list %s\n", volfile_servers
);
170 while (next_token_talloc(frame
, &volfile_servers
, &server
, " \t")) {
171 char *transport
= NULL
;
176 DBG_INFO("server %zu %s\n", server_count
, server
);
178 /* Determine the transport type */
179 if (strncmp(server
, "unix+", 5) == 0) {
181 transport
= talloc_strdup(frame
, "unix");
186 host
= talloc_strdup(frame
, server
+ 5);
193 char *port_index
= NULL
;
195 if (strncmp(server
, "tcp+", 4) == 0) {
199 /* IPv6 is enclosed in []
200 * ':' before ']' is part of IPv6
201 * ':' after ']' indicates port
204 if (server
[0] == '[') {
206 p
= index(server
, ']');
215 port_index
= index(p
, ':');
217 if (port_index
== NULL
) {
220 port
= atoi(port_index
+ 1);
221 port_index
[0] = '\0';
223 transport
= talloc_strdup(frame
, "tcp");
228 host
= talloc_strdup(frame
, server
);
235 DBG_INFO("Calling set volfile server with params "
236 "transport=%s, host=%s, port=%d\n", transport
,
239 ret
= glfs_set_volfile_server(fs
, transport
, host
, port
);
241 DBG_WARNING("Failed to set volfile_server "
242 "transport=%s, host=%s, port=%d (%s)\n",
243 transport
, host
, port
, strerror(errno
));
250 if (server_count
== 0) {
252 } else if (server_success
< server_count
) {
253 DBG_WARNING("Failed to set %zu out of %zu servers parsed\n",
254 server_count
- server_success
, server_count
);
262 /* Disk Operations */
264 static int check_for_write_behind_translator(TALLOC_CTX
*mem_ctx
,
273 bool write_behind_present
= false;
277 ret
= glfs_get_volfile(fs
, NULL
, 0);
279 DBG_ERR("%s: Failed to get volfile for "
280 "volume (%s): No volfile\n",
286 DBG_ERR("%s: Invalid return %d for glfs_get_volfile for "
287 "volume (%s): No volfile\n",
296 buf
= talloc_zero_array(mem_ctx
, char, newlen
);
301 ret
= glfs_get_volfile(fs
, buf
, newlen
);
304 DBG_ERR("%s: Failed to get volfile for volume (%s)\n",
305 volume
, strerror(errno
));
309 option
= talloc_asprintf(mem_ctx
, "volume %s-write-behind", volume
);
310 if (option
== NULL
) {
316 * file_lines_parse() plays horrible tricks with
317 * the passed-in talloc pointers and the hierarcy
318 * which makes freeing hard to get right.
320 * As we know mem_ctx is freed by the caller, after
321 * this point don't free on exit and let the caller
322 * handle it. This violates good Samba coding practice
323 * but we know we're not leaking here.
326 lines
= file_lines_parse(buf
,
330 if (lines
== NULL
|| numlines
<= 0) {
333 /* On success, buf is now a talloc child of lines !! */
335 for (i
=0; i
< numlines
; i
++) {
336 if (strequal(lines
[i
], option
)) {
337 write_behind_present
= true;
342 if (write_behind_present
) {
343 DBG_ERR("Write behind translator is enabled for "
344 "volume (%s), refusing to connect! "
345 "Please turn off the write behind translator by calling "
346 "'gluster volume set %s performance.write-behind off' "
347 "on the commandline. "
348 "Check the vfs_glusterfs(8) manpage for "
349 "further details.\n",
357 static int vfs_gluster_connect(struct vfs_handle_struct
*handle
,
361 const struct loadparm_substitution
*lp_sub
=
362 loadparm_s3_global_substitution();
363 const char *volfile_servers
;
370 bool write_behind_pass_through_set
= false;
372 tmp_ctx
= talloc_new(NULL
);
373 if (tmp_ctx
== NULL
) {
377 logfile
= lp_parm_substituted_string(tmp_ctx
,
384 loglevel
= lp_parm_int(SNUM(handle
->conn
), "glusterfs", "loglevel", -1);
386 volfile_servers
= lp_parm_substituted_string(tmp_ctx
,
392 if (volfile_servers
== NULL
) {
393 volfile_servers
= DEFAULT_VOLFILE_SERVER
;
396 volume
= lp_parm_const_string(SNUM(handle
->conn
), "glusterfs", "volume",
398 if (volume
== NULL
) {
402 fs
= glfs_find_preopened(volume
, handle
->conn
->connectpath
);
407 fs
= glfs_new(volume
);
413 ret
= vfs_gluster_set_volfile_servers(fs
, volfile_servers
);
415 DBG_ERR("Failed to set volfile_servers from list %s\n",
420 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-posix-acl",
423 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
427 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-selinux",
430 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
434 ret
= glfs_set_xlator_option(fs
, "*-snapview-client",
435 "snapdir-entry-path",
436 handle
->conn
->connectpath
);
438 DEBUG(0, ("%s: Failed to set xlator option:"
439 " snapdir-entry-path\n", volume
));
443 #ifdef HAVE_GFAPI_VER_7_9
444 ret
= glfs_set_xlator_option(fs
, "*-write-behind", "pass-through",
447 DBG_ERR("%s: Failed to set xlator option: pass-through\n",
451 write_behind_pass_through_set
= true;
454 ret
= glfs_set_logging(fs
, logfile
, loglevel
);
456 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
457 volume
, logfile
, loglevel
));
463 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
464 volume
, strerror(errno
)));
468 if (!write_behind_pass_through_set
) {
469 ret
= check_for_write_behind_translator(tmp_ctx
, fs
, volume
);
475 ret
= glfs_set_preopened(volume
, handle
->conn
->connectpath
, fs
);
477 DEBUG(0, ("%s: Failed to register volume (%s)\n",
478 volume
, strerror(errno
)));
483 * The shadow_copy2 module will fail to export subdirectories
484 * of a gluster volume unless we specify the mount point,
485 * because the detection fails if the file system is not
487 * https://bugzilla.samba.org/show_bug.cgi?id=13091
489 lp_do_parameter(SNUM(handle
->conn
), "shadow:mountpoint", "/");
492 * Unless we have an async implementation of getxattrat turn this off.
494 lp_do_parameter(SNUM(handle
->conn
), "smbd async dosmode", "false");
501 DBG_ERR("%s: Initialized volume from servers %s\n",
502 volume
, volfile_servers
);
505 talloc_free(tmp_ctx
);
509 static void vfs_gluster_disconnect(struct vfs_handle_struct
*handle
)
515 glfs_clear_preopened(fs
);
518 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct
*handle
,
519 const struct smb_filename
*smb_fname
,
524 struct statvfs statvfs
= { 0, };
527 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
532 if (bsize_p
!= NULL
) {
533 *bsize_p
= (uint64_t)statvfs
.f_bsize
; /* Block size */
535 if (dfree_p
!= NULL
) {
536 *dfree_p
= (uint64_t)statvfs
.f_bavail
; /* Available Block units */
538 if (dsize_p
!= NULL
) {
539 *dsize_p
= (uint64_t)statvfs
.f_blocks
; /* Total Block units */
542 return (uint64_t)statvfs
.f_bavail
;
545 static int vfs_gluster_get_quota(struct vfs_handle_struct
*handle
,
546 const struct smb_filename
*smb_fname
,
547 enum SMB_QUOTA_TYPE qtype
,
556 vfs_gluster_set_quota(struct vfs_handle_struct
*handle
,
557 enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
563 static int vfs_gluster_statvfs(struct vfs_handle_struct
*handle
,
564 const struct smb_filename
*smb_fname
,
565 struct vfs_statvfs_struct
*vfs_statvfs
)
567 struct statvfs statvfs
= { 0, };
570 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
572 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
573 smb_fname
->base_name
, strerror(errno
)));
577 ZERO_STRUCTP(vfs_statvfs
);
579 vfs_statvfs
->OptimalTransferSize
= statvfs
.f_frsize
;
580 vfs_statvfs
->BlockSize
= statvfs
.f_bsize
;
581 vfs_statvfs
->TotalBlocks
= statvfs
.f_blocks
;
582 vfs_statvfs
->BlocksAvail
= statvfs
.f_bfree
;
583 vfs_statvfs
->UserBlocksAvail
= statvfs
.f_bavail
;
584 vfs_statvfs
->TotalFileNodes
= statvfs
.f_files
;
585 vfs_statvfs
->FreeFileNodes
= statvfs
.f_ffree
;
586 vfs_statvfs
->FsIdentifier
= statvfs
.f_fsid
;
587 vfs_statvfs
->FsCapabilities
=
588 FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
593 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct
*handle
,
594 enum timestamp_set_resolution
*p_ts_res
)
596 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
598 #ifdef HAVE_GFAPI_VER_6
599 caps
|= FILE_SUPPORTS_SPARSE_FILES
;
602 #ifdef STAT_HAVE_NSEC
603 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
609 static glfs_fd_t
*vfs_gluster_fetch_glfd(struct vfs_handle_struct
*handle
,
610 const files_struct
*fsp
)
612 glfs_fd_t
**glfd
= (glfs_fd_t
**)VFS_FETCH_FSP_EXTENSION(handle
, fsp
);
614 DBG_INFO("Failed to fetch fsp extension\n");
618 DBG_INFO("Empty glfs_fd_t pointer\n");
625 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct
*handle
,
626 files_struct
*fsp
, const char *mask
,
629 glfs_fd_t
*glfd
= NULL
;
631 glfd
= glfs_opendir(handle
->data
, fsp
->fsp_name
->base_name
);
639 static int vfs_gluster_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
643 START_PROFILE(syscall_closedir
);
644 ret
= glfs_closedir((void *)dirp
);
645 END_PROFILE(syscall_closedir
);
650 static struct dirent
*vfs_gluster_readdir(struct vfs_handle_struct
*handle
,
651 struct files_struct
*dirfsp
,
653 SMB_STRUCT_STAT
*sbuf
)
655 static char direntbuf
[512];
658 struct dirent
*dirent
= 0;
660 START_PROFILE(syscall_readdir
);
662 ret
= glfs_readdirplus_r((void *)dirp
, &stat
, (void *)direntbuf
,
665 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
668 if ((ret
< 0) || (dirent
== NULL
)) {
669 END_PROFILE(syscall_readdir
);
674 SET_STAT_INVALID(*sbuf
);
675 if (!S_ISLNK(stat
.st_mode
)) {
676 smb_stat_ex_from_stat(sbuf
, &stat
);
680 END_PROFILE(syscall_readdir
);
684 static long vfs_gluster_telldir(struct vfs_handle_struct
*handle
, DIR *dirp
)
688 START_PROFILE(syscall_telldir
);
689 ret
= glfs_telldir((void *)dirp
);
690 END_PROFILE(syscall_telldir
);
695 static void vfs_gluster_seekdir(struct vfs_handle_struct
*handle
, DIR *dirp
,
698 START_PROFILE(syscall_seekdir
);
699 glfs_seekdir((void *)dirp
, offset
);
700 END_PROFILE(syscall_seekdir
);
703 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
705 START_PROFILE(syscall_rewinddir
);
706 glfs_seekdir((void *)dirp
, 0);
707 END_PROFILE(syscall_rewinddir
);
710 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
711 struct files_struct
*dirfsp
,
712 const struct smb_filename
*smb_fname
,
717 #ifdef HAVE_GFAPI_VER_7_11
718 glfs_fd_t
*pglfd
= NULL
;
720 START_PROFILE(syscall_mkdirat
);
722 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
724 END_PROFILE(syscall_mkdirat
);
725 DBG_ERR("Failed to fetch gluster fd\n");
729 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
731 struct smb_filename
*full_fname
= NULL
;
733 START_PROFILE(syscall_mkdirat
);
735 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
738 if (full_fname
== NULL
) {
739 END_PROFILE(syscall_mkdirat
);
743 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
745 TALLOC_FREE(full_fname
);
748 END_PROFILE(syscall_mkdirat
);
753 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
754 const struct files_struct
*dirfsp
,
755 const struct smb_filename
*smb_fname
,
757 const struct vfs_open_how
*how
)
759 int flags
= how
->flags
;
760 struct smb_filename
*full_fname
= NULL
;
761 bool have_opath
= false;
762 bool became_root
= false;
764 glfs_fd_t
*pglfd
= NULL
;
767 START_PROFILE(syscall_openat
);
769 if (how
->resolve
!= 0) {
770 END_PROFILE(syscall_openat
);
775 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
777 END_PROFILE(syscall_openat
);
784 if (fsp
->fsp_flags
.is_pathref
) {
789 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
792 if (full_fname
== NULL
) {
793 END_PROFILE(syscall_openat
);
797 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
802 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
803 #ifdef HAVE_GFAPI_VER_7_11
805 * Fetch Gluster fd for parent directory using dirfsp
806 * before calling glfs_openat();
808 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
810 END_PROFILE(syscall_openat
);
811 DBG_ERR("Failed to fetch gluster fd\n");
815 glfd
= glfs_openat(pglfd
,
816 smb_fname
->base_name
,
821 * Replace smb_fname with full_path constructed above.
823 smb_fname
= full_fname
;
829 * smb_fname can either be a full_path or the same one
830 * as received from the caller. In the latter case we
831 * are operating at current working directory.
833 if (flags
& O_CREAT
) {
834 glfd
= glfs_creat(handle
->data
,
835 smb_fname
->base_name
,
839 glfd
= glfs_open(handle
->data
,
840 smb_fname
->base_name
,
849 TALLOC_FREE(full_fname
);
851 fsp
->fsp_flags
.have_proc_fds
= false;
854 END_PROFILE(syscall_openat
);
855 /* no extension destroy_fn, so no need to save errno */
856 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
862 END_PROFILE(syscall_openat
);
863 /* An arbitrary value for error reporting, so you know its us. */
867 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
871 glfs_fd_t
*glfd
= NULL
;
873 START_PROFILE(syscall_close
);
875 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
877 END_PROFILE(syscall_close
);
878 DBG_ERR("Failed to fetch gluster fd\n");
882 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
884 ret
= glfs_close(glfd
);
885 END_PROFILE(syscall_close
);
890 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
891 files_struct
*fsp
, void *data
, size_t n
,
895 glfs_fd_t
*glfd
= NULL
;
897 START_PROFILE_BYTES(syscall_pread
, n
);
899 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
901 END_PROFILE_BYTES(syscall_pread
);
902 DBG_ERR("Failed to fetch gluster fd\n");
906 #ifdef HAVE_GFAPI_VER_7_6
907 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
909 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
911 END_PROFILE_BYTES(syscall_pread
);
916 struct vfs_gluster_pread_state
{
923 struct vfs_aio_state vfs_aio_state
;
924 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
927 static void vfs_gluster_pread_do(void *private_data
);
928 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
929 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
931 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
932 *handle
, TALLOC_CTX
*mem_ctx
,
933 struct tevent_context
*ev
,
935 void *data
, size_t n
,
938 struct vfs_gluster_pread_state
*state
;
939 struct tevent_req
*req
, *subreq
;
941 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
943 DBG_ERR("Failed to fetch gluster fd\n");
947 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
956 state
->offset
= offset
;
958 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
959 state
->profile_bytes
, n
);
960 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
962 subreq
= pthreadpool_tevent_job_send(
963 state
, ev
, handle
->conn
->sconn
->pool
,
964 vfs_gluster_pread_do
, state
);
965 if (tevent_req_nomem(subreq
, req
)) {
966 return tevent_req_post(req
, ev
);
968 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
970 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
975 static void vfs_gluster_pread_do(void *private_data
)
977 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
978 private_data
, struct vfs_gluster_pread_state
);
979 struct timespec start_time
;
980 struct timespec end_time
;
982 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
984 PROFILE_TIMESTAMP(&start_time
);
987 #ifdef HAVE_GFAPI_VER_7_6
988 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
989 state
->offset
, 0, NULL
);
991 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
994 } while ((state
->ret
== -1) && (errno
== EINTR
));
996 if (state
->ret
== -1) {
997 state
->vfs_aio_state
.error
= errno
;
1000 PROFILE_TIMESTAMP(&end_time
);
1002 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1004 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1007 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
1012 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
1014 struct tevent_req
*req
= tevent_req_callback_data(
1015 subreq
, struct tevent_req
);
1016 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1017 req
, struct vfs_gluster_pread_state
);
1020 ret
= pthreadpool_tevent_job_recv(subreq
);
1021 TALLOC_FREE(subreq
);
1022 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1023 talloc_set_destructor(state
, NULL
);
1025 if (ret
!= EAGAIN
) {
1026 tevent_req_error(req
, ret
);
1030 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1031 * means the lower level pthreadpool failed to create a new
1032 * thread. Fallback to sync processing in that case to allow
1033 * some progress for the client.
1035 vfs_gluster_pread_do(state
);
1038 tevent_req_done(req
);
1041 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1042 struct vfs_aio_state
*vfs_aio_state
)
1044 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1045 req
, struct vfs_gluster_pread_state
);
1047 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1051 *vfs_aio_state
= state
->vfs_aio_state
;
1055 struct vfs_gluster_pwrite_state
{
1062 struct vfs_aio_state vfs_aio_state
;
1063 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1066 static void vfs_gluster_pwrite_do(void *private_data
);
1067 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1068 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1070 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1071 *handle
, TALLOC_CTX
*mem_ctx
,
1072 struct tevent_context
*ev
,
1074 const void *data
, size_t n
,
1077 struct tevent_req
*req
, *subreq
;
1078 struct vfs_gluster_pwrite_state
*state
;
1080 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1082 DBG_ERR("Failed to fetch gluster fd\n");
1086 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1095 state
->offset
= offset
;
1097 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1098 state
->profile_bytes
, n
);
1099 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1101 subreq
= pthreadpool_tevent_job_send(
1102 state
, ev
, handle
->conn
->sconn
->pool
,
1103 vfs_gluster_pwrite_do
, state
);
1104 if (tevent_req_nomem(subreq
, req
)) {
1105 return tevent_req_post(req
, ev
);
1107 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1109 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1114 static void vfs_gluster_pwrite_do(void *private_data
)
1116 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1117 private_data
, struct vfs_gluster_pwrite_state
);
1118 struct timespec start_time
;
1119 struct timespec end_time
;
1121 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1123 PROFILE_TIMESTAMP(&start_time
);
1126 #ifdef HAVE_GFAPI_VER_7_6
1127 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1128 state
->offset
, 0, NULL
, NULL
);
1130 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1133 } while ((state
->ret
== -1) && (errno
== EINTR
));
1135 if (state
->ret
== -1) {
1136 state
->vfs_aio_state
.error
= errno
;
1139 PROFILE_TIMESTAMP(&end_time
);
1141 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1143 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1146 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1151 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1153 struct tevent_req
*req
= tevent_req_callback_data(
1154 subreq
, struct tevent_req
);
1155 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1156 req
, struct vfs_gluster_pwrite_state
);
1159 ret
= pthreadpool_tevent_job_recv(subreq
);
1160 TALLOC_FREE(subreq
);
1161 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1162 talloc_set_destructor(state
, NULL
);
1164 if (ret
!= EAGAIN
) {
1165 tevent_req_error(req
, ret
);
1169 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1170 * means the lower level pthreadpool failed to create a new
1171 * thread. Fallback to sync processing in that case to allow
1172 * some progress for the client.
1174 vfs_gluster_pwrite_do(state
);
1177 tevent_req_done(req
);
1180 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1181 struct vfs_aio_state
*vfs_aio_state
)
1183 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1184 req
, struct vfs_gluster_pwrite_state
);
1186 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1190 *vfs_aio_state
= state
->vfs_aio_state
;
1195 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1196 files_struct
*fsp
, const void *data
,
1197 size_t n
, off_t offset
)
1200 glfs_fd_t
*glfd
= NULL
;
1202 START_PROFILE_BYTES(syscall_pwrite
, n
);
1204 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1206 END_PROFILE_BYTES(syscall_pwrite
);
1207 DBG_ERR("Failed to fetch gluster fd\n");
1211 #ifdef HAVE_GFAPI_VER_7_6
1212 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1214 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1216 END_PROFILE_BYTES(syscall_pwrite
);
1221 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1222 files_struct
*fsp
, off_t offset
, int whence
)
1225 glfs_fd_t
*glfd
= NULL
;
1227 START_PROFILE(syscall_lseek
);
1229 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1231 END_PROFILE(syscall_lseek
);
1232 DBG_ERR("Failed to fetch gluster fd\n");
1236 ret
= glfs_lseek(glfd
, offset
, whence
);
1237 END_PROFILE(syscall_lseek
);
1242 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1243 files_struct
*fromfsp
,
1244 const DATA_BLOB
*hdr
,
1245 off_t offset
, size_t n
)
1251 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1252 int fromfd
, files_struct
*tofsp
,
1253 off_t offset
, size_t n
)
1259 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1260 files_struct
*srcfsp
,
1261 const struct smb_filename
*smb_fname_src
,
1262 files_struct
*dstfsp
,
1263 const struct smb_filename
*smb_fname_dst
)
1267 #ifdef HAVE_GFAPI_VER_7_11
1268 glfs_fd_t
*src_pglfd
= NULL
;
1269 glfs_fd_t
*dst_pglfd
= NULL
;
1271 START_PROFILE(syscall_renameat
);
1273 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1274 if (src_pglfd
== NULL
) {
1275 END_PROFILE(syscall_renameat
);
1276 DBG_ERR("Failed to fetch gluster fd\n");
1280 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1281 if (dst_pglfd
== NULL
) {
1282 END_PROFILE(syscall_renameat
);
1283 DBG_ERR("Failed to fetch gluster fd\n");
1287 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1288 dst_pglfd
, smb_fname_dst
->base_name
);
1290 struct smb_filename
*full_fname_src
= NULL
;
1291 struct smb_filename
*full_fname_dst
= NULL
;
1293 START_PROFILE(syscall_renameat
);
1295 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1298 if (full_fname_src
== NULL
) {
1299 END_PROFILE(syscall_renameat
);
1304 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1307 if (full_fname_dst
== NULL
) {
1308 END_PROFILE(syscall_renameat
);
1309 TALLOC_FREE(full_fname_src
);
1313 ret
= glfs_rename(handle
->data
,
1314 full_fname_src
->base_name
,
1315 full_fname_dst
->base_name
);
1317 TALLOC_FREE(full_fname_src
);
1318 TALLOC_FREE(full_fname_dst
);
1321 END_PROFILE(syscall_renameat
);
1326 struct vfs_gluster_fsync_state
{
1330 struct vfs_aio_state vfs_aio_state
;
1331 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1334 static void vfs_gluster_fsync_do(void *private_data
);
1335 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1336 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1338 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1339 *handle
, TALLOC_CTX
*mem_ctx
,
1340 struct tevent_context
*ev
,
1343 struct tevent_req
*req
, *subreq
;
1344 struct vfs_gluster_fsync_state
*state
;
1346 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1348 DBG_ERR("Failed to fetch gluster fd\n");
1352 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1360 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1361 state
->profile_bytes
, 0);
1362 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1364 subreq
= pthreadpool_tevent_job_send(
1365 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1366 if (tevent_req_nomem(subreq
, req
)) {
1367 return tevent_req_post(req
, ev
);
1369 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1371 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1376 static void vfs_gluster_fsync_do(void *private_data
)
1378 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1379 private_data
, struct vfs_gluster_fsync_state
);
1380 struct timespec start_time
;
1381 struct timespec end_time
;
1383 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1385 PROFILE_TIMESTAMP(&start_time
);
1388 #ifdef HAVE_GFAPI_VER_7_6
1389 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1391 state
->ret
= glfs_fsync(state
->fd
);
1393 } while ((state
->ret
== -1) && (errno
== EINTR
));
1395 if (state
->ret
== -1) {
1396 state
->vfs_aio_state
.error
= errno
;
1399 PROFILE_TIMESTAMP(&end_time
);
1401 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1403 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1406 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1411 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1413 struct tevent_req
*req
= tevent_req_callback_data(
1414 subreq
, struct tevent_req
);
1415 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1416 req
, struct vfs_gluster_fsync_state
);
1419 ret
= pthreadpool_tevent_job_recv(subreq
);
1420 TALLOC_FREE(subreq
);
1421 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1422 talloc_set_destructor(state
, NULL
);
1424 if (ret
!= EAGAIN
) {
1425 tevent_req_error(req
, ret
);
1429 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1430 * means the lower level pthreadpool failed to create a new
1431 * thread. Fallback to sync processing in that case to allow
1432 * some progress for the client.
1434 vfs_gluster_fsync_do(state
);
1437 tevent_req_done(req
);
1440 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1441 struct vfs_aio_state
*vfs_aio_state
)
1443 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1444 req
, struct vfs_gluster_fsync_state
);
1446 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1450 *vfs_aio_state
= state
->vfs_aio_state
;
1454 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1455 struct smb_filename
*smb_fname
)
1460 START_PROFILE(syscall_stat
);
1461 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1463 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1465 if (ret
< 0 && errno
!= ENOENT
) {
1466 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1467 smb_fname
->base_name
, strerror(errno
)));
1469 END_PROFILE(syscall_stat
);
1474 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1475 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1479 glfs_fd_t
*glfd
= NULL
;
1481 START_PROFILE(syscall_fstat
);
1483 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1485 END_PROFILE(syscall_fstat
);
1486 DBG_ERR("Failed to fetch gluster fd\n");
1490 ret
= glfs_fstat(glfd
, &st
);
1492 smb_stat_ex_from_stat(sbuf
, &st
);
1495 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1496 fsp_get_io_fd(fsp
), strerror(errno
)));
1498 END_PROFILE(syscall_fstat
);
1503 static int vfs_gluster_fstatat(struct vfs_handle_struct
*handle
,
1504 const struct files_struct
*dirfsp
,
1505 const struct smb_filename
*smb_fname
,
1506 SMB_STRUCT_STAT
*sbuf
,
1512 #ifdef HAVE_GFAPI_VER_7_11
1513 glfs_fd_t
*pglfd
= NULL
;
1515 START_PROFILE(syscall_fstatat
);
1517 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1518 if (pglfd
== NULL
) {
1519 END_PROFILE(syscall_fstatat
);
1520 DBG_ERR("Failed to fetch gluster fd\n");
1524 ret
= glfs_fstatat(pglfd
, smb_fname
->base_name
, &st
, flags
);
1526 struct smb_filename
*full_fname
= NULL
;
1528 START_PROFILE(syscall_fstatat
);
1530 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1533 if (full_fname
== NULL
) {
1534 END_PROFILE(syscall_fstatat
);
1538 ret
= glfs_stat(handle
->data
, full_fname
->base_name
, &st
);
1540 TALLOC_FREE(full_fname
->base_name
);
1544 smb_stat_ex_from_stat(sbuf
, &st
);
1547 END_PROFILE(syscall_fstatat
);
1552 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1553 struct smb_filename
*smb_fname
)
1558 START_PROFILE(syscall_lstat
);
1559 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1561 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1563 if (ret
< 0 && errno
!= ENOENT
) {
1564 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1565 smb_fname
->base_name
, strerror(errno
)));
1567 END_PROFILE(syscall_lstat
);
1572 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1574 const SMB_STRUCT_STAT
*sbuf
)
1578 START_PROFILE(syscall_get_alloc_size
);
1579 ret
= sbuf
->st_ex_blocks
* 512;
1580 END_PROFILE(syscall_get_alloc_size
);
1585 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1586 struct files_struct
*dirfsp
,
1587 const struct smb_filename
*smb_fname
,
1592 #ifdef HAVE_GFAPI_VER_7_11
1593 glfs_fd_t
*pglfd
= NULL
;
1595 START_PROFILE(syscall_unlinkat
);
1597 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1598 if (pglfd
== NULL
) {
1599 END_PROFILE(syscall_unlinkat
);
1600 DBG_ERR("Failed to fetch gluster fd\n");
1604 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1606 struct smb_filename
*full_fname
= NULL
;
1608 START_PROFILE(syscall_unlinkat
);
1610 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1613 if (full_fname
== NULL
) {
1614 END_PROFILE(syscall_unlinkat
);
1618 if (flags
& AT_REMOVEDIR
) {
1619 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1621 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1624 TALLOC_FREE(full_fname
);
1627 END_PROFILE(syscall_unlinkat
);
1632 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1633 files_struct
*fsp
, mode_t mode
)
1636 glfs_fd_t
*glfd
= NULL
;
1638 START_PROFILE(syscall_fchmod
);
1640 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1642 END_PROFILE(syscall_fchmod
);
1643 DBG_ERR("Failed to fetch gluster fd\n");
1647 if (!fsp
->fsp_flags
.is_pathref
) {
1649 * We can use an io_fd to remove xattrs.
1651 ret
= glfs_fchmod(glfd
, mode
);
1654 * This is no longer a handle based call.
1656 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1658 END_PROFILE(syscall_fchmod
);
1663 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1664 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1667 glfs_fd_t
*glfd
= NULL
;
1669 START_PROFILE(syscall_fchown
);
1671 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1673 END_PROFILE(syscall_fchown
);
1674 DBG_ERR("Failed to fetch gluster fd\n");
1678 ret
= glfs_fchown(glfd
, uid
, gid
);
1679 END_PROFILE(syscall_fchown
);
1684 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1685 const struct smb_filename
*smb_fname
,
1691 START_PROFILE(syscall_lchown
);
1692 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1693 END_PROFILE(syscall_lchown
);
1698 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1699 const struct smb_filename
*smb_fname
)
1703 START_PROFILE(syscall_chdir
);
1704 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1705 END_PROFILE(syscall_chdir
);
1710 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1713 char cwd
[PATH_MAX
] = { '\0' };
1715 struct smb_filename
*smb_fname
= NULL
;
1717 START_PROFILE(syscall_getwd
);
1719 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1720 END_PROFILE(syscall_getwd
);
1725 smb_fname
= synthetic_smb_fname(ctx
,
1734 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1736 struct smb_file_time
*ft
)
1739 struct timespec times
[2];
1740 glfs_fd_t
*glfd
= NULL
;
1742 START_PROFILE(syscall_fntimes
);
1744 if (is_omit_timespec(&ft
->atime
)) {
1745 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1746 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1748 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1749 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1752 if (is_omit_timespec(&ft
->mtime
)) {
1753 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1754 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1756 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1757 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1760 if ((timespec_compare(×
[0],
1761 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1762 (timespec_compare(×
[1],
1763 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1764 END_PROFILE(syscall_fntimes
);
1768 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1770 END_PROFILE(syscall_fntimes
);
1771 DBG_ERR("Failed to fetch gluster fd\n");
1775 if (!fsp
->fsp_flags
.is_pathref
) {
1776 ret
= glfs_futimens(glfd
, times
);
1778 ret
= glfs_utimens(handle
->data
,
1779 fsp
->fsp_name
->base_name
,
1782 END_PROFILE(syscall_fntimes
);
1787 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1788 files_struct
*fsp
, off_t offset
)
1791 glfs_fd_t
*glfd
= NULL
;
1793 START_PROFILE(syscall_ftruncate
);
1795 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1797 END_PROFILE(syscall_ftruncate
);
1798 DBG_ERR("Failed to fetch gluster fd\n");
1802 #ifdef HAVE_GFAPI_VER_7_6
1803 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1805 ret
= glfs_ftruncate(glfd
, offset
);
1807 END_PROFILE(syscall_ftruncate
);
1812 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1813 struct files_struct
*fsp
,
1815 off_t offset
, off_t len
)
1818 #ifdef HAVE_GFAPI_VER_6
1819 glfs_fd_t
*glfd
= NULL
;
1820 int keep_size
, punch_hole
;
1822 START_PROFILE(syscall_fallocate
);
1824 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1826 END_PROFILE(syscall_fallocate
);
1827 DBG_ERR("Failed to fetch gluster fd\n");
1831 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1832 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1834 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1836 END_PROFILE(syscall_fallocate
);
1842 ret
= glfs_discard(glfd
, offset
, len
);
1844 DBG_DEBUG("glfs_discard failed: %s\n",
1849 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1850 END_PROFILE(syscall_fallocate
);
1858 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1860 const struct smb_filename
*smb_fname
)
1862 char *result
= NULL
;
1863 struct smb_filename
*result_fname
= NULL
;
1864 char *resolved_path
= NULL
;
1866 START_PROFILE(syscall_realpath
);
1868 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1869 if (resolved_path
== NULL
) {
1870 END_PROFILE(syscall_realpath
);
1875 result
= glfs_realpath(handle
->data
,
1876 smb_fname
->base_name
,
1878 if (result
!= NULL
) {
1879 result_fname
= synthetic_smb_fname(ctx
,
1887 SAFE_FREE(resolved_path
);
1888 END_PROFILE(syscall_realpath
);
1890 return result_fname
;
1893 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1894 files_struct
*fsp
, int op
, off_t offset
,
1895 off_t count
, int type
)
1897 struct flock flock
= { 0, };
1899 glfs_fd_t
*glfd
= NULL
;
1902 START_PROFILE(syscall_fcntl_lock
);
1904 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1906 DBG_ERR("Failed to fetch gluster fd\n");
1911 flock
.l_type
= type
;
1912 flock
.l_whence
= SEEK_SET
;
1913 flock
.l_start
= offset
;
1914 flock
.l_len
= count
;
1917 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1919 if (op
== F_GETLK
) {
1920 /* lock query, true if someone else has locked */
1922 (flock
.l_type
!= F_UNLCK
) &&
1923 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1939 END_PROFILE(syscall_fcntl_lock
);
1944 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1946 uint32_t share_access
,
1947 uint32_t access_mask
)
1953 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1954 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1957 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1958 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1960 if (cmd
== F_GETFL
) {
1962 } else if (cmd
== F_SETFL
) {
1963 va_list dup_cmd_arg
;
1966 va_copy(dup_cmd_arg
, cmd_arg
);
1967 opt
= va_arg(dup_cmd_arg
, int);
1968 va_end(dup_cmd_arg
);
1972 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1975 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1981 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1982 files_struct
*fsp
, int leasetype
)
1988 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1989 files_struct
*fsp
, off_t
*poffset
,
1990 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1992 struct flock flock
= { 0, };
1994 glfs_fd_t
*glfd
= NULL
;
1996 START_PROFILE(syscall_fcntl_getlock
);
1998 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2000 END_PROFILE(syscall_fcntl_getlock
);
2001 DBG_ERR("Failed to fetch gluster fd\n");
2005 flock
.l_type
= *ptype
;
2006 flock
.l_whence
= SEEK_SET
;
2007 flock
.l_start
= *poffset
;
2008 flock
.l_len
= *pcount
;
2011 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
2014 END_PROFILE(syscall_fcntl_getlock
);
2018 *ptype
= flock
.l_type
;
2019 *poffset
= flock
.l_start
;
2020 *pcount
= flock
.l_len
;
2021 *ppid
= flock
.l_pid
;
2022 END_PROFILE(syscall_fcntl_getlock
);
2027 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
2028 const struct smb_filename
*link_target
,
2029 struct files_struct
*dirfsp
,
2030 const struct smb_filename
*new_smb_fname
)
2034 #ifdef HAVE_GFAPI_VER_7_11
2035 glfs_fd_t
*pglfd
= NULL
;
2037 START_PROFILE(syscall_symlinkat
);
2039 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2040 if (pglfd
== NULL
) {
2041 END_PROFILE(syscall_symlinkat
);
2042 DBG_ERR("Failed to fetch gluster fd\n");
2046 ret
= glfs_symlinkat(link_target
->base_name
,
2048 new_smb_fname
->base_name
);
2050 struct smb_filename
*full_fname
= NULL
;
2052 START_PROFILE(syscall_symlinkat
);
2054 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2057 if (full_fname
== NULL
) {
2058 END_PROFILE(syscall_symlinkat
);
2062 ret
= glfs_symlink(handle
->data
,
2063 link_target
->base_name
,
2064 full_fname
->base_name
);
2066 TALLOC_FREE(full_fname
);
2069 END_PROFILE(syscall_symlinkat
);
2074 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2075 const struct files_struct
*dirfsp
,
2076 const struct smb_filename
*smb_fname
,
2082 #ifdef HAVE_GFAPI_VER_7_11
2083 glfs_fd_t
*pglfd
= NULL
;
2085 START_PROFILE(syscall_readlinkat
);
2087 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2088 if (pglfd
== NULL
) {
2089 END_PROFILE(syscall_readlinkat
);
2090 DBG_ERR("Failed to fetch gluster fd\n");
2094 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2096 struct smb_filename
*full_fname
= NULL
;
2098 START_PROFILE(syscall_readlinkat
);
2100 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2103 if (full_fname
== NULL
) {
2104 END_PROFILE(syscall_readlinkat
);
2108 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2110 TALLOC_FREE(full_fname
);
2113 END_PROFILE(syscall_readlinkat
);
2118 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2119 files_struct
*srcfsp
,
2120 const struct smb_filename
*old_smb_fname
,
2121 files_struct
*dstfsp
,
2122 const struct smb_filename
*new_smb_fname
,
2127 #ifdef HAVE_GFAPI_VER_7_11
2128 glfs_fd_t
*src_pglfd
= NULL
;
2129 glfs_fd_t
*dst_pglfd
= NULL
;
2131 START_PROFILE(syscall_linkat
);
2133 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
2134 if (src_pglfd
== NULL
) {
2135 END_PROFILE(syscall_linkat
);
2136 DBG_ERR("Failed to fetch gluster fd\n");
2140 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
2141 if (dst_pglfd
== NULL
) {
2142 END_PROFILE(syscall_linkat
);
2143 DBG_ERR("Failed to fetch gluster fd\n");
2147 ret
= glfs_linkat(src_pglfd
,
2148 old_smb_fname
->base_name
,
2150 new_smb_fname
->base_name
,
2153 struct smb_filename
*full_fname_old
= NULL
;
2154 struct smb_filename
*full_fname_new
= NULL
;
2156 START_PROFILE(syscall_linkat
);
2158 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2161 if (full_fname_old
== NULL
) {
2162 END_PROFILE(syscall_linkat
);
2166 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2169 if (full_fname_new
== NULL
) {
2170 END_PROFILE(syscall_linkat
);
2171 TALLOC_FREE(full_fname_old
);
2175 ret
= glfs_link(handle
->data
,
2176 full_fname_old
->base_name
,
2177 full_fname_new
->base_name
);
2179 TALLOC_FREE(full_fname_old
);
2180 TALLOC_FREE(full_fname_new
);
2183 END_PROFILE(syscall_linkat
);
2188 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2189 files_struct
*dirfsp
,
2190 const struct smb_filename
*smb_fname
,
2196 #ifdef HAVE_GFAPI_VER_7_11
2197 glfs_fd_t
*pglfd
= NULL
;
2199 START_PROFILE(syscall_mknodat
);
2201 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2202 if (pglfd
== NULL
) {
2203 END_PROFILE(syscall_mknodat
);
2204 DBG_ERR("Failed to fetch gluster fd\n");
2208 ret
= glfs_mknodat(pglfd
, smb_fname
->base_name
, mode
, dev
);
2210 struct smb_filename
*full_fname
= NULL
;
2212 START_PROFILE(syscall_mknodat
);
2214 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2217 if (full_fname
== NULL
) {
2218 END_PROFILE(syscall_mknodat
);
2222 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2224 TALLOC_FREE(full_fname
);
2227 END_PROFILE(syscall_mknodat
);
2232 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2233 struct files_struct
*fsp
,
2240 static NTSTATUS
vfs_gluster_get_real_filename_at(
2241 struct vfs_handle_struct
*handle
,
2242 struct files_struct
*dirfsp
,
2244 TALLOC_CTX
*mem_ctx
,
2248 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2249 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2251 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2252 return NT_STATUS_OBJECT_NAME_INVALID
;
2255 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2256 "glusterfs.get_real_filename:%s", name
);
2258 ret
= glfs_getxattr(handle
->data
,
2259 dirfsp
->fsp_name
->base_name
,
2262 GLUSTER_NAME_MAX
+ 1);
2264 if (errno
== ENOATTR
) {
2267 return map_nt_error_from_unix(errno
);
2270 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2271 if (found_name
[0] == NULL
) {
2272 return NT_STATUS_NO_MEMORY
;
2275 return NT_STATUS_OK
;
2278 static const char *vfs_gluster_connectpath(
2279 struct vfs_handle_struct
*handle
,
2280 const struct files_struct
*dirfsp
,
2281 const struct smb_filename
*smb_fname
)
2283 return handle
->conn
->connectpath
;
2288 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2289 files_struct
*fsp
, const char *name
,
2290 void *value
, size_t size
)
2292 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2294 DBG_ERR("Failed to fetch gluster fd\n");
2298 if (!fsp
->fsp_flags
.is_pathref
) {
2300 * We can use an io_fd to retrieve xattr value.
2302 return glfs_fgetxattr(glfd
, name
, value
, size
);
2306 * This is no longer a handle based call.
2308 return glfs_getxattr(handle
->data
,
2309 fsp
->fsp_name
->base_name
,
2315 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2316 files_struct
*fsp
, char *list
,
2319 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2321 DBG_ERR("Failed to fetch gluster fd\n");
2324 if (!fsp
->fsp_flags
.is_pathref
) {
2326 * We can use an io_fd to list xattrs.
2328 return glfs_flistxattr(glfd
, list
, size
);
2331 * This is no longer a handle based call.
2333 return glfs_listxattr(handle
->data
,
2334 fsp
->fsp_name
->base_name
,
2340 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2341 files_struct
*fsp
, const char *name
)
2343 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2345 DBG_ERR("Failed to fetch gluster fd\n");
2348 if (!fsp
->fsp_flags
.is_pathref
) {
2350 * We can use an io_fd to remove xattrs.
2352 return glfs_fremovexattr(glfd
, name
);
2355 * This is no longer a handle based call.
2357 return glfs_removexattr(handle
->data
,
2358 fsp
->fsp_name
->base_name
,
2363 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2364 files_struct
*fsp
, const char *name
,
2365 const void *value
, size_t size
, int flags
)
2367 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2369 DBG_ERR("Failed to fetch gluster fd\n");
2373 if (!fsp
->fsp_flags
.is_pathref
) {
2375 * We can use an io_fd to set xattrs.
2377 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2380 * This is no longer a handle based call.
2382 return glfs_setxattr(handle
->data
,
2383 fsp
->fsp_name
->base_name
,
2391 /* AIO Operations */
2393 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2399 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2400 struct files_struct
*dirfsp
,
2401 const struct smb_filename
*smb_fname
,
2402 const struct referral
*reflist
,
2403 size_t referral_count
)
2405 TALLOC_CTX
*frame
= talloc_stackframe();
2406 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2408 char *msdfs_link
= NULL
;
2409 #ifdef HAVE_GFAPI_VER_7_11
2410 glfs_fd_t
*pglfd
= NULL
;
2412 struct smb_filename
*full_fname
= NULL
;
2415 /* Form the msdfs_link contents */
2416 msdfs_link
= msdfs_link_string(frame
,
2419 if (msdfs_link
== NULL
) {
2423 #ifdef HAVE_GFAPI_VER_7_11
2424 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2425 if (pglfd
== NULL
) {
2426 DBG_ERR("Failed to fetch gluster fd\n");
2427 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2431 ret
= glfs_symlinkat(msdfs_link
, pglfd
, smb_fname
->base_name
);
2433 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2436 if (full_fname
== NULL
) {
2440 ret
= glfs_symlink(handle
->data
, msdfs_link
, full_fname
->base_name
);
2442 TALLOC_FREE(full_fname
);
2445 status
= NT_STATUS_OK
;
2447 status
= map_nt_error_from_unix(errno
);
2457 * Read and return the contents of a DFS redirect given a
2458 * pathname. A caller can pass in NULL for ppreflist and
2459 * preferral_count but still determine if this was a
2460 * DFS redirect point by getting NT_STATUS_OK back
2461 * without incurring the overhead of reading and parsing
2462 * the referral contents.
2465 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2466 TALLOC_CTX
*mem_ctx
,
2467 struct files_struct
*dirfsp
,
2468 struct smb_filename
*smb_fname
,
2469 struct referral
**ppreflist
,
2470 size_t *preferral_count
)
2472 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2474 char *link_target
= NULL
;
2477 #if defined(HAVE_BROKEN_READLINK)
2478 char link_target_buf
[PATH_MAX
];
2480 char link_target_buf
[7];
2483 struct smb_filename
*full_fname
= NULL
;
2485 #ifdef HAVE_GFAPI_VER_7_11
2486 glfs_fd_t
*pglfd
= NULL
;
2489 if (is_named_stream(smb_fname
)) {
2490 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2494 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2496 * We're only checking if this is a DFS
2497 * redirect. We don't need to return data.
2499 bufsize
= sizeof(link_target_buf
);
2500 link_target
= link_target_buf
;
2503 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2509 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2512 if (full_fname
== NULL
) {
2513 status
= NT_STATUS_NO_MEMORY
;
2517 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2519 status
= map_nt_error_from_unix(errno
);
2523 #ifdef HAVE_GFAPI_VER_7_11
2524 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2525 if (pglfd
== NULL
) {
2526 DBG_ERR("Failed to fetch gluster fd\n");
2527 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2530 referral_len
= glfs_readlinkat(pglfd
,
2531 smb_fname
->base_name
,
2535 referral_len
= glfs_readlink(handle
->data
,
2536 full_fname
->base_name
,
2540 if (referral_len
< 0) {
2541 if (errno
== EINVAL
) {
2542 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2543 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2545 status
= map_nt_error_from_unix(errno
);
2546 DBG_ERR("Error reading "
2547 "msdfs link %s: %s\n",
2548 full_fname
->base_name
,
2553 link_target
[referral_len
] = '\0';
2555 DBG_INFO("%s -> %s\n",
2556 full_fname
->base_name
,
2559 if (!strnequal(link_target
, "msdfs:", 6)) {
2560 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2564 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2565 /* Early return for checking if this is a DFS link. */
2566 TALLOC_FREE(full_fname
);
2567 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2568 return NT_STATUS_OK
;
2571 ok
= parse_msdfs_symlink(mem_ctx
,
2572 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2578 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2579 status
= NT_STATUS_OK
;
2581 status
= NT_STATUS_NO_MEMORY
;
2586 if (link_target
!= link_target_buf
) {
2587 TALLOC_FREE(link_target
);
2589 TALLOC_FREE(full_fname
);
2593 static struct vfs_fn_pointers glusterfs_fns
= {
2595 /* Disk Operations */
2597 .connect_fn
= vfs_gluster_connect
,
2598 .disconnect_fn
= vfs_gluster_disconnect
,
2599 .disk_free_fn
= vfs_gluster_disk_free
,
2600 .get_quota_fn
= vfs_gluster_get_quota
,
2601 .set_quota_fn
= vfs_gluster_set_quota
,
2602 .statvfs_fn
= vfs_gluster_statvfs
,
2603 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2605 .get_dfs_referrals_fn
= NULL
,
2607 /* Directory Operations */
2609 .fdopendir_fn
= vfs_gluster_fdopendir
,
2610 .readdir_fn
= vfs_gluster_readdir
,
2611 .seekdir_fn
= vfs_gluster_seekdir
,
2612 .telldir_fn
= vfs_gluster_telldir
,
2613 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2614 .mkdirat_fn
= vfs_gluster_mkdirat
,
2615 .closedir_fn
= vfs_gluster_closedir
,
2617 /* File Operations */
2619 .openat_fn
= vfs_gluster_openat
,
2620 .create_file_fn
= NULL
,
2621 .close_fn
= vfs_gluster_close
,
2622 .pread_fn
= vfs_gluster_pread
,
2623 .pread_send_fn
= vfs_gluster_pread_send
,
2624 .pread_recv_fn
= vfs_gluster_pread_recv
,
2625 .pwrite_fn
= vfs_gluster_pwrite
,
2626 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2627 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2628 .lseek_fn
= vfs_gluster_lseek
,
2629 .sendfile_fn
= vfs_gluster_sendfile
,
2630 .recvfile_fn
= vfs_gluster_recvfile
,
2631 .renameat_fn
= vfs_gluster_renameat
,
2632 .fsync_send_fn
= vfs_gluster_fsync_send
,
2633 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2635 .stat_fn
= vfs_gluster_stat
,
2636 .fstat_fn
= vfs_gluster_fstat
,
2637 .fstatat_fn
= vfs_gluster_fstatat
,
2638 .lstat_fn
= vfs_gluster_lstat
,
2639 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2640 .unlinkat_fn
= vfs_gluster_unlinkat
,
2642 .fchmod_fn
= vfs_gluster_fchmod
,
2643 .fchown_fn
= vfs_gluster_fchown
,
2644 .lchown_fn
= vfs_gluster_lchown
,
2645 .chdir_fn
= vfs_gluster_chdir
,
2646 .getwd_fn
= vfs_gluster_getwd
,
2647 .fntimes_fn
= vfs_gluster_fntimes
,
2648 .ftruncate_fn
= vfs_gluster_ftruncate
,
2649 .fallocate_fn
= vfs_gluster_fallocate
,
2650 .lock_fn
= vfs_gluster_lock
,
2651 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2652 .fcntl_fn
= vfs_gluster_fcntl
,
2653 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2654 .getlock_fn
= vfs_gluster_getlock
,
2655 .symlinkat_fn
= vfs_gluster_symlinkat
,
2656 .readlinkat_fn
= vfs_gluster_readlinkat
,
2657 .linkat_fn
= vfs_gluster_linkat
,
2658 .mknodat_fn
= vfs_gluster_mknodat
,
2659 .realpath_fn
= vfs_gluster_realpath
,
2660 .fchflags_fn
= vfs_gluster_fchflags
,
2661 .file_id_create_fn
= NULL
,
2662 .fstreaminfo_fn
= NULL
,
2663 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2664 .connectpath_fn
= vfs_gluster_connectpath
,
2665 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2666 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2668 .brl_lock_windows_fn
= NULL
,
2669 .brl_unlock_windows_fn
= NULL
,
2670 .strict_lock_check_fn
= NULL
,
2671 .translate_name_fn
= NULL
,
2674 /* NT ACL Operations */
2675 .fget_nt_acl_fn
= NULL
,
2676 .fset_nt_acl_fn
= NULL
,
2677 .audit_file_fn
= NULL
,
2679 /* Posix ACL Operations */
2680 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2681 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2682 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2683 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2686 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2687 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2688 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2689 .flistxattr_fn
= vfs_gluster_flistxattr
,
2690 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2691 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2693 /* AIO Operations */
2694 .aio_force_fn
= vfs_gluster_aio_force
,
2696 /* Durable handle Operations */
2697 .durable_cookie_fn
= NULL
,
2698 .durable_disconnect_fn
= NULL
,
2699 .durable_reconnect_fn
= NULL
,
2703 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2705 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2706 "glusterfs", &glusterfs_fns
);