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