summaryrefslogtreecommitdiffstats
path: root/source3/modules/vfs_glusterfs.c
diff options
context:
space:
mode:
authorraghavendra talur <raghavendra.talur@gmail.com>2014-12-10 12:26:34 +0530
committerGünther Deschner <gd@samba.org>2014-12-10 14:15:06 +0100
commit2fb4317352a165d0dd4af78fcf0a576fa246eab2 (patch)
tree0ceb2539c526dd1188279e538f7ee9fa7ec88644 /source3/modules/vfs_glusterfs.c
parenta4fa9ca5a7a4c0b770079ab126f8172ff6d6851c (diff)
downloadsamba-2fb4317352a165d0dd4af78fcf0a576fa246eab2.tar.gz
samba-2fb4317352a165d0dd4af78fcf0a576fa246eab2.tar.xz
samba-2fb4317352a165d0dd4af78fcf0a576fa246eab2.zip
vfs_glusterfs: Remember the connect path too for reopening.
As Samba allows us to share subdirs, lets re-use preopened connections to glusterfs only if they are for same volume AND same connectpath. Signed-off-by: raghavendra talur <raghavendra.talur@gmail.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/modules/vfs_glusterfs.c')
-rw-r--r--source3/modules/vfs_glusterfs.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index c47013bdf8..2dd9d71667 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -78,13 +78,14 @@ static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
static struct glfs_preopened {
char *volume;
+ char *connectpath;
glfs_t *fs;
int ref;
struct glfs_preopened *next, *prev;
} *glfs_preopened;
-static int glfs_set_preopened(const char *volume, glfs_t *fs)
+static int glfs_set_preopened(const char *volume, const char *connectpath, glfs_t *fs)
{
struct glfs_preopened *entry = NULL;
@@ -101,6 +102,13 @@ static int glfs_set_preopened(const char *volume, glfs_t *fs)
return -1;
}
+ entry->connectpath = talloc_strdup(entry, connectpath);
+ if (entry->connectpath == NULL) {
+ talloc_free(entry);
+ errno = ENOMEM;
+ return -1;
+ }
+
entry->fs = fs;
entry->ref = 1;
@@ -109,12 +117,14 @@ static int glfs_set_preopened(const char *volume, glfs_t *fs)
return 0;
}
-static glfs_t *glfs_find_preopened(const char *volume)
+static glfs_t *glfs_find_preopened(const char *volume, const char *connectpath)
{
struct glfs_preopened *entry = NULL;
for (entry = glfs_preopened; entry; entry = entry->next) {
- if (strcmp(entry->volume, volume) == 0) {
+ if (strcmp(entry->volume, volume) == 0 &&
+ strcmp(entry->connectpath, connectpath) == 0)
+ {
entry->ref++;
return entry->fs;
}
@@ -176,7 +186,7 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
volume = service;
}
- fs = glfs_find_preopened(volume);
+ fs = glfs_find_preopened(volume, handle->conn->connectpath);
if (fs) {
goto done;
}
@@ -214,7 +224,7 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
goto done;
}
- ret = glfs_set_preopened(volume, fs);
+ ret = glfs_set_preopened(volume, handle->conn->connectpath, fs);
if (ret < 0) {
DEBUG(0, ("%s: Failed to register volume (%s)\n",
volume, strerror(errno)));