extern rwlock_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 *);
extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
int lustre_get_jobid(char *jobid, size_t len);
/* Passed as data param to class_config_parse_llog */
struct config_llog_instance {
- char *cfg_obdname;
void *cfg_instance;
struct super_block *cfg_sb;
struct obd_uuid cfg_uuid;
int class_manual_cleanup(struct obd_device *obd);
void class_disconnect_stale_exports(struct obd_device *,
int (*test_export)(struct obd_export *));
+
static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
{
return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
#define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
#define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## 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)
+static inline int obd_check_dev(struct obd_device *obd)
+{
+ if (!obd) {
+ CERROR("NULL device\n");
+ return -ENODEV;
+ }
+ return 0;
+}
/* ensure obd_setup and !obd_stopping */
#define OBD_CHECK_DEV_ACTIVE(obd) \
do { \
- OBD_CHECK_DEV(obd); \
+ rc = obd_check_dev(obd); \
+ if (rc) \
+ return rc; \
+ \
if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
CERROR("Device %d not setup\n", \
(obd)->obd_minor); \
time64_t max_age,
struct ptlrpc_request_set *rqset)
{
- int rc = 0;
struct obd_device *obd;
+ int rc = 0;
ENTRY;
RETURN(-EOPNOTSUPP);
}
- CDEBUG(D_SUPER, "%s: osfs %p age %lld, max_age %lld\n",
- obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
+ CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
+ obd->obd_name, obd->obd_osfs_age, max_age);
if (obd->obd_osfs_age < max_age) {
rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
} else {
obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
spin_lock(&obd->obd_osfs_lock);
- memcpy(oinfo->oi_osfs, &obd->obd_osfs,
- sizeof(*oinfo->oi_osfs));
+ memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs));
spin_unlock(&obd->obd_osfs_lock);
oinfo->oi_flags |= OBD_STATFS_FROM_CACHE;
if (oinfo->oi_cb_up)
*/
static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
struct obd_statfs *osfs, time64_t max_age,
- __u32 flags)
+ __u32 flags)
{
- int rc = 0;
- struct obd_device *obd = exp->exp_obd;
- ENTRY;
+ struct obd_device *obd = exp->exp_obd;
+ int rc = 0;
- if (obd == NULL)
- RETURN(-EINVAL);
+ ENTRY;
+ if (unlikely(obd == NULL))
+ RETURN(-EINVAL);
OBD_CHECK_DEV_ACTIVE(obd);
- if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
+ if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {
CERROR("%s: no %s operation\n", obd->obd_name, __func__);
RETURN(-EOPNOTSUPP);
}
- CDEBUG(D_SUPER, "osfs %lld, max_age %lld\n",
- obd->obd_osfs_age, max_age);
+ CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
+ obd->obd_name, obd->obd_osfs_age, max_age);
/* ignore cache if aggregated isn't expected */
if (obd->obd_osfs_age < max_age ||
((obd->obd_osfs.os_state & OS_STATE_SUM) &&
!(flags & OBD_STATFS_SUM))) {
- rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
- if (rc == 0) {
+ rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
+ if (rc == 0) {
spin_lock(&obd->obd_osfs_lock);
memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
obd->obd_osfs_age = ktime_get_seconds();
spin_unlock(&obd->obd_osfs_lock);
}
} else {
- CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu"
- " objects %llu/%llu\n",
+ CDEBUG(D_SUPER,
+ "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
obd->obd_name, &obd->obd_osfs,
obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
struct obd_export *exp, struct obdo *oa,
int objcount, struct obd_ioobj *obj,
struct niobuf_remote *rnb, int pages,
- struct niobuf_local *local, int rc)
+ struct niobuf_local *local, const int orig_rc)
{
+ int rc;
ENTRY;
rc = exp_check_ops(exp);
}
rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
- rnb, pages, local, rc);
+ rnb, pages, local, orig_rc);
RETURN(rc);
}
{
int rc;
ENTRY;
- OBD_CHECK_DEV(obd);
+
+ rc = obd_check_dev(obd);
+ if (rc)
+ return rc;
if (!obd->obd_set_up) {
CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
static inline int obd_register_observer(struct obd_device *obd,
struct obd_device *observer)
{
+ int rc;
ENTRY;
- OBD_CHECK_DEV(obd);
+
+ rc = obd_check_dev(obd);
+ if (rc)
+ return rc;
+
down_write(&obd->obd_observer_link_sem);
if (obd->obd_observer && observer) {
up_write(&obd->obd_observer_link_sem);
extern int obd_init_caches(void);
extern void obd_cleanup_caches(void);
-/* support routines */
-extern struct kmem_cache *obdo_cachep;
-
-#define OBDO_ALLOC(ptr) \
-do { \
- OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \
-} while(0)
-
-#define OBDO_FREE(ptr) \
-do { \
- OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
-} while(0)
-
-
typedef int (*register_lwp_cb)(void *data);
struct lwp_register_item {