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