Blob Blame History Raw
From fe73255f5283baec514cc7f6a31f042d34bca0fa Mon Sep 17 00:00:00 2001
From: Saravanakumar Arumugam <sarumuga@redhat.com>
Date: Tue, 9 Jun 2015 17:49:58 +0530
Subject: [PATCH 58/73] features/changelog: Avoid setattr fop logging during rename

Problem:
        When a file is renamed and the (renamed)file's Hashing
falls into a different brick, DHT creates a special file(linkto file)
in the brick(Hashed subvolume) and carries out setattr operation
on that file.

Currently, Changelog records this(setattr) operation in Hashed
subvolume. glusterfind in turn records this operation
as MODIFY operation.

So, there is a NEW entry in Cached subvolume and MODIFY entry
in Hashed subvolume for the same file.

Solution:
        Avoid logging setattr operation carried out, by
marking the operation as internal fop using xdata.

In changelog translator, check whether setattr is set
as internal fop and skip accordingly.

Change-Id: I21b09afb5a638b88a4ccb822442216680b7b74fd
BUG: 1226889
Reviewed-On: http://review.gluster.org/c/10984
Reviewed-On: http://review.gluster.org/c/11183
Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50535
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 xlators/cluster/dht/src/dht-common.h       |   18 ++++++++++++++++++
 xlators/cluster/dht/src/dht-linkfile.c     |   23 ++++++++++++++++-------
 xlators/cluster/dht/src/dht-rename.c       |   16 ----------------
 xlators/features/changelog/src/changelog.c |    2 ++
 4 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 0351819..c04e85d 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -582,6 +582,24 @@ typedef struct dht_migrate_info {
         } while (0)
 
 #define is_greater_time(a, an, b, bn) (((a) < (b)) || (((a) == (b)) && ((an) < (bn))))
+
+#define DHT_MARK_FOP_INTERNAL(xattr) do {                                      \
+                int tmp = -1;                                                  \
+                if (!xattr) {                                                  \
+                        xattr = dict_new ();                                   \
+                        if (!xattr)                                            \
+                                break;                                         \
+                }                                                              \
+                tmp = dict_set_str (xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \
+                if (tmp) {                                                     \
+                        gf_msg (this->name, GF_LOG_ERROR, 0,                   \
+                                DHT_MSG_DICT_SET_FAILED,                       \
+                                "Failed to set dictionary value: key = %s,"    \
+                                " path = %s", GLUSTERFS_INTERNAL_FOP_KEY,      \
+                                 local->loc.path);                             \
+                }                                                              \
+        } while (0)
+
 dht_layout_t                            *dht_layout_new (xlator_t *this, int cnt);
 dht_layout_t                            *dht_layout_get (xlator_t *this, inode_t *inode);
 dht_layout_t                            *dht_layout_for_subvol (xlator_t *this, xlator_t *subvol);
diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c
index 14df318..923dde0 100644
--- a/xlators/cluster/dht/src/dht-linkfile.c
+++ b/xlators/cluster/dht/src/dht-linkfile.c
@@ -312,12 +312,13 @@ dht_linkfile_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
 int
 dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this)
 {
-        int     ret = -1;
-        call_frame_t *copy = NULL;
-        dht_local_t  *local = NULL;
-        dht_local_t  *copy_local = NULL;
-        xlator_t     *subvol = NULL;
-        struct iatt   stbuf = {0,};
+        int           ret         = -1;
+        call_frame_t  *copy       = NULL;
+        dht_local_t   *local      = NULL;
+        dht_local_t   *copy_local = NULL;
+        xlator_t      *subvol     = NULL;
+        struct iatt   stbuf       = {0,};
+        dict_t        *xattr      = NULL;
 
         local = frame->local;
 
@@ -327,6 +328,8 @@ dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this)
         if (local->stbuf.ia_type == IA_INVAL)
                 return 0;
 
+        DHT_MARK_FOP_INTERNAL (xattr);
+
         gf_uuid_copy (local->loc.gfid, local->stbuf.ia_gfid);
 
         copy = copy_frame (frame);
@@ -348,8 +351,14 @@ dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this)
 
         STACK_WIND (copy, dht_linkfile_setattr_cbk, subvol,
                     subvol->fops->setattr, &copy_local->loc,
-                    &stbuf, (GF_SET_ATTR_UID | GF_SET_ATTR_GID), NULL);
+                    &stbuf, (GF_SET_ATTR_UID | GF_SET_ATTR_GID), xattr);
         ret = 0;
 out:
+        if ((ret < 0) && (copy))
+                DHT_STACK_DESTROY (copy);
+
+        if (xattr)
+                dict_unref (xattr);
+
         return ret;
 }
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
index 4e4e986..097ae9a 100644
--- a/xlators/cluster/dht/src/dht-rename.c
+++ b/xlators/cluster/dht/src/dht-rename.c
@@ -369,22 +369,6 @@ dht_rename_track_for_changelog (xlator_t *this, dict_t *xattr,
 }
 
 
-#define DHT_MARK_FOP_INTERNAL(xattr) do {                                      \
-                int tmp = -1;                                                  \
-                if (!xattr) {                                                  \
-                        xattr = dict_new ();                                   \
-                        if (!xattr)                                            \
-                                break;                                         \
-                }                                                              \
-                tmp = dict_set_str (xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \
-                if (tmp) {                                                     \
-                        gf_msg (this->name, GF_LOG_ERROR, 0,                   \
-                                DHT_MSG_DICT_SET_FAILED,                       \
-                                "Failed to set dictionary value: key = %s,"    \
-                                " path = %s", GLUSTERFS_INTERNAL_FOP_KEY,      \
-                                 local->loc.path);                             \
-                }                                                              \
-        }while (0)
 
 #define DHT_MARKER_DONT_ACCOUNT(xattr) do {                             \
                 int tmp = -1;                                                  \
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
index ed58979..bea7334 100644
--- a/xlators/features/changelog/src/changelog.c
+++ b/xlators/features/changelog/src/changelog.c
@@ -1220,6 +1220,8 @@ changelog_setattr (call_frame_t *frame,
         priv = this->private;
         CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind);
 
+        CHANGELOG_IF_INTERNAL_FOP_THEN_GOTO (frame, xdata, wind);
+
         CHANGELOG_OP_BOUNDARY_CHECK (frame, wind);
 
         CHANGELOG_INIT (this, frame->local,
-- 
1.7.1