-#define OBD_BRW_READ (READ)
-#define OBD_BRW_WRITE (WRITE)
-#define OBD_BRW_RWMASK (READ | WRITE)
-#define OBD_BRW_CREATE (0x00000010UL)
-
-struct obd_ops {
- int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
- void *uarg);
- int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
- obd_count *vallen, void **val);
- int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
- obd_count vallen, void *val);
- int (*o_attach)(struct obd_device *dev, struct obd_ioctl_data *data);
- int (*o_detach)(struct obd_device *dev);
- int (*o_setup) (struct obd_device *dev, struct obd_ioctl_data *data);
- int (*o_cleanup)(struct obd_device *dev);
- int (*o_connect)(struct obd_conn *conn);
- int (*o_disconnect)(struct obd_conn *conn);
- int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
- int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
- int (*o_create)(struct obd_conn *conn, struct obdo *oa);
- int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
- int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
- int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
- int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
- obd_size *count, obd_off offset);
- int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
- obd_size *count, obd_off offset);
- int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
- struct obdo **oa, obd_count *oa_bufs, struct page **buf,
- obd_size *count, obd_off *offset, obd_flag *flags);
- int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
- obd_off offset);
- int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
- obd_off offset);
- int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
- struct obdo *src, obd_size count, obd_off offset);
- int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
- struct obd_conn *srconn, struct obdo *src,
- obd_size count, obd_off offset);
- int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
- obd_id *startid, obd_gr group, void *data);
-};
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, getattr);
+
+ rc = OBP(exp->exp_obd, getattr)(conn, obdo, ea);
+ RETURN(rc);
+}
+
+static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo,
+ struct lov_stripe_md *ea)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, close);
+
+ rc = OBP(exp->exp_obd, close)(conn, obdo, ea);
+ RETURN(rc);
+}
+
+static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo,
+ struct lov_stripe_md *ea)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, open);
+
+ rc = OBP(exp->exp_obd, open)(conn, obdo, ea);
+ RETURN(rc);
+}
+
+static inline int obd_setattr(struct lustre_handle *conn, struct obdo *obdo,
+ struct lov_stripe_md *ea)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, setattr);
+
+ rc = OBP(exp->exp_obd, setattr)(conn, obdo, ea);
+ RETURN(rc);
+}
+
+static inline int obd_connect(struct lustre_handle *conn,
+ struct obd_device *obd, obd_uuid_t cluuid)
+{
+ int rc;
+
+ OBD_CHECK_DEVSETUP(obd);
+ OBD_CHECK_OP(obd, connect);
+
+ rc = OBP(obd, connect)(conn, obd, cluuid);
+ RETURN(rc);
+}
+
+static inline int obd_disconnect(struct lustre_handle *conn)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, disconnect);
+
+ rc = OBP(exp->exp_obd, disconnect)(conn);
+ RETURN(rc);
+}
+
+static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, statfs);
+
+ rc = OBP(exp->exp_obd, statfs)(conn, osfs);
+ RETURN(rc);
+}
+
+static inline int obd_punch(struct lustre_handle *conn, struct obdo *oa,
+ struct lov_stripe_md *ea,
+ obd_size count, obd_off offset)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, punch);
+
+ rc = OBP(exp->exp_obd, punch)(conn, oa, ea, count, offset);
+ RETURN(rc);
+}
+
+static inline int obd_brw(int cmd, struct lustre_handle *conn,
+ struct lov_stripe_md *ea, obd_count oa_bufs,
+ struct brw_page *pg,
+ brw_callback_t callback, void *data)
+{
+ struct obd_export *exp;
+ int rc;
+
+ OBD_CHECK_SETUP(conn, exp);
+ OBD_CHECK_OP(exp->exp_obd, brw);
+
+ if (!(cmd & OBD_BRW_RWMASK)) {
+ CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
+ LBUG();
+ }
+
+ rc = OBP(exp->exp_obd, brw)(cmd, conn, ea, oa_bufs, pg, callback, data);
+ RETURN(rc);
+}