|
|
21ab4e |
From eff25494501810de50cfefa414403f7fdbf8fb25 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
21ab4e |
Date: Mon, 3 Jul 2017 12:45:38 +0530
|
|
|
21ab4e |
Subject: [PATCH 555/557] svc: send revalidate lookup on special dir
|
|
|
21ab4e |
|
|
|
21ab4e |
.snaps directory is a virtual direcotory, that doesn't
|
|
|
21ab4e |
exist on the backend. Even though it is a special dentry,
|
|
|
21ab4e |
it doesn't have a dedicated inode. So the inode number is
|
|
|
21ab4e |
always random. Which means it will get different inode
|
|
|
21ab4e |
number when reboot happens on snapd process.
|
|
|
21ab4e |
|
|
|
21ab4e |
Now with windows client the show-direcotry feature requires
|
|
|
21ab4e |
a lookup on the .snpas direcoty post readdirp on root.
|
|
|
21ab4e |
If the snapd restarted after a lookup, then subsequent lookup
|
|
|
21ab4e |
will fail, because linked inode will be stale.
|
|
|
21ab4e |
|
|
|
21ab4e |
This patch will do a revalidate lookup with a new inode.
|
|
|
21ab4e |
Back port of>
|
|
|
21ab4e |
>Change-Id: If97c07ecb307cefe7c86be8ebd05e28cbf678d1f
|
|
|
21ab4e |
>BUG: 1467513
|
|
|
21ab4e |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/17690
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: If97c07ecb307cefe7c86be8ebd05e28cbf678d1f
|
|
|
21ab4e |
BUG: 1191480
|
|
|
21ab4e |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/111807
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
.../features/snapview-client/src/snapview-client.c | 77 ++++++++++++++++++++++
|
|
|
21ab4e |
.../features/snapview-client/src/snapview-client.h | 4 ++
|
|
|
21ab4e |
2 files changed, 81 insertions(+)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c
|
|
|
21ab4e |
index 6eb7cc0..efc3362 100644
|
|
|
21ab4e |
--- a/xlators/features/snapview-client/src/snapview-client.c
|
|
|
21ab4e |
+++ b/xlators/features/snapview-client/src/snapview-client.c
|
|
|
21ab4e |
@@ -1666,6 +1666,14 @@ gf_svc_readdirp_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
21ab4e |
dict_unref (xdata);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (op_ret) {
|
|
|
21ab4e |
+ if (op_errno == ESTALE && !local->revalidate) {
|
|
|
21ab4e |
+ local->revalidate = 1;
|
|
|
21ab4e |
+ ret = gf_svc_special_dir_revalidate_lookup (frame,
|
|
|
21ab4e |
+ this);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!ret)
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
op_ret = 0;
|
|
|
21ab4e |
op_errno = ENOENT;
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
@@ -1715,6 +1723,75 @@ out:
|
|
|
21ab4e |
return 0;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+gf_svc_special_dir_revalidate_lookup (call_frame_t *frame, xlator_t *this)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ svc_private_t *private = NULL;
|
|
|
21ab4e |
+ svc_local_t *local = NULL;
|
|
|
21ab4e |
+ loc_t *loc = NULL;
|
|
|
21ab4e |
+ dict_t *tmp_xdata = NULL;
|
|
|
21ab4e |
+ char *path = NULL;
|
|
|
21ab4e |
+ int ret = -1;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO ("snapview-client", this, out);
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (this->name, this->private, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ private = this->private;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ local = frame->local;
|
|
|
21ab4e |
+ loc = &local->loc;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ inode_unref (loc->inode);
|
|
|
21ab4e |
+ loc->inode = inode_new (loc->parent->table);
|
|
|
21ab4e |
+ if (!loc->inode) {
|
|
|
21ab4e |
+ gf_log (this->name, GF_LOG_ERROR, "failed to "
|
|
|
21ab4e |
+ "allocate new inode");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gf_uuid_copy (local->loc.gfid, loc->inode->gfid);
|
|
|
21ab4e |
+ ret = inode_path (loc->parent, private->path, &path);
|
|
|
21ab4e |
+ if (ret < 0)
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (loc->path)
|
|
|
21ab4e |
+ GF_FREE ((char *)loc->path);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ loc->path = gf_strdup (path);
|
|
|
21ab4e |
+ if (loc->path) {
|
|
|
21ab4e |
+ if (!loc->name ||
|
|
|
21ab4e |
+ (loc->name && !strcmp (loc->name, ""))) {
|
|
|
21ab4e |
+ loc->name = strrchr (loc->path, '/');
|
|
|
21ab4e |
+ if (loc->name)
|
|
|
21ab4e |
+ loc->name++;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ } else
|
|
|
21ab4e |
+ loc->path = NULL;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ tmp_xdata = dict_new ();
|
|
|
21ab4e |
+ if (!tmp_xdata) {
|
|
|
21ab4e |
+ ret = -1;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = dict_set_str (tmp_xdata, "entry-point", "true");
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_log (this->name, GF_LOG_ERROR, "failed to set dict");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ STACK_WIND (frame, gf_svc_readdirp_lookup_cbk,
|
|
|
21ab4e |
+ SECOND_CHILD (this),
|
|
|
21ab4e |
+ SECOND_CHILD (this)->fops->lookup, loc,
|
|
|
21ab4e |
+ tmp_xdata);
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ if (tmp_xdata)
|
|
|
21ab4e |
+ dict_unref (tmp_xdata);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ GF_FREE (path);
|
|
|
21ab4e |
+ return ret;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
static gf_boolean_t
|
|
|
21ab4e |
gf_svc_readdir_on_special_dir (call_frame_t *frame, void *cookie,
|
|
|
21ab4e |
xlator_t *this, int32_t op_ret,
|
|
|
21ab4e |
diff --git a/xlators/features/snapview-client/src/snapview-client.h b/xlators/features/snapview-client/src/snapview-client.h
|
|
|
21ab4e |
index 5b7a862..e1fcb37 100644
|
|
|
21ab4e |
--- a/xlators/features/snapview-client/src/snapview-client.h
|
|
|
21ab4e |
+++ b/xlators/features/snapview-client/src/snapview-client.h
|
|
|
21ab4e |
@@ -23,6 +23,7 @@ struct __svc_local {
|
|
|
21ab4e |
fd_t *fd;
|
|
|
21ab4e |
void *cookie;
|
|
|
21ab4e |
dict_t *xdata;
|
|
|
21ab4e |
+ uint16_t revalidate;
|
|
|
21ab4e |
};
|
|
|
21ab4e |
typedef struct __svc_local svc_local_t;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -94,4 +95,7 @@ typedef enum {
|
|
|
21ab4e |
VIRTUAL_INODE
|
|
|
21ab4e |
} inode_type_t;
|
|
|
21ab4e |
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+gf_svc_special_dir_revalidate_lookup (call_frame_t *frame, xlator_t *this);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
#endif /* __SNAP_VIEW_CLIENT_H__ */
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|