out_free:
if (ha != NULL && ha->ha_archive_id != NULL)
- OBD_FREE(ha->ha_archive_id,
- ha->ha_archive_cnt * sizeof(*ha->ha_archive_id));
+ OBD_FREE_PTR_ARRAY(ha->ha_archive_id, ha->ha_archive_cnt);
if (ha != NULL)
OBD_FREE_PTR(ha);
out:
+ /* wake the coordinator to potentially schedule requests */
+ if (rc == -EEXIST || rc == 0)
+ mdt_hsm_cdt_event(cdt);
+
return rc;
}
nr_archives = hweight32(archive_mask);
if (nr_archives != 0) {
- OBD_ALLOC(archive_id, nr_archives * sizeof(*archive_id));
+ OBD_ALLOC_PTR_ARRAY(archive_id, nr_archives);
if (!archive_id)
RETURN(-ENOMEM);
nr_archives = 0;
for (i = 0; i < sizeof(archive_mask) * 8; i++) {
- if ((1 << i) & archive_mask) {
+ if (BIT(i) & archive_mask) {
archive_id[nr_archives] = i + 1;
nr_archives++;
}
rc = mdt_hsm_agent_register(mti, uuid, nr_archives, archive_id);
if (archive_id != NULL)
- OBD_FREE(archive_id, nr_archives * sizeof(*archive_id));
+ OBD_FREE_PTR_ARRAY(archive_id, nr_archives);
RETURN(rc);
}
GOTO(out, rc = -ENOENT);
if (ha->ha_archive_cnt != 0)
- OBD_FREE(ha->ha_archive_id,
- ha->ha_archive_cnt * sizeof(*ha->ha_archive_id));
+ OBD_FREE_PTR_ARRAY(ha->ha_archive_id, ha->ha_archive_cnt);
OBD_FREE_PTR(ha);
GOTO(out, rc = 0);
list_for_each_entry(ha, &cdt->cdt_agents, ha_list) {
for (i = 0; (i < ha->ha_archive_cnt); i++) {
/* only send once for each archive_id */
- if ((1 << ha->ha_archive_id[i]) & archive_mask)
+ if (BIT(ha->ha_archive_id[i]) & archive_mask)
continue;
- archive_mask |= (1 << ha->ha_archive_id[i]);
+ archive_mask |= BIT(ha->ha_archive_id[i]);
/* XXX: it could make sense to gather all
* actions for the same archive_id like in
* the ldlm_callback_handler. Note this sends a request RPC
* from a server (MDT) to a client (MDC), backwards of normal comms.
*/
- exp = cfs_hash_lookup(mdt2obd_dev(mdt)->obd_uuid_hash, &uuid);
+ exp = obd_uuid_lookup(mdt2obd_dev(mdt), &uuid);
if (exp == NULL || exp->exp_disconnected) {
if (exp != NULL)
class_export_put(exp);
}
/**
- * seq_file method called to start access to /proc file
+ * seq_file method called to start access to debugfs file
*/
-static void *mdt_hsm_agent_proc_start(struct seq_file *s, loff_t *off)
+static void *mdt_hsm_agent_debugfs_start(struct seq_file *s, loff_t *off)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
* seq_file method called to get next item
* just returns NULL at eof
*/
-static void *mdt_hsm_agent_proc_next(struct seq_file *s, void *v, loff_t *p)
+static void *mdt_hsm_agent_debugfs_next(struct seq_file *s, void *v, loff_t *p)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
/**
*/
-static int mdt_hsm_agent_proc_show(struct seq_file *s, void *v)
+static int mdt_hsm_agent_debugfs_show(struct seq_file *s, void *v)
{
struct list_head *pos = v;
struct hsm_agent *ha;
}
/**
- * seq_file method called to stop access to /proc file
+ * seq_file method called to stop access to debugfs file
*/
-static void mdt_hsm_agent_proc_stop(struct seq_file *s, void *v)
+static void mdt_hsm_agent_debugfs_stop(struct seq_file *s, void *v)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
up_read(&cdt->cdt_agent_lock);
}
-/* hsm agent list proc functions */
-static const struct seq_operations mdt_hsm_agent_proc_ops = {
- .start = mdt_hsm_agent_proc_start,
- .next = mdt_hsm_agent_proc_next,
- .show = mdt_hsm_agent_proc_show,
- .stop = mdt_hsm_agent_proc_stop,
+/* hsm agent list debugfs functions */
+static const struct seq_operations mdt_hsm_agent_debugfs_ops = {
+ .start = mdt_hsm_agent_debugfs_start,
+ .next = mdt_hsm_agent_debugfs_next,
+ .show = mdt_hsm_agent_debugfs_show,
+ .stop = mdt_hsm_agent_debugfs_stop,
};
/**
- * public function called at open of /proc file to get
+ * public function called at open of debugfs file to get
* list of agents
*/
-static int lprocfs_open_hsm_agent(struct inode *inode, struct file *file)
+static int ldebugfs_open_hsm_agent(struct inode *inode, struct file *file)
{
struct seq_file *s;
int rc;
ENTRY;
- rc = seq_open(file, &mdt_hsm_agent_proc_ops);
+ rc = seq_open(file, &mdt_hsm_agent_debugfs_ops);
if (rc)
RETURN(rc);
s = file->private_data;
- s->private = PDE_DATA(inode);
+ s->private = inode->i_private;
RETURN(rc);
}
/* methods to access hsm agent list */
const struct file_operations mdt_hsm_agent_fops = {
.owner = THIS_MODULE,
- .open = lprocfs_open_hsm_agent,
+ .open = ldebugfs_open_hsm_agent,
.read = seq_read,
.llseek = seq_lseek,
- .release = lprocfs_seq_release,
+ .release = seq_release,
};