Whamcloud - gitweb
LU-5722 obdclass: reorganize busy object accounting 68/12468/5
authorFrank Zago <fzago@cray.com>
Tue, 28 Oct 2014 22:02:14 +0000 (17:02 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 8 Feb 2015 02:26:09 +0000 (02:26 +0000)
Due to some accounting bug, lsb_busy of a hash bucket can become
larger than the total number of objects in said bucket. A busy object
can be counted more than once. When that happens, a negative value is
returned by the shrinker to Linux's shrink_slab() function. In older
kernel, such as 2.6.32 used in RHEL 6, this will cause a forever loop
inside shrink_slab(), in essence hanging the host.

Instead of trying (and failing) to count the busy objects, count the
objects than are not busy, i.e. the objects that are present on the
lsb_lru list. The number of busy objects is then the difference
between the number of objects in the hash and the objects on the
lsb_lru list.

Change-Id: Ia6973991a1ff7fc53cdf8132bf2aab532934cf94
Signed-off-by: frank zago <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/12468
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lu_object.h
lustre/obdclass/lu_object.c

index 2ac4144..e40e826 100644 (file)
@@ -560,9 +560,9 @@ struct fld;
 
 struct lu_site_bkt_data {
        /**
 
 struct lu_site_bkt_data {
        /**
-        * number of busy object on this bucket
+        * number of object in this bucket on the lsb_lru list.
         */
         */
-       long                    lsb_busy;
+       long                    lsb_lru_len;
        /**
         * LRU list, updated on each access to object. Protected by
         * bucket lock of lu_site::ls_obj_hash.
        /**
         * LRU list, updated on each access to object. Protected by
         * bucket lock of lu_site::ls_obj_hash.
index a8ff775..337069b 100644 (file)
@@ -140,8 +140,6 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
                return;
        }
 
                return;
        }
 
-        LASSERT(bkt->lsb_busy > 0);
-        bkt->lsb_busy--;
         /*
          * When last reference is released, iterate over object
          * layers, and notify them that object is no longer busy.
         /*
          * When last reference is released, iterate over object
          * layers, and notify them that object is no longer busy.
@@ -155,6 +153,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
            (lu_object_exists(orig) || lu_object_is_cl(orig))) {
                LASSERT(list_empty(&top->loh_lru));
                list_add_tail(&top->loh_lru, &bkt->lsb_lru);
            (lu_object_exists(orig) || lu_object_is_cl(orig))) {
                LASSERT(list_empty(&top->loh_lru));
                list_add_tail(&top->loh_lru, &bkt->lsb_lru);
+               bkt->lsb_lru_len++;
                 cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
                 return;
         }
                 cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
                 return;
         }
@@ -207,7 +206,13 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o)
                cfs_hash_bd_t bd;
 
                cfs_hash_bd_get_and_lock(obj_hash, &top->loh_fid, &bd, 1);
                cfs_hash_bd_t bd;
 
                cfs_hash_bd_get_and_lock(obj_hash, &top->loh_fid, &bd, 1);
-               list_del_init(&top->loh_lru);
+               if (!list_empty(&top->loh_lru)) {
+                       struct lu_site_bkt_data *bkt;
+
+                       list_del_init(&top->loh_lru);
+                       bkt = cfs_hash_bd_extra_get(obj_hash, &bd);
+                       bkt->lsb_lru_len--;
+               }
                cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
                cfs_hash_bd_unlock(obj_hash, &bd, 1);
        }
                cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
                cfs_hash_bd_unlock(obj_hash, &bd, 1);
        }
@@ -383,6 +388,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
                         cfs_hash_bd_del_locked(s->ls_obj_hash,
                                                &bd2, &h->loh_hash);
                        list_move(&h->loh_lru, &dispose);
                         cfs_hash_bd_del_locked(s->ls_obj_hash,
                                                &bd2, &h->loh_hash);
                        list_move(&h->loh_lru, &dispose);
+                       bkt->lsb_lru_len--;
                         if (did_sth == 0)
                                 did_sth = 1;
 
                         if (did_sth == 0)
                                 did_sth = 1;
 
@@ -595,7 +601,10 @@ static struct lu_object *htable_lookup(struct lu_site *s,
         if (likely(!lu_object_is_dying(h))) {
                cfs_hash_get(s->ls_obj_hash, hnode);
                 lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
         if (likely(!lu_object_is_dying(h))) {
                cfs_hash_get(s->ls_obj_hash, hnode);
                 lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
-               list_del_init(&h->loh_lru);
+               if (!list_empty(&h->loh_lru)) {
+                       list_del_init(&h->loh_lru);
+                       bkt->lsb_lru_len--;
+               }
                 return lu_object_top(h);
         }
 
                 return lu_object_top(h);
         }
 
@@ -660,7 +669,6 @@ static struct lu_object *lu_object_new(const struct lu_env *env,
         struct lu_object        *o;
         cfs_hash_t              *hs;
         cfs_hash_bd_t            bd;
         struct lu_object        *o;
         cfs_hash_t              *hs;
         cfs_hash_bd_t            bd;
-        struct lu_site_bkt_data *bkt;
 
         o = lu_object_alloc(env, dev, f, conf);
         if (unlikely(IS_ERR(o)))
 
         o = lu_object_alloc(env, dev, f, conf);
         if (unlikely(IS_ERR(o)))
@@ -668,9 +676,7 @@ static struct lu_object *lu_object_new(const struct lu_env *env,
 
         hs = dev->ld_site->ls_obj_hash;
         cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
 
         hs = dev->ld_site->ls_obj_hash;
         cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
-        bkt = cfs_hash_bd_extra_get(hs, &bd);
         cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
         cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-        bkt->lsb_busy++;
         cfs_hash_bd_unlock(hs, &bd, 1);
 
        lu_object_limit(env, dev);
         cfs_hash_bd_unlock(hs, &bd, 1);
 
        lu_object_limit(env, dev);
@@ -739,11 +745,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
 
         shadow = htable_lookup(s, &bd, f, waiter, &version);
        if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
 
         shadow = htable_lookup(s, &bd, f, waiter, &version);
        if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
-                struct lu_site_bkt_data *bkt;
-
-                bkt = cfs_hash_bd_extra_get(hs, &bd);
                 cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
                 cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-                bkt->lsb_busy++;
                 cfs_hash_bd_unlock(hs, &bd, 1);
 
                lu_object_limit(env, dev);
                 cfs_hash_bd_unlock(hs, &bd, 1);
 
                lu_object_limit(env, dev);
@@ -1000,14 +1002,7 @@ static void lu_obj_hop_get(cfs_hash_t *hs, struct hlist_node *hnode)
        struct lu_object_header *h;
 
        h = hlist_entry(hnode, struct lu_object_header, loh_hash);
        struct lu_object_header *h;
 
        h = hlist_entry(hnode, struct lu_object_header, loh_hash);
-       if (atomic_add_return(1, &h->loh_ref) == 1) {
-               struct lu_site_bkt_data *bkt;
-               cfs_hash_bd_t            bd;
-
-               cfs_hash_bd_get(hs, &h->loh_fid, &bd);
-               bkt = cfs_hash_bd_extra_get(hs, &bd);
-               bkt->lsb_busy++;
-       }
+       atomic_inc(&h->loh_ref);
 }
 
 static void lu_obj_hop_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
 }
 
 static void lu_obj_hop_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
@@ -1875,7 +1870,8 @@ static void lu_site_stats_get(cfs_hash_t *hs,
                struct hlist_head       *hhead;
 
                 cfs_hash_bd_lock(hs, &bd, 1);
                struct hlist_head       *hhead;
 
                 cfs_hash_bd_lock(hs, &bd, 1);
-                stats->lss_busy  += bkt->lsb_busy;
+               stats->lss_busy  +=
+                       cfs_hash_bd_count_get(&bd) - bkt->lsb_lru_len;
                 stats->lss_total += cfs_hash_bd_count_get(&bd);
                 stats->lss_max_search = max((int)stats->lss_max_search,
                                             cfs_hash_bd_depmax_get(&bd));
                 stats->lss_total += cfs_hash_bd_count_get(&bd);
                 stats->lss_max_search = max((int)stats->lss_max_search,
                                             cfs_hash_bd_depmax_get(&bd));
@@ -2222,7 +2218,6 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
 {
        struct lu_site          *s = o->lo_dev->ld_site;
        struct lu_fid           *old = &o->lo_header->loh_fid;
 {
        struct lu_site          *s = o->lo_dev->ld_site;
        struct lu_fid           *old = &o->lo_header->loh_fid;
-       struct lu_site_bkt_data *bkt;
        struct lu_object        *shadow;
        wait_queue_t             waiter;
        cfs_hash_t              *hs;
        struct lu_object        *shadow;
        wait_queue_t             waiter;
        cfs_hash_t              *hs;
@@ -2237,9 +2232,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
        /* supposed to be unique */
        LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT);
        *old = *fid;
        /* supposed to be unique */
        LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT);
        *old = *fid;
-       bkt = cfs_hash_bd_extra_get(hs, &bd);
        cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
        cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-       bkt->lsb_busy++;
        cfs_hash_bd_unlock(hs, &bd, 1);
 }
 EXPORT_SYMBOL(lu_object_assign_fid);
        cfs_hash_bd_unlock(hs, &bd, 1);
 }
 EXPORT_SYMBOL(lu_object_assign_fid);