📄 obd_class.h
字号:
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * Copyright (C) 2001-2003 Cluster File Systems, Inc. * * This file is part of Lustre, http://www.lustre.org. * * Lustre is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * Lustre is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Lustre; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */#ifndef __CLASS_OBD_H#define __CLASS_OBD_H#include <obd_support.h>#include <lustre_import.h>#include <lustre_net.h>#include <obd.h>#include <lustre_lib.h>#include <lustre/lustre_idl.h>#include <lprocfs_status.h>#if defined(__linux__)#include <linux/obd_class.h>#elif defined(__APPLE__)#include <darwin/obd_class.h>#elif defined(__WINNT__)#include <winnt/obd_class.h>#else#error Unsupported operating system.#endif/* OBD Device Declarations */extern struct obd_device *obd_devs[MAX_OBD_DEVICES];extern spinlock_t obd_dev_lock;/* OBD Operations Declarations */extern struct obd_device *class_conn2obd(struct lustre_handle *);extern struct obd_device *class_exp2obd(struct obd_export *);/* genops.c */struct obd_export *class_conn2export(struct lustre_handle *);int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, const char *nm);int class_unregister_type(const char *nm);struct obd_device *class_newdev(const char *type_name, const char *name);void class_release_dev(struct obd_device *obd);int class_name2dev(const char *name);struct obd_device *class_name2obd(const char *name);int class_uuid2dev(struct obd_uuid *uuid);struct obd_device *class_uuid2obd(struct obd_uuid *uuid);void class_obd_list(void);struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid, const char * typ_name, struct obd_uuid *grp_uuid);struct obd_device * class_find_client_notype(struct obd_uuid *tgt_uuid, struct obd_uuid *grp_uuid);struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, int *next);struct obd_device * class_num2obd(int num);int oig_init(struct obd_io_group **oig);int oig_add_one(struct obd_io_group *oig, struct oig_callback_context *occ);void oig_complete_one(struct obd_io_group *oig, struct oig_callback_context *occ, int rc);void oig_release(struct obd_io_group *oig);int oig_wait(struct obd_io_group *oig);char *obd_export_nid2str(struct obd_export *exp);int obd_export_evict_by_nid(struct obd_device *obd, char *nid);int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid);/* obd_config.c */int class_process_config(struct lustre_cfg *lcfg);int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data);int class_attach(struct lustre_cfg *lcfg);int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);struct obd_device *class_incref(struct obd_device *obd);void class_decref(struct obd_device *obd);/*obdecho*/#ifdef LPROCFSextern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);#elsestatic inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars){ memset(lvars, 0, sizeof(*lvars));}#endif#define CFG_F_START 0x01 /* Set when we start updating from a log */#define CFG_F_MARKER 0x02 /* We are within a maker */#define CFG_F_SKIP 0x04 /* We should ignore this cfg command */#define CFG_F_COMPAT146 0x08 /* Allow old-style logs */#define CFG_F_EXCLUDE 0x10 /* OST exclusion list *//* Passed as data param to class_config_parse_llog */struct config_llog_instance { char * cfg_instance; struct super_block *cfg_sb; struct obd_uuid cfg_uuid; int cfg_last_idx; /* for partial llog processing */ int cfg_flags; };int class_config_parse_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg);int class_config_dump_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg);/* list of active configuration logs */struct config_llog_data { char *cld_logname; struct ldlm_res_id cld_resid; struct config_llog_instance cld_cfg; struct list_head cld_list_chain; atomic_t cld_refcount; struct obd_export *cld_mgcexp; unsigned int cld_stopping:1; /* we were told to stop watching */ unsigned int cld_lostlock:1; /* lock not requeued */};struct lustre_profile { struct list_head lp_list; char * lp_profile; char * lp_osc; char * lp_mdc;};struct lustre_profile *class_get_profile(char * prof);void class_del_profile(char *prof);void class_del_profiles(void);#define class_export_rpc_get(exp) \({ \ atomic_inc(&(exp)->exp_rpc_count); \ CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \ (exp), atomic_read(&(exp)->exp_rpc_count)); \ class_export_get(exp); \})#define class_export_rpc_put(exp) \({ \ atomic_dec(&(exp)->exp_rpc_count); \ CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \ (exp), atomic_read(&(exp)->exp_rpc_count)); \ class_export_put(exp); \})/* genops.c */#define class_export_get(exp) \({ \ struct obd_export *exp_ = exp; \ atomic_inc(&exp_->exp_refcount); \ CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp_, \ atomic_read(&exp_->exp_refcount)); \ exp_; \})#define class_export_put(exp) \do { \ LASSERT((exp) != NULL); \ CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", (exp), \ atomic_read(&(exp)->exp_refcount) - 1); \ LASSERT(atomic_read(&(exp)->exp_refcount) > 0); \ LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \ __class_export_put(exp); \} while (0)void __class_export_put(struct obd_export *);struct obd_export *class_new_export(struct obd_device *obddev, struct obd_uuid *cluuid);void class_unlink_export(struct obd_export *exp);struct obd_import *class_import_get(struct obd_import *);void class_import_put(struct obd_import *);struct obd_import *class_new_import(struct obd_device *obd);void class_destroy_import(struct obd_import *exp);struct obd_type *class_search_type(const char *name);struct obd_type *class_get_type(const char *name);void class_put_type(struct obd_type *type);int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid);int class_disconnect(struct obd_export *exp);void class_fail_export(struct obd_export *exp);void class_disconnect_exports(struct obd_device *obddev);void class_disconnect_stale_exports(struct obd_device *obddev);int class_manual_cleanup(struct obd_device *obd);/* obdo.c */void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);#define OBT(dev) (dev)->obd_type#define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op/* Ensure obd_setup: used for cleanup which must be called while obd is stopping */#define OBD_CHECK_DEV(obd) \do { \ if (!(obd)) { \ CERROR("NULL device\n"); \ RETURN(-ENODEV); \ } \} while (0)/* ensure obd_setup and !obd_stopping */#define OBD_CHECK_DEV_ACTIVE(obd) \do { \ OBD_CHECK_DEV(obd); \ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ RETURN(-ENODEV); \ } \} while (0)#ifdef LPROCFS#define OBD_COUNTER_OFFSET(op) \ ((offsetof(struct obd_ops, o_ ## op) - \ offsetof(struct obd_ops, o_iocontrol)) \ / sizeof(((struct obd_ops *)(0))->o_iocontrol))#define OBD_COUNTER_INCREMENT(obdx, op) \ if ((obdx)->obd_stats != NULL) { \ unsigned int coffset; \ coffset = (unsigned int)((obdx)->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ LASSERT(coffset < (obdx)->obd_stats->ls_num); \ lprocfs_counter_incr((obdx)->obd_stats, coffset); \ }#define EXP_COUNTER_INCREMENT(export, op) \ if ((export)->exp_obd->obd_stats != NULL) { \ unsigned int coffset; \ coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ if ((export)->exp_nid_stats != NULL && \ (export)->exp_nid_stats->nid_stats != NULL) \ lprocfs_counter_incr( \ (export)->exp_nid_stats->nid_stats, coffset);\ }#else#define OBD_COUNTER_OFFSET(op)#define OBD_COUNTER_INCREMENT(obd, op)#define EXP_COUNTER_INCREMENT(exp, op);#endif#define OBD_CHECK_OP(obd, op, err) \do { \ if (!OBT(obd) || !OBP((obd), op)) {\ if (err) \ CERROR("obd_" #op ": dev %d no operation\n", \ obd->obd_minor); \ RETURN(err); \ } \} while (0)#define EXP_CHECK_OP(exp, op) \do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ RETURN(-ENODEV); \ } \ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ RETURN(-EOPNOTSUPP); \ } \ if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ CERROR("obd_" #op ": dev %d no operation\n", \ (exp)->exp_obd->obd_minor); \ RETURN(-EOPNOTSUPP); \ } \} while (0)#define CTXT_CHECK_OP(ctxt, op, err) \do { \ if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ if (err) \ CERROR("lop_" #op ": dev %d no operation\n", \ ctxt->loc_obd->obd_minor); \ RETURN(err); \ } \} while (0)static inline int class_devno_max(void){ return MAX_OBD_DEVICES;}static inline int obd_get_info(struct obd_export *exp, __u32 keylen, void *key, __u32 *vallen, void *val){ int rc; ENTRY; EXP_CHECK_OP(exp, get_info); EXP_COUNTER_INCREMENT(exp, get_info); rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val); RETURN(rc);}static inline int obd_set_info_async(struct obd_export *exp, obd_count keylen, void *key, obd_count vallen, void *val, struct ptlrpc_request_set *set){ int rc; ENTRY; EXP_CHECK_OP(exp, set_info_async); EXP_COUNTER_INCREMENT(exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(exp, keylen, key, vallen, val, set); RETURN(rc);}static inline int obd_setup(struct obd_device *obd, int datalen, void *data){ int rc; ENTRY; OBD_CHECK_OP(obd, setup, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, datalen, data); RETURN(rc);}static inline int obd_precleanup(struct obd_device *obd, enum obd_cleanup_stage cleanup_stage){ int rc; ENTRY; OBD_CHECK_OP(obd, precleanup, 0); OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd, cleanup_stage); RETURN(rc);}static inline int obd_cleanup(struct obd_device *obd){ int rc; ENTRY; OBD_CHECK_DEV(obd); OBD_CHECK_OP(obd, cleanup, 0); OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); RETURN(rc);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -