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 hierarchy
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
,
654 static char direntbuf
[512];
656 struct dirent
*dirent
= 0;
658 START_PROFILE(syscall_readdir
);
660 ret
= glfs_readdir_r((void *)dirp
, (void *)direntbuf
, &dirent
);
662 if ((ret
< 0) || (dirent
== NULL
)) {
663 END_PROFILE(syscall_readdir
);
667 END_PROFILE(syscall_readdir
);
671 static void vfs_gluster_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
673 START_PROFILE(syscall_rewinddir
);
674 glfs_seekdir((void *)dirp
, 0);
675 END_PROFILE(syscall_rewinddir
);
678 static int vfs_gluster_mkdirat(struct vfs_handle_struct
*handle
,
679 struct files_struct
*dirfsp
,
680 const struct smb_filename
*smb_fname
,
685 #ifdef HAVE_GFAPI_VER_7_11
686 glfs_fd_t
*pglfd
= NULL
;
688 START_PROFILE(syscall_mkdirat
);
690 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
692 END_PROFILE(syscall_mkdirat
);
693 DBG_ERR("Failed to fetch gluster fd\n");
697 ret
= glfs_mkdirat(pglfd
, smb_fname
->base_name
, mode
);
699 struct smb_filename
*full_fname
= NULL
;
701 START_PROFILE(syscall_mkdirat
);
703 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
706 if (full_fname
== NULL
) {
707 END_PROFILE(syscall_mkdirat
);
711 ret
= glfs_mkdir(handle
->data
, full_fname
->base_name
, mode
);
713 TALLOC_FREE(full_fname
);
716 END_PROFILE(syscall_mkdirat
);
721 static int vfs_gluster_openat(struct vfs_handle_struct
*handle
,
722 const struct files_struct
*dirfsp
,
723 const struct smb_filename
*smb_fname
,
725 const struct vfs_open_how
*how
)
727 int flags
= how
->flags
;
728 struct smb_filename
*full_fname
= NULL
;
729 bool have_opath
= false;
730 bool became_root
= false;
731 glfs_fd_t
*glfd
= NULL
;
732 glfs_fd_t
*pglfd
= NULL
;
735 START_PROFILE(syscall_openat
);
737 if (how
->resolve
!= 0) {
738 END_PROFILE(syscall_openat
);
743 p_tmp
= VFS_ADD_FSP_EXTENSION(handle
, fsp
, glfs_fd_t
*, NULL
);
745 END_PROFILE(syscall_openat
);
752 if (fsp
->fsp_flags
.is_pathref
) {
757 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
760 if (full_fname
== NULL
) {
761 END_PROFILE(syscall_openat
);
765 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
770 if (fsp_get_pathref_fd(dirfsp
) != AT_FDCWD
) {
771 #ifdef HAVE_GFAPI_VER_7_11
773 * Fetch Gluster fd for parent directory using dirfsp
774 * before calling glfs_openat();
776 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
778 END_PROFILE(syscall_openat
);
779 DBG_ERR("Failed to fetch gluster fd\n");
783 glfd
= glfs_openat(pglfd
,
784 smb_fname
->base_name
,
789 * Replace smb_fname with full_path constructed above.
791 smb_fname
= full_fname
;
797 * smb_fname can either be a full_path or the same one
798 * as received from the caller. In the latter case we
799 * are operating at current working directory.
801 if (flags
& O_CREAT
) {
802 glfd
= glfs_creat(handle
->data
,
803 smb_fname
->base_name
,
807 glfd
= glfs_open(handle
->data
,
808 smb_fname
->base_name
,
817 TALLOC_FREE(full_fname
);
819 fsp
->fsp_flags
.have_proc_fds
= false;
822 END_PROFILE(syscall_openat
);
823 /* no extension destroy_fn, so no need to save errno */
824 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
830 END_PROFILE(syscall_openat
);
831 /* An arbitrary value for error reporting, so you know its us. */
835 static int vfs_gluster_close(struct vfs_handle_struct
*handle
,
839 glfs_fd_t
*glfd
= NULL
;
841 START_PROFILE(syscall_close
);
843 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
845 END_PROFILE(syscall_close
);
846 DBG_ERR("Failed to fetch gluster fd\n");
850 VFS_REMOVE_FSP_EXTENSION(handle
, fsp
);
852 ret
= glfs_close(glfd
);
853 END_PROFILE(syscall_close
);
858 static ssize_t
vfs_gluster_pread(struct vfs_handle_struct
*handle
,
859 files_struct
*fsp
, void *data
, size_t n
,
863 glfs_fd_t
*glfd
= NULL
;
865 START_PROFILE_BYTES(syscall_pread
, n
);
867 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
869 END_PROFILE_BYTES(syscall_pread
);
870 DBG_ERR("Failed to fetch gluster fd\n");
874 #ifdef HAVE_GFAPI_VER_7_6
875 ret
= glfs_pread(glfd
, data
, n
, offset
, 0, NULL
);
877 ret
= glfs_pread(glfd
, data
, n
, offset
, 0);
879 END_PROFILE_BYTES(syscall_pread
);
884 struct vfs_gluster_pread_state
{
891 struct vfs_aio_state vfs_aio_state
;
892 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
895 static void vfs_gluster_pread_do(void *private_data
);
896 static void vfs_gluster_pread_done(struct tevent_req
*subreq
);
897 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
);
899 static struct tevent_req
*vfs_gluster_pread_send(struct vfs_handle_struct
900 *handle
, TALLOC_CTX
*mem_ctx
,
901 struct tevent_context
*ev
,
903 void *data
, size_t n
,
906 struct vfs_gluster_pread_state
*state
;
907 struct tevent_req
*req
, *subreq
;
909 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
911 DBG_ERR("Failed to fetch gluster fd\n");
915 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pread_state
);
924 state
->offset
= offset
;
926 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread
, profile_p
,
927 state
->profile_bytes
, n
);
928 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
930 subreq
= pthreadpool_tevent_job_send(
931 state
, ev
, handle
->conn
->sconn
->pool
,
932 vfs_gluster_pread_do
, state
);
933 if (tevent_req_nomem(subreq
, req
)) {
934 return tevent_req_post(req
, ev
);
936 tevent_req_set_callback(subreq
, vfs_gluster_pread_done
, req
);
938 talloc_set_destructor(state
, vfs_gluster_pread_state_destructor
);
943 static void vfs_gluster_pread_do(void *private_data
)
945 struct vfs_gluster_pread_state
*state
= talloc_get_type_abort(
946 private_data
, struct vfs_gluster_pread_state
);
947 struct timespec start_time
;
948 struct timespec end_time
;
950 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
952 PROFILE_TIMESTAMP(&start_time
);
955 #ifdef HAVE_GFAPI_VER_7_6
956 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
957 state
->offset
, 0, NULL
);
959 state
->ret
= glfs_pread(state
->fd
, state
->buf
, state
->count
,
962 } while ((state
->ret
== -1) && (errno
== EINTR
));
964 if (state
->ret
== -1) {
965 state
->vfs_aio_state
.error
= errno
;
968 PROFILE_TIMESTAMP(&end_time
);
970 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
972 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
975 static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state
*state
)
980 static void vfs_gluster_pread_done(struct tevent_req
*subreq
)
982 struct tevent_req
*req
= tevent_req_callback_data(
983 subreq
, struct tevent_req
);
984 struct vfs_gluster_pread_state
*state
= tevent_req_data(
985 req
, struct vfs_gluster_pread_state
);
988 ret
= pthreadpool_tevent_job_recv(subreq
);
990 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
991 talloc_set_destructor(state
, NULL
);
994 tevent_req_error(req
, ret
);
998 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
999 * means the lower level pthreadpool failed to create a new
1000 * thread. Fallback to sync processing in that case to allow
1001 * some progress for the client.
1003 vfs_gluster_pread_do(state
);
1006 tevent_req_done(req
);
1009 static ssize_t
vfs_gluster_pread_recv(struct tevent_req
*req
,
1010 struct vfs_aio_state
*vfs_aio_state
)
1012 struct vfs_gluster_pread_state
*state
= tevent_req_data(
1013 req
, struct vfs_gluster_pread_state
);
1015 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1019 *vfs_aio_state
= state
->vfs_aio_state
;
1023 struct vfs_gluster_pwrite_state
{
1030 struct vfs_aio_state vfs_aio_state
;
1031 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1034 static void vfs_gluster_pwrite_do(void *private_data
);
1035 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
);
1036 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
);
1038 static struct tevent_req
*vfs_gluster_pwrite_send(struct vfs_handle_struct
1039 *handle
, TALLOC_CTX
*mem_ctx
,
1040 struct tevent_context
*ev
,
1042 const void *data
, size_t n
,
1045 struct tevent_req
*req
, *subreq
;
1046 struct vfs_gluster_pwrite_state
*state
;
1048 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1050 DBG_ERR("Failed to fetch gluster fd\n");
1054 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_pwrite_state
);
1063 state
->offset
= offset
;
1065 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite
, profile_p
,
1066 state
->profile_bytes
, n
);
1067 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1069 subreq
= pthreadpool_tevent_job_send(
1070 state
, ev
, handle
->conn
->sconn
->pool
,
1071 vfs_gluster_pwrite_do
, state
);
1072 if (tevent_req_nomem(subreq
, req
)) {
1073 return tevent_req_post(req
, ev
);
1075 tevent_req_set_callback(subreq
, vfs_gluster_pwrite_done
, req
);
1077 talloc_set_destructor(state
, vfs_gluster_pwrite_state_destructor
);
1082 static void vfs_gluster_pwrite_do(void *private_data
)
1084 struct vfs_gluster_pwrite_state
*state
= talloc_get_type_abort(
1085 private_data
, struct vfs_gluster_pwrite_state
);
1086 struct timespec start_time
;
1087 struct timespec end_time
;
1089 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1091 PROFILE_TIMESTAMP(&start_time
);
1094 #ifdef HAVE_GFAPI_VER_7_6
1095 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1096 state
->offset
, 0, NULL
, NULL
);
1098 state
->ret
= glfs_pwrite(state
->fd
, state
->buf
, state
->count
,
1101 } while ((state
->ret
== -1) && (errno
== EINTR
));
1103 if (state
->ret
== -1) {
1104 state
->vfs_aio_state
.error
= errno
;
1107 PROFILE_TIMESTAMP(&end_time
);
1109 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1111 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1114 static int vfs_gluster_pwrite_state_destructor(struct vfs_gluster_pwrite_state
*state
)
1119 static void vfs_gluster_pwrite_done(struct tevent_req
*subreq
)
1121 struct tevent_req
*req
= tevent_req_callback_data(
1122 subreq
, struct tevent_req
);
1123 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1124 req
, struct vfs_gluster_pwrite_state
);
1127 ret
= pthreadpool_tevent_job_recv(subreq
);
1128 TALLOC_FREE(subreq
);
1129 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1130 talloc_set_destructor(state
, NULL
);
1132 if (ret
!= EAGAIN
) {
1133 tevent_req_error(req
, ret
);
1137 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1138 * means the lower level pthreadpool failed to create a new
1139 * thread. Fallback to sync processing in that case to allow
1140 * some progress for the client.
1142 vfs_gluster_pwrite_do(state
);
1145 tevent_req_done(req
);
1148 static ssize_t
vfs_gluster_pwrite_recv(struct tevent_req
*req
,
1149 struct vfs_aio_state
*vfs_aio_state
)
1151 struct vfs_gluster_pwrite_state
*state
= tevent_req_data(
1152 req
, struct vfs_gluster_pwrite_state
);
1154 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1158 *vfs_aio_state
= state
->vfs_aio_state
;
1163 static ssize_t
vfs_gluster_pwrite(struct vfs_handle_struct
*handle
,
1164 files_struct
*fsp
, const void *data
,
1165 size_t n
, off_t offset
)
1168 glfs_fd_t
*glfd
= NULL
;
1170 START_PROFILE_BYTES(syscall_pwrite
, n
);
1172 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1174 END_PROFILE_BYTES(syscall_pwrite
);
1175 DBG_ERR("Failed to fetch gluster fd\n");
1179 #ifdef HAVE_GFAPI_VER_7_6
1180 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0, NULL
, NULL
);
1182 ret
= glfs_pwrite(glfd
, data
, n
, offset
, 0);
1184 END_PROFILE_BYTES(syscall_pwrite
);
1189 static off_t
vfs_gluster_lseek(struct vfs_handle_struct
*handle
,
1190 files_struct
*fsp
, off_t offset
, int whence
)
1193 glfs_fd_t
*glfd
= NULL
;
1195 START_PROFILE(syscall_lseek
);
1197 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1199 END_PROFILE(syscall_lseek
);
1200 DBG_ERR("Failed to fetch gluster fd\n");
1204 ret
= glfs_lseek(glfd
, offset
, whence
);
1205 END_PROFILE(syscall_lseek
);
1210 static ssize_t
vfs_gluster_sendfile(struct vfs_handle_struct
*handle
, int tofd
,
1211 files_struct
*fromfsp
,
1212 const DATA_BLOB
*hdr
,
1213 off_t offset
, size_t n
)
1219 static ssize_t
vfs_gluster_recvfile(struct vfs_handle_struct
*handle
,
1220 int fromfd
, files_struct
*tofsp
,
1221 off_t offset
, size_t n
)
1227 static int vfs_gluster_renameat(struct vfs_handle_struct
*handle
,
1228 files_struct
*srcfsp
,
1229 const struct smb_filename
*smb_fname_src
,
1230 files_struct
*dstfsp
,
1231 const struct smb_filename
*smb_fname_dst
)
1235 #ifdef HAVE_GFAPI_VER_7_11
1236 glfs_fd_t
*src_pglfd
= NULL
;
1237 glfs_fd_t
*dst_pglfd
= NULL
;
1239 START_PROFILE(syscall_renameat
);
1241 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
1242 if (src_pglfd
== NULL
) {
1243 END_PROFILE(syscall_renameat
);
1244 DBG_ERR("Failed to fetch gluster fd\n");
1248 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
1249 if (dst_pglfd
== NULL
) {
1250 END_PROFILE(syscall_renameat
);
1251 DBG_ERR("Failed to fetch gluster fd\n");
1255 ret
= glfs_renameat(src_pglfd
, smb_fname_src
->base_name
,
1256 dst_pglfd
, smb_fname_dst
->base_name
);
1258 struct smb_filename
*full_fname_src
= NULL
;
1259 struct smb_filename
*full_fname_dst
= NULL
;
1261 START_PROFILE(syscall_renameat
);
1263 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
1266 if (full_fname_src
== NULL
) {
1267 END_PROFILE(syscall_renameat
);
1272 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
1275 if (full_fname_dst
== NULL
) {
1276 END_PROFILE(syscall_renameat
);
1277 TALLOC_FREE(full_fname_src
);
1281 ret
= glfs_rename(handle
->data
,
1282 full_fname_src
->base_name
,
1283 full_fname_dst
->base_name
);
1285 TALLOC_FREE(full_fname_src
);
1286 TALLOC_FREE(full_fname_dst
);
1289 END_PROFILE(syscall_renameat
);
1294 struct vfs_gluster_fsync_state
{
1298 struct vfs_aio_state vfs_aio_state
;
1299 SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes
);
1302 static void vfs_gluster_fsync_do(void *private_data
);
1303 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
);
1304 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
);
1306 static struct tevent_req
*vfs_gluster_fsync_send(struct vfs_handle_struct
1307 *handle
, TALLOC_CTX
*mem_ctx
,
1308 struct tevent_context
*ev
,
1311 struct tevent_req
*req
, *subreq
;
1312 struct vfs_gluster_fsync_state
*state
;
1314 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1316 DBG_ERR("Failed to fetch gluster fd\n");
1320 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_gluster_fsync_state
);
1328 SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync
, profile_p
,
1329 state
->profile_bytes
, 0);
1330 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1332 subreq
= pthreadpool_tevent_job_send(
1333 state
, ev
, handle
->conn
->sconn
->pool
, vfs_gluster_fsync_do
, state
);
1334 if (tevent_req_nomem(subreq
, req
)) {
1335 return tevent_req_post(req
, ev
);
1337 tevent_req_set_callback(subreq
, vfs_gluster_fsync_done
, req
);
1339 talloc_set_destructor(state
, vfs_gluster_fsync_state_destructor
);
1344 static void vfs_gluster_fsync_do(void *private_data
)
1346 struct vfs_gluster_fsync_state
*state
= talloc_get_type_abort(
1347 private_data
, struct vfs_gluster_fsync_state
);
1348 struct timespec start_time
;
1349 struct timespec end_time
;
1351 SMBPROFILE_BYTES_ASYNC_SET_BUSY(state
->profile_bytes
);
1353 PROFILE_TIMESTAMP(&start_time
);
1356 #ifdef HAVE_GFAPI_VER_7_6
1357 state
->ret
= glfs_fsync(state
->fd
, NULL
, NULL
);
1359 state
->ret
= glfs_fsync(state
->fd
);
1361 } while ((state
->ret
== -1) && (errno
== EINTR
));
1363 if (state
->ret
== -1) {
1364 state
->vfs_aio_state
.error
= errno
;
1367 PROFILE_TIMESTAMP(&end_time
);
1369 state
->vfs_aio_state
.duration
= nsec_time_diff(&end_time
, &start_time
);
1371 SMBPROFILE_BYTES_ASYNC_SET_IDLE(state
->profile_bytes
);
1374 static int vfs_gluster_fsync_state_destructor(struct vfs_gluster_fsync_state
*state
)
1379 static void vfs_gluster_fsync_done(struct tevent_req
*subreq
)
1381 struct tevent_req
*req
= tevent_req_callback_data(
1382 subreq
, struct tevent_req
);
1383 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1384 req
, struct vfs_gluster_fsync_state
);
1387 ret
= pthreadpool_tevent_job_recv(subreq
);
1388 TALLOC_FREE(subreq
);
1389 SMBPROFILE_BYTES_ASYNC_END(state
->profile_bytes
);
1390 talloc_set_destructor(state
, NULL
);
1392 if (ret
!= EAGAIN
) {
1393 tevent_req_error(req
, ret
);
1397 * If we get EAGAIN from pthreadpool_tevent_job_recv() this
1398 * means the lower level pthreadpool failed to create a new
1399 * thread. Fallback to sync processing in that case to allow
1400 * some progress for the client.
1402 vfs_gluster_fsync_do(state
);
1405 tevent_req_done(req
);
1408 static int vfs_gluster_fsync_recv(struct tevent_req
*req
,
1409 struct vfs_aio_state
*vfs_aio_state
)
1411 struct vfs_gluster_fsync_state
*state
= tevent_req_data(
1412 req
, struct vfs_gluster_fsync_state
);
1414 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1418 *vfs_aio_state
= state
->vfs_aio_state
;
1422 static int vfs_gluster_stat(struct vfs_handle_struct
*handle
,
1423 struct smb_filename
*smb_fname
)
1428 START_PROFILE(syscall_stat
);
1429 ret
= glfs_stat(handle
->data
, smb_fname
->base_name
, &st
);
1431 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1433 if (ret
< 0 && errno
!= ENOENT
) {
1434 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
1435 smb_fname
->base_name
, strerror(errno
)));
1437 END_PROFILE(syscall_stat
);
1442 static int vfs_gluster_fstat(struct vfs_handle_struct
*handle
,
1443 files_struct
*fsp
, SMB_STRUCT_STAT
*sbuf
)
1447 glfs_fd_t
*glfd
= NULL
;
1449 START_PROFILE(syscall_fstat
);
1451 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1453 END_PROFILE(syscall_fstat
);
1454 DBG_ERR("Failed to fetch gluster fd\n");
1458 ret
= glfs_fstat(glfd
, &st
);
1460 smb_stat_ex_from_stat(sbuf
, &st
);
1463 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1464 fsp_get_io_fd(fsp
), strerror(errno
)));
1466 END_PROFILE(syscall_fstat
);
1471 static int vfs_gluster_fstatat(struct vfs_handle_struct
*handle
,
1472 const struct files_struct
*dirfsp
,
1473 const struct smb_filename
*smb_fname
,
1474 SMB_STRUCT_STAT
*sbuf
,
1480 #ifdef HAVE_GFAPI_VER_7_11
1481 glfs_fd_t
*pglfd
= NULL
;
1483 START_PROFILE(syscall_fstatat
);
1485 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1486 if (pglfd
== NULL
) {
1487 END_PROFILE(syscall_fstatat
);
1488 DBG_ERR("Failed to fetch gluster fd\n");
1492 ret
= glfs_fstatat(pglfd
, smb_fname
->base_name
, &st
, flags
);
1494 struct smb_filename
*full_fname
= NULL
;
1496 START_PROFILE(syscall_fstatat
);
1498 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1501 if (full_fname
== NULL
) {
1502 END_PROFILE(syscall_fstatat
);
1506 ret
= glfs_stat(handle
->data
, full_fname
->base_name
, &st
);
1508 TALLOC_FREE(full_fname
->base_name
);
1512 smb_stat_ex_from_stat(sbuf
, &st
);
1515 END_PROFILE(syscall_fstatat
);
1520 static int vfs_gluster_lstat(struct vfs_handle_struct
*handle
,
1521 struct smb_filename
*smb_fname
)
1526 START_PROFILE(syscall_lstat
);
1527 ret
= glfs_lstat(handle
->data
, smb_fname
->base_name
, &st
);
1529 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
1531 if (ret
< 0 && errno
!= ENOENT
) {
1532 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1533 smb_fname
->base_name
, strerror(errno
)));
1535 END_PROFILE(syscall_lstat
);
1540 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct
*handle
,
1542 const SMB_STRUCT_STAT
*sbuf
)
1546 START_PROFILE(syscall_get_alloc_size
);
1547 ret
= sbuf
->st_ex_blocks
* 512;
1548 END_PROFILE(syscall_get_alloc_size
);
1553 static int vfs_gluster_unlinkat(struct vfs_handle_struct
*handle
,
1554 struct files_struct
*dirfsp
,
1555 const struct smb_filename
*smb_fname
,
1560 #ifdef HAVE_GFAPI_VER_7_11
1561 glfs_fd_t
*pglfd
= NULL
;
1563 START_PROFILE(syscall_unlinkat
);
1565 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
1566 if (pglfd
== NULL
) {
1567 END_PROFILE(syscall_unlinkat
);
1568 DBG_ERR("Failed to fetch gluster fd\n");
1572 ret
= glfs_unlinkat(pglfd
, smb_fname
->base_name
, flags
);
1574 struct smb_filename
*full_fname
= NULL
;
1576 START_PROFILE(syscall_unlinkat
);
1578 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1581 if (full_fname
== NULL
) {
1582 END_PROFILE(syscall_unlinkat
);
1586 if (flags
& AT_REMOVEDIR
) {
1587 ret
= glfs_rmdir(handle
->data
, full_fname
->base_name
);
1589 ret
= glfs_unlink(handle
->data
, full_fname
->base_name
);
1592 TALLOC_FREE(full_fname
);
1595 END_PROFILE(syscall_unlinkat
);
1600 static int vfs_gluster_fchmod(struct vfs_handle_struct
*handle
,
1601 files_struct
*fsp
, mode_t mode
)
1604 glfs_fd_t
*glfd
= NULL
;
1606 START_PROFILE(syscall_fchmod
);
1608 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1610 END_PROFILE(syscall_fchmod
);
1611 DBG_ERR("Failed to fetch gluster fd\n");
1615 if (!fsp
->fsp_flags
.is_pathref
) {
1617 * We can use an io_fd to remove xattrs.
1619 ret
= glfs_fchmod(glfd
, mode
);
1622 * This is no longer a handle based call.
1624 ret
= glfs_chmod(handle
->data
, fsp
->fsp_name
->base_name
, mode
);
1626 END_PROFILE(syscall_fchmod
);
1631 static int vfs_gluster_fchown(struct vfs_handle_struct
*handle
,
1632 files_struct
*fsp
, uid_t uid
, gid_t gid
)
1635 glfs_fd_t
*glfd
= NULL
;
1637 START_PROFILE(syscall_fchown
);
1639 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1641 END_PROFILE(syscall_fchown
);
1642 DBG_ERR("Failed to fetch gluster fd\n");
1646 ret
= glfs_fchown(glfd
, uid
, gid
);
1647 END_PROFILE(syscall_fchown
);
1652 static int vfs_gluster_lchown(struct vfs_handle_struct
*handle
,
1653 const struct smb_filename
*smb_fname
,
1659 START_PROFILE(syscall_lchown
);
1660 ret
= glfs_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1661 END_PROFILE(syscall_lchown
);
1666 static int vfs_gluster_chdir(struct vfs_handle_struct
*handle
,
1667 const struct smb_filename
*smb_fname
)
1671 START_PROFILE(syscall_chdir
);
1672 ret
= glfs_chdir(handle
->data
, smb_fname
->base_name
);
1673 END_PROFILE(syscall_chdir
);
1678 static struct smb_filename
*vfs_gluster_getwd(struct vfs_handle_struct
*handle
,
1681 char cwd
[PATH_MAX
] = { '\0' };
1683 struct smb_filename
*smb_fname
= NULL
;
1685 START_PROFILE(syscall_getwd
);
1687 ret
= glfs_getcwd(handle
->data
, cwd
, PATH_MAX
- 1);
1688 END_PROFILE(syscall_getwd
);
1693 smb_fname
= synthetic_smb_fname(ctx
,
1702 static int vfs_gluster_fntimes(struct vfs_handle_struct
*handle
,
1704 struct smb_file_time
*ft
)
1707 struct timespec times
[2];
1708 glfs_fd_t
*glfd
= NULL
;
1710 START_PROFILE(syscall_fntimes
);
1712 if (is_omit_timespec(&ft
->atime
)) {
1713 times
[0].tv_sec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_sec
;
1714 times
[0].tv_nsec
= fsp
->fsp_name
->st
.st_ex_atime
.tv_nsec
;
1716 times
[0].tv_sec
= ft
->atime
.tv_sec
;
1717 times
[0].tv_nsec
= ft
->atime
.tv_nsec
;
1720 if (is_omit_timespec(&ft
->mtime
)) {
1721 times
[1].tv_sec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_sec
;
1722 times
[1].tv_nsec
= fsp
->fsp_name
->st
.st_ex_mtime
.tv_nsec
;
1724 times
[1].tv_sec
= ft
->mtime
.tv_sec
;
1725 times
[1].tv_nsec
= ft
->mtime
.tv_nsec
;
1728 if ((timespec_compare(×
[0],
1729 &fsp
->fsp_name
->st
.st_ex_atime
) == 0) &&
1730 (timespec_compare(×
[1],
1731 &fsp
->fsp_name
->st
.st_ex_mtime
) == 0)) {
1732 END_PROFILE(syscall_fntimes
);
1736 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1738 END_PROFILE(syscall_fntimes
);
1739 DBG_ERR("Failed to fetch gluster fd\n");
1743 if (!fsp
->fsp_flags
.is_pathref
) {
1744 ret
= glfs_futimens(glfd
, times
);
1746 ret
= glfs_utimens(handle
->data
,
1747 fsp
->fsp_name
->base_name
,
1750 END_PROFILE(syscall_fntimes
);
1755 static int vfs_gluster_ftruncate(struct vfs_handle_struct
*handle
,
1756 files_struct
*fsp
, off_t offset
)
1759 glfs_fd_t
*glfd
= NULL
;
1761 START_PROFILE(syscall_ftruncate
);
1763 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1765 END_PROFILE(syscall_ftruncate
);
1766 DBG_ERR("Failed to fetch gluster fd\n");
1770 #ifdef HAVE_GFAPI_VER_7_6
1771 ret
= glfs_ftruncate(glfd
, offset
, NULL
, NULL
);
1773 ret
= glfs_ftruncate(glfd
, offset
);
1775 END_PROFILE(syscall_ftruncate
);
1780 static int vfs_gluster_fallocate(struct vfs_handle_struct
*handle
,
1781 struct files_struct
*fsp
,
1783 off_t offset
, off_t len
)
1786 #ifdef HAVE_GFAPI_VER_6
1787 glfs_fd_t
*glfd
= NULL
;
1788 int keep_size
, punch_hole
;
1790 START_PROFILE(syscall_fallocate
);
1792 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1794 END_PROFILE(syscall_fallocate
);
1795 DBG_ERR("Failed to fetch gluster fd\n");
1799 keep_size
= mode
& VFS_FALLOCATE_FL_KEEP_SIZE
;
1800 punch_hole
= mode
& VFS_FALLOCATE_FL_PUNCH_HOLE
;
1802 mode
&= ~(VFS_FALLOCATE_FL_KEEP_SIZE
|VFS_FALLOCATE_FL_PUNCH_HOLE
);
1804 END_PROFILE(syscall_fallocate
);
1810 ret
= glfs_discard(glfd
, offset
, len
);
1812 DBG_DEBUG("glfs_discard failed: %s\n",
1817 ret
= glfs_fallocate(glfd
, keep_size
, offset
, len
);
1818 END_PROFILE(syscall_fallocate
);
1826 static struct smb_filename
*vfs_gluster_realpath(struct vfs_handle_struct
*handle
,
1828 const struct smb_filename
*smb_fname
)
1830 char *result
= NULL
;
1831 struct smb_filename
*result_fname
= NULL
;
1832 char *resolved_path
= NULL
;
1834 START_PROFILE(syscall_realpath
);
1836 resolved_path
= SMB_MALLOC_ARRAY(char, PATH_MAX
+1);
1837 if (resolved_path
== NULL
) {
1838 END_PROFILE(syscall_realpath
);
1843 result
= glfs_realpath(handle
->data
,
1844 smb_fname
->base_name
,
1846 if (result
!= NULL
) {
1847 result_fname
= synthetic_smb_fname(ctx
,
1855 SAFE_FREE(resolved_path
);
1856 END_PROFILE(syscall_realpath
);
1858 return result_fname
;
1861 static bool vfs_gluster_lock(struct vfs_handle_struct
*handle
,
1862 files_struct
*fsp
, int op
, off_t offset
,
1863 off_t count
, int type
)
1865 struct flock flock
= { 0, };
1867 glfs_fd_t
*glfd
= NULL
;
1870 START_PROFILE(syscall_fcntl_lock
);
1872 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1874 DBG_ERR("Failed to fetch gluster fd\n");
1879 flock
.l_type
= type
;
1880 flock
.l_whence
= SEEK_SET
;
1881 flock
.l_start
= offset
;
1882 flock
.l_len
= count
;
1885 ret
= glfs_posix_lock(glfd
, op
, &flock
);
1887 if (op
== F_GETLK
) {
1888 /* lock query, true if someone else has locked */
1890 (flock
.l_type
!= F_UNLCK
) &&
1891 (flock
.l_pid
!= 0) && (flock
.l_pid
!= getpid())) {
1907 END_PROFILE(syscall_fcntl_lock
);
1912 static int vfs_gluster_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1914 uint32_t share_access
,
1915 uint32_t access_mask
)
1921 static int vfs_gluster_fcntl(vfs_handle_struct
*handle
,
1922 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1925 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1926 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1928 if (cmd
== F_GETFL
) {
1930 } else if (cmd
== F_SETFL
) {
1931 va_list dup_cmd_arg
;
1934 va_copy(dup_cmd_arg
, cmd_arg
);
1935 opt
= va_arg(dup_cmd_arg
, int);
1936 va_end(dup_cmd_arg
);
1940 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1943 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1949 static int vfs_gluster_linux_setlease(struct vfs_handle_struct
*handle
,
1950 files_struct
*fsp
, int leasetype
)
1956 static bool vfs_gluster_getlock(struct vfs_handle_struct
*handle
,
1957 files_struct
*fsp
, off_t
*poffset
,
1958 off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1960 struct flock flock
= { 0, };
1962 glfs_fd_t
*glfd
= NULL
;
1964 START_PROFILE(syscall_fcntl_getlock
);
1966 glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
1968 END_PROFILE(syscall_fcntl_getlock
);
1969 DBG_ERR("Failed to fetch gluster fd\n");
1973 flock
.l_type
= *ptype
;
1974 flock
.l_whence
= SEEK_SET
;
1975 flock
.l_start
= *poffset
;
1976 flock
.l_len
= *pcount
;
1979 ret
= glfs_posix_lock(glfd
, F_GETLK
, &flock
);
1982 END_PROFILE(syscall_fcntl_getlock
);
1986 *ptype
= flock
.l_type
;
1987 *poffset
= flock
.l_start
;
1988 *pcount
= flock
.l_len
;
1989 *ppid
= flock
.l_pid
;
1990 END_PROFILE(syscall_fcntl_getlock
);
1995 static int vfs_gluster_symlinkat(struct vfs_handle_struct
*handle
,
1996 const struct smb_filename
*link_target
,
1997 struct files_struct
*dirfsp
,
1998 const struct smb_filename
*new_smb_fname
)
2002 #ifdef HAVE_GFAPI_VER_7_11
2003 glfs_fd_t
*pglfd
= NULL
;
2005 START_PROFILE(syscall_symlinkat
);
2007 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2008 if (pglfd
== NULL
) {
2009 END_PROFILE(syscall_symlinkat
);
2010 DBG_ERR("Failed to fetch gluster fd\n");
2014 ret
= glfs_symlinkat(link_target
->base_name
,
2016 new_smb_fname
->base_name
);
2018 struct smb_filename
*full_fname
= NULL
;
2020 START_PROFILE(syscall_symlinkat
);
2022 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2025 if (full_fname
== NULL
) {
2026 END_PROFILE(syscall_symlinkat
);
2030 ret
= glfs_symlink(handle
->data
,
2031 link_target
->base_name
,
2032 full_fname
->base_name
);
2034 TALLOC_FREE(full_fname
);
2037 END_PROFILE(syscall_symlinkat
);
2042 static int vfs_gluster_readlinkat(struct vfs_handle_struct
*handle
,
2043 const struct files_struct
*dirfsp
,
2044 const struct smb_filename
*smb_fname
,
2050 #ifdef HAVE_GFAPI_VER_7_11
2051 glfs_fd_t
*pglfd
= NULL
;
2053 START_PROFILE(syscall_readlinkat
);
2055 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2056 if (pglfd
== NULL
) {
2057 END_PROFILE(syscall_readlinkat
);
2058 DBG_ERR("Failed to fetch gluster fd\n");
2062 ret
= glfs_readlinkat(pglfd
, smb_fname
->base_name
, buf
, bufsiz
);
2064 struct smb_filename
*full_fname
= NULL
;
2066 START_PROFILE(syscall_readlinkat
);
2068 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2071 if (full_fname
== NULL
) {
2072 END_PROFILE(syscall_readlinkat
);
2076 ret
= glfs_readlink(handle
->data
, full_fname
->base_name
, buf
, bufsiz
);
2078 TALLOC_FREE(full_fname
);
2081 END_PROFILE(syscall_readlinkat
);
2086 static int vfs_gluster_linkat(struct vfs_handle_struct
*handle
,
2087 files_struct
*srcfsp
,
2088 const struct smb_filename
*old_smb_fname
,
2089 files_struct
*dstfsp
,
2090 const struct smb_filename
*new_smb_fname
,
2095 #ifdef HAVE_GFAPI_VER_7_11
2096 glfs_fd_t
*src_pglfd
= NULL
;
2097 glfs_fd_t
*dst_pglfd
= NULL
;
2099 START_PROFILE(syscall_linkat
);
2101 src_pglfd
= vfs_gluster_fetch_glfd(handle
, srcfsp
);
2102 if (src_pglfd
== NULL
) {
2103 END_PROFILE(syscall_linkat
);
2104 DBG_ERR("Failed to fetch gluster fd\n");
2108 dst_pglfd
= vfs_gluster_fetch_glfd(handle
, dstfsp
);
2109 if (dst_pglfd
== NULL
) {
2110 END_PROFILE(syscall_linkat
);
2111 DBG_ERR("Failed to fetch gluster fd\n");
2115 ret
= glfs_linkat(src_pglfd
,
2116 old_smb_fname
->base_name
,
2118 new_smb_fname
->base_name
,
2121 struct smb_filename
*full_fname_old
= NULL
;
2122 struct smb_filename
*full_fname_new
= NULL
;
2124 START_PROFILE(syscall_linkat
);
2126 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
2129 if (full_fname_old
== NULL
) {
2130 END_PROFILE(syscall_linkat
);
2134 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
2137 if (full_fname_new
== NULL
) {
2138 END_PROFILE(syscall_linkat
);
2139 TALLOC_FREE(full_fname_old
);
2143 ret
= glfs_link(handle
->data
,
2144 full_fname_old
->base_name
,
2145 full_fname_new
->base_name
);
2147 TALLOC_FREE(full_fname_old
);
2148 TALLOC_FREE(full_fname_new
);
2151 END_PROFILE(syscall_linkat
);
2156 static int vfs_gluster_mknodat(struct vfs_handle_struct
*handle
,
2157 files_struct
*dirfsp
,
2158 const struct smb_filename
*smb_fname
,
2164 #ifdef HAVE_GFAPI_VER_7_11
2165 glfs_fd_t
*pglfd
= NULL
;
2167 START_PROFILE(syscall_mknodat
);
2169 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2170 if (pglfd
== NULL
) {
2171 END_PROFILE(syscall_mknodat
);
2172 DBG_ERR("Failed to fetch gluster fd\n");
2176 ret
= glfs_mknodat(pglfd
, smb_fname
->base_name
, mode
, dev
);
2178 struct smb_filename
*full_fname
= NULL
;
2180 START_PROFILE(syscall_mknodat
);
2182 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2185 if (full_fname
== NULL
) {
2186 END_PROFILE(syscall_mknodat
);
2190 ret
= glfs_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
2192 TALLOC_FREE(full_fname
);
2195 END_PROFILE(syscall_mknodat
);
2200 static int vfs_gluster_fchflags(struct vfs_handle_struct
*handle
,
2201 struct files_struct
*fsp
,
2208 static NTSTATUS
vfs_gluster_get_real_filename_at(
2209 struct vfs_handle_struct
*handle
,
2210 struct files_struct
*dirfsp
,
2212 TALLOC_CTX
*mem_ctx
,
2216 char key_buf
[GLUSTER_NAME_MAX
+ 64];
2217 char val_buf
[GLUSTER_NAME_MAX
+ 1];
2219 if (strlen(name
) >= GLUSTER_NAME_MAX
) {
2220 return NT_STATUS_OBJECT_NAME_INVALID
;
2223 snprintf(key_buf
, GLUSTER_NAME_MAX
+ 64,
2224 "glusterfs.get_real_filename:%s", name
);
2226 ret
= glfs_getxattr(handle
->data
,
2227 dirfsp
->fsp_name
->base_name
,
2230 GLUSTER_NAME_MAX
+ 1);
2232 if (errno
== ENOATTR
) {
2235 return map_nt_error_from_unix(errno
);
2238 *found_name
= talloc_strdup(mem_ctx
, val_buf
);
2239 if (found_name
[0] == NULL
) {
2240 return NT_STATUS_NO_MEMORY
;
2243 return NT_STATUS_OK
;
2246 static const char *vfs_gluster_connectpath(
2247 struct vfs_handle_struct
*handle
,
2248 const struct files_struct
*dirfsp
,
2249 const struct smb_filename
*smb_fname
)
2251 return handle
->conn
->connectpath
;
2256 static ssize_t
vfs_gluster_fgetxattr(struct vfs_handle_struct
*handle
,
2257 files_struct
*fsp
, const char *name
,
2258 void *value
, size_t size
)
2260 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2262 DBG_ERR("Failed to fetch gluster fd\n");
2266 if (!fsp
->fsp_flags
.is_pathref
) {
2268 * We can use an io_fd to retrieve xattr value.
2270 return glfs_fgetxattr(glfd
, name
, value
, size
);
2274 * This is no longer a handle based call.
2276 return glfs_getxattr(handle
->data
,
2277 fsp
->fsp_name
->base_name
,
2283 static ssize_t
vfs_gluster_flistxattr(struct vfs_handle_struct
*handle
,
2284 files_struct
*fsp
, char *list
,
2287 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2289 DBG_ERR("Failed to fetch gluster fd\n");
2292 if (!fsp
->fsp_flags
.is_pathref
) {
2294 * We can use an io_fd to list xattrs.
2296 return glfs_flistxattr(glfd
, list
, size
);
2299 * This is no longer a handle based call.
2301 return glfs_listxattr(handle
->data
,
2302 fsp
->fsp_name
->base_name
,
2308 static int vfs_gluster_fremovexattr(struct vfs_handle_struct
*handle
,
2309 files_struct
*fsp
, const char *name
)
2311 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2313 DBG_ERR("Failed to fetch gluster fd\n");
2316 if (!fsp
->fsp_flags
.is_pathref
) {
2318 * We can use an io_fd to remove xattrs.
2320 return glfs_fremovexattr(glfd
, name
);
2323 * This is no longer a handle based call.
2325 return glfs_removexattr(handle
->data
,
2326 fsp
->fsp_name
->base_name
,
2331 static int vfs_gluster_fsetxattr(struct vfs_handle_struct
*handle
,
2332 files_struct
*fsp
, const char *name
,
2333 const void *value
, size_t size
, int flags
)
2335 glfs_fd_t
*glfd
= vfs_gluster_fetch_glfd(handle
, fsp
);
2337 DBG_ERR("Failed to fetch gluster fd\n");
2341 if (!fsp
->fsp_flags
.is_pathref
) {
2343 * We can use an io_fd to set xattrs.
2345 return glfs_fsetxattr(glfd
, name
, value
, size
, flags
);
2348 * This is no longer a handle based call.
2350 return glfs_setxattr(handle
->data
,
2351 fsp
->fsp_name
->base_name
,
2359 /* AIO Operations */
2361 static bool vfs_gluster_aio_force(struct vfs_handle_struct
*handle
,
2367 static NTSTATUS
vfs_gluster_create_dfs_pathat(struct vfs_handle_struct
*handle
,
2368 struct files_struct
*dirfsp
,
2369 const struct smb_filename
*smb_fname
,
2370 const struct referral
*reflist
,
2371 size_t referral_count
)
2373 TALLOC_CTX
*frame
= talloc_stackframe();
2374 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2376 char *msdfs_link
= NULL
;
2377 #ifdef HAVE_GFAPI_VER_7_11
2378 glfs_fd_t
*pglfd
= NULL
;
2380 struct smb_filename
*full_fname
= NULL
;
2383 /* Form the msdfs_link contents */
2384 msdfs_link
= msdfs_link_string(frame
,
2387 if (msdfs_link
== NULL
) {
2391 #ifdef HAVE_GFAPI_VER_7_11
2392 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2393 if (pglfd
== NULL
) {
2394 DBG_ERR("Failed to fetch gluster fd\n");
2395 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2399 ret
= glfs_symlinkat(msdfs_link
, pglfd
, smb_fname
->base_name
);
2401 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2404 if (full_fname
== NULL
) {
2408 ret
= glfs_symlink(handle
->data
, msdfs_link
, full_fname
->base_name
);
2410 TALLOC_FREE(full_fname
);
2413 status
= NT_STATUS_OK
;
2415 status
= map_nt_error_from_unix(errno
);
2425 * Read and return the contents of a DFS redirect given a
2426 * pathname. A caller can pass in NULL for ppreflist and
2427 * preferral_count but still determine if this was a
2428 * DFS redirect point by getting NT_STATUS_OK back
2429 * without incurring the overhead of reading and parsing
2430 * the referral contents.
2433 static NTSTATUS
vfs_gluster_read_dfs_pathat(struct vfs_handle_struct
*handle
,
2434 TALLOC_CTX
*mem_ctx
,
2435 struct files_struct
*dirfsp
,
2436 struct smb_filename
*smb_fname
,
2437 struct referral
**ppreflist
,
2438 size_t *preferral_count
)
2440 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
2442 char *link_target
= NULL
;
2445 #if defined(HAVE_BROKEN_READLINK)
2446 char link_target_buf
[PATH_MAX
];
2448 char link_target_buf
[7];
2451 struct smb_filename
*full_fname
= NULL
;
2453 #ifdef HAVE_GFAPI_VER_7_11
2454 glfs_fd_t
*pglfd
= NULL
;
2457 if (is_named_stream(smb_fname
)) {
2458 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2462 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2464 * We're only checking if this is a DFS
2465 * redirect. We don't need to return data.
2467 bufsize
= sizeof(link_target_buf
);
2468 link_target
= link_target_buf
;
2471 link_target
= talloc_array(mem_ctx
, char, bufsize
);
2477 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
2480 if (full_fname
== NULL
) {
2481 status
= NT_STATUS_NO_MEMORY
;
2485 ret
= glfs_lstat(handle
->data
, full_fname
->base_name
, &st
);
2487 status
= map_nt_error_from_unix(errno
);
2491 #ifdef HAVE_GFAPI_VER_7_11
2492 pglfd
= vfs_gluster_fetch_glfd(handle
, dirfsp
);
2493 if (pglfd
== NULL
) {
2494 DBG_ERR("Failed to fetch gluster fd\n");
2495 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
2498 referral_len
= glfs_readlinkat(pglfd
,
2499 smb_fname
->base_name
,
2503 referral_len
= glfs_readlink(handle
->data
,
2504 full_fname
->base_name
,
2508 if (referral_len
< 0) {
2509 if (errno
== EINVAL
) {
2510 DBG_INFO("%s is not a link.\n", full_fname
->base_name
);
2511 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2513 status
= map_nt_error_from_unix(errno
);
2514 DBG_ERR("Error reading "
2515 "msdfs link %s: %s\n",
2516 full_fname
->base_name
,
2521 link_target
[referral_len
] = '\0';
2523 DBG_INFO("%s -> %s\n",
2524 full_fname
->base_name
,
2527 if (!strnequal(link_target
, "msdfs:", 6)) {
2528 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
2532 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
2533 /* Early return for checking if this is a DFS link. */
2534 TALLOC_FREE(full_fname
);
2535 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2536 return NT_STATUS_OK
;
2539 ok
= parse_msdfs_symlink(mem_ctx
,
2540 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
2546 smb_stat_ex_from_stat(&smb_fname
->st
, &st
);
2547 status
= NT_STATUS_OK
;
2549 status
= NT_STATUS_NO_MEMORY
;
2554 if (link_target
!= link_target_buf
) {
2555 TALLOC_FREE(link_target
);
2557 TALLOC_FREE(full_fname
);
2561 static struct vfs_fn_pointers glusterfs_fns
= {
2563 /* Disk Operations */
2565 .connect_fn
= vfs_gluster_connect
,
2566 .disconnect_fn
= vfs_gluster_disconnect
,
2567 .disk_free_fn
= vfs_gluster_disk_free
,
2568 .get_quota_fn
= vfs_gluster_get_quota
,
2569 .set_quota_fn
= vfs_gluster_set_quota
,
2570 .statvfs_fn
= vfs_gluster_statvfs
,
2571 .fs_capabilities_fn
= vfs_gluster_fs_capabilities
,
2573 .get_dfs_referrals_fn
= NULL
,
2575 /* Directory Operations */
2577 .fdopendir_fn
= vfs_gluster_fdopendir
,
2578 .readdir_fn
= vfs_gluster_readdir
,
2579 .rewind_dir_fn
= vfs_gluster_rewinddir
,
2580 .mkdirat_fn
= vfs_gluster_mkdirat
,
2581 .closedir_fn
= vfs_gluster_closedir
,
2583 /* File Operations */
2585 .openat_fn
= vfs_gluster_openat
,
2586 .create_file_fn
= NULL
,
2587 .close_fn
= vfs_gluster_close
,
2588 .pread_fn
= vfs_gluster_pread
,
2589 .pread_send_fn
= vfs_gluster_pread_send
,
2590 .pread_recv_fn
= vfs_gluster_pread_recv
,
2591 .pwrite_fn
= vfs_gluster_pwrite
,
2592 .pwrite_send_fn
= vfs_gluster_pwrite_send
,
2593 .pwrite_recv_fn
= vfs_gluster_pwrite_recv
,
2594 .lseek_fn
= vfs_gluster_lseek
,
2595 .sendfile_fn
= vfs_gluster_sendfile
,
2596 .recvfile_fn
= vfs_gluster_recvfile
,
2597 .renameat_fn
= vfs_gluster_renameat
,
2598 .fsync_send_fn
= vfs_gluster_fsync_send
,
2599 .fsync_recv_fn
= vfs_gluster_fsync_recv
,
2601 .stat_fn
= vfs_gluster_stat
,
2602 .fstat_fn
= vfs_gluster_fstat
,
2603 .fstatat_fn
= vfs_gluster_fstatat
,
2604 .lstat_fn
= vfs_gluster_lstat
,
2605 .get_alloc_size_fn
= vfs_gluster_get_alloc_size
,
2606 .unlinkat_fn
= vfs_gluster_unlinkat
,
2608 .fchmod_fn
= vfs_gluster_fchmod
,
2609 .fchown_fn
= vfs_gluster_fchown
,
2610 .lchown_fn
= vfs_gluster_lchown
,
2611 .chdir_fn
= vfs_gluster_chdir
,
2612 .getwd_fn
= vfs_gluster_getwd
,
2613 .fntimes_fn
= vfs_gluster_fntimes
,
2614 .ftruncate_fn
= vfs_gluster_ftruncate
,
2615 .fallocate_fn
= vfs_gluster_fallocate
,
2616 .lock_fn
= vfs_gluster_lock
,
2617 .filesystem_sharemode_fn
= vfs_gluster_filesystem_sharemode
,
2618 .fcntl_fn
= vfs_gluster_fcntl
,
2619 .linux_setlease_fn
= vfs_gluster_linux_setlease
,
2620 .getlock_fn
= vfs_gluster_getlock
,
2621 .symlinkat_fn
= vfs_gluster_symlinkat
,
2622 .readlinkat_fn
= vfs_gluster_readlinkat
,
2623 .linkat_fn
= vfs_gluster_linkat
,
2624 .mknodat_fn
= vfs_gluster_mknodat
,
2625 .realpath_fn
= vfs_gluster_realpath
,
2626 .fchflags_fn
= vfs_gluster_fchflags
,
2627 .file_id_create_fn
= NULL
,
2628 .fstreaminfo_fn
= NULL
,
2629 .get_real_filename_at_fn
= vfs_gluster_get_real_filename_at
,
2630 .connectpath_fn
= vfs_gluster_connectpath
,
2631 .create_dfs_pathat_fn
= vfs_gluster_create_dfs_pathat
,
2632 .read_dfs_pathat_fn
= vfs_gluster_read_dfs_pathat
,
2634 .brl_lock_windows_fn
= NULL
,
2635 .brl_unlock_windows_fn
= NULL
,
2636 .strict_lock_check_fn
= NULL
,
2637 .translate_name_fn
= NULL
,
2640 /* NT ACL Operations */
2641 .fget_nt_acl_fn
= NULL
,
2642 .fset_nt_acl_fn
= NULL
,
2643 .audit_file_fn
= NULL
,
2645 /* Posix ACL Operations */
2646 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
2647 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
2648 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
2649 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
2652 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
2653 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
2654 .fgetxattr_fn
= vfs_gluster_fgetxattr
,
2655 .flistxattr_fn
= vfs_gluster_flistxattr
,
2656 .fremovexattr_fn
= vfs_gluster_fremovexattr
,
2657 .fsetxattr_fn
= vfs_gluster_fsetxattr
,
2659 /* AIO Operations */
2660 .aio_force_fn
= vfs_gluster_aio_force
,
2662 /* Durable handle Operations */
2663 .durable_cookie_fn
= NULL
,
2664 .durable_disconnect_fn
= NULL
,
2665 .durable_reconnect_fn
= NULL
,
2669 NTSTATUS
vfs_glusterfs_init(TALLOC_CTX
*ctx
)
2671 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2672 "glusterfs", &glusterfs_fns
);