summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2014-11-28 15:24:46 +0530
committerVijay Bellur <vbellur@redhat.com>2014-12-03 06:47:24 -0800
commit8261f0deb9bf75611135a6571bc4d9cef687ad37 (patch)
tree003311b0dec5d6d68c7ff1d9978bb70b03f86750 /xlators
parent85fa19eef36c166287ba87597684d1e0b532add0 (diff)
uss: CIFS gives error while accessing .snaps directory
CIFS sends getxattr call while accessing .snaps directory. snapview server should return ENODATA if getxattr is called on .snaps folder. Also flush on .snaps folder should be handled. Windows client sends and getxattr call on the parent folder of .snaps with a special key to get the real filename of a file. This is used by samba to do case insensitive check of files. Fixed few FreeBSD compilation error. bug: 1168875 Change-Id: I74d5cb4419568c8ed8709ba6d1ddff0e41392204 Signed-off-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-on: http://review.gluster.org/9211 Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/snapview-client/src/snapview-client.c55
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c8
-rw-r--r--xlators/features/snapview-server/src/snapview-server.c25
-rw-r--r--xlators/features/snapview-server/src/snapview-server.h6
4 files changed, 70 insertions, 24 deletions
diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c
index 0f8913d18ce..849cab390fa 100644
--- a/xlators/features/snapview-client/src/snapview-client.c
+++ b/xlators/features/snapview-client/src/snapview-client.c
@@ -546,17 +546,58 @@ int32_t
svc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name,
dict_t *xdata)
{
- int32_t ret = -1;
- int inode_type = -1;
- xlator_t *subvolume = NULL;
- int op_ret = -1;
- int op_errno = EINVAL;
- gf_boolean_t wind = _gf_false;
+ int32_t ret = -1;
+ int inode_type = -1;
+ xlator_t *subvolume = NULL;
+ int op_ret = -1;
+ int op_errno = EINVAL;
+ gf_boolean_t wind = _gf_false;
+ svc_private_t *priv = NULL;
+ char attrname[PATH_MAX] = "";
+ char attrval[64] = "";
+ dict_t *dict = NULL;
GF_VALIDATE_OR_GOTO ("svc", this, out);
GF_VALIDATE_OR_GOTO (this->name, frame, out);
GF_VALIDATE_OR_GOTO (this->name, loc, out);
GF_VALIDATE_OR_GOTO (this->name, loc->inode, out);
+ priv = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, priv, out);
+
+ /*
+ * Samba sends this special key for case insensitive
+ * filename check. This request comes with a parent
+ * path and with a special key GF_XATTR_GET_REAL_FILENAME_KEY.
+ * e.g. "glusterfs.get_real_filename:.snaps".
+ * If the name variable matches this key then we have
+ * to send back .snaps as the real filename.
+ */
+ sscanf (name, "%[^:]:%[^@]", attrname, attrval);
+ strcat (attrname, ":");
+
+ if (!strcmp (attrname, GF_XATTR_GET_REAL_FILENAME_KEY)) {
+ if (!strcasecmp (attrval, priv->path)) {
+ dict = dict_new ();
+ if (NULL == dict) {
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ ret = dict_set_dynstr_with_alloc (dict,
+ (char *)name,
+ priv->path);
+ if (ret) {
+ op_errno = ENOMEM;
+ dict_unref (dict);
+ goto out;
+ }
+
+ op_errno = 0;
+ op_ret = strlen (priv->path) + 1;
+ /* We should return from here */
+ goto out;
+ }
+ }
SVC_GET_SUBVOL_FROM_CTX (this, op_ret, op_errno, inode_type, ret,
loc->inode, subvolume, out);
@@ -569,7 +610,7 @@ svc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name,
out:
if (!wind)
SVC_STACK_UNWIND (getxattr, frame, op_ret, op_errno,
- NULL, NULL);
+ dict, NULL);
return 0;
}
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index a8183e35d01..a038126eb07 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -98,7 +98,7 @@ out:
}
svs_inode_t *
-svs_inode_new ()
+svs_inode_new (void)
{
svs_inode_t *svs_inode = NULL;
@@ -120,7 +120,7 @@ svs_inode_ctx_get_or_new (xlator_t *this, inode_t *inode)
{
svs_inode = __svs_inode_ctx_get (this, inode);
if (!svs_inode) {
- svs_inode = svs_inode_new (this, inode);
+ svs_inode = svs_inode_new ();
if (svs_inode) {
ret = __svs_inode_ctx_set (this, inode,
svs_inode);
@@ -138,7 +138,7 @@ out:
}
svs_fd_t *
-svs_fd_new ()
+svs_fd_new (void)
{
svs_fd_t *svs_fd = NULL;
@@ -243,7 +243,7 @@ __svs_fd_ctx_get_or_new (xlator_t *this, fd_t *fd)
goto out;
}
- svs_fd = svs_fd_new (this, fd);
+ svs_fd = svs_fd_new ();
if (!svs_fd) {
gf_log (this->name, GF_LOG_ERROR, "failed to allocate new fd "
"context for gfid %s", uuid_utoa (inode->gfid));
diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c
index 8655bf5636c..14fb6f14907 100644
--- a/xlators/features/snapview-server/src/snapview-server.c
+++ b/xlators/features/snapview-server/src/snapview-server.c
@@ -14,6 +14,7 @@
#include "snapview-server.h"
#include "snapview-server-mem-types.h"
+#include "compat-errno.h"
#include "xlator.h"
#include "rpc-clnt.h"
@@ -746,7 +747,7 @@ svs_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name,
goto out;
}
- /* EINVAL is sent if the getxattr is on entry point directory
+ /* ENODATA is sent if the getxattr is on entry point directory
or the inode is SNAP_VIEW_ENTRY_POINT_INODE. Entry point is
a virtual directory on which setxattr operations are not
allowed. If getxattr has to be faked as success, then a value
@@ -754,7 +755,7 @@ svs_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name,
*/
if (inode_ctx->type == SNAP_VIEW_ENTRY_POINT_INODE) {
op_ret = -1;
- op_errno = EINVAL;
+ op_errno = ENODATA;
goto out;
}
else {
@@ -1032,17 +1033,27 @@ int32_t
svs_flush (call_frame_t *frame, xlator_t *this,
fd_t *fd, dict_t *xdata)
{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int ret = -1;
- uint64_t value = 0;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ int ret = -1;
+ uint64_t value = 0;
+ svs_inode_t *inode_ctx = NULL;
GF_VALIDATE_OR_GOTO ("snapview-server", this, out);
GF_VALIDATE_OR_GOTO (this->name, frame, out);
GF_VALIDATE_OR_GOTO (this->name, fd, out);
+ inode_ctx = svs_inode_ctx_get (this, fd->inode);
+ if (!inode_ctx) {
+ gf_log (this->name, GF_LOG_ERROR, "inode context not found for"
+ " the inode %s", uuid_utoa (fd->inode->gfid));
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
+
ret = fd_ctx_get (fd, this, &value);
- if (ret < 0) {
+ if (ret < 0 && inode_ctx->type != SNAP_VIEW_ENTRY_POINT_INODE) {
op_errno = EINVAL;
gf_log (this->name, GF_LOG_WARNING,
"pfd is NULL on fd=%p", fd);
diff --git a/xlators/features/snapview-server/src/snapview-server.h b/xlators/features/snapview-server/src/snapview-server.h
index 9c13cf74610..c80d3456c30 100644
--- a/xlators/features/snapview-server/src/snapview-server.h
+++ b/xlators/features/snapview-server/src/snapview-server.h
@@ -173,14 +173,8 @@ int32_t
svs_inode_ctx_set (xlator_t *this, inode_t *inode, svs_inode_t *svs_inode);
svs_inode_t *
-svs_inode_new ();
-
-svs_inode_t *
svs_inode_ctx_get_or_new (xlator_t *this, inode_t *inode);
-svs_fd_t *
-svs_fd_new ();
-
int
__svs_fd_ctx_set (xlator_t *this, fd_t *fd, svs_fd_t *svs_fd);