e7a346
From 90dc8d7cee42eeacc3214fef8bb45cbffc4c8de5 Mon Sep 17 00:00:00 2001
e7a346
From: N Balachandran <nbalacha@redhat.com>
e7a346
Date: Mon, 19 Feb 2018 09:44:29 +0530
e7a346
Subject: [PATCH 162/180] cluster/dht: Handle single dht child in dht_lookup
e7a346
e7a346
This patch limits itself to only handling the case
e7a346
where no file (data or linkto) exists on the subvol.
e7a346
e7a346
Additional cases to be handled:
e7a346
1. A linkto file was found on the only child subvol. This currently
e7a346
calls dht_lookup_everywhere which eventually deletes it. It can be
e7a346
deleted directly as it will not be pointing to a valid subvol.
e7a346
2. Directory lookups - locking might be unnecessary in some cases.
e7a346
e7a346
upstream patch: https://review.gluster.org/19581
e7a346
e7a346
> Change-Id: I940ba34531f2aaee1d36fd9ca45ecfd46be662a4
e7a346
> BUG: 1546620
e7a346
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
e7a346
e7a346
Change-Id: I1cc1b9866fa18fe825847585e6a9b8c92898951a
e7a346
BUG: 1545570
e7a346
Signed-off-by: N Balachandran <nbalacha@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/130976
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Shyam Ranganathan <srangana@redhat.com>
e7a346
---
e7a346
 xlators/cluster/dht/src/dht-common.c | 12 ++++++++++++
e7a346
 1 file changed, 12 insertions(+)
e7a346
e7a346
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
e7a346
index 1262732..5641330 100644
e7a346
--- a/xlators/cluster/dht/src/dht-common.c
e7a346
+++ b/xlators/cluster/dht/src/dht-common.c
e7a346
@@ -2352,6 +2352,12 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
e7a346
         }
e7a346
 
e7a346
         if (ENTRY_MISSING (op_ret, op_errno)) {
e7a346
+
e7a346
+                if (1 == conf->subvolume_cnt) {
e7a346
+                        /* No need to lookup again */
e7a346
+                        goto out;
e7a346
+                }
e7a346
+
e7a346
                 gf_msg_debug (this->name, 0,
e7a346
                               "Entry %s missing on subvol %s",
e7a346
                               loc->path, prev->name);
e7a346
@@ -2581,6 +2587,8 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
e7a346
                 local->xattr_req = dict_new ();
e7a346
         }
e7a346
 
e7a346
+        /* Nameless lookup */
e7a346
+
e7a346
         if (gf_uuid_is_null (loc->pargfid) && !gf_uuid_is_null (loc->gfid) &&
e7a346
             !__is_root_gfid (loc->inode->gfid)) {
e7a346
                 local->cached_subvol = NULL;
e7a346
@@ -2598,6 +2606,9 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
e7a346
                 hashed_subvol = dht_subvol_get_hashed (this, loc);
e7a346
         local->hashed_subvol = hashed_subvol;
e7a346
 
e7a346
+
e7a346
+        /* The entry has been looked up before and has an inode_ctx set
e7a346
+         */
e7a346
         if (is_revalidate (loc)) {
e7a346
                 layout = local->layout;
e7a346
                 if (!layout) {
e7a346
@@ -2638,6 +2649,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
e7a346
                                 "path %s", conf->xattr_name, loc->path);
e7a346
                         goto err;
e7a346
                 }
e7a346
+
e7a346
                 /* need it in case file is not found on cached file
e7a346
                  * on revalidate path and we may encounter linkto files on
e7a346
                  * with dht_lookup_everywhere*/
e7a346
-- 
e7a346
1.8.3.1
e7a346