CERROR("NULL device\n");
return -ENODEV;
}
+
+ if (!test_bit(OBDF_SET_UP, (obd)->obd_flags) ||
+ (obd)->obd_stopping) {
+ CERROR("Device %d not setup\n",
+ (obd)->obd_minor);
+ return -ENODEV;
+ }
+
return 0;
}
-/* ensure obd_setup and !obd_stopping */
-#define OBD_CHECK_DEV_ACTIVE(obd) \
-do { \
- rc = obd_check_dev(obd); \
- if (rc) \
- return rc; \
- \
- if (!test_bit(OBDF_SET_UP, (obd)->obd_flags) || \
- (obd)->obd_stopping) { \
- CERROR("Device %d not setup\n", \
- (obd)->obd_minor); \
- RETURN(-ENODEV); \
- } \
-} while (0)
-
static inline int exp_check_ops(struct obd_export *exp)
{
- if (exp == NULL) {
- RETURN(-ENODEV);
- }
- if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) {
- RETURN(-EOPNOTSUPP);
- }
- RETURN(0);
+ if (!exp)
+ return -ENODEV;
+
+ if (!exp->exp_obd || !exp->exp_obd->obd_type)
+ return -EOPNOTSUPP;
+
+ return 0;
}
static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp,
ENTRY;
- OBD_CHECK_DEV_ACTIVE(obd);
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN(rc);
+
if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) {
CERROR("%s: no %s operation\n", obd->obd_name, __func__);
RETURN(-EOPNOTSUPP);
ENTRY;
- OBD_CHECK_DEV_ACTIVE(obd);
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN(rc);
+
if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) {
CERROR("%s: no %s operation\n", obd->obd_name, __func__);
RETURN(-EOPNOTSUPP);
ENTRY;
- OBD_CHECK_DEV_ACTIVE(obd);
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN(rc);
+
if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) {
CERROR("%s: no %s operation\n", obd->obd_name, __func__);
RETURN(-EOPNOTSUPP);
ENTRY;
- OBD_CHECK_DEV_ACTIVE(obd);
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN(rc);
+
if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect)
RETURN(0);
RETURN(-EINVAL);
obd = exp->exp_obd;
- OBD_CHECK_DEV_ACTIVE(obd);
+
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN(rc);
if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {
CERROR("%s: no %s operation\n", obd->obd_name, __func__);
struct obd_import *imp,
enum obd_import_event event)
{
+ int rc;
+
ENTRY;
- if (!obd) {
- CERROR("NULL device\n");
- EXIT;
- return;
- }
- if (test_bit(OBDF_SET_UP, obd->obd_flags) &&
- obd->obd_type->typ_dt_ops->o_import_event)
+ rc = obd_check_dev(obd);
+ if (rc)
+ RETURN_EXIT;
+
+ if (obd->obd_type->typ_dt_ops->o_import_event)
obd->obd_type->typ_dt_ops->o_import_event(obd, imp, event);
EXIT;
if (rc)
return rc;
- if (!test_bit(OBDF_SET_UP, obd->obd_flags)) {
- CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
- RETURN(-EINVAL);
- }
-
if (!obd->obd_type->typ_dt_ops->o_notify) {
CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
- RETURN(-ENOSYS);
+ RETURN(-EOPNOTSUPP);
}
rc = obd->obd_type->typ_dt_ops->o_notify(obd, watched, ev);
rc = obd_check_dev(obd);
if (rc)
- return rc;
+ RETURN(rc);
down_write(&obd->obd_observer_link_sem);
if (obd->obd_observer && observer) {