2 Unix SMB/CIFS implementation.
4 Wrap GlusterFS GFAPI calls in vfs functions.
6 Copyright (c) 2013 Anand Avati <avati@redhat.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @file vfs_glusterfs.c
24 * @author Anand Avati <avati@redhat.com>
26 * @brief Samba VFS module for glusterfs
29 * - sendfile/recvfile support
31 * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
32 * This is a "bottom" vfs module (not something to be stacked on top of
33 * another module), and translates (most) calls to the closest actions
34 * available in libgfapi.
39 #include "smbd/smbd.h"
41 #include <glusterfs/api/glfs.h>
42 #include "lib/util/dlinklist.h"
43 #include "lib/util/tevent_unix.h"
44 #include "smbd/globals.h"
45 #include "lib/util/sys_rw.h"
46 #include "smbprofile.h"
47 #include "modules/posixacl_xattr.h"
48 #include "lib/pthreadpool/pthreadpool_tevent.h"
50 #define DEFAULT_VOLFILE_SERVER "localhost"
51 #define GLUSTER_NAME_MAX 255
54 * Helper to convert struct stat to struct stat_ex.
56 static void smb_stat_ex_from_stat(struct stat_ex
*dst
, const struct stat
*src
)
60 dst
->st_ex_dev
= src
->st_dev
;
61 dst
->st_ex_ino
= src
->st_ino
;
62 dst
->st_ex_mode
= src
->st_mode
;
63 dst
->st_ex_nlink
= src
->st_nlink
;
64 dst
->st_ex_uid
= src
->st_uid
;
65 dst
->st_ex_gid
= src
->st_gid
;
66 dst
->st_ex_rdev
= src
->st_rdev
;
67 dst
->st_ex_size
= src
->st_size
;
68 dst
->st_ex_atime
.tv_sec
= src
->st_atime
;
69 dst
->st_ex_mtime
.tv_sec
= src
->st_mtime
;
70 dst
->st_ex_ctime
.tv_sec
= src
->st_ctime
;
71 dst
->st_ex_btime
.tv_sec
= src
->st_mtime
;
72 dst
->st_ex_blksize
= src
->st_blksize
;
73 dst
->st_ex_blocks
= src
->st_blocks
;
75 dst
->st_ex_atime
.tv_nsec
= src
->st_atime_nsec
;
76 dst
->st_ex_mtime
.tv_nsec
= src
->st_mtime_nsec
;
77 dst
->st_ex_ctime
.tv_nsec
= src
->st_ctime_nsec
;
78 dst
->st_ex_btime
.tv_nsec
= src
->st_mtime_nsec
;
82 /* pre-opened glfs_t */
84 static struct glfs_preopened
{
89 struct glfs_preopened
*next
, *prev
;
93 static int glfs_set_preopened(const char *volume
, const char *connectpath
, glfs_t
*fs
)
95 struct glfs_preopened
*entry
= NULL
;
97 entry
= talloc_zero(NULL
, struct glfs_preopened
);
103 entry
->volume
= talloc_strdup(entry
, volume
);
104 if (!entry
->volume
) {
110 entry
->connectpath
= talloc_strdup(entry
, connectpath
);
111 if (entry
->connectpath
== NULL
) {
120 DLIST_ADD(glfs_preopened
, entry
);
125 static glfs_t
*glfs_find_preopened(const char *volume
, const char *connectpath
)
127 struct glfs_preopened
*entry
= NULL
;
129 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
130 if (strcmp(entry
->volume
, volume
) == 0 &&
131 strcmp(entry
->connectpath
, connectpath
) == 0)
141 static void glfs_clear_preopened(glfs_t
*fs
)
143 struct glfs_preopened
*entry
= NULL
;
145 for (entry
= glfs_preopened
; entry
; entry
= entry
->next
) {
146 if (entry
->fs
== fs
) {
150 DLIST_REMOVE(glfs_preopened
, entry
);
152 glfs_fini(entry
->fs
);
158 static int vfs_gluster_set_volfile_servers(glfs_t
*fs
,
159 const char *volfile_servers
)
162 size_t server_count
= 0;
163 size_t server_success
= 0;
165 TALLOC_CTX
*frame
= talloc_stackframe();
167 DBG_INFO("servers list %s\n", volfile_servers
);
169 while (next_token_talloc(frame
, &volfile_servers
, &server
, " \t")) {
170 char *transport
= NULL
;
175 DBG_INFO("server %zu %s\n", server_count
, server
);
177 /* Determine the transport type */
178 if (strncmp(server
, "unix+", 5) == 0) {
180 transport
= talloc_strdup(frame
, "unix");
185 host
= talloc_strdup(frame
, server
+ 5);
192 char *port_index
= NULL
;
194 if (strncmp(server
, "tcp+", 4) == 0) {
198 /* IPv6 is enclosed in []
199 * ':' before ']' is part of IPv6
200 * ':' after ']' indicates port
203 if (server
[0] == '[') {
205 p
= index(server
, ']');
214 port_index
= index(p
, ':');
216 if (port_index
== NULL
) {
219 port
= atoi(port_index
+ 1);
220 port_index
[0] = '\0';
222 transport
= talloc_strdup(frame
, "tcp");
227 host
= talloc_strdup(frame
, server
);
234 DBG_INFO("Calling set volfile server with params "
235 "transport=%s, host=%s, port=%d\n", transport
,
238 ret
= glfs_set_volfile_server(fs
, transport
, host
, port
);
240 DBG_WARNING("Failed to set volfile_server "
241 "transport=%s, host=%s, port=%d (%s)\n",
242 transport
, host
, port
, strerror(errno
));
249 if (server_count
== 0) {
251 } else if (server_success
< server_count
) {
252 DBG_WARNING("Failed to set %zu out of %zu servers parsed\n",
253 server_count
- server_success
, server_count
);
261 /* Disk Operations */
263 static int check_for_write_behind_translator(TALLOC_CTX
*mem_ctx
,
272 bool write_behind_present
= false;
276 ret
= glfs_get_volfile(fs
, NULL
, 0);
278 DBG_ERR("%s: Failed to get volfile for "
279 "volume (%s): No volfile\n",
285 DBG_ERR("%s: Invalid return %d for glfs_get_volfile for "
286 "volume (%s): No volfile\n",
295 buf
= talloc_zero_array(mem_ctx
, char, newlen
);
300 ret
= glfs_get_volfile(fs
, buf
, newlen
);
303 DBG_ERR("%s: Failed to get volfile for volume (%s)\n",
304 volume
, strerror(errno
));
308 option
= talloc_asprintf(mem_ctx
, "volume %s-write-behind", volume
);
309 if (option
== NULL
) {
315 * file_lines_parse() plays horrible tricks with
316 * the passed-in talloc pointers and the hierarcy
317 * which makes freeing hard to get right.
319 * As we know mem_ctx is freed by the caller, after
320 * this point don't free on exit and let the caller
321 * handle it. This violates good Samba coding practice
322 * but we know we're not leaking here.
325 lines
= file_lines_parse(buf
,
329 if (lines
== NULL
|| numlines
<= 0) {
332 /* On success, buf is now a talloc child of lines !! */
334 for (i
=0; i
< numlines
; i
++) {
335 if (strequal(lines
[i
], option
)) {
336 write_behind_present
= true;
341 if (write_behind_present
) {
342 DBG_ERR("Write behind translator is enabled for "
343 "volume (%s), refusing to connect! "
344 "Please turn off the write behind translator by calling "
345 "'gluster volume set %s performance.write-behind off' "
346 "on the commandline. "
347 "Check the vfs_glusterfs(8) manpage for "
348 "further details.\n",
356 static int vfs_gluster_connect(struct vfs_handle_struct
*handle
,
360 const struct loadparm_substitution
*lp_sub
=
361 loadparm_s3_global_substitution();
362 const char *volfile_servers
;
369 bool write_behind_pass_through_set
= false;
371 tmp_ctx
= talloc_new(NULL
);
372 if (tmp_ctx
== NULL
) {
376 logfile
= lp_parm_substituted_string(tmp_ctx
,
383 loglevel
= lp_parm_int(SNUM(handle
->conn
), "glusterfs", "loglevel", -1);
385 volfile_servers
= lp_parm_substituted_string(tmp_ctx
,
391 if (volfile_servers
== NULL
) {
392 volfile_servers
= DEFAULT_VOLFILE_SERVER
;
395 volume
= lp_parm_const_string(SNUM(handle
->conn
), "glusterfs", "volume",
397 if (volume
== NULL
) {
401 fs
= glfs_find_preopened(volume
, handle
->conn
->connectpath
);
406 fs
= glfs_new(volume
);
412 ret
= vfs_gluster_set_volfile_servers(fs
, volfile_servers
);
414 DBG_ERR("Failed to set volfile_servers from list %s\n",
419 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-posix-acl",
422 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
426 ret
= glfs_set_xlator_option(fs
, "*-md-cache", "cache-selinux",
429 DEBUG(0, ("%s: Failed to set xlator options\n", volume
));
433 ret
= glfs_set_xlator_option(fs
, "*-snapview-client",
434 "snapdir-entry-path",
435 handle
->conn
->connectpath
);
437 DEBUG(0, ("%s: Failed to set xlator option:"
438 " snapdir-entry-path\n", volume
));
442 #ifdef HAVE_GFAPI_VER_7_9
443 ret
= glfs_set_xlator_option(fs
, "*-write-behind", "pass-through",
446 DBG_ERR("%s: Failed to set xlator option: pass-through\n",
450 write_behind_pass_through_set
= true;
453 ret
= glfs_set_logging(fs
, logfile
, loglevel
);
455 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
456 volume
, logfile
, loglevel
));
462 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
463 volume
, strerror(errno
)));
467 if (!write_behind_pass_through_set
) {
468 ret
= check_for_write_behind_translator(tmp_ctx
, fs
, volume
);
474 ret
= glfs_set_preopened(volume
, handle
->conn
->connectpath
, fs
);
476 DEBUG(0, ("%s: Failed to register volume (%s)\n",
477 volume
, strerror(errno
)));
482 * The shadow_copy2 module will fail to export subdirectories
483 * of a gluster volume unless we specify the mount point,
484 * because the detection fails if the file system is not
486 * https://bugzilla.samba.org/show_bug.cgi?id=13091
488 lp_do_parameter(SNUM(handle
->conn
), "shadow:mountpoint", "/");
491 * Unless we have an async implementation of getxattrat turn this off.
493 lp_do_parameter(SNUM(handle
->conn
), "smbd async dosmode", "false");
500 DBG_ERR("%s: Initialized volume from servers %s\n",
501 volume
, volfile_servers
);
504 talloc_free(tmp_ctx
);
508 static void vfs_gluster_disconnect(struct vfs_handle_struct
*handle
)
514 glfs_clear_preopened(fs
);
517 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct
*handle
,
518 const struct smb_filename
*smb_fname
,
523 struct statvfs statvfs
= { 0, };
526 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
531 if (bsize_p
!= NULL
) {
532 *bsize_p
= (uint64_t)statvfs
.f_bsize
; /* Block size */
534 if (dfree_p
!= NULL
) {
535 *dfree_p
= (uint64_t)statvfs
.f_bavail
; /* Available Block units */
537 if (dsize_p
!= NULL
) {
538 *dsize_p
= (uint64_t)statvfs
.f_blocks
; /* Total Block units */
541 return (uint64_t)statvfs
.f_bavail
;
544 static int vfs_gluster_get_quota(struct vfs_handle_struct
*handle
,
545 const struct smb_filename
*smb_fname
,
546 enum SMB_QUOTA_TYPE qtype
,
555 vfs_gluster_set_quota(struct vfs_handle_struct
*handle
,
556 enum SMB_QUOTA_TYPE qtype
, unid_t id
, SMB_DISK_QUOTA
*qt
)
562 static int vfs_gluster_statvfs(struct vfs_handle_struct
*handle
,
563 const struct smb_filename
*smb_fname
,
564 struct vfs_statvfs_struct
*vfs_statvfs
)
566 struct statvfs statvfs
= { 0, };
569 ret
= glfs_statvfs(handle
->data
, smb_fname
->base_name
, &statvfs
);
571 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
572 smb_fname
->base_name
, strerror(errno
)));
576 ZERO_STRUCTP(vfs_statvfs
);
578 vfs_statvfs
->OptimalTransferSize
= statvfs
.f_frsize
;
579 vfs_statvfs
->BlockSize
= statvfs
.f_bsize
;
580 vfs_statvfs
->TotalBlocks
= statvfs
.f_blocks
;
581 vfs_statvfs
->BlocksAvail
= statvfs
.f_bfree
;
582 vfs_statvfs
->UserBlocksAvail
= statvfs
.f_bavail
;
583 vfs_statvfs
->TotalFileNodes
= statvfs
.f_files
;
584 vfs_statvfs
->FreeFileNodes
= statvfs
.f_ffree
;
585 vfs_statvfs
->FsIdentifier
= statvfs
.f_fsid
;
586 vfs_statvfs
->FsCapabilities
=
587 FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
592 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct
*handle
,
593 enum timestamp_set_resolution
*p_ts_res
)
595 uint32_t caps
= FILE_CASE_SENSITIVE_SEARCH
| FILE_CASE_PRESERVED_NAMES
;
597 #ifdef HAVE_GFAPI_VER_6
598 caps
|= FILE_SUPPORTS_SPARSE_FILES
;
601 #ifdef STAT_HAVE_NSEC
602 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
608 static glfs_fd_t
*vfs_gluster_fetch_glfd(struct vfs_handle_struct
*handle
,
609 const files_struct
*fsp
)
611 glfs_fd_t
**glfd
= (glfs_fd_t
**)VFS_FETCH_FSP_EXTENSION(handle
, fsp
);
613 DBG_INFO("Failed to fetch fsp extension\n");
617 DBG_INFO("Empty glfs_fd_t pointer\n");
624 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct
*handle
,
625 files_struct
*fsp
, const char *mask
,
628 glfs_fd_t
*glfd
= NULL
;
630 glfd
= glfs_opendir(handle
->data
, fsp
->fsp_name
->base_name
);
638 static int vfs_gluster_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
642 START_PROFILE(syscall_closedir
);
643 ret
= glfs_closedir((void *)dirp
);
644 END_PROFILE(syscall_closedir
);
649 static struct dirent
*vfs_gluster_readdir(struct vfs_handle_struct
*handle
,
650 struct files_struct
*dirfsp
,
652 SMB_STRUCT_STAT
*sbuf
)
654 static char direntbuf
[512];
657 struct dirent
*dirent
= 0;
659 START_PROFILE(syscall_readdir
);
661 ret
= glfs_readdirplus_r((void *)dirp
, &stat
, (void *)direntbuf
,
664 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
667 if ((ret
< 0) || (dirent
== NULL
)) {
668 END_PROFILE(syscall_readdir
);
673 SET_STAT_INVALID(*sbuf
);
674 if (!S_ISLNK(stat
.st_mode
)) {
675 smb_stat_ex_from_stat(sbuf
, &stat
);
679 END_PROFILE(syscall_readdir
);
683 static long vfs_gluster_telldir(struct vfs_handle_struct
*handle
, DIR *dirp
)
687 START_PROFILE(syscall_telldir
);
688 ret
= glfs_telldir((void *)dirp
);
689 END_PROFILE(syscall_telldir
);
694 static void vfs_gluster_seekdir(struct vfs_handle_struct
*handle
, DIR *dirp
,
697 START_PROFILE(syscall_seekdir
);
698 glfs_seekdir((void *)dirp
, offset
);
699 END_PROFILE(syscall_seekdir
);
702 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
704 START_PROFILE(syscall_rewinddir
);
705 glfs_seekdir((void *)dirp
, 0);
706 END_PROFILE(syscall_rewinddir
);
709 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
710 struct files_struct
*dirfsp
,
711 const struct smb_filename
*smb_fname
,
716 #ifdef HAVE_GFAPI_VER_7_11
717 glfs_fd_t
*pglfd
= NULL
;
719 START_PROFILE(syscall_mkdirat
);
721 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
723 END_PROFILE(syscall_mkdirat
);
724 DBG_ERR("Failed to fetch gluster fd\n");
728 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
730 struct smb_filename
*full_fname
= NULL
;
732 START_PROFILE(syscall_mkdirat
);
734 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
737 if (full_fname
== NULL
) {
738 END_PROFILE(syscall_mkdirat
);
742 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
744 TALLOC_FREE(full_fname
);
747 END_PROFILE(syscall_mkdirat
);
752 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
753 const struct files_struct
*dirfsp
,
754 const struct smb_filename
*smb_fname
,
756 const struct vfs_open_how
*how
)
758 int flags
= how
->flags
;
759 struct smb_filename
*full_fname
= NULL
;
760 bool have_opath
= false;
761 bool became_root
= false;
763 glfs_fd_t
*pglfd
= NULL
;
766 START_PROFILE(syscall_openat
);
768 if (how
->resolve
!= 0) {
769 END_PROFILE(syscall_openat
);
774 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
776 END_PROFILE(syscall_openat
);
783 if (fsp
->fsp_flags
.is_pathref
) {
788 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
791 if (full_fname
== NULL
) {
792 END_PROFILE(syscall_openat
);
796 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
801 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
802 #ifdef HAVE_GFAPI_VER_7_11
804 * Fetch Gluster fd for parent directory using dirfsp
805 * before calling glfs_openat();
807 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
809 END_PROFILE(syscall_openat
);
810 DBG_ERR("Failed to fetch gluster fd\n");
814 glfd
= glfs_openat(pglfd
,
815 smb_fname
->base_name
,
820 * Replace smb_fname with full_path constructed above.
822 smb_fname
= full_fname
;
828 * smb_fname can either be a full_path or the same one
829 * as received from the caller. In the latter case we
830 * are operating at current working directory.
832 if (flags
& O_CREAT
) {
833 glfd
= glfs_creat(handle
->data
,
834 smb_fname
->base_name
,
838 glfd
= glfs_open(handle
->data
,
839 smb_fname
->base_name
,
848 TALLOC_FREE(full_fname
);
850 fsp
->fsp_flags
.have_proc_fds
= false;
853 END_PROFILE(syscall_openat
);
854 /* no extension destroy_fn, so no need to save errno */
855 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
861 END_PROFILE(syscall_openat
);
862 /* An arbitrary value for error reporting, so you know its us. */
866 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
870 glfs_fd_t
*glfd
= NULL
;
872 START_PROFILE(syscall_close
);
874 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
876 END_PROFILE(syscall_close
);
877 DBG_ERR("Failed to fetch gluster fd\n");
881 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
883 ret
= glfs_close(glfd
);
884 END_PROFILE(syscall_close
);
889 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
890 files_struct
*fsp
, void *data
, size_t n
,
894 glfs_fd_t
*glfd
= NULL
;
896 START_PROFILE_BYTES(syscall_pread
, n
);
898 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
900 END_PROFILE_BYTES(syscall_pread
);
901 DBG_ERR("Failed to fetch gluster fd\n");
905 #ifdef HAVE_GFAPI_VER_7_6
906 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
908 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
910 END_PROFILE_BYTES(syscall_pread
);
915 struct vfs_gluster_pread_state
{
922 struct vfs_aio_state vfs_aio_state
;
923 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
926 static void vfs_gluster_pread_do(void *private_data
);
927 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
928 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
930 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
931 *handle
, TALLOC_CTX
*mem_ctx
,
932 struct tevent_context
*ev
,
934 void *data
, size_t n
,
937 struct vfs_gluster_pread_state
*state
;
938 struct tevent_req
*req
, *subreq
;
940 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
942 DBG_ERR("Failed to fetch gluster fd\n");
946 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
955 state
->offset
= offset
;
957 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
958 state
->profile_bytes
, n
);
959 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
961 subreq
= pthreadpool_tevent_job_send(
962 state
, ev
, handle
->conn
->sconn
->pool
,
963 vfs_gluster_pread_do
, state
);
964 if (tevent_req_nomem(subreq
, req
)) {
965 return tevent_req_post(req
, ev
);
967 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
969 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
974 static void vfs_gluster_pread_do(void *private_data
)
976 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
977 private_data
, struct vfs_gluster_pread_state
);
978 struct timespec start_time
;
979 struct timespec end_time
;
981 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
983 PROFILE_TIMESTAMP(&start_time
);
986 #ifdef HAVE_GFAPI_VER_7_6
987 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
988 state
->offset
, 0, NULL
);
990 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
993 } while ((state
->ret
== -1) && (errno
== EINTR
));
995 if (state
->ret
== -1) {
996 state
->vfs_aio_state
.error
= errno
;
999 PROFILE_TIMESTAMP(&end_time
);
1001 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1003 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1006 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
1011 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
1013 struct tevent_req
*req
= tevent_req_callback_data(
1014 subreq
, struct tevent_req
);
1015 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1016 req
, struct vfs_gluster_pread_state
);
1019 ret
= pthreadpool_tevent_job_recv(subreq
);
1020 TALLOC_FREE(subreq
);
1021 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1022 talloc_set_destructor(state
, NULL
);
1024 if (ret
!= EAGAIN
) {
1025 tevent_req_error(req
, ret
);
1029 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1030 * means the lower level pthreadpool failed to create a new
1031 * thread. Fallback to sync processing in that case to allow
1032 * some progress for the client.
1034 vfs_gluster_pread_do(state
);
1037 tevent_req_done(req
);
1040 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1041 struct vfs_aio_state
*vfs_aio_state
)
1043 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1044 req
, struct vfs_gluster_pread_state
);
1046 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1050 *vfs_aio_state
= state
->vfs_aio_state
;
1054 struct vfs_gluster_pwrite_state
{
1061 struct vfs_aio_state vfs_aio_state
;
1062 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1065 static void vfs_gluster_pwrite_do(void *private_data
);
1066 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1067 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1069 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1070 *handle
, TALLOC_CTX
*mem_ctx
,
1071 struct tevent_context
*ev
,
1073 const void *data
, size_t n
,
1076 struct tevent_req
*req
, *subreq
;
1077 struct vfs_gluster_pwrite_state
*state
;
1079 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1081 DBG_ERR("Failed to fetch gluster fd\n");
1085 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1094 state
->offset
= offset
;
1096 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1097 state
->profile_bytes
, n
);
1098 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1100 subreq
= pthreadpool_tevent_job_send(
1101 state
, ev
, handle
->conn
->sconn
->pool
,
1102 vfs_gluster_pwrite_do
, state
);
1103 if (tevent_req_nomem(subreq
, req
)) {
1104 return tevent_req_post(req
, ev
);
1106 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1108 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1113 static void vfs_gluster_pwrite_do(void *private_data
)
1115 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1116 private_data
, struct vfs_gluster_pwrite_state
);
1117 struct timespec start_time
;
1118 struct timespec end_time
;
1120 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1122 PROFILE_TIMESTAMP(&start_time
);
1125 #ifdef HAVE_GFAPI_VER_7_6
1126 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1127 state
->offset
, 0, NULL
, NULL
);
1129 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1132 } while ((state
->ret
== -1) && (errno
== EINTR
));
1134 if (state
->ret
== -1) {
1135 state
->vfs_aio_state
.error
= errno
;
1138 PROFILE_TIMESTAMP(&end_time
);
1140 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1142 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1145 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1150 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1152 struct tevent_req
*req
= tevent_req_callback_data(
1153 subreq
, struct tevent_req
);
1154 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1155 req
, struct vfs_gluster_pwrite_state
);
1158 ret
= pthreadpool_tevent_job_recv(subreq
);
1159 TALLOC_FREE(subreq
);
1160 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1161 talloc_set_destructor(state
, NULL
);
1163 if (ret
!= EAGAIN
) {
1164 tevent_req_error(req
, ret
);
1168 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1169 * means the lower level pthreadpool failed to create a new
1170 * thread. Fallback to sync processing in that case to allow
1171 * some progress for the client.
1173 vfs_gluster_pwrite_do(state
);
1176 tevent_req_done(req
);
1179 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1180 struct vfs_aio_state
*vfs_aio_state
)
1182 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1183 req
, struct vfs_gluster_pwrite_state
);
1185 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1189 *vfs_aio_state
= state
->vfs_aio_state
;
1194 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1195 files_struct
*fsp
, const void *data
,
1196 size_t n
, off_t offset
)
1199 glfs_fd_t
*glfd
= NULL
;
1201 START_PROFILE_BYTES(syscall_pwrite
, n
);
1203 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1205 END_PROFILE_BYTES(syscall_pwrite
);
1206 DBG_ERR("Failed to fetch gluster fd\n");
1210 #ifdef HAVE_GFAPI_VER_7_6
1211 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1213 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1215 END_PROFILE_BYTES(syscall_pwrite
);
1220 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1221 files_struct
*fsp
, off_t offset
, int whence
)
1224 glfs_fd_t
*glfd
= NULL
;
1226 START_PROFILE(syscall_lseek
);
1228 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1230 END_PROFILE(syscall_lseek
);
1231 DBG_ERR("Failed to fetch gluster fd\n");
1235 ret
= glfs_lseek(glfd
, offset
, whence
);
1236 END_PROFILE(syscall_lseek
);
1241 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1242 files_struct
*fromfsp
,
1243 const DATA_BLOB
*hdr
,
1244 off_t offset
, size_t n
)
1250 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1251 int fromfd
, files_struct
*tofsp
,
1252 off_t offset
, size_t n
)
1258 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1259 files_struct
*srcfsp
,
1260 const struct smb_filename
*smb_fname_src
,
1261 files_struct
*dstfsp
,
1262 const struct smb_filename
*smb_fname_dst
)
1266 #ifdef HAVE_GFAPI_VER_7_11
1267 glfs_fd_t
*src_pglfd
= NULL
;
1268 glfs_fd_t
*dst_pglfd
= NULL
;
1270 START_PROFILE(syscall_renameat
);
1272 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1273 if (src_pglfd
== NULL
) {
1274 END_PROFILE(syscall_renameat
);
1275 DBG_ERR("Failed to fetch gluster fd\n");
1279 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1280 if (dst_pglfd
== NULL
) {
1281 END_PROFILE(syscall_renameat
);
1282 DBG_ERR("Failed to fetch gluster fd\n");
1286 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1287 dst_pglfd
, smb_fname_dst
->base_name
);
1289 struct smb_filename
*full_fname_src
= NULL
;
1290 struct smb_filename
*full_fname_dst
= NULL
;
1292 START_PROFILE(syscall_renameat
);
1294 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1297 if (full_fname_src
== NULL
) {
1298 END_PROFILE(syscall_renameat
);
1303 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1306 if (full_fname_dst
== NULL
) {
1307 END_PROFILE(syscall_renameat
);
1308 TALLOC_FREE(full_fname_src
);
1312 ret
= glfs_rename(handle
->data
,
1313 full_fname_src
->base_name
,
1314 full_fname_dst
->base_name
);
1316 TALLOC_FREE(full_fname_src
);
1317 TALLOC_FREE(full_fname_dst
);
1320 END_PROFILE(syscall_renameat
);
1325 struct vfs_gluster_fsync_state
{
1329 struct vfs_aio_state vfs_aio_state
;
1330 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1333 static void vfs_gluster_fsync_do(void *private_data
);
1334 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1335 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1337 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1338 *handle
, TALLOC_CTX
*mem_ctx
,
1339 struct tevent_context
*ev
,
1342 struct tevent_req
*req
, *subreq
;
1343 struct vfs_gluster_fsync_state
*state
;
1345 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1347 DBG_ERR("Failed to fetch gluster fd\n");
1351 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1359 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1360 state
->profile_bytes
, 0);
1361 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1363 subreq
= pthreadpool_tevent_job_send(
1364 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1365 if (tevent_req_nomem(subreq
, req
)) {
1366 return tevent_req_post(req
, ev
);
1368 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1370 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1375 static void vfs_gluster_fsync_do(void *private_data
)
1377 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1378 private_data
, struct vfs_gluster_fsync_state
);
1379 struct timespec start_time
;
1380 struct timespec end_time
;
1382 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1384 PROFILE_TIMESTAMP(&start_time
);
1387 #ifdef HAVE_GFAPI_VER_7_6
1388 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1390 state
->ret
= glfs_fsync(state
->fd
);
1392 } while ((state
->ret
== -1) && (errno
== EINTR
));
1394 if (state
->ret
== -1) {
1395 state
->vfs_aio_state
.error
= errno
;
1398 PROFILE_TIMESTAMP(&end_time
);
1400 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1402 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1405 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1410 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1412 struct tevent_req
*req
= tevent_req_callback_data(
1413 subreq
, struct tevent_req
);
1414 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1415 req
, struct vfs_gluster_fsync_state
);
1418 ret
= pthreadpool_tevent_job_recv(subreq
);
1419 TALLOC_FREE(subreq
);
1420 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1421 talloc_set_destructor(state
, NULL
);
1423 if (ret
!= EAGAIN
) {
1424 tevent_req_error(req
, ret
);
1428 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1429 * means the lower level pthreadpool failed to create a new
1430 * thread. Fallback to sync processing in that case to allow
1431 * some progress for the client.
1433 vfs_gluster_fsync_do(state
);
1436 tevent_req_done(req
);
1439 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1440 struct vfs_aio_state
*vfs_aio_state
)
1442 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1443 req
, struct vfs_gluster_fsync_state
);
1445 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1449 *vfs_aio_state
= state
->vfs_aio_state
;
1453 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1454 struct smb_filename
*smb_fname
)
1459 START_PROFILE(syscall_stat
);
1460 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1462 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1464 if (ret
< 0 && errno
!= ENOENT
) {
1465 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1466 smb_fname
->base_name
, strerror(errno
)));
1468 END_PROFILE(syscall_stat
);
1473 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1474 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1478 glfs_fd_t
*glfd
= NULL
;
1480 START_PROFILE(syscall_fstat
);
1482 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1484 END_PROFILE(syscall_fstat
);
1485 DBG_ERR("Failed to fetch gluster fd\n");
1489 ret
= glfs_fstat(glfd
, &st
);
1491 smb_stat_ex_from_stat(sbuf
, &st
);
1494 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1495 fsp_get_io_fd(fsp
), strerror(errno
)));
1497 END_PROFILE(syscall_fstat
);
1502 static int vfs_gluster_fstatat(struct vfs_handle_struct
*handle
,
1503 const struct files_struct
*dirfsp
,
1504 const struct smb_filename
*smb_fname
,
1505 SMB_STRUCT_STAT
*sbuf
,
1511 #ifdef HAVE_GFAPI_VER_7_11
1512 glfs_fd_t
*pglfd
= NULL
;
1514 START_PROFILE(syscall_fstatat
);
1516 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1517 if (pglfd
== NULL
) {
1518 END_PROFILE(syscall_fstatat
);
1519 DBG_ERR("Failed to fetch gluster fd\n");
1523 ret
= glfs_fstatat(pglfd
, smb_fname
->base_name
, &st
, flags
);
1525 struct smb_filename
*full_fname
= NULL
;
1527 START_PROFILE(syscall_fstatat
);
1529 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1532 if (full_fname
== NULL
) {
1533 END_PROFILE(syscall_fstatat
);
1537 ret
= glfs_stat(handle
->data
, full_fname
->base_name
, &st
);
1539 TALLOC_FREE(full_fname
->base_name
);
1543 smb_stat_ex_from_stat(sbuf
, &st
);
1546 END_PROFILE(syscall_fstatat
);
1551 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1552 struct smb_filename
*smb_fname
)
1557 START_PROFILE(syscall_lstat
);
1558 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1560 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1562 if (ret
< 0 && errno
!= ENOENT
) {
1563 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1564 smb_fname
->base_name
, strerror(errno
)));
1566 END_PROFILE(syscall_lstat
);
1571 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1573 const SMB_STRUCT_STAT
*sbuf
)
1577 START_PROFILE(syscall_get_alloc_size
);
1578 ret
= sbuf
->st_ex_blocks
* 512;
1579 END_PROFILE(syscall_get_alloc_size
);
1584 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1585 struct files_struct
*dirfsp
,
1586 const struct smb_filename
*smb_fname
,
1591 #ifdef HAVE_GFAPI_VER_7_11
1592 glfs_fd_t
*pglfd
= NULL
;
1594 START_PROFILE(syscall_unlinkat
);
1596 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1597 if (pglfd
== NULL
) {
1598 END_PROFILE(syscall_unlinkat
);
1599 DBG_ERR("Failed to fetch gluster fd\n");
1603 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1605 struct smb_filename
*full_fname
= NULL
;
1607 START_PROFILE(syscall_unlinkat
);
1609 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1612 if (full_fname
== NULL
) {
1613 END_PROFILE(syscall_unlinkat
);
1617 if (flags
& AT_REMOVEDIR
) {
1618 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1620 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1623 TALLOC_FREE(full_fname
);
1626 END_PROFILE(syscall_unlinkat
);
1631 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1632 files_struct
*fsp
, mode_t mode
)
1635 glfs_fd_t
*glfd
= NULL
;
1637 START_PROFILE(syscall_fchmod
);
1639 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1641 END_PROFILE(syscall_fchmod
);
1642 DBG_ERR("Failed to fetch gluster fd\n");
1646 if (!fsp
->fsp_flags
.is_pathref
) {
1648 * We can use an io_fd to remove xattrs.
1650 ret
= glfs_fchmod(glfd
, mode
);
1653 * This is no longer a handle based call.
1655 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1657 END_PROFILE(syscall_fchmod
);
1662 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1663 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1666 glfs_fd_t
*glfd
= NULL
;
1668 START_PROFILE(syscall_fchown
);
1670 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1672 END_PROFILE(syscall_fchown
);
1673 DBG_ERR("Failed to fetch gluster fd\n");
1677 ret
= glfs_fchown(glfd
, uid
, gid
);
1678 END_PROFILE(syscall_fchown
);
1683 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1684 const struct smb_filename
*smb_fname
,
1690 START_PROFILE(syscall_lchown
);
1691 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1692 END_PROFILE(syscall_lchown
);
1697 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1698 const struct smb_filename
*smb_fname
)
1702 START_PROFILE(syscall_chdir
);
1703 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1704 END_PROFILE(syscall_chdir
);
1709 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1712 char cwd
[PATH_MAX
] = { '\0' };
1714 struct smb_filename
*smb_fname
= NULL
;
1716 START_PROFILE(syscall_getwd
);
1718 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1719 END_PROFILE(syscall_getwd
);
1724 smb_fname
= synthetic_smb_fname(ctx
,
1733 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1735 struct smb_file_time
*ft
)
1738 struct timespec times
[2];
1739 glfs_fd_t
*glfd
= NULL
;
1741 START_PROFILE(syscall_fntimes
);
1743 if (is_omit_timespec(&ft
->atime
)) {
1744 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1745 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1747 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1748 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1751 if (is_omit_timespec(&ft
->mtime
)) {
1752 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1753 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1755 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1756 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1759 if ((timespec_compare(×
[0],
1760 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1761 (timespec_compare(×
[1],
1762 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1763 END_PROFILE(syscall_fntimes
);
1767 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1769 END_PROFILE(syscall_fntimes
);
1770 DBG_ERR("Failed to fetch gluster fd\n");
1774 if (!fsp
->fsp_flags
.is_pathref
) {
1775 ret
= glfs_futimens(glfd
, times
);
1777 ret
= glfs_utimens(handle
->data
,
1778 fsp
->fsp_name
->base_name
,
1781 END_PROFILE(syscall_fntimes
);
1786 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1787 files_struct
*fsp
, off_t offset
)
1790 glfs_fd_t
*glfd
= NULL
;
1792 START_PROFILE(syscall_ftruncate
);
1794 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1796 END_PROFILE(syscall_ftruncate
);
1797 DBG_ERR("Failed to fetch gluster fd\n");
1801 #ifdef HAVE_GFAPI_VER_7_6
1802 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1804 ret
= glfs_ftruncate(glfd
, offset
);
1806 END_PROFILE(syscall_ftruncate
);
1811 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1812 struct files_struct
*fsp
,
1814 off_t offset
, off_t len
)
1817 #ifdef HAVE_GFAPI_VER_6
1818 glfs_fd_t
*glfd
= NULL
;
1819 int keep_size
, punch_hole
;
1821 START_PROFILE(syscall_fallocate
);
1823 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1825 END_PROFILE(syscall_fallocate
);
1826 DBG_ERR("Failed to fetch gluster fd\n");
1830 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1831 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1833 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1835 END_PROFILE(syscall_fallocate
);
1841 ret
= glfs_discard(glfd
, offset
, len
);
1843 DBG_DEBUG("glfs_discard failed: %s\n",
1848 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1849 END_PROFILE(syscall_fallocate
);
1857 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1859 const struct smb_filename
*smb_fname
)
1861 char *result
= NULL
;
1862 struct smb_filename
*result_fname
= NULL
;
1863 char *resolved_path
= NULL
;
1865 START_PROFILE(syscall_realpath
);
1867 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1868 if (resolved_path
== NULL
) {
1869 END_PROFILE(syscall_realpath
);
1874 result
= glfs_realpath(handle
->data
,
1875 smb_fname
->base_name
,
1877 if (result
!= NULL
) {
1878 result_fname
= synthetic_smb_fname(ctx
,
1886 SAFE_FREE(resolved_path
);
1887 END_PROFILE(syscall_realpath
);
1889 return result_fname
;
1892 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1893 files_struct
*fsp
, int op
, off_t offset
,
1894 off_t count
, int type
)
1896 struct flock flock
= { 0, };
1898 glfs_fd_t
*glfd
= NULL
;
1901 START_PROFILE(syscall_fcntl_lock
);
1903 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1905 DBG_ERR("Failed to fetch gluster fd\n");
1910 flock
.l_type
= type
;
1911 flock
.l_whence
= SEEK_SET
;
1912 flock
.l_start
= offset
;
1913 flock
.l_len
= count
;
1916 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1918 if (op
== F_GETLK
) {
1919 /* lock query, true if someone else has locked */
1921 (flock
.l_type
!= F_UNLCK
) &&
1922 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1938 END_PROFILE(syscall_fcntl_lock
);
1943 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1945 uint32_t share_access
,
1946 uint32_t access_mask
)
1952 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1953 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1956 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1957 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1959 if (cmd
== F_GETFL
) {
1961 } else if (cmd
== F_SETFL
) {
1962 va_list dup_cmd_arg
;
1965 va_copy(dup_cmd_arg
, cmd_arg
);
1966 opt
= va_arg(dup_cmd_arg
, int);
1967 va_end(dup_cmd_arg
);
1971 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1974 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1980 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1981 files_struct
*fsp
, int leasetype
)
1987 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1988 files_struct
*fsp
, off_t
*poffset
,
1989 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1991 struct flock flock
= { 0, };
1993 glfs_fd_t
*glfd
= NULL
;
1995 START_PROFILE(syscall_fcntl_getlock
);
1997 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1999 END_PROFILE(syscall_fcntl_getlock
);
2000 DBG_ERR("Failed to fetch gluster fd\n");
2004 flock
.l_type
= *ptype
;
2005 flock
.l_whence
= SEEK_SET
;
2006 flock
.l_start
= *poffset
;
2007 flock
.l_len
= *pcount
;
2010 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
2013 END_PROFILE(syscall_fcntl_getlock
);
2017 *ptype
= flock
.l_type
;
2018 *poffset
= flock
.l_start
;
2019 *pcount
= flock
.l_len
;
2020 *ppid
= flock
.l_pid
;
2021 END_PROFILE(syscall_fcntl_getlock
);
2026 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
2027 const struct smb_filename
*link_target
,
2028 struct files_struct
*dirfsp
,
2029 const struct smb_filename
*new_smb_fname
)
2033 #ifdef HAVE_GFAPI_VER_7_11
2034 glfs_fd_t
*pglfd
= NULL
;
2036 START_PROFILE(syscall_symlinkat
);
2038 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2039 if (pglfd
== NULL
) {
2040 END_PROFILE(syscall_symlinkat
);
2041 DBG_ERR("Failed to fetch gluster fd\n");
2045 ret
= glfs_symlinkat(link_target
->base_name
,
2047 new_smb_fname
->base_name
);
2049 struct smb_filename
*full_fname
= NULL
;
2051 START_PROFILE(syscall_symlinkat
);
2053 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2056 if (full_fname
== NULL
) {
2057 END_PROFILE(syscall_symlinkat
);
2061 ret
= glfs_symlink(handle
->data
,
2062 link_target
->base_name
,
2063 full_fname
->base_name
);
2065 TALLOC_FREE(full_fname
);
2068 END_PROFILE(syscall_symlinkat
);
2073 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2074 const struct files_struct
*dirfsp
,
2075 const struct smb_filename
*smb_fname
,
2081 #ifdef HAVE_GFAPI_VER_7_11
2082 glfs_fd_t
*pglfd
= NULL
;
2084 START_PROFILE(syscall_readlinkat
);
2086 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2087 if (pglfd
== NULL
) {
2088 END_PROFILE(syscall_readlinkat
);
2089 DBG_ERR("Failed to fetch gluster fd\n");
2093 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2095 struct smb_filename
*full_fname
= NULL
;
2097 START_PROFILE(syscall_readlinkat
);
2099 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2102 if (full_fname
== NULL
) {
2103 END_PROFILE(syscall_readlinkat
);
2107 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2109 TALLOC_FREE(full_fname
);
2112 END_PROFILE(syscall_readlinkat
);
2117 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2118 files_struct
*srcfsp
,
2119 const struct smb_filename
*old_smb_fname
,
2120 files_struct
*dstfsp
,
2121 const struct smb_filename
*new_smb_fname
,
2126 #ifdef HAVE_GFAPI_VER_7_11
2127 glfs_fd_t
*src_pglfd
= NULL
;
2128 glfs_fd_t
*dst_pglfd
= NULL
;
2130 START_PROFILE(syscall_linkat
);
2132 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
2133 if (src_pglfd
== NULL
) {
2134 END_PROFILE(syscall_linkat
);
2135 DBG_ERR("Failed to fetch gluster fd\n");
2139 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
2140 if (dst_pglfd
== NULL
) {
2141 END_PROFILE(syscall_linkat
);
2142 DBG_ERR("Failed to fetch gluster fd\n");
2146 ret
= glfs_linkat(src_pglfd
,
2147 old_smb_fname
->base_name
,
2149 new_smb_fname
->base_name
,
2152 struct smb_filename
*full_fname_old
= NULL
;
2153 struct smb_filename
*full_fname_new
= NULL
;
2155 START_PROFILE(syscall_linkat
);
2157 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2160 if (full_fname_old
== NULL
) {
2161 END_PROFILE(syscall_linkat
);
2165 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2168 if (full_fname_new
== NULL
) {
2169 END_PROFILE(syscall_linkat
);
2170 TALLOC_FREE(full_fname_old
);
2174 ret
= glfs_link(handle
->data
,
2175 full_fname_old
->base_name
,
2176 full_fname_new
->base_name
);
2178 TALLOC_FREE(full_fname_old
);
2179 TALLOC_FREE(full_fname_new
);
2182 END_PROFILE(syscall_linkat
);
2187 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2188 files_struct
*dirfsp
,
2189 const struct smb_filename
*smb_fname
,
2195 #ifdef HAVE_GFAPI_VER_7_11
2196 glfs_fd_t
*pglfd
= NULL
;
2198 START_PROFILE(syscall_mknodat
);
2200 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2201 if (pglfd
== NULL
) {
2202 END_PROFILE(syscall_mknodat
);
2203 DBG_ERR("Failed to fetch gluster fd\n");
2207 ret
= glfs_mknodat(pglfd
, smb_fname
->base_name
, mode
, dev
);
2209 struct smb_filename
*full_fname
= NULL
;
2211 START_PROFILE(syscall_mknodat
);
2213 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2216 if (full_fname
== NULL
) {
2217 END_PROFILE(syscall_mknodat
);
2221 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2223 TALLOC_FREE(full_fname
);
2226 END_PROFILE(syscall_mknodat
);
2231 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2232 struct files_struct
*fsp
,
2239 static NTSTATUS
vfs_gluster_get_real_filename_at(
2240 struct vfs_handle_struct
*handle
,
2241 struct files_struct
*dirfsp
,
2243 TALLOC_CTX
*mem_ctx
,
2247 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2248 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2250 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2251 return NT_STATUS_OBJECT_NAME_INVALID
;
2254 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2255 "glusterfs.get_real_filename:%s", name
);
2257 ret
= glfs_getxattr(handle
->data
,
2258 dirfsp
->fsp_name
->base_name
,
2261 GLUSTER_NAME_MAX
+ 1);
2263 if (errno
== ENOATTR
) {
2266 return map_nt_error_from_unix(errno
);
2269 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2270 if (found_name
[0] == NULL
) {
2271 return NT_STATUS_NO_MEMORY
;
2274 return NT_STATUS_OK
;
2277 static const char *vfs_gluster_connectpath(struct vfs_handle_struct
*handle
,
2278 const struct smb_filename
*smb_fname
)
2280 return handle
->conn
->connectpath
;
2285 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2286 files_struct
*fsp
, const char *name
,
2287 void *value
, size_t size
)
2289 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2291 DBG_ERR("Failed to fetch gluster fd\n");
2295 if (!fsp
->fsp_flags
.is_pathref
) {
2297 * We can use an io_fd to retrieve xattr value.
2299 return glfs_fgetxattr(glfd
, name
, value
, size
);
2303 * This is no longer a handle based call.
2305 return glfs_getxattr(handle
->data
,
2306 fsp
->fsp_name
->base_name
,
2312 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2313 files_struct
*fsp
, char *list
,
2316 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2318 DBG_ERR("Failed to fetch gluster fd\n");
2321 if (!fsp
->fsp_flags
.is_pathref
) {
2323 * We can use an io_fd to list xattrs.
2325 return glfs_flistxattr(glfd
, list
, size
);
2328 * This is no longer a handle based call.
2330 return glfs_listxattr(handle
->data
,
2331 fsp
->fsp_name
->base_name
,
2337 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2338 files_struct
*fsp
, const char *name
)
2340 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2342 DBG_ERR("Failed to fetch gluster fd\n");
2345 if (!fsp
->fsp_flags
.is_pathref
) {
2347 * We can use an io_fd to remove xattrs.
2349 return glfs_fremovexattr(glfd
, name
);
2352 * This is no longer a handle based call.
2354 return glfs_removexattr(handle
->data
,
2355 fsp
->fsp_name
->base_name
,
2360 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2361 files_struct
*fsp
, const char *name
,
2362 const void *value
, size_t size
, int flags
)
2364 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2366 DBG_ERR("Failed to fetch gluster fd\n");
2370 if (!fsp
->fsp_flags
.is_pathref
) {
2372 * We can use an io_fd to set xattrs.
2374 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2377 * This is no longer a handle based call.
2379 return glfs_setxattr(handle
->data
,
2380 fsp
->fsp_name
->base_name
,
2388 /* AIO Operations */
2390 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2396 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2397 struct files_struct
*dirfsp
,
2398 const struct smb_filename
*smb_fname
,
2399 const struct referral
*reflist
,
2400 size_t referral_count
)
2402 TALLOC_CTX
*frame
= talloc_stackframe();
2403 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2405 char *msdfs_link
= NULL
;
2406 #ifdef HAVE_GFAPI_VER_7_11
2407 glfs_fd_t
*pglfd
= NULL
;
2409 struct smb_filename
*full_fname
= NULL
;
2412 /* Form the msdfs_link contents */
2413 msdfs_link
= msdfs_link_string(frame
,
2416 if (msdfs_link
== NULL
) {
2420 #ifdef HAVE_GFAPI_VER_7_11
2421 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2422 if (pglfd
== NULL
) {
2423 DBG_ERR("Failed to fetch gluster fd\n");
2424 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2428 ret
= glfs_symlinkat(msdfs_link
, pglfd
, smb_fname
->base_name
);
2430 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2433 if (full_fname
== NULL
) {
2437 ret
= glfs_symlink(handle
->data
, msdfs_link
, full_fname
->base_name
);
2439 TALLOC_FREE(full_fname
);
2442 status
= NT_STATUS_OK
;
2444 status
= map_nt_error_from_unix(errno
);
2454 * Read and return the contents of a DFS redirect given a
2455 * pathname. A caller can pass in NULL for ppreflist and
2456 * preferral_count but still determine if this was a
2457 * DFS redirect point by getting NT_STATUS_OK back
2458 * without incurring the overhead of reading and parsing
2459 * the referral contents.
2462 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2463 TALLOC_CTX
*mem_ctx
,
2464 struct files_struct
*dirfsp
,
2465 struct smb_filename
*smb_fname
,
2466 struct referral
**ppreflist
,
2467 size_t *preferral_count
)
2469 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2471 char *link_target
= NULL
;
2474 #if defined(HAVE_BROKEN_READLINK)
2475 char link_target_buf
[PATH_MAX
];
2477 char link_target_buf
[7];
2480 struct smb_filename
*full_fname
= NULL
;
2482 #ifdef HAVE_GFAPI_VER_7_11
2483 glfs_fd_t
*pglfd
= NULL
;
2486 if (is_named_stream(smb_fname
)) {
2487 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2491 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2493 * We're only checking if this is a DFS
2494 * redirect. We don't need to return data.
2496 bufsize
= sizeof(link_target_buf
);
2497 link_target
= link_target_buf
;
2500 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2506 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2509 if (full_fname
== NULL
) {
2510 status
= NT_STATUS_NO_MEMORY
;
2514 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2516 status
= map_nt_error_from_unix(errno
);
2520 #ifdef HAVE_GFAPI_VER_7_11
2521 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2522 if (pglfd
== NULL
) {
2523 DBG_ERR("Failed to fetch gluster fd\n");
2524 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2527 referral_len
= glfs_readlinkat(pglfd
,
2528 smb_fname
->base_name
,
2532 referral_len
= glfs_readlink(handle
->data
,
2533 full_fname
->base_name
,
2537 if (referral_len
< 0) {
2538 if (errno
== EINVAL
) {
2539 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2540 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2542 status
= map_nt_error_from_unix(errno
);
2543 DBG_ERR("Error reading "
2544 "msdfs link %s: %s\n",
2545 full_fname
->base_name
,
2550 link_target
[referral_len
] = '\0';
2552 DBG_INFO("%s -> %s\n",
2553 full_fname
->base_name
,
2556 if (!strnequal(link_target
, "msdfs:", 6)) {
2557 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2561 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2562 /* Early return for checking if this is a DFS link. */
2563 TALLOC_FREE(full_fname
);
2564 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2565 return NT_STATUS_OK
;
2568 ok
= parse_msdfs_symlink(mem_ctx
,
2569 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2575 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2576 status
= NT_STATUS_OK
;
2578 status
= NT_STATUS_NO_MEMORY
;
2583 if (link_target
!= link_target_buf
) {
2584 TALLOC_FREE(link_target
);
2586 TALLOC_FREE(full_fname
);
2590 static struct vfs_fn_pointers glusterfs_fns
= {
2592 /* Disk Operations */
2594 .connect_fn
= vfs_gluster_connect
,
2595 .disconnect_fn
= vfs_gluster_disconnect
,
2596 .disk_free_fn
= vfs_gluster_disk_free
,
2597 .get_quota_fn
= vfs_gluster_get_quota
,
2598 .set_quota_fn
= vfs_gluster_set_quota
,
2599 .statvfs_fn
= vfs_gluster_statvfs
,
2600 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2602 .get_dfs_referrals_fn
= NULL
,
2604 /* Directory Operations */
2606 .fdopendir_fn
= vfs_gluster_fdopendir
,
2607 .readdir_fn
= vfs_gluster_readdir
,
2608 .seekdir_fn
= vfs_gluster_seekdir
,
2609 .telldir_fn
= vfs_gluster_telldir
,
2610 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2611 .mkdirat_fn
= vfs_gluster_mkdirat
,
2612 .closedir_fn
= vfs_gluster_closedir
,
2614 /* File Operations */
2616 .openat_fn
= vfs_gluster_openat
,
2617 .create_file_fn
= NULL
,
2618 .close_fn
= vfs_gluster_close
,
2619 .pread_fn
= vfs_gluster_pread
,
2620 .pread_send_fn
= vfs_gluster_pread_send
,
2621 .pread_recv_fn
= vfs_gluster_pread_recv
,
2622 .pwrite_fn
= vfs_gluster_pwrite
,
2623 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2624 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2625 .lseek_fn
= vfs_gluster_lseek
,
2626 .sendfile_fn
= vfs_gluster_sendfile
,
2627 .recvfile_fn
= vfs_gluster_recvfile
,
2628 .renameat_fn
= vfs_gluster_renameat
,
2629 .fsync_send_fn
= vfs_gluster_fsync_send
,
2630 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2632 .stat_fn
= vfs_gluster_stat
,
2633 .fstat_fn
= vfs_gluster_fstat
,
2634 .fstatat_fn
= vfs_gluster_fstatat
,
2635 .lstat_fn
= vfs_gluster_lstat
,
2636 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2637 .unlinkat_fn
= vfs_gluster_unlinkat
,
2639 .fchmod_fn
= vfs_gluster_fchmod
,
2640 .fchown_fn
= vfs_gluster_fchown
,
2641 .lchown_fn
= vfs_gluster_lchown
,
2642 .chdir_fn
= vfs_gluster_chdir
,
2643 .getwd_fn
= vfs_gluster_getwd
,
2644 .fntimes_fn
= vfs_gluster_fntimes
,
2645 .ftruncate_fn
= vfs_gluster_ftruncate
,
2646 .fallocate_fn
= vfs_gluster_fallocate
,
2647 .lock_fn
= vfs_gluster_lock
,
2648 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2649 .fcntl_fn
= vfs_gluster_fcntl
,
2650 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2651 .getlock_fn
= vfs_gluster_getlock
,
2652 .symlinkat_fn
= vfs_gluster_symlinkat
,
2653 .readlinkat_fn
= vfs_gluster_readlinkat
,
2654 .linkat_fn
= vfs_gluster_linkat
,
2655 .mknodat_fn
= vfs_gluster_mknodat
,
2656 .realpath_fn
= vfs_gluster_realpath
,
2657 .fchflags_fn
= vfs_gluster_fchflags
,
2658 .file_id_create_fn
= NULL
,
2659 .fstreaminfo_fn
= NULL
,
2660 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2661 .connectpath_fn
= vfs_gluster_connectpath
,
2662 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2663 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2665 .brl_lock_windows_fn
= NULL
,
2666 .brl_unlock_windows_fn
= NULL
,
2667 .strict_lock_check_fn
= NULL
,
2668 .translate_name_fn
= NULL
,
2671 /* NT ACL Operations */
2672 .fget_nt_acl_fn
= NULL
,
2673 .fset_nt_acl_fn
= NULL
,
2674 .audit_file_fn
= NULL
,
2676 /* Posix ACL Operations */
2677 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2678 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2679 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2680 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2683 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2684 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2685 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2686 .flistxattr_fn
= vfs_gluster_flistxattr
,
2687 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2688 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2690 /* AIO Operations */
2691 .aio_force_fn
= vfs_gluster_aio_force
,
2693 /* Durable handle Operations */
2694 .durable_cookie_fn
= NULL
,
2695 .durable_disconnect_fn
= NULL
,
2696 .durable_reconnect_fn
= NULL
,
2700 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2702 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2703 "glusterfs", &glusterfs_fns
);