struct lu_device_type *ldt;
struct lu_device *d;
struct ofd_thread_info *info = ofd_info(env);
+ struct lustre_mount_info *lmi;
int rc;
ENTRY;
- /* XXX: we should be able to use different OSDs here */
- type = class_get_type(LUSTRE_OSD_NAME);
+ lmi = server_get_mount_2(dev);
+ if (lmi == NULL) {
+ CERROR("Cannot get mount info for %s!\n", dev);
+ RETURN(-ENODEV);
+ }
+
+ type = class_get_type(s2lsi(lmi->lmi_sb)->lsi_osd_type);
if (!type) {
- CERROR("Unknown type: '%s'\n", LUSTRE_OSD_NAME);
+ CERROR("Unknown type: '%s'\n",
+ s2lsi(lmi->lmi_sb)->lsi_osd_type);
RETURN(-ENODEV);
}
ldt = type->typ_lu;
if (ldt == NULL) {
- CERROR("type: '%s'\n", LUSTRE_OSD_NAME);
+ CERROR("type: '%s'\n", s2lsi(lmi->lmi_sb)->lsi_osd_type);
GOTO(out_type, rc = -EINVAL);
}
ldt->ldt_obd_type = type;
d = ldt->ldt_ops->ldto_device_alloc(env, ldt, cfg);
if (IS_ERR(d)) {
- CERROR("Cannot allocate device: '%s'\n", LUSTRE_OSD_NAME);
+ CERROR("Cannot allocate device: '%s'\n",
+ s2lsi(lmi->lmi_sb)->lsi_osd_type);
GOTO(out_type, rc = -ENODEV);
}
type->typ_refcnt++;
rc = ldt->ldt_ops->ldto_device_init(env, d, dev, NULL);
if (rc) {
- CERROR("can't init device '%s', rc %d\n", LUSTRE_OSD_NAME, rc);
+ CERROR("can't init device '%s', rc = %d\n",
+ s2lsi(lmi->lmi_sb)->lsi_osd_type, rc);
GOTO(out_free, rc);
}
lu_device_get(d);
ENTRY;
+ /* Grant space for object precreation on the self export.
+ * This initial reserved space (i.e. 20MB for zfs and 560KB for ldiskfs)
+ * is enough to create 20k objects. It is then adapted based on the
+ * precreate request size (see ofd_grant_create()
+ */
+ ofd_grant_connect(env, dev->ld_obd->obd_self_export,
+ OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace);
rc = next->ld_ops->ldo_recovery_complete(env, next);
RETURN(rc);
}
const char *dev = lustre_cfg_string(cfg, 0);
struct ofd_thread_info *info = NULL;
struct obd_device *obd;
+ struct obd_statfs *osfs;
int rc;
ENTRY;
obd->u.obt.obt_magic = OBT_MAGIC;
+ m->ofd_fmd_max_num = OFD_FMD_MAX_NUM_DEFAULT;
+ m->ofd_fmd_max_age = OFD_FMD_MAX_AGE_DEFAULT;
+
cfs_spin_lock_init(&m->ofd_flags_lock);
m->ofd_raid_degraded = 0;
m->ofd_syncjournal = 0;
ofd_slc_set(m);
-
+ m->ofd_grant_compat_disable = 0;
+
+ /* statfs data */
+ cfs_spin_lock_init(&m->ofd_osfs_lock);
+ m->ofd_osfs_age = cfs_time_shift_64(-1000);
+ m->ofd_osfs_unstable = 0;
+ m->ofd_statfs_inflight = 0;
+ m->ofd_osfs_inflight = 0;
+
+ /* grant data */
+ cfs_spin_lock_init(&m->ofd_grant_lock);
+ m->ofd_tot_dirty = 0;
+ m->ofd_tot_granted = 0;
+ m->ofd_tot_pending = 0;
m->ofd_max_group = 0;
cfs_rwlock_init(&obd->u.filter.fo_sptlrpc_lock);
GOTO(err_lu_site, rc);
}
+ /* populate cached statfs data */
+ osfs = &ofd_info(env)->fti_u.osfs;
+ rc = ofd_statfs_internal(env, m, osfs, 0, NULL);
+ if (rc != 0) {
+ CERROR("%s: can't get statfs data, rc %d\n", obd->obd_name, rc);
+ GOTO(err_fini_stack, rc);
+ }
+ if (!IS_PO2(osfs->os_bsize)) {
+ CERROR("%s: blocksize (%d) is not a power of 2\n",
+ obd->obd_name, osfs->os_bsize);
+ GOTO(err_fini_stack, rc = -EPROTO);
+ }
+ m->ofd_blockbits = cfs_fls(osfs->os_bsize) - 1;
+
+ snprintf(info->fti_u.name, sizeof(info->fti_u.name), "filter-%p", m);
m->ofd_namespace = ldlm_namespace_new(obd, info->fti_u.name,
LDLM_NAMESPACE_SERVER,
LDLM_NAMESPACE_GREEDY,
GOTO(err_fini_stack, rc = -ENOMEM);
/* set obd_namespace for compatibility with old code */
obd->obd_namespace = m->ofd_namespace;
+ ldlm_register_intent(m->ofd_namespace, ofd_intent_policy);
+ m->ofd_namespace->ns_lvbo = &ofd_lvbo;
+ m->ofd_namespace->ns_lvbp = m;
+
+ ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
+ "filter_ldlm_cb_client", &obd->obd_ldlm_client);
dt_conf_get(env, m->ofd_osd, &m->ofd_dt_conf);
+ /* Allow at most ddp_grant_reserved% of the available filesystem space
+ * to be granted to clients, so that any errors in the grant overhead
+ * calculations do not allow granting more space to clients than can be
+ * written. Assumes that in aggregate the grant overhead calculations do
+ * not have more than ddp_grant_reserved% estimation error in them. */
+ m->ofd_grant_ratio =
+ ofd_grant_ratio_conv(m->ofd_dt_conf.ddp_grant_reserved);
+
rc = ofd_start(env, &m->ofd_dt_dev.dd_lu_dev);
if (rc)
GOTO(err_fini_stack, rc);
info->fti_env = NULL;
info->fti_exp = NULL;
+
+ info->fti_xid = 0;
+ info->fti_transno = 0;
+ info->fti_pre_version = 0;
+ info->fti_obj = NULL;
+ info->fti_has_trans = 0;
+ info->fti_mult_trans = 0;
+ info->fti_used = 0;
+
+ memset(&info->fti_attr, 0, sizeof info->fti_attr);
}
struct lu_context_key ofd_thread_key = {
if (rc)
return rc;
+ rc = ofd_fmd_init();
+ if (rc) {
+ lu_kmem_fini(ofd_caches);
+ return(rc);
+ }
+
lprocfs_ofd_init_vars(&lvars);
rc = class_register_type(&ofd_obd_ops, NULL, lvars.module_vars,
void __exit ofd_exit(void)
{
- class_unregister_type(LUSTRE_OST_NAME);
+ ofd_fmd_exit();
lu_kmem_fini(ofd_caches);
+ class_unregister_type(LUSTRE_OST_NAME);
}
MODULE_AUTHOR("Whamcloud, Inc. <http://www.whamcloud.com/>");