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