/* Dummy hash for iteration against the rbtree. */
__u64 llst_hash;
__u64 llst_gen;
- atomic_t llst_ref;
+ struct kref llst_ref;
__u32 llst_index;
/* How many times we have failed to get the master status. */
int llst_failures;
}
static inline void
-lfsck_layout_llst_put(struct lfsck_layout_slave_target *llst)
+lfsck_layout_llst_put(struct kref *kref)
{
- if (atomic_dec_and_test(&llst->llst_ref)) {
- LASSERT(list_empty(&llst->llst_list));
+ struct lfsck_layout_slave_target *llst;
- OBD_FREE_PTR(llst);
- }
+ llst = container_of(kref, struct lfsck_layout_slave_target, llst_ref);
+ LASSERT(list_empty(&llst->llst_list));
+ OBD_FREE_PTR(llst);
}
static inline int
INIT_LIST_HEAD(&llst->llst_list);
llst->llst_gen = 0;
llst->llst_index = index;
- atomic_set(&llst->llst_ref, 1);
+ kref_init(&llst->llst_ref);
spin_lock(&llsd->llsd_lock);
list_for_each_entry(tmp, &llsd->llsd_master_list, llst_list) {
spin_unlock(&llsd->llsd_lock);
if (del)
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
}
static inline struct lfsck_layout_slave_target *
if (unlink)
list_del_init(&llst->llst_list);
else
- atomic_inc(&llst->llst_ref);
+ kref_get(&llst->llst_ref);
spin_unlock(&llsd->llsd_lock);
return llst;
lfsck_layout_llst_del(llsd, llst);
}
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
lfsck_component_put(env, com);
class_export_put(exp);
llst->llst_gen = llsd->llsd_touch_gen;
list_move_tail(&llst->llst_list,
&llsd->llsd_master_list);
- atomic_inc(&llst->llst_ref);
+ kref_get(&llst->llst_ref);
spin_unlock(&llsd->llsd_lock);
exp = lustre_find_lwp_by_index(lfsck->li_obd->obd_name,
llst->llst_index);
if (exp == NULL) {
lfsck_layout_llst_del(llsd, llst);
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
spin_lock(&llsd->llsd_lock);
continue;
}
exp->exp_obd->obd_name, rc);
rc1 = rc;
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
class_export_put(exp);
}
spin_lock(&llsd->llsd_lock);
llst->llst_gen = llsd->llsd_touch_gen;
list_move_tail(&llst->llst_list,
&llsd->llsd_master_list);
- atomic_inc(&llst->llst_ref);
+ kref_get(&llst->llst_ref);
spin_unlock(&llsd->llsd_lock);
exp = lustre_find_lwp_by_index(lfsck->li_obd->obd_name,
llst->llst_index);
if (exp == NULL) {
lfsck_layout_llst_del(llsd, llst);
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
spin_lock(&llsd->llsd_lock);
continue;
}
lfsck_lfsck2name(lfsck),
exp->exp_obd->obd_name, rc);
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
class_export_put(exp);
spin_lock(&llsd->llsd_lock);
}
llst_list);
list_del_init(&llst->llst_list);
spin_unlock(&llsd->llsd_lock);
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
spin_lock(&llsd->llsd_lock);
}
spin_unlock(&llsd->llsd_lock);
lr->lr_index,
true);
if (llst != NULL) {
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref,
+ lfsck_layout_llst_put);
wake_up(&lfsck->li_thread.t_ctl_waitq);
}
}
if (llst == NULL)
RETURN(0);
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
if (list_empty(&llsd->llsd_master_list))
wake_up(&lfsck->li_thread.t_ctl_waitq);
llst = lfsck_layout_llst_find_and_del(llsd, lsp->lsp_index,
true);
if (llst != NULL)
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
spin_lock(&lfsck->li_lock);
rc = -EAGAIN;
}
/* Save the key and hash for iterate next. */
llst->llst_fid = it->loi_key;
llst->llst_hash = it->loi_hash;
- lfsck_layout_llst_put(llst);
+ kref_put(&llst->llst_ref, lfsck_layout_llst_put);
lfsck_component_put(env, com);
}
OBD_FREE_PTR(it);