Whamcloud - gitweb
LU-12003 osd: take reference to object in osd_trunc_lock() 47/40547/2
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 9 Jan 2020 13:28:54 +0000 (16:28 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 4 Mar 2021 08:35:08 +0000 (08:35 +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.

Lustre-change: https://review.whamcloud.com/37170
Lustre-commit: 4fcb9081378f6ad0b7d3cf4105cf5fb2d506966f

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>
Reviewed-on: https://review.whamcloud.com/40547

lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index ffec5c7..83e4223 100644 (file)
@@ -2121,7 +2121,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 d6285e4..7b78c18 100644 (file)
@@ -1441,7 +1441,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 d9fba93..1bdc6e9 100644 (file)
@@ -2486,13 +2486,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) {
@@ -2500,6 +2501,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);
        }