e7a346
From fd0a8f99f853e923d485acfcdda556156105c8d1 Mon Sep 17 00:00:00 2001
e7a346
From: Poornima G <pgurusid@redhat.com>
e7a346
Date: Mon, 13 Nov 2017 12:55:06 +0530
e7a346
Subject: [PATCH 150/180] dht: Fill first_up_subvol before use in dht_opendir
e7a346
e7a346
Reported by: Sam McLeod
e7a346
e7a346
> Upstream patch: https://review.gluster.org/#/c/18723/
e7a346
e7a346
Change-Id: Ic8f9b46b173796afd70aff1042834b03ac3e80b2
e7a346
BUG: 1529072
e7a346
Signed-off-by: Poornima G <pgurusid@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/130059
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 tests/bugs/readdir-ahead/bug-1512437.t | 23 +++++++++++++++++++++++
e7a346
 xlators/cluster/dht/src/dht-common.c   |  5 +++++
e7a346
 2 files changed, 28 insertions(+)
e7a346
 create mode 100755 tests/bugs/readdir-ahead/bug-1512437.t
e7a346
e7a346
diff --git a/tests/bugs/readdir-ahead/bug-1512437.t b/tests/bugs/readdir-ahead/bug-1512437.t
e7a346
new file mode 100755
e7a346
index 0000000..50eaa7d
e7a346
--- /dev/null
e7a346
+++ b/tests/bugs/readdir-ahead/bug-1512437.t
e7a346
@@ -0,0 +1,23 @@
e7a346
+#!/bin/bash
e7a346
+
e7a346
+. $(dirname $0)/../../include.rc
e7a346
+. $(dirname $0)/../../volume.rc
e7a346
+
e7a346
+cleanup;
e7a346
+
e7a346
+TEST glusterd
e7a346
+
e7a346
+TEST $CLI volume create $V0 $H0:$B0/${V0}1
e7a346
+TEST $CLI volume start $V0
e7a346
+
e7a346
+TEST $CLI volume set $V0 parallel-readdir on
e7a346
+TEST $CLI volume set $V0 readdir-optimize on
e7a346
+
e7a346
+TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0
e7a346
+TEST mkdir -p $M0/subdir1/subdir2;
e7a346
+umount $M0
e7a346
+TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0
e7a346
+count=`ls -1 $M0/subdir1 | wc -l`
e7a346
+TEST [ $count -eq 1 ]
e7a346
+
e7a346
+cleanup;
e7a346
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
e7a346
index 727a47b..1262732 100644
e7a346
--- a/xlators/cluster/dht/src/dht-common.c
e7a346
+++ b/xlators/cluster/dht/src/dht-common.c
e7a346
@@ -5043,6 +5043,7 @@ dht_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
e7a346
                 op_errno = ENOMEM;
e7a346
                 goto err;
e7a346
         }
e7a346
+        local->first_up_subvol = dht_first_up_subvol (this);
e7a346
 
e7a346
         if (!xdata) {
e7a346
                 xdata = dict_new ();
e7a346
@@ -5070,6 +5071,10 @@ dht_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
e7a346
                 subvolumes = conf->local_subvols;
e7a346
         }
e7a346
 
e7a346
+        /* In case of parallel-readdir, the readdir-ahead will be loaded
e7a346
+         * below dht, in this case, if we want to enable or disable SKIP_DIRs
e7a346
+         * it has to be done in opendir, so that prefetching logic in
e7a346
+         * readdir-ahead, honors it */
e7a346
         for (i = 0; i < call_count; i++) {
e7a346
                 if (conf->readdir_optimize == _gf_true) {
e7a346
                         if (subvolumes[i] != local->first_up_subvol) {
e7a346
-- 
e7a346
1.8.3.1
e7a346