Whamcloud - gitweb
LU-12003 osd: take reference to object in osd_trunc_lock() 70/37170/8
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 9 Jan 2020 13:28:54 +0000 (16:28 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:22:44 +0000 (08:22 +0000)
normally the references to objects are held until a transaction
is over, but in few cases reference is released before. and then
such an object can be release, so OSD should have own reference
to prevent early release.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I81647fdec8d42f123e990553edb5e371636f45c0
Reviewed-on: https://review.whamcloud.com/37170
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index e606f7d..099510d 100644 (file)
@@ -2034,7 +2034,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                OBD_FREE_PTR(oh);
        }
 
-       osd_trunc_unlock_all(&truncates);
+       osd_trunc_unlock_all(env, &truncates);
 
        /* inform the quota slave device that the transaction is stopping */
        qsd_op_end(env, qsd, qtrans);
index 81afee0..8419834 100644 (file)
@@ -1475,7 +1475,7 @@ osd_index_backup(const struct lu_env *env, struct osd_device *osd, bool backup)
 
 int osd_trunc_lock(struct osd_object *obj, struct osd_thandle *oh,
                   bool shared);
-void osd_trunc_unlock_all(struct list_head *list);
+void osd_trunc_unlock_all(const struct lu_env *env, struct list_head *list);
 void osd_process_truncates(struct list_head *list);
 void osd_execute_truncate(struct osd_object *obj);
 
index 0cf03c4..b3e4c07 100644 (file)
@@ -2196,13 +2196,14 @@ int osd_trunc_lock(struct osd_object *obj, struct osd_thandle *oh, bool shared)
        else
                down_write(&obj->oo_ext_idx_sem);
        al->tl_shared = shared;
+       lu_object_get(&obj->oo_dt.do_lu);
 
        list_add(&al->tl_list, &oh->ot_trunc_locks);
 
        return 0;
 }
 
-void osd_trunc_unlock_all(struct list_head *list)
+void osd_trunc_unlock_all(const struct lu_env *env, struct list_head *list)
 {
        struct osd_access_lock *al, *tmp;
        list_for_each_entry_safe(al, tmp, list, tl_list) {
@@ -2210,6 +2211,7 @@ void osd_trunc_unlock_all(struct list_head *list)
                        up_read(&al->tl_obj->oo_ext_idx_sem);
                else
                        up_write(&al->tl_obj->oo_ext_idx_sem);
+               osd_object_put(env, al->tl_obj);
                list_del(&al->tl_list);
                OBD_FREE_PTR(al);
        }