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