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