Whamcloud - gitweb
LU-7164 osc: osc_extent should hold refcount to osc_object 33/16433/3
authorJinshan Xiong <jinshan.xiong@intel.com>
Tue, 15 Sep 2015 19:19:10 +0000 (12:19 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Nov 2015 14:26:37 +0000 (14:26 +0000)
To avoid a race that osc_extent and osc_object destroy happens on the
same time, which causes kernel crash.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I3e3237f0d1cff4bd992bef4e4c01355a1d5c8d9f
Reviewed-on: http://review.whamcloud.com/16433
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_cache.c

index 981f35c..0d616bf 100644 (file)
@@ -325,6 +325,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
 
        RB_CLEAR_NODE(&ext->oe_node);
        ext->oe_obj = obj;
 
        RB_CLEAR_NODE(&ext->oe_node);
        ext->oe_obj = obj;
+       cl_object_get(osc2cl(obj));
        atomic_set(&ext->oe_refc, 1);
        atomic_set(&ext->oe_users, 0);
        INIT_LIST_HEAD(&ext->oe_link);
        atomic_set(&ext->oe_refc, 1);
        atomic_set(&ext->oe_users, 0);
        INIT_LIST_HEAD(&ext->oe_link);
@@ -363,6 +364,7 @@ static void osc_extent_put(const struct lu_env *env, struct osc_extent *ext)
                        LDLM_LOCK_PUT(ext->oe_dlmlock);
                        ext->oe_dlmlock = NULL;
                }
                        LDLM_LOCK_PUT(ext->oe_dlmlock);
                        ext->oe_dlmlock = NULL;
                }
+               cl_object_put(env, osc2cl(ext->oe_obj));
                osc_extent_free(ext);
        }
 }
                osc_extent_free(ext);
        }
 }