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