X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosp%2Fosp_dev.c;h=0aaf16292aeb6abe9094680f52be2023fc7b18ce;hb=392dab3c01bb802892466f9a05ef1b56406b8522;hp=7c630876ff893a6b6b21220195af5f0874e89e1c;hpb=3e61bbbcd4baaac76a67093404b60810261812e0;p=fs%2Flustre-release.git diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 7c63087..0aaf162 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -258,25 +258,23 @@ static int osp_init_last_objid(const struct lu_env *env, struct osp_device *osp) if (IS_ERR(dto)) RETURN(PTR_ERR(dto)); + osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &osp->opd_last_id, + osp->opd_index); + /* object will be released in device cleanup path */ - if (osi->osi_attr.la_size >= - sizeof(osi->osi_id) * (osp->opd_index + 1)) { - osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &osi->osi_id, - osp->opd_index); + if (osi->osi_attr.la_size >= (osi->osi_off + osi->osi_lb.lb_len)) { rc = dt_record_read(env, dto, &osi->osi_lb, &osi->osi_off); if (rc != 0 && rc != -EFAULT) GOTO(out, rc); /* In case of idif bits 32-48 go to f_seq * (see osp_init_last_seq). So don't care * about u64->u32 convertion. */ - fid->f_oid = osi->osi_id; + fid->f_oid = osp->opd_last_id; } if (rc == -EFAULT) { /* fresh LAST_ID */ - osi->osi_id = 0; + osp->opd_last_id = 0; fid->f_oid = 0; - osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &osi->osi_id, - osp->opd_index); rc = osp_write_local_file(env, osp, dto, &osi->osi_lb, osi->osi_off); if (rc != 0) @@ -320,22 +318,21 @@ static int osp_init_last_seq(const struct lu_env *env, struct osp_device *osp) if (IS_ERR(dto)) RETURN(PTR_ERR(dto)); + osp_objseq_buf_prep(&osi->osi_lb, &osi->osi_off, &fid->f_seq, + osp->opd_index); + /* object will be released in device cleanup path */ - if (osi->osi_attr.la_size >= - sizeof(osi->osi_id) * (osp->opd_index + 1)) { - osp_objseq_buf_prep(&osi->osi_lb, &osi->osi_off, &fid->f_seq, - osp->opd_index); + if (osi->osi_attr.la_size >= (osi->osi_off + osi->osi_lb.lb_len)) { rc = dt_record_read(env, dto, &osi->osi_lb, &osi->osi_off); if (rc != 0 && rc != -EFAULT) GOTO(out, rc); if (fid_is_idif(fid)) - fid->f_seq = fid_idif_seq(osi->osi_id, osp->opd_index); + fid->f_seq = fid_idif_seq(osp->opd_last_id, + osp->opd_index); } if (rc == -EFAULT) { /* fresh OSP */ fid->f_seq = 0; - osp_objseq_buf_prep(&osi->osi_lb, &osi->osi_off, &fid->f_seq, - osp->opd_index); rc = osp_write_local_file(env, osp, dto, &osi->osi_lb, osi->osi_off); if (rc != 0) @@ -412,6 +409,7 @@ static int osp_last_used_init(const struct lu_env *env, struct osp_device *osp) GOTO(out, rc = -EINVAL); } + osp_fid_to_obdid(&osp->opd_last_used_fid, &osp->opd_last_id); CDEBUG(D_INFO, "%s: Init last used fid "DFID"\n", osp->opd_obd->obd_name, PFID(&osp->opd_last_used_fid)); out: @@ -603,6 +601,8 @@ static int osp_shutdown(const struct lu_env *env, struct osp_device *d) rc = osp_disconnect(d); + osp_statfs_fini(d); + if (!d->opd_connect_mdt) { /* stop sync thread */ osp_sync_fini(d); @@ -743,12 +743,12 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev, if (unlikely(d->opd_imp_active == 0)) RETURN(-ENOTCONN); - if (d->opd_pre == NULL) - RETURN(0); - /* return recently updated data */ *sfs = d->opd_statfs; + if (d->opd_pre == NULL) + RETURN(0); + /* * layer above osp (usually lod) can use ffree to estimate * how many objects are available for immediate creation @@ -1010,7 +1010,6 @@ static int osp_init0(const struct lu_env *env, struct osp_device *osp, { struct obd_device *obd; struct obd_import *imp; - class_uuid_t uuid; char *src, *tgt, *mdt, *osdname = NULL; int rc; long idx; @@ -1131,14 +1130,7 @@ static int osp_init0(const struct lu_env *env, struct osp_device *osp, strcat(osdname, "-osd"); CDEBUG(D_HA, "%s: connect to %s (%s)\n", obd->obd_name, osdname, src); - if (osp->opd_connect_mdt) { - struct client_obd *cli = &osp->opd_obd->u.cli; - - OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); - if (!cli->cl_rpc_lock) - GOTO(out_fini, rc = -ENOMEM); - osp_init_rpc_lock(cli->cl_rpc_lock); - } + osp_init_rpc_lock(osp); osp->opd_dt_dev.dd_lu_dev.ld_ops = &osp_lu_ops; osp->opd_dt_dev.dd_ops = &osp_dt_ops; @@ -1194,19 +1186,21 @@ static int osp_init0(const struct lu_env *env, struct osp_device *osp, if (rc < 0) GOTO(out_precreat, rc); } else { + osp->opd_got_disconnected = 1; rc = osp_update_init(osp); if (rc != 0) GOTO(out_fid, rc); } + rc = osp_init_statfs(osp); + if (rc) + GOTO(out_precreat, rc); + ns_register_cancel(obd->obd_namespace, osp_cancel_weight); /* * Initiate connect to OST */ - ll_generate_random_uuid(uuid); - class_uuid_unparse(uuid, &osp->opd_cluuid); - imp = obd->u.cli.cl_import; rc = ptlrpc_init_import(imp); @@ -1237,13 +1231,6 @@ out_proc: out_ref: ptlrpcd_decref(); out_disconnect: - if (osp->opd_connect_mdt) { - struct client_obd *cli = &osp->opd_obd->u.cli; - if (cli->cl_rpc_lock != NULL) { - OBD_FREE_PTR(cli->cl_rpc_lock); - cli->cl_rpc_lock = NULL; - } - } obd_disconnect(osp->opd_storage_exp); out_fini: if (osdname) @@ -1349,14 +1336,6 @@ static struct lu_device *osp_device_fini(const struct lu_env *env, LASSERT(osp->opd_obd); osp_tunables_fini(osp); - if (osp->opd_connect_mdt) { - struct client_obd *cli = &osp->opd_obd->u.cli; - if (cli->cl_rpc_lock != NULL) { - OBD_FREE_PTR(cli->cl_rpc_lock); - cli->cl_rpc_lock = NULL; - } - } - rc = client_obd_cleanup(osp->opd_obd); if (rc != 0) { ptlrpcd_decref(); @@ -1622,12 +1601,10 @@ static int osp_import_event(struct obd_device *obd, struct obd_import *imp, d->opd_imp_connected = 1; d->opd_imp_seen_connected = 1; d->opd_obd->obd_inactive = 0; + wake_up(&d->opd_pre_waitq); if (d->opd_connect_mdt) break; - if (d->opd_pre != NULL) - wake_up(&d->opd_pre_waitq); - osp_sync_check_for_work(d); CDEBUG(D_HA, "got connected\n"); break; @@ -1698,9 +1675,6 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = ptlrpc_set_import_active(obd->u.cli.cl_import, data->ioc_offset); break; - case OBD_IOC_PING_TARGET: - rc = ptlrpc_obd_ping(obd); - break; default: CERROR("%s: unrecognized ioctl %#x by %s\n", obd->obd_name, cmd, current_comm()); @@ -1907,7 +1881,7 @@ static struct obd_ops osp_obd_device_ops = { .o_fid_alloc = osp_fid_alloc, }; -static struct obd_type sym; +static struct obd_type *sym; /** * Initialize OSP module. @@ -1925,7 +1899,6 @@ static int __init osp_init(void) { struct dentry *symlink; struct obd_type *type; - struct kobject *kobj; struct qstr dname; int rc; @@ -1948,6 +1921,15 @@ static int __init osp_init(void) return rc; } + sym = class_setup_tunables(LUSTRE_OSC_NAME); + if (IS_ERR(sym)) { + rc = PTR_ERR(sym); + /* does real "osc" already exist ? */ + if (rc == -EEXIST) + GOTO(try_proc, rc = 0); + GOTO(no_osc, rc); + } + /* create "osc" entry for compatibility purposes */ dname.name = "osc"; dname.len = strlen(dname.name); @@ -1960,26 +1942,11 @@ static int __init osp_init(void) rc = symlink ? PTR_ERR(symlink) : -ENOMEM; GOTO(no_osc, rc); } - sym.typ_debugfs_entry = symlink; + sym->typ_debugfs_entry = symlink; } else { dput(symlink); } - kobj = kset_find_obj(lustre_kset, dname.name); - if (kobj) { - kobject_put(kobj); - goto try_proc; - } - - kobj = class_setup_tunables(dname.name); - if (IS_ERR(kobj)) { - rc = PTR_ERR(kobj); - if (sym.typ_debugfs_entry) - ldebugfs_remove(&sym.typ_debugfs_entry); - GOTO(no_osc, rc); - } - sym.typ_kobj = kobj; - try_proc: type = class_search_type(LUSTRE_OSC_NAME); if (type != NULL && type->typ_procroot != NULL) @@ -2005,8 +1972,10 @@ no_osc: */ static void __exit osp_exit(void) { - ldebugfs_remove(&sym.typ_debugfs_entry); - kobject_put(sym.typ_kobj); + if (!IS_ERR_OR_NULL(sym)) { + ldebugfs_remove(&sym->typ_debugfs_entry); + kobject_put(&sym->typ_kobj); + } class_unregister_type(LUSTRE_LWP_NAME); class_unregister_type(LUSTRE_OSP_NAME); lu_kmem_fini(osp_caches);