s3:smb_macros.h: add IS_AD_DC as addition to IS_DC
[Samba.git] / source3 / modules / vfs_glusterfs.c
blobf9a96fa004d3ddc72832f74104b7035a328004ad
1 /*
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/>.
22 /**
23 * @file vfs_glusterfs.c
24 * @author Anand Avati <avati@redhat.com>
25 * @date May 2013
26 * @brief Samba VFS module for glusterfs
28 * @todo
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.
38 #include "includes.h"
39 #include "smbd/smbd.h"
40 #include <stdio.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"
49 #define DEFAULT_VOLFILE_SERVER "localhost"
51 static int read_fd = -1;
52 static int write_fd = -1;
53 static struct tevent_fd *aio_read_event = NULL;
55 /**
56 * Helper to convert struct stat to struct stat_ex.
58 static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
60 ZERO_STRUCTP(dst);
62 dst->st_ex_dev = src->st_dev;
63 dst->st_ex_ino = src->st_ino;
64 dst->st_ex_mode = src->st_mode;
65 dst->st_ex_nlink = src->st_nlink;
66 dst->st_ex_uid = src->st_uid;
67 dst->st_ex_gid = src->st_gid;
68 dst->st_ex_rdev = src->st_rdev;
69 dst->st_ex_size = src->st_size;
70 dst->st_ex_atime.tv_sec = src->st_atime;
71 dst->st_ex_mtime.tv_sec = src->st_mtime;
72 dst->st_ex_ctime.tv_sec = src->st_ctime;
73 dst->st_ex_btime.tv_sec = src->st_mtime;
74 dst->st_ex_blksize = src->st_blksize;
75 dst->st_ex_blocks = src->st_blocks;
76 #ifdef STAT_HAVE_NSEC
77 dst->st_ex_atime.tv_nsec = src->st_atime_nsec;
78 dst->st_ex_mtime.tv_nsec = src->st_mtime_nsec;
79 dst->st_ex_ctime.tv_nsec = src->st_ctime_nsec;
80 dst->st_ex_btime.tv_nsec = src->st_mtime_nsec;
81 #endif
84 /* pre-opened glfs_t */
86 static struct glfs_preopened {
87 char *volume;
88 char *connectpath;
89 glfs_t *fs;
90 int ref;
91 struct glfs_preopened *next, *prev;
92 } *glfs_preopened;
95 static int glfs_set_preopened(const char *volume, const char *connectpath, glfs_t *fs)
97 struct glfs_preopened *entry = NULL;
99 entry = talloc_zero(NULL, struct glfs_preopened);
100 if (!entry) {
101 errno = ENOMEM;
102 return -1;
105 entry->volume = talloc_strdup(entry, volume);
106 if (!entry->volume) {
107 talloc_free(entry);
108 errno = ENOMEM;
109 return -1;
112 entry->connectpath = talloc_strdup(entry, connectpath);
113 if (entry->connectpath == NULL) {
114 talloc_free(entry);
115 errno = ENOMEM;
116 return -1;
119 entry->fs = fs;
120 entry->ref = 1;
122 DLIST_ADD(glfs_preopened, entry);
124 return 0;
127 static glfs_t *glfs_find_preopened(const char *volume, const char *connectpath)
129 struct glfs_preopened *entry = NULL;
131 for (entry = glfs_preopened; entry; entry = entry->next) {
132 if (strcmp(entry->volume, volume) == 0 &&
133 strcmp(entry->connectpath, connectpath) == 0)
135 entry->ref++;
136 return entry->fs;
140 return NULL;
143 static void glfs_clear_preopened(glfs_t *fs)
145 struct glfs_preopened *entry = NULL;
147 for (entry = glfs_preopened; entry; entry = entry->next) {
148 if (entry->fs == fs) {
149 if (--entry->ref)
150 return;
152 DLIST_REMOVE(glfs_preopened, entry);
154 glfs_fini(entry->fs);
155 talloc_free(entry);
160 static int vfs_gluster_set_volfile_servers(glfs_t *fs,
161 const char *volfile_servers)
163 char *server = NULL;
164 int server_count = 0;
165 int server_success = 0;
166 int ret = -1;
167 TALLOC_CTX *frame = talloc_stackframe();
169 DBG_INFO("servers list %s\n", volfile_servers);
171 while (next_token_talloc(frame, &volfile_servers, &server, " \t")) {
172 char *transport = NULL;
173 char *host = NULL;
174 int port = 0;
176 server_count++;
177 DBG_INFO("server %d %s\n", server_count, server);
179 /* Determine the transport type */
180 if (strncmp(server, "unix+", 5) == 0) {
181 port = 0;
182 transport = talloc_strdup(frame, "unix");
183 if (!transport) {
184 errno = ENOMEM;
185 goto out;
187 host = talloc_strdup(frame, server + 5);
188 if (!host) {
189 errno = ENOMEM;
190 goto out;
192 } else {
193 char *p = NULL;
194 char *port_index = NULL;
196 if (strncmp(server, "tcp+", 4) == 0) {
197 server += 4;
200 /* IPv6 is enclosed in []
201 * ':' before ']' is part of IPv6
202 * ':' after ']' indicates port
204 p = server;
205 if (server[0] == '[') {
206 server++;
207 p = index(server, ']');
208 if (p == NULL) {
209 /* Malformed IPv6 */
210 continue;
212 p[0] = '\0';
213 p++;
216 port_index = index(p, ':');
218 if (port_index == NULL) {
219 port = 0;
220 } else {
221 port = atoi(port_index + 1);
222 port_index[0] = '\0';
224 transport = talloc_strdup(frame, "tcp");
225 if (!transport) {
226 errno = ENOMEM;
227 goto out;
229 host = talloc_strdup(frame, server);
230 if (!host) {
231 errno = ENOMEM;
232 goto out;
236 DBG_INFO("Calling set volfile server with params "
237 "transport=%s, host=%s, port=%d\n", transport,
238 host, port);
240 ret = glfs_set_volfile_server(fs, transport, host, port);
241 if (ret < 0) {
242 DBG_WARNING("Failed to set volfile_server "
243 "transport=%s, host=%s, port=%d (%s)\n",
244 transport, host, port, strerror(errno));
245 } else {
246 server_success++;
250 out:
251 if (server_count == 0) {
252 ret = -1;
253 } else if (server_success < server_count) {
254 DBG_WARNING("Failed to set %d out of %d servers parsed\n",
255 server_count - server_success, server_count);
256 ret = 0;
259 TALLOC_FREE(frame);
260 return ret;
263 /* Disk Operations */
265 static int vfs_gluster_connect(struct vfs_handle_struct *handle,
266 const char *service,
267 const char *user)
269 const char *volfile_servers;
270 const char *volume;
271 char *logfile;
272 int loglevel;
273 glfs_t *fs = NULL;
274 TALLOC_CTX *tmp_ctx;
275 int ret = 0;
277 tmp_ctx = talloc_new(NULL);
278 if (tmp_ctx == NULL) {
279 ret = -1;
280 goto done;
282 logfile = lp_parm_talloc_string(tmp_ctx, SNUM(handle->conn), "glusterfs",
283 "logfile", NULL);
285 loglevel = lp_parm_int(SNUM(handle->conn), "glusterfs", "loglevel", -1);
287 volfile_servers = lp_parm_talloc_string(tmp_ctx, SNUM(handle->conn),
288 "glusterfs", "volfile_server",
289 NULL);
290 if (volfile_servers == NULL) {
291 volfile_servers = DEFAULT_VOLFILE_SERVER;
294 volume = lp_parm_const_string(SNUM(handle->conn), "glusterfs", "volume",
295 NULL);
296 if (volume == NULL) {
297 volume = service;
300 fs = glfs_find_preopened(volume, handle->conn->connectpath);
301 if (fs) {
302 goto done;
305 fs = glfs_new(volume);
306 if (fs == NULL) {
307 ret = -1;
308 goto done;
311 ret = vfs_gluster_set_volfile_servers(fs, volfile_servers);
312 if (ret < 0) {
313 DBG_ERR("Failed to set volfile_servers from list %s\n",
314 volfile_servers);
315 goto done;
318 ret = glfs_set_xlator_option(fs, "*-md-cache", "cache-posix-acl",
319 "true");
320 if (ret < 0) {
321 DEBUG(0, ("%s: Failed to set xlator options\n", volume));
322 goto done;
326 ret = glfs_set_xlator_option(fs, "*-snapview-client",
327 "snapdir-entry-path",
328 handle->conn->connectpath);
329 if (ret < 0) {
330 DEBUG(0, ("%s: Failed to set xlator option:"
331 " snapdir-entry-path\n", volume));
332 goto done;
335 ret = glfs_set_logging(fs, logfile, loglevel);
336 if (ret < 0) {
337 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
338 volume, logfile, loglevel));
339 goto done;
342 ret = glfs_init(fs);
343 if (ret < 0) {
344 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
345 volume, strerror(errno)));
346 goto done;
349 ret = glfs_set_preopened(volume, handle->conn->connectpath, fs);
350 if (ret < 0) {
351 DEBUG(0, ("%s: Failed to register volume (%s)\n",
352 volume, strerror(errno)));
353 goto done;
357 * The shadow_copy2 module will fail to export subdirectories
358 * of a gluster volume unless we specify the mount point,
359 * because the detection fails if the file system is not
360 * locally mounted:
361 * https://bugzilla.samba.org/show_bug.cgi?id=13091
363 lp_do_parameter(SNUM(handle->conn), "shadow:mountpoint", "/");
365 done:
366 if (ret < 0) {
367 if (fs)
368 glfs_fini(fs);
369 } else {
370 DBG_ERR("%s: Initialized volume from servers %s\n",
371 volume, volfile_servers);
372 handle->data = fs;
374 talloc_free(tmp_ctx);
375 return ret;
378 static void vfs_gluster_disconnect(struct vfs_handle_struct *handle)
380 glfs_t *fs = NULL;
382 fs = handle->data;
384 glfs_clear_preopened(fs);
387 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
388 const struct smb_filename *smb_fname,
389 uint64_t *bsize_p,
390 uint64_t *dfree_p,
391 uint64_t *dsize_p)
393 struct statvfs statvfs = { 0, };
394 int ret;
396 ret = glfs_statvfs(handle->data, smb_fname->base_name, &statvfs);
397 if (ret < 0) {
398 return -1;
401 if (bsize_p != NULL) {
402 *bsize_p = (uint64_t)statvfs.f_bsize; /* Block size */
404 if (dfree_p != NULL) {
405 *dfree_p = (uint64_t)statvfs.f_bavail; /* Available Block units */
407 if (dsize_p != NULL) {
408 *dsize_p = (uint64_t)statvfs.f_blocks; /* Total Block units */
411 return (uint64_t)statvfs.f_bavail;
414 static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
415 const struct smb_filename *smb_fname,
416 enum SMB_QUOTA_TYPE qtype,
417 unid_t id,
418 SMB_DISK_QUOTA *qt)
420 errno = ENOSYS;
421 return -1;
424 static int
425 vfs_gluster_set_quota(struct vfs_handle_struct *handle,
426 enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
428 errno = ENOSYS;
429 return -1;
432 static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
433 const struct smb_filename *smb_fname,
434 struct vfs_statvfs_struct *vfs_statvfs)
436 struct statvfs statvfs = { 0, };
437 int ret;
439 ret = glfs_statvfs(handle->data, smb_fname->base_name, &statvfs);
440 if (ret < 0) {
441 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
442 smb_fname->base_name, strerror(errno)));
443 return -1;
446 ZERO_STRUCTP(vfs_statvfs);
448 vfs_statvfs->OptimalTransferSize = statvfs.f_frsize;
449 vfs_statvfs->BlockSize = statvfs.f_bsize;
450 vfs_statvfs->TotalBlocks = statvfs.f_blocks;
451 vfs_statvfs->BlocksAvail = statvfs.f_bfree;
452 vfs_statvfs->UserBlocksAvail = statvfs.f_bavail;
453 vfs_statvfs->TotalFileNodes = statvfs.f_files;
454 vfs_statvfs->FreeFileNodes = statvfs.f_ffree;
455 vfs_statvfs->FsIdentifier = statvfs.f_fsid;
456 vfs_statvfs->FsCapabilities =
457 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
459 return ret;
462 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle,
463 enum timestamp_set_resolution *p_ts_res)
465 uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
467 #ifdef HAVE_GFAPI_VER_6
468 caps |= FILE_SUPPORTS_SPARSE_FILES;
469 #endif
471 #ifdef STAT_HAVE_NSEC
472 *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
473 #endif
475 return caps;
478 static DIR *vfs_gluster_opendir(struct vfs_handle_struct *handle,
479 const struct smb_filename *smb_fname,
480 const char *mask,
481 uint32_t attributes)
483 glfs_fd_t *fd;
485 fd = glfs_opendir(handle->data, smb_fname->base_name);
486 if (fd == NULL) {
487 DEBUG(0, ("glfs_opendir(%s) failed: %s\n",
488 smb_fname->base_name, strerror(errno)));
491 return (DIR *) fd;
494 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle,
495 files_struct *fsp, const char *mask,
496 uint32_t attributes)
498 return (DIR *) *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
501 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
503 return glfs_closedir((void *)dirp);
506 static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
507 DIR *dirp, SMB_STRUCT_STAT *sbuf)
509 static char direntbuf[512];
510 int ret;
511 struct stat stat;
512 struct dirent *dirent = 0;
514 if (sbuf != NULL) {
515 ret = glfs_readdirplus_r((void *)dirp, &stat, (void *)direntbuf,
516 &dirent);
517 } else {
518 ret = glfs_readdir_r((void *)dirp, (void *)direntbuf, &dirent);
521 if ((ret < 0) || (dirent == NULL)) {
522 return NULL;
525 if (sbuf != NULL) {
526 smb_stat_ex_from_stat(sbuf, &stat);
529 return dirent;
532 static long vfs_gluster_telldir(struct vfs_handle_struct *handle, DIR *dirp)
534 return glfs_telldir((void *)dirp);
537 static void vfs_gluster_seekdir(struct vfs_handle_struct *handle, DIR *dirp,
538 long offset)
540 glfs_seekdir((void *)dirp, offset);
543 static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
545 glfs_seekdir((void *)dirp, 0);
548 static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
549 const struct smb_filename *smb_fname,
550 mode_t mode)
552 return glfs_mkdir(handle->data, smb_fname->base_name, mode);
555 static int vfs_gluster_rmdir(struct vfs_handle_struct *handle,
556 const struct smb_filename *smb_fname)
558 return glfs_rmdir(handle->data, smb_fname->base_name);
561 static int vfs_gluster_open(struct vfs_handle_struct *handle,
562 struct smb_filename *smb_fname, files_struct *fsp,
563 int flags, mode_t mode)
565 glfs_fd_t *glfd;
566 glfs_fd_t **p_tmp;
568 if (flags & O_DIRECTORY) {
569 glfd = glfs_opendir(handle->data, smb_fname->base_name);
570 } else if (flags & O_CREAT) {
571 glfd = glfs_creat(handle->data, smb_fname->base_name, flags,
572 mode);
573 } else {
574 glfd = glfs_open(handle->data, smb_fname->base_name, flags);
577 if (glfd == NULL) {
578 return -1;
580 p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
581 *p_tmp = glfd;
582 /* An arbitrary value for error reporting, so you know its us. */
583 return 13371337;
586 static int vfs_gluster_close(struct vfs_handle_struct *handle,
587 files_struct *fsp)
589 glfs_fd_t *glfd;
590 glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
591 VFS_REMOVE_FSP_EXTENSION(handle, fsp);
592 return glfs_close(glfd);
595 static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
596 files_struct *fsp, void *data, size_t n)
598 return glfs_read(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
601 static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
602 files_struct *fsp, void *data, size_t n,
603 off_t offset)
605 return glfs_pread(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, offset, 0);
608 struct glusterfs_aio_state;
610 struct glusterfs_aio_wrapper {
611 struct glusterfs_aio_state *state;
614 struct glusterfs_aio_state {
615 ssize_t ret;
616 struct tevent_req *req;
617 bool cancelled;
618 struct vfs_aio_state vfs_aio_state;
619 struct timespec start;
622 static int aio_wrapper_destructor(struct glusterfs_aio_wrapper *wrap)
624 if (wrap->state != NULL) {
625 wrap->state->cancelled = true;
628 return 0;
632 * This function is the callback that will be called on glusterfs
633 * threads once the async IO submitted is complete. To notify
634 * Samba of the completion we use a pipe based queue.
636 static void aio_glusterfs_done(glfs_fd_t *fd, ssize_t ret, void *data)
638 struct glusterfs_aio_state *state = NULL;
639 int sts = 0;
640 struct timespec end;
642 state = (struct glusterfs_aio_state *)data;
644 PROFILE_TIMESTAMP(&end);
646 if (ret < 0) {
647 state->ret = -1;
648 state->vfs_aio_state.error = errno;
649 } else {
650 state->ret = ret;
652 state->vfs_aio_state.duration = nsec_time_diff(&end, &state->start);
655 * Write the state pointer to glusterfs_aio_state to the
656 * pipe, so we can call tevent_req_done() from the main thread,
657 * because tevent_req_done() is not designed to be executed in
658 * the multithread environment, so tevent_req_done() must be
659 * executed from the smbd main thread.
661 * write(2) on pipes with sizes under _POSIX_PIPE_BUF
662 * in size is atomic, without this, the use op pipes in this
663 * code would not work.
665 * sys_write is a thin enough wrapper around write(2)
666 * that we can trust it here.
669 sts = sys_write(write_fd, &state, sizeof(struct glusterfs_aio_state *));
670 if (sts < 0) {
671 DEBUG(0,("\nWrite to pipe failed (%s)", strerror(errno)));
674 return;
678 * Read each req off the pipe and process it.
680 static void aio_tevent_fd_done(struct tevent_context *event_ctx,
681 struct tevent_fd *fde,
682 uint16_t flags, void *data)
684 struct tevent_req *req = NULL;
685 struct glusterfs_aio_state *state = NULL;
686 int sts = 0;
689 * read(2) on pipes is atomic if the needed data is available
690 * in the pipe, per SUS and POSIX. Because we always write
691 * to the pipe in sizeof(struct tevent_req *) chunks, we can
692 * always read in those chunks, atomically.
694 * sys_read is a thin enough wrapper around read(2) that we
695 * can trust it here.
698 sts = sys_read(read_fd, &state, sizeof(struct glusterfs_aio_state *));
700 if (sts < 0) {
701 DEBUG(0,("\nRead from pipe failed (%s)", strerror(errno)));
704 /* if we've cancelled the op, there is no req, so just clean up. */
705 if (state->cancelled == true) {
706 TALLOC_FREE(state);
707 return;
710 req = state->req;
712 if (req) {
713 tevent_req_done(req);
715 return;
718 static bool init_gluster_aio(struct vfs_handle_struct *handle)
720 int fds[2];
721 int ret = -1;
723 if (read_fd != -1) {
725 * Already initialized.
727 return true;
730 ret = pipe(fds);
731 if (ret == -1) {
732 goto fail;
735 read_fd = fds[0];
736 write_fd = fds[1];
738 aio_read_event = tevent_add_fd(handle->conn->sconn->ev_ctx,
739 NULL,
740 read_fd,
741 TEVENT_FD_READ,
742 aio_tevent_fd_done,
743 NULL);
744 if (aio_read_event == NULL) {
745 goto fail;
748 return true;
749 fail:
750 TALLOC_FREE(aio_read_event);
751 if (read_fd != -1) {
752 close(read_fd);
753 close(write_fd);
754 read_fd = -1;
755 write_fd = -1;
757 return false;
760 static struct glusterfs_aio_state *aio_state_create(TALLOC_CTX *mem_ctx)
762 struct tevent_req *req = NULL;
763 struct glusterfs_aio_state *state = NULL;
764 struct glusterfs_aio_wrapper *wrapper = NULL;
766 req = tevent_req_create(mem_ctx, &wrapper, struct glusterfs_aio_wrapper);
768 if (req == NULL) {
769 return NULL;
772 state = talloc_zero(NULL, struct glusterfs_aio_state);
774 if (state == NULL) {
775 TALLOC_FREE(req);
776 return NULL;
779 talloc_set_destructor(wrapper, aio_wrapper_destructor);
780 state->cancelled = false;
781 state->req = req;
783 wrapper->state = state;
785 return state;
788 static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
789 *handle, TALLOC_CTX *mem_ctx,
790 struct tevent_context *ev,
791 files_struct *fsp,
792 void *data, size_t n,
793 off_t offset)
795 struct glusterfs_aio_state *state = NULL;
796 struct tevent_req *req = NULL;
797 int ret = 0;
799 state = aio_state_create(mem_ctx);
801 if (state == NULL) {
802 return NULL;
805 req = state->req;
807 if (!init_gluster_aio(handle)) {
808 tevent_req_error(req, EIO);
809 return tevent_req_post(req, ev);
812 PROFILE_TIMESTAMP(&state->start);
813 ret = glfs_pread_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
814 fsp), data, n, offset, 0, aio_glusterfs_done,
815 state);
816 if (ret < 0) {
817 tevent_req_error(req, -ret);
818 return tevent_req_post(req, ev);
821 return req;
824 static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
825 *handle, TALLOC_CTX *mem_ctx,
826 struct tevent_context *ev,
827 files_struct *fsp,
828 const void *data, size_t n,
829 off_t offset)
831 struct glusterfs_aio_state *state = NULL;
832 struct tevent_req *req = NULL;
833 int ret = 0;
835 state = aio_state_create(mem_ctx);
837 if (state == NULL) {
838 return NULL;
841 req = state->req;
843 if (!init_gluster_aio(handle)) {
844 tevent_req_error(req, EIO);
845 return tevent_req_post(req, ev);
848 PROFILE_TIMESTAMP(&state->start);
849 ret = glfs_pwrite_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
850 fsp), data, n, offset, 0, aio_glusterfs_done,
851 state);
852 if (ret < 0) {
853 tevent_req_error(req, -ret);
854 return tevent_req_post(req, ev);
857 return req;
860 static ssize_t vfs_gluster_recv(struct tevent_req *req,
861 struct vfs_aio_state *vfs_aio_state)
863 struct glusterfs_aio_wrapper *wrapper = NULL;
864 int ret = 0;
866 wrapper = tevent_req_data(req, struct glusterfs_aio_wrapper);
868 if (wrapper == NULL) {
869 return -1;
872 if (wrapper->state == NULL) {
873 return -1;
876 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
877 return -1;
880 *vfs_aio_state = wrapper->state->vfs_aio_state;
881 ret = wrapper->state->ret;
883 /* Clean up the state, it is in a NULL context. */
885 TALLOC_FREE(wrapper->state);
887 return ret;
890 static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
891 files_struct *fsp, const void *data, size_t n)
893 return glfs_write(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
896 static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
897 files_struct *fsp, const void *data,
898 size_t n, off_t offset)
900 return glfs_pwrite(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, offset, 0);
903 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
904 files_struct *fsp, off_t offset, int whence)
906 return glfs_lseek(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), offset, whence);
909 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
910 files_struct *fromfsp,
911 const DATA_BLOB *hdr,
912 off_t offset, size_t n)
914 errno = ENOTSUP;
915 return -1;
918 static ssize_t vfs_gluster_recvfile(struct vfs_handle_struct *handle,
919 int fromfd, files_struct *tofsp,
920 off_t offset, size_t n)
922 errno = ENOTSUP;
923 return -1;
926 static int vfs_gluster_rename(struct vfs_handle_struct *handle,
927 const struct smb_filename *smb_fname_src,
928 const struct smb_filename *smb_fname_dst)
930 return glfs_rename(handle->data, smb_fname_src->base_name,
931 smb_fname_dst->base_name);
934 static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
935 files_struct *fsp)
937 return glfs_fsync(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp));
940 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
941 *handle, TALLOC_CTX *mem_ctx,
942 struct tevent_context *ev,
943 files_struct *fsp)
945 struct tevent_req *req = NULL;
946 struct glusterfs_aio_state *state = NULL;
947 int ret = 0;
949 state = aio_state_create(mem_ctx);
951 if (state == NULL) {
952 return NULL;
955 req = state->req;
957 if (!init_gluster_aio(handle)) {
958 tevent_req_error(req, EIO);
959 return tevent_req_post(req, ev);
962 PROFILE_TIMESTAMP(&state->start);
963 ret = glfs_fsync_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
964 fsp), aio_glusterfs_done, req);
965 if (ret < 0) {
966 tevent_req_error(req, -ret);
967 return tevent_req_post(req, ev);
969 return req;
972 static int vfs_gluster_fsync_recv(struct tevent_req *req,
973 struct vfs_aio_state *vfs_aio_state)
976 * Use implicit conversion ssize_t->int
978 return vfs_gluster_recv(req, vfs_aio_state);
981 static int vfs_gluster_stat(struct vfs_handle_struct *handle,
982 struct smb_filename *smb_fname)
984 struct stat st;
985 int ret;
987 ret = glfs_stat(handle->data, smb_fname->base_name, &st);
988 if (ret == 0) {
989 smb_stat_ex_from_stat(&smb_fname->st, &st);
991 if (ret < 0 && errno != ENOENT) {
992 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
993 smb_fname->base_name, strerror(errno)));
995 return ret;
998 static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
999 files_struct *fsp, SMB_STRUCT_STAT *sbuf)
1001 struct stat st;
1002 int ret;
1004 ret = glfs_fstat(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), &st);
1005 if (ret == 0) {
1006 smb_stat_ex_from_stat(sbuf, &st);
1008 if (ret < 0) {
1009 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
1010 fsp->fh->fd, strerror(errno)));
1012 return ret;
1015 static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
1016 struct smb_filename *smb_fname)
1018 struct stat st;
1019 int ret;
1021 ret = glfs_lstat(handle->data, smb_fname->base_name, &st);
1022 if (ret == 0) {
1023 smb_stat_ex_from_stat(&smb_fname->st, &st);
1025 if (ret < 0 && errno != ENOENT) {
1026 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
1027 smb_fname->base_name, strerror(errno)));
1029 return ret;
1032 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct *handle,
1033 files_struct *fsp,
1034 const SMB_STRUCT_STAT *sbuf)
1036 return sbuf->st_ex_blocks * 512;
1039 static int vfs_gluster_unlink(struct vfs_handle_struct *handle,
1040 const struct smb_filename *smb_fname)
1042 return glfs_unlink(handle->data, smb_fname->base_name);
1045 static int vfs_gluster_chmod(struct vfs_handle_struct *handle,
1046 const struct smb_filename *smb_fname,
1047 mode_t mode)
1049 return glfs_chmod(handle->data, smb_fname->base_name, mode);
1052 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
1053 files_struct *fsp, mode_t mode)
1055 return glfs_fchmod(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), mode);
1058 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
1059 const struct smb_filename *smb_fname,
1060 uid_t uid,
1061 gid_t gid)
1063 return glfs_chown(handle->data, smb_fname->base_name, uid, gid);
1066 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
1067 files_struct *fsp, uid_t uid, gid_t gid)
1069 return glfs_fchown(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), uid, gid);
1072 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
1073 const struct smb_filename *smb_fname,
1074 uid_t uid,
1075 gid_t gid)
1077 return glfs_lchown(handle->data, smb_fname->base_name, uid, gid);
1080 static int vfs_gluster_chdir(struct vfs_handle_struct *handle,
1081 const struct smb_filename *smb_fname)
1083 return glfs_chdir(handle->data, smb_fname->base_name);
1086 static struct smb_filename *vfs_gluster_getwd(struct vfs_handle_struct *handle,
1087 TALLOC_CTX *ctx)
1089 char *cwd;
1090 char *ret;
1091 struct smb_filename *smb_fname = NULL;
1093 cwd = SMB_CALLOC_ARRAY(char, PATH_MAX);
1094 if (cwd == NULL) {
1095 return NULL;
1098 ret = glfs_getcwd(handle->data, cwd, PATH_MAX - 1);
1099 if (ret == NULL) {
1100 SAFE_FREE(cwd);
1101 return NULL;
1103 smb_fname = synthetic_smb_fname(ctx,
1104 ret,
1105 NULL,
1106 NULL,
1108 SAFE_FREE(cwd);
1109 return smb_fname;
1112 static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
1113 const struct smb_filename *smb_fname,
1114 struct smb_file_time *ft)
1116 struct timespec times[2];
1118 if (null_timespec(ft->atime)) {
1119 times[0].tv_sec = smb_fname->st.st_ex_atime.tv_sec;
1120 times[0].tv_nsec = smb_fname->st.st_ex_atime.tv_nsec;
1121 } else {
1122 times[0].tv_sec = ft->atime.tv_sec;
1123 times[0].tv_nsec = ft->atime.tv_nsec;
1126 if (null_timespec(ft->mtime)) {
1127 times[1].tv_sec = smb_fname->st.st_ex_mtime.tv_sec;
1128 times[1].tv_nsec = smb_fname->st.st_ex_mtime.tv_nsec;
1129 } else {
1130 times[1].tv_sec = ft->mtime.tv_sec;
1131 times[1].tv_nsec = ft->mtime.tv_nsec;
1134 if ((timespec_compare(&times[0],
1135 &smb_fname->st.st_ex_atime) == 0) &&
1136 (timespec_compare(&times[1],
1137 &smb_fname->st.st_ex_mtime) == 0)) {
1138 return 0;
1141 return glfs_utimens(handle->data, smb_fname->base_name, times);
1144 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
1145 files_struct *fsp, off_t offset)
1147 return glfs_ftruncate(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), offset);
1150 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
1151 struct files_struct *fsp,
1152 uint32_t mode,
1153 off_t offset, off_t len)
1155 #ifdef HAVE_GFAPI_VER_6
1156 int keep_size, punch_hole;
1158 keep_size = mode & VFS_FALLOCATE_FL_KEEP_SIZE;
1159 punch_hole = mode & VFS_FALLOCATE_FL_PUNCH_HOLE;
1161 mode &= ~(VFS_FALLOCATE_FL_KEEP_SIZE|VFS_FALLOCATE_FL_PUNCH_HOLE);
1162 if (mode != 0) {
1163 errno = ENOTSUP;
1164 return -1;
1167 if (punch_hole) {
1168 return glfs_discard(*(glfs_fd_t **)
1169 VFS_FETCH_FSP_EXTENSION(handle, fsp),
1170 offset, len);
1173 return glfs_fallocate(*(glfs_fd_t **)
1174 VFS_FETCH_FSP_EXTENSION(handle, fsp),
1175 keep_size, offset, len);
1176 #else
1177 errno = ENOTSUP;
1178 return -1;
1179 #endif
1182 static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handle,
1183 TALLOC_CTX *ctx,
1184 const struct smb_filename *smb_fname)
1186 char *result = NULL;
1187 struct smb_filename *result_fname = NULL;
1188 char *resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
1190 if (resolved_path == NULL) {
1191 errno = ENOMEM;
1192 return NULL;
1195 result = glfs_realpath(handle->data,
1196 smb_fname->base_name,
1197 resolved_path);
1198 if (result != NULL) {
1199 result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0);
1202 SAFE_FREE(resolved_path);
1203 return result_fname;
1206 static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
1207 files_struct *fsp, int op, off_t offset,
1208 off_t count, int type)
1210 struct flock flock = { 0, };
1211 int ret;
1213 flock.l_type = type;
1214 flock.l_whence = SEEK_SET;
1215 flock.l_start = offset;
1216 flock.l_len = count;
1217 flock.l_pid = 0;
1219 ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), op, &flock);
1221 if (op == F_GETLK) {
1222 /* lock query, true if someone else has locked */
1223 if ((ret != -1) &&
1224 (flock.l_type != F_UNLCK) &&
1225 (flock.l_pid != 0) && (flock.l_pid != getpid()))
1226 return true;
1227 /* not me */
1228 return false;
1231 if (ret == -1) {
1232 return false;
1235 return true;
1238 static int vfs_gluster_kernel_flock(struct vfs_handle_struct *handle,
1239 files_struct *fsp, uint32_t share_mode,
1240 uint32_t access_mask)
1242 errno = ENOSYS;
1243 return -1;
1246 static int vfs_gluster_linux_setlease(struct vfs_handle_struct *handle,
1247 files_struct *fsp, int leasetype)
1249 errno = ENOSYS;
1250 return -1;
1253 static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
1254 files_struct *fsp, off_t *poffset,
1255 off_t *pcount, int *ptype, pid_t *ppid)
1257 struct flock flock = { 0, };
1258 int ret;
1260 flock.l_type = *ptype;
1261 flock.l_whence = SEEK_SET;
1262 flock.l_start = *poffset;
1263 flock.l_len = *pcount;
1264 flock.l_pid = 0;
1266 ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), F_GETLK, &flock);
1268 if (ret == -1) {
1269 return false;
1272 *ptype = flock.l_type;
1273 *poffset = flock.l_start;
1274 *pcount = flock.l_len;
1275 *ppid = flock.l_pid;
1277 return true;
1280 static int vfs_gluster_symlink(struct vfs_handle_struct *handle,
1281 const char *link_target,
1282 const struct smb_filename *new_smb_fname)
1284 return glfs_symlink(handle->data,
1285 link_target,
1286 new_smb_fname->base_name);
1289 static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
1290 const struct smb_filename *smb_fname,
1291 char *buf,
1292 size_t bufsiz)
1294 return glfs_readlink(handle->data, smb_fname->base_name, buf, bufsiz);
1297 static int vfs_gluster_link(struct vfs_handle_struct *handle,
1298 const struct smb_filename *old_smb_fname,
1299 const struct smb_filename *new_smb_fname)
1301 return glfs_link(handle->data,
1302 old_smb_fname->base_name,
1303 new_smb_fname->base_name);
1306 static int vfs_gluster_mknod(struct vfs_handle_struct *handle,
1307 const struct smb_filename *smb_fname,
1308 mode_t mode,
1309 SMB_DEV_T dev)
1311 return glfs_mknod(handle->data, smb_fname->base_name, mode, dev);
1314 static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
1315 const struct smb_filename *smb_fname,
1316 unsigned int flags)
1318 errno = ENOSYS;
1319 return -1;
1322 static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
1323 const char *path, const char *name,
1324 TALLOC_CTX *mem_ctx, char **found_name)
1326 int ret;
1327 char key_buf[NAME_MAX + 64];
1328 char val_buf[NAME_MAX + 1];
1330 if (strlen(name) >= NAME_MAX) {
1331 errno = ENAMETOOLONG;
1332 return -1;
1335 snprintf(key_buf, NAME_MAX + 64,
1336 "glusterfs.get_real_filename:%s", name);
1338 ret = glfs_getxattr(handle->data, path, key_buf, val_buf, NAME_MAX + 1);
1339 if (ret == -1) {
1340 if (errno == ENODATA) {
1341 errno = EOPNOTSUPP;
1343 return -1;
1346 *found_name = talloc_strdup(mem_ctx, val_buf);
1347 if (found_name[0] == NULL) {
1348 errno = ENOMEM;
1349 return -1;
1351 return 0;
1354 static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
1355 const struct smb_filename *smb_fname)
1357 return handle->conn->connectpath;
1360 /* EA Operations */
1362 static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
1363 const struct smb_filename *smb_fname,
1364 const char *name,
1365 void *value,
1366 size_t size)
1368 return glfs_getxattr(handle->data, smb_fname->base_name,
1369 name, value, size);
1372 static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,
1373 files_struct *fsp, const char *name,
1374 void *value, size_t size)
1376 return glfs_fgetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name, value, size);
1379 static ssize_t vfs_gluster_listxattr(struct vfs_handle_struct *handle,
1380 const struct smb_filename *smb_fname,
1381 char *list,
1382 size_t size)
1384 return glfs_listxattr(handle->data, smb_fname->base_name, list, size);
1387 static ssize_t vfs_gluster_flistxattr(struct vfs_handle_struct *handle,
1388 files_struct *fsp, char *list,
1389 size_t size)
1391 return glfs_flistxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), list, size);
1394 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
1395 const struct smb_filename *smb_fname,
1396 const char *name)
1398 return glfs_removexattr(handle->data, smb_fname->base_name, name);
1401 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
1402 files_struct *fsp, const char *name)
1404 return glfs_fremovexattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name);
1407 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
1408 const struct smb_filename *smb_fname,
1409 const char *name,
1410 const void *value, size_t size, int flags)
1412 return glfs_setxattr(handle->data, smb_fname->base_name, name, value, size, flags);
1415 static int vfs_gluster_fsetxattr(struct vfs_handle_struct *handle,
1416 files_struct *fsp, const char *name,
1417 const void *value, size_t size, int flags)
1419 return glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name, value, size,
1420 flags);
1423 /* AIO Operations */
1425 static bool vfs_gluster_aio_force(struct vfs_handle_struct *handle,
1426 files_struct *fsp)
1428 return false;
1431 static struct vfs_fn_pointers glusterfs_fns = {
1433 /* Disk Operations */
1435 .connect_fn = vfs_gluster_connect,
1436 .disconnect_fn = vfs_gluster_disconnect,
1437 .disk_free_fn = vfs_gluster_disk_free,
1438 .get_quota_fn = vfs_gluster_get_quota,
1439 .set_quota_fn = vfs_gluster_set_quota,
1440 .statvfs_fn = vfs_gluster_statvfs,
1441 .fs_capabilities_fn = vfs_gluster_fs_capabilities,
1443 .get_dfs_referrals_fn = NULL,
1445 /* Directory Operations */
1447 .opendir_fn = vfs_gluster_opendir,
1448 .fdopendir_fn = vfs_gluster_fdopendir,
1449 .readdir_fn = vfs_gluster_readdir,
1450 .seekdir_fn = vfs_gluster_seekdir,
1451 .telldir_fn = vfs_gluster_telldir,
1452 .rewind_dir_fn = vfs_gluster_rewinddir,
1453 .mkdir_fn = vfs_gluster_mkdir,
1454 .rmdir_fn = vfs_gluster_rmdir,
1455 .closedir_fn = vfs_gluster_closedir,
1457 /* File Operations */
1459 .open_fn = vfs_gluster_open,
1460 .create_file_fn = NULL,
1461 .close_fn = vfs_gluster_close,
1462 .read_fn = vfs_gluster_read,
1463 .pread_fn = vfs_gluster_pread,
1464 .pread_send_fn = vfs_gluster_pread_send,
1465 .pread_recv_fn = vfs_gluster_recv,
1466 .write_fn = vfs_gluster_write,
1467 .pwrite_fn = vfs_gluster_pwrite,
1468 .pwrite_send_fn = vfs_gluster_pwrite_send,
1469 .pwrite_recv_fn = vfs_gluster_recv,
1470 .lseek_fn = vfs_gluster_lseek,
1471 .sendfile_fn = vfs_gluster_sendfile,
1472 .recvfile_fn = vfs_gluster_recvfile,
1473 .rename_fn = vfs_gluster_rename,
1474 .fsync_fn = vfs_gluster_fsync,
1475 .fsync_send_fn = vfs_gluster_fsync_send,
1476 .fsync_recv_fn = vfs_gluster_fsync_recv,
1478 .stat_fn = vfs_gluster_stat,
1479 .fstat_fn = vfs_gluster_fstat,
1480 .lstat_fn = vfs_gluster_lstat,
1481 .get_alloc_size_fn = vfs_gluster_get_alloc_size,
1482 .unlink_fn = vfs_gluster_unlink,
1484 .chmod_fn = vfs_gluster_chmod,
1485 .fchmod_fn = vfs_gluster_fchmod,
1486 .chown_fn = vfs_gluster_chown,
1487 .fchown_fn = vfs_gluster_fchown,
1488 .lchown_fn = vfs_gluster_lchown,
1489 .chdir_fn = vfs_gluster_chdir,
1490 .getwd_fn = vfs_gluster_getwd,
1491 .ntimes_fn = vfs_gluster_ntimes,
1492 .ftruncate_fn = vfs_gluster_ftruncate,
1493 .fallocate_fn = vfs_gluster_fallocate,
1494 .lock_fn = vfs_gluster_lock,
1495 .kernel_flock_fn = vfs_gluster_kernel_flock,
1496 .linux_setlease_fn = vfs_gluster_linux_setlease,
1497 .getlock_fn = vfs_gluster_getlock,
1498 .symlink_fn = vfs_gluster_symlink,
1499 .readlink_fn = vfs_gluster_readlink,
1500 .link_fn = vfs_gluster_link,
1501 .mknod_fn = vfs_gluster_mknod,
1502 .realpath_fn = vfs_gluster_realpath,
1503 .chflags_fn = vfs_gluster_chflags,
1504 .file_id_create_fn = NULL,
1505 .streaminfo_fn = NULL,
1506 .get_real_filename_fn = vfs_gluster_get_real_filename,
1507 .connectpath_fn = vfs_gluster_connectpath,
1509 .brl_lock_windows_fn = NULL,
1510 .brl_unlock_windows_fn = NULL,
1511 .brl_cancel_windows_fn = NULL,
1512 .strict_lock_check_fn = NULL,
1513 .translate_name_fn = NULL,
1514 .fsctl_fn = NULL,
1516 /* NT ACL Operations */
1517 .fget_nt_acl_fn = NULL,
1518 .get_nt_acl_fn = NULL,
1519 .fset_nt_acl_fn = NULL,
1520 .audit_file_fn = NULL,
1522 /* Posix ACL Operations */
1523 .chmod_acl_fn = NULL, /* passthrough to default */
1524 .fchmod_acl_fn = NULL, /* passthrough to default */
1525 .sys_acl_get_file_fn = posixacl_xattr_acl_get_file,
1526 .sys_acl_get_fd_fn = posixacl_xattr_acl_get_fd,
1527 .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
1528 .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
1529 .sys_acl_set_file_fn = posixacl_xattr_acl_set_file,
1530 .sys_acl_set_fd_fn = posixacl_xattr_acl_set_fd,
1531 .sys_acl_delete_def_file_fn = posixacl_xattr_acl_delete_def_file,
1533 /* EA Operations */
1534 .getxattr_fn = vfs_gluster_getxattr,
1535 .fgetxattr_fn = vfs_gluster_fgetxattr,
1536 .listxattr_fn = vfs_gluster_listxattr,
1537 .flistxattr_fn = vfs_gluster_flistxattr,
1538 .removexattr_fn = vfs_gluster_removexattr,
1539 .fremovexattr_fn = vfs_gluster_fremovexattr,
1540 .setxattr_fn = vfs_gluster_setxattr,
1541 .fsetxattr_fn = vfs_gluster_fsetxattr,
1543 /* AIO Operations */
1544 .aio_force_fn = vfs_gluster_aio_force,
1546 /* Durable handle Operations */
1547 .durable_cookie_fn = NULL,
1548 .durable_disconnect_fn = NULL,
1549 .durable_reconnect_fn = NULL,
1552 static_decl_vfs;
1553 NTSTATUS vfs_glusterfs_init(TALLOC_CTX *ctx)
1555 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
1556 "glusterfs", &glusterfs_fns);