From: nikita Date: Wed, 29 Mar 2006 18:48:37 +0000 (+0000) Subject: yank lu_device and lu_device_type inside of obd_device and obd_type resp. This is... X-Git-Tag: v1_8_0_110~486^2~2130 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=2499a306f3246cd235109983faed0a409c96eb7c;p=fs%2Flustre-release.git yank lu_device and lu_device_type inside of obd_device and obd_type resp. This is temporary measure to avoid changing a lot of code at prototype stage --- diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index faaa273..28d2d61 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -32,6 +32,8 @@ #include #include +#include + /* this is really local to the OSC */ struct loi_oap_pages { struct list_head lop_pending; @@ -144,6 +146,7 @@ struct obd_type { struct proc_dir_entry *typ_procroot; char *typ_name; int typ_refcnt; + struct lu_device_type *typ_lu; }; struct brw_page { @@ -621,6 +624,8 @@ struct obd_device { char *obd_name; struct obd_uuid obd_uuid; + struct lu_device *obd_lu_dev; + int obd_minor; unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1, obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1, @@ -714,7 +719,7 @@ struct obd_ops { __u32 vallen, void *val); int (*o_attach)(struct obd_device *dev, obd_count len, void *data); int (*o_detach)(struct obd_device *dev); - int (*o_setup) (struct obd_device *dev, obd_count len, void *data); + int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg); int (*o_precleanup)(struct obd_device *dev, int cleanup_stage); int (*o_cleanup)(struct obd_device *dev); int (*o_process_config)(struct obd_device *dev, obd_count len, @@ -739,15 +744,15 @@ struct obd_ops { int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt, struct lov_stripe_md *mem_src); int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt, - struct lov_mds_md *disk_src, int disk_len); - int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp, + struct lov_mds_md *disk_src, int disk_len); + int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp, struct lov_stripe_md *mem_tgt); int (*o_preallocate)(struct lustre_handle *, obd_count *req, obd_id *ids); int (*o_create)(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti); int (*o_destroy)(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *ea, struct obd_trans_info *oti, + struct lov_stripe_md *ea, struct obd_trans_info *oti, struct obd_export *md_exp); int (*o_setattr)(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, struct obd_trans_info *oti); @@ -877,7 +882,7 @@ struct obd_ops { struct lsm_operations { void (*lsm_free)(struct lov_stripe_md *); - int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa, + int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa, struct obd_export *md_exp); void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *, unsigned long *); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index ec1ca7b..409ac7b 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -117,7 +117,7 @@ struct config_llog_instance { struct super_block *cfg_sb; struct obd_uuid cfg_uuid; int cfg_last_idx; /* for partial llog processing */ - int cfg_flags; + int cfg_flags; }; int class_config_parse_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg); @@ -305,15 +305,27 @@ static inline int obd_set_info(struct obd_export *exp, obd_count keylen, RETURN(rc); } -static inline int obd_setup(struct obd_device *obd, int datalen, void *data) +static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) { int rc; + struct lu_device_type *ldt; ENTRY; - OBD_CHECK_OP(obd, setup, -EOPNOTSUPP); - OBD_COUNTER_INCREMENT(obd, setup); + ldt = obd->obd_type->typ_lu; + if (ldt != NULL) { + struct lu_device *d; - rc = OBP(obd, setup)(obd, datalen, data); + d = ldt->ldt_ops->ldto_device_alloc(ldt, cfg); + if (!IS_ERR(d)) { + obd->obd_lu_dev = d; + rc = 0; + } else + rc = PTR_ERR(d); + } else { + OBD_CHECK_OP(obd, setup, -EOPNOTSUPP); + OBD_COUNTER_INCREMENT(obd, setup); + rc = OBP(obd, setup)(obd, cfg); + } RETURN(rc); } @@ -332,13 +344,23 @@ static inline int obd_precleanup(struct obd_device *obd, int cleanup_stage) static inline int obd_cleanup(struct obd_device *obd) { int rc; + struct lu_device *d; + struct lu_device_type *ldt; ENTRY; OBD_CHECK_DEV(obd); - OBD_CHECK_OP(obd, cleanup, 0); - OBD_COUNTER_INCREMENT(obd, cleanup); - rc = OBP(obd, cleanup)(obd); + ldt = obd->obd_type->typ_lu; + d = obd->obd_lu_dev; + if (ldt != NULL && d != NULL) { + ldt->ldt_ops->ldto_device_free(d); + obd->obd_lu_dev = NULL; + rc = 0; + } else { + OBD_CHECK_OP(obd, cleanup, 0); + rc = OBP(obd, cleanup)(obd); + } + OBD_COUNTER_INCREMENT(obd, cleanup); RETURN(rc); } @@ -646,13 +668,13 @@ obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr) exp->exp_obd); } -static inline int +static inline int obd_lvfs_open_llog(struct obd_export *exp, __u64 id_ino, struct dentry *dentry) { LASSERT(exp->exp_obd); CERROR("FIXME what's the story here? This needs to be an obd fn?\n"); #if 0 - return lvfs_open_llog(&exp->exp_obd->obd_lvfs_ctxt, id_ino, + return lvfs_open_llog(&exp->exp_obd->obd_lvfs_ctxt, id_ino, dentry, exp->exp_obd); #endif return 0; @@ -905,7 +927,7 @@ static inline int obd_merge_lvb(struct obd_export *exp, { int rc; ENTRY; - + OBD_CHECK_OP(exp->exp_obd, merge_lvb, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, merge_lvb); @@ -1094,7 +1116,7 @@ static inline int obd_notify(struct obd_device *obd, /* the check for async_recov is a complete hack - I'm hereby overloading the meaning to also mean "this was called from mds_postsetup". I know that my mds is able to handle notifies - by this point, and it needs to get them to execute mds_postrecov. */ + by this point, and it needs to get them to execute mds_postrecov. */ if (!obd->obd_set_up && !obd->obd_async_recov) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); return -EINVAL; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index a624183..0384e71 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -75,7 +75,7 @@ struct obd_type *class_get_type(char *name) #ifdef CONFIG_KMOD if (!type) { char *modname = name; - if (strcmp(modname, LUSTRE_MDT_NAME) == 0) + if (strcmp(modname, LUSTRE_MDT_NAME) == 0) modname = LUSTRE_MDS_NAME; if (!request_module(modname)) { CDEBUG(D_INFO, "Loaded module '%s'\n", modname); @@ -171,6 +171,9 @@ int class_unregister_type(char *name) type->typ_procroot = NULL; } + if (type->typ_lu) + type->typ_lu->ldt_ops->ldto_fini(type->typ_lu); + spin_lock(&obd_types_lock); list_del(&type->typ_chain); spin_unlock(&obd_types_lock); @@ -998,7 +1001,7 @@ char *obd_export_nid2str(struct obd_export *exp) { if (exp->exp_connection != NULL) return libcfs_nid2str(exp->exp_connection->c_peer.nid); - + return "(no nid)"; } EXPORT_SYMBOL(obd_export_nid2str);