#ifdef __KERNEL__
#include <obd_class.h>
#include <linux/string.h>
+#include <lustre_disk.h>
#else
#include <liblustre.h>
#include <string.h>
#include <obd_class.h>
#include <obd.h>
#endif
+#include <lustre_ioctl.h>
#include <lustre_log.h>
#include <lprocfs_status.h>
#include <lustre_param.h>
CFS_INIT_LIST_HEAD(&obd->obd_lock_replay_queue);
CFS_INIT_LIST_HEAD(&obd->obd_final_req_queue);
CFS_INIT_LIST_HEAD(&obd->obd_evict_list);
+ INIT_LIST_HEAD(&obd->obd_lwp_list);
- llog_group_init(&obd->obd_olg, FID_SEQ_LLOG);
+ llog_group_init(&obd->obd_olg);
obd->obd_conn_inprogress = 0;
}
memcpy(obd->obd_uuid.uuid, uuid, len);
- /* do the attach */
- if (OBP(obd, attach)) {
- rc = OBP(obd,attach)(obd, sizeof *lcfg, lcfg);
- if (rc)
- GOTO(out, rc = -EINVAL);
- }
-
/* Detach drops this */
spin_lock(&obd->obd_dev_lock);
atomic_set(&obd->obd_refcount, 1);
}
/* Leave this on forever */
obd->obd_stopping = 1;
+ spin_unlock(&obd->obd_dev_lock);
/* wait for already-arrived-connections to finish. */
- while (obd->obd_conn_inprogress > 0) {
- spin_unlock(&obd->obd_dev_lock);
-
- cond_resched();
-
- spin_lock(&obd->obd_dev_lock);
- }
- spin_unlock(&obd->obd_dev_lock);
+ while (obd->obd_conn_inprogress > 0)
+ yield();
+ smp_rmb();
if (lcfg->lcfg_bufcount >= 2 && LUSTRE_CFG_BUFLEN(lcfg, 1) > 0) {
for (flag = lustre_cfg_string(lcfg, 1); *flag != 0; flag++)
CERROR("Cleanup %s returned %d\n",
obd->obd_name, err);
}
- if (OBP(obd, detach)) {
- err = OBP(obd, detach)(obd);
- if (err)
- CERROR("Detach returned %d\n", err);
- }
+
class_release_dev(obd);
}
}
#define lustre_check_exclusion(a,b) 0
#endif
+/*
+ * Supplemental functions for config logs, it allocates lustre_cfg
+ * buffers plus initialized llog record header at the beginning.
+ */
+struct llog_cfg_rec *lustre_cfg_rec_new(int cmd, struct lustre_cfg_bufs *bufs)
+{
+ struct llog_cfg_rec *lcr;
+ int reclen;
+
+ ENTRY;
+
+ reclen = lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen);
+ reclen = llog_data_len(reclen) + sizeof(struct llog_rec_hdr) +
+ sizeof(struct llog_rec_tail);
+
+ OBD_ALLOC(lcr, reclen);
+ if (lcr == NULL)
+ RETURN(NULL);
+
+ lustre_cfg_init(&lcr->lcr_cfg, cmd, bufs);
+
+ lcr->lcr_hdr.lrh_len = reclen;
+ lcr->lcr_hdr.lrh_type = OBD_CFG_REC;
+
+ RETURN(lcr);
+}
+EXPORT_SYMBOL(lustre_cfg_rec_new);
+
+void lustre_cfg_rec_free(struct llog_cfg_rec *lcr)
+{
+ ENTRY;
+ OBD_FREE(lcr, lcr->lcr_hdr.lrh_len);
+ EXIT;
+}
+EXPORT_SYMBOL(lustre_cfg_rec_free);
+
/** Parse a configuration llog, doing various manipulations on them
* for various reasons, (modifications for compatibility, skip obsolete
* records, change uuids, etc), then class_process_config() resulting
if (marker->cm_flags & CM_START) {
/* all previous flags off */
clli->cfg_flags = CFG_F_MARKER;
+ server_name2index(marker->cm_tgtname,
+ &clli->cfg_lwp_idx, NULL);
if (marker->cm_flags & CM_SKIP) {
clli->cfg_flags |= CFG_F_SKIP;
CDEBUG(D_CONFIG, "SKIP #%d\n",
}
lcfg_new = lustre_cfg_new(lcfg->lcfg_command, &bufs);
+ if (lcfg_new == NULL)
+ GOTO(out, rc = -ENOMEM);
lcfg_new->lcfg_num = lcfg->lcfg_num;
lcfg_new->lcfg_flags = lcfg->lcfg_flags;
if (rec->lrh_type == OBD_CFG_REC) {
class_config_parse_rec(rec, outstr, 256);
- LCONSOLE(D_WARNING, " %s", outstr);
+ LCONSOLE(D_WARNING, " %s\n", outstr);
} else {
LCONSOLE(D_WARNING, "unhandled lrh_type: %#x\n", rec->lrh_type);
rc = -EINVAL;