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