17b94a
From 693fcf327eace37fe698953b90050d67fc840ac6 Mon Sep 17 00:00:00 2001
17b94a
From: Anuradha Talur <atalur@commvault.com>
17b94a
Date: Wed, 24 Apr 2019 12:06:23 -0700
17b94a
Subject: [PATCH 155/169] cloudsync: Make readdirp return stat info of all the
17b94a
 dirents
17b94a
17b94a
This change got missed while the initial changes were sent.
17b94a
Should have been a part of :
17b94a
	https://review.gluster.org/#/c/glusterfs/+/21757/
17b94a
17b94a
Gist of the change:
17b94a
	Function that fills in stat info for dirents is
17b94a
invoked in readdirp in posix when cloudsync populates xdata
17b94a
request with GF_CS_OBJECT_STATUS.
17b94a
17b94a
backport of:https://review.gluster.org/#/c/glusterfs/+/22616/
17b94a
17b94a
> Change-Id: Ide0c4e80afb74cd2120f74ba934ed40123152d69
17b94a
> updates: bz#1642168
17b94a
> Signed-off-by: Anuradha Talur <atalur@commvault.com>
17b94a
17b94a
Change-Id: I77de3f9d8ae01a0280a9d1753f94d74b5e5ce2fd
17b94a
Signed-off-by: Susant Palai <spalai@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/172193
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
17b94a
---
17b94a
 xlators/features/cloudsync/src/cloudsync-fops-c.py |  2 +-
17b94a
 xlators/features/cloudsync/src/cloudsync.c         | 35 ++++++++++++++++++++++
17b94a
 xlators/storage/posix/src/posix-inode-fd-ops.c     |  2 ++
17b94a
 3 files changed, 38 insertions(+), 1 deletion(-)
17b94a
17b94a
diff --git a/xlators/features/cloudsync/src/cloudsync-fops-c.py b/xlators/features/cloudsync/src/cloudsync-fops-c.py
17b94a
index a7a2201..8878b70 100755
17b94a
--- a/xlators/features/cloudsync/src/cloudsync-fops-c.py
17b94a
+++ b/xlators/features/cloudsync/src/cloudsync-fops-c.py
17b94a
@@ -285,7 +285,7 @@ loc_stat_op_fop_template = ['lookup', 'stat', 'discover', 'access', 'setattr',
17b94a
 
17b94a
 # These fops need a separate implementation
17b94a
 special_fops = ['statfs', 'setxattr', 'unlink', 'getxattr',
17b94a
-                'truncate', 'fstat', 'readv']
17b94a
+                'truncate', 'fstat', 'readv', 'readdirp']
17b94a
 
17b94a
 def gen_defaults():
17b94a
     for name in ops:
17b94a
diff --git a/xlators/features/cloudsync/src/cloudsync.c b/xlators/features/cloudsync/src/cloudsync.c
17b94a
index 8026b05..26e512c 100644
17b94a
--- a/xlators/features/cloudsync/src/cloudsync.c
17b94a
+++ b/xlators/features/cloudsync/src/cloudsync.c
17b94a
@@ -280,6 +280,40 @@ out:
17b94a
 }
17b94a
 
17b94a
 int32_t
17b94a
+cs_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
17b94a
+            off_t off, dict_t *xdata)
17b94a
+{
17b94a
+    int ret = 0;
17b94a
+    int op_errno = ENOMEM;
17b94a
+
17b94a
+    if (!xdata) {
17b94a
+        xdata = dict_new();
17b94a
+        if (!xdata) {
17b94a
+            gf_msg(this->name, GF_LOG_ERROR, 0, ENOMEM,
17b94a
+                   "failed to create "
17b94a
+                   "dict");
17b94a
+            goto err;
17b94a
+        }
17b94a
+    }
17b94a
+
17b94a
+    ret = dict_set_uint32(xdata, GF_CS_OBJECT_STATUS, 1);
17b94a
+    if (ret) {
17b94a
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
17b94a
+               "dict_set failed key:"
17b94a
+               " %s",
17b94a
+               GF_CS_OBJECT_STATUS);
17b94a
+        goto err;
17b94a
+    }
17b94a
+
17b94a
+    STACK_WIND(frame, default_readdirp_cbk, FIRST_CHILD(this),
17b94a
+               FIRST_CHILD(this)->fops->readdirp, fd, size, off, xdata);
17b94a
+    return 0;
17b94a
+err:
17b94a
+    STACK_UNWIND_STRICT(readdirp, frame, -1, op_errno, NULL, NULL);
17b94a
+    return 0;
17b94a
+}
17b94a
+
17b94a
+int32_t
17b94a
 cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
17b94a
                 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
17b94a
                 struct iatt *postbuf, dict_t *xdata)
17b94a
@@ -2026,6 +2060,7 @@ cs_notify(xlator_t *this, int event, void *data, ...)
17b94a
 
17b94a
 struct xlator_fops cs_fops = {
17b94a
     .stat = cs_stat,
17b94a
+    .readdirp = cs_readdirp,
17b94a
     .truncate = cs_truncate,
17b94a
     .seek = cs_seek,
17b94a
     .statfs = cs_statfs,
17b94a
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
17b94a
index 065fced..2c19ce1 100644
17b94a
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
17b94a
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
17b94a
@@ -5472,6 +5472,8 @@ posix_readdirp_fill(xlator_t *this, fd_t *fd, gf_dirent_t *entries,
17b94a
             continue;
17b94a
         }
17b94a
 
17b94a
+        posix_update_iatt_buf(&stbuf, -1, hpath, dict);
17b94a
+
17b94a
         if (!inode)
17b94a
             inode = inode_find(itable, stbuf.ia_gfid);
17b94a
 
17b94a
-- 
17b94a
1.8.3.1
17b94a