summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2014-07-03 17:13:38 +0530
committerVijay Bellur <vbellur@redhat.com>2014-07-16 02:27:50 -0700
commit1dea949cb60c3814c9206df6ba8dddec8d471a94 (patch)
tree4685ce644e5d4f813eb4dd9309b7b335e20ffd6c /api
parentdcc1696045f12127ff37e6312a04c0024c8a4e24 (diff)
make snapview-server more compatible with NFS server
* There was no handle based API for listxattr. With this change, glfs_h_getxattrs also handles the listxattr functionality by checking whether the name is NULL or not (like posix). But all the gfapi functions for listxattr (glfs_h_getxattrs AND glfs_listxattr AND glfs_flistxattr) returns the names of the xattrs in a buffer provided by the caller. But snapview-server has to return the list of xattrs in a dict itself (similar to posix xlator). But the buffer just contains the names of the xattrs. So for each xattr, a zero byte value is set (i.e. "") into the dict and sent back. Translators which do xattr caching (as of now md-cache which caches selinux and acl related xattrs) should not cache those xattrs whose value is a zero byte data (""). So made changes in md-cache to ignore zero byte values. * NFS server was not linking the inodes to inode table in readdirp. This was leading to applications getting errors. The below set of operations would lead to applications getting error 1) ls -l in one of the snaopshots (snapview-server would generate gfids for each entry on the fly and link the inodes associated with those entries) 2) NFS server upon getting readdirp reply would not link the inodes of the entries. But it used to generate filehandles for each entry and associate the gfid of that entry with the filehandle and send it as part of the reply to nfs client. 3) NFS client would send the filehandle of one of those entries when some activity is done on it. 4) NFS server would not be able to find the inode for the gfid present in the filehandle (as the inode was not linked) and would go for hard resolution by sending a lookup on the gfid by creating a new inode. 5) snapview-client will not able to identify whether the inode is a real inode existing in the main volume or a virtual inode existing in the snapshots as there would not be any inode context. 6) Since the gfid upon which lookup is sent is a virtual gfid which is not present in the disk, lookup would fail and the application would get an error. To handle above situation, now nfs server also does inode linking in readdirp. Change-Id: Ibb191408347b6b5f21cff72319ccee619ea77bcd BUG: 1115949 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/8230 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c10
-rw-r--r--api/src/glfs-handleops.c9
2 files changed, 15 insertions, 4 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 535dad3fea1..bc9c758a9c9 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -2568,11 +2568,14 @@ glfs_listxattr_process (void *value, size_t size, dict_t *xattr)
{
int ret = -1;
- if (!value || !size || !xattr)
+ if (!xattr)
goto out;
ret = dict_keys_join (NULL, 0, xattr, NULL);
+ if (!value || !size)
+ goto out;
+
if (size < ret) {
ret = -1;
errno = ERANGE;
@@ -2580,9 +2583,10 @@ glfs_listxattr_process (void *value, size_t size, dict_t *xattr)
dict_keys_join (value, size, xattr, NULL);
}
- dict_unref (xattr);
-
out:
+ if (xattr)
+ dict_unref (xattr);
+
return ret;
}
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index e3df8c00b1a..ba468382077 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -15,6 +15,9 @@
#include "glfs.h"
#include "glfs-handles.h"
+int
+glfs_listxattr_process (void *value, size_t size, dict_t *xattr);
+
static void
glfs_iatt_from_stat (struct stat *stat, int valid, struct iatt *iatt,
int *glvalid)
@@ -259,7 +262,11 @@ glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, const char *name,
if (ret)
goto out;
- ret = glfs_getxattr_process (value, size, xattr, name);
+ /* If @name is NULL, means get all the xattrs (i.e listxattr). */
+ if (name)
+ ret = glfs_getxattr_process (value, size, xattr, name);
+ else
+ ret = glfs_listxattr_process (value, size, xattr);
out:
loc_wipe (&loc);