list_for_each_entry(dataset, &super->pccs_datasets, pccd_linkage) {
if (pcc_dataset_attach_allowed(dataset, type) &&
pcc_cond_match(&dataset->pccd_rule, matcher)) {
- atomic_inc(&dataset->pccd_refcount);
+ kref_get(&dataset->pccd_refcount);
selected = dataset;
break;
}
dataset->pccd_roid = cmd->u.pccc_add.pccc_roid;
dataset->pccd_flags = cmd->u.pccc_add.pccc_flags;
dataset->pccd_hsmtool_type = cmd->u.pccc_add.pccc_hsmtool_type;
- atomic_set(&dataset->pccd_refcount, 1);
+ kref_init(&dataset->pccd_refcount);
rc = pcc_dataset_rule_init(&dataset->pccd_rule, cmd);
if (rc) {
(!(dataset->pccd_roid == id || id == 0) ||
!(dataset->pccd_flags & PCC_DATASET_PCCRO)))
continue;
- atomic_inc(&dataset->pccd_refcount);
+ kref_get(&dataset->pccd_refcount);
selected = dataset;
break;
}
return selected;
}
+void pcc_dataset_free(struct kref *kref)
+{
+ struct pcc_dataset *dataset = container_of(kref, struct pcc_dataset,
+ pccd_refcount);
+
+ pcc_dataset_rule_fini(&dataset->pccd_rule);
+ path_put(&dataset->pccd_path);
+ OBD_FREE_PTR(dataset);
+}
+
void
pcc_dataset_put(struct pcc_dataset *dataset)
{
- if (atomic_dec_and_test(&dataset->pccd_refcount)) {
- pcc_dataset_rule_fini(&dataset->pccd_rule);
- path_put(&dataset->pccd_path);
- OBD_FREE_PTR(dataset);
- }
+ kref_put(&dataset->pccd_refcount, pcc_dataset_free);
}
static int
#ifndef LLITE_PCC_H
#define LLITE_PCC_H
-#include <linux/types.h>
#include <linux/fs.h>
-#include <linux/seq_file.h>
#include <linux/mm.h>
+#include <linux/kref.h>
+#include <linux/types.h>
+#include <linux/seq_file.h>
#include <uapi/linux/lustre/lustre_user.h>
extern struct kmem_cache *pcc_inode_slab;
char pccd_pathname[PATH_MAX]; /* full path */
struct path pccd_path; /* Root path */
struct list_head pccd_linkage; /* Linked to pccs_datasets */
- atomic_t pccd_refcount; /* Reference count */
+ struct kref pccd_refcount; /* Reference count */
enum hsmtool_type pccd_hsmtool_type; /* HSM copytool type */
};
struct pcc_dataset *pcc_dataset_match_get(struct pcc_super *super,
enum lu_pcc_type type,
struct pcc_matcher *matcher);
+void pcc_dataset_free(struct kref *kref);
void pcc_dataset_put(struct pcc_dataset *dataset);
void pcc_inode_free(struct inode *inode);
void pcc_layout_invalidate(struct inode *inode);