}
cobd->cache_exp = class_conn2export(&conn);
- /* default set cache on, but nothins is realy connected yet, will be
+ /* default set cache on, but nothing is realy connected yet, will be
* done in cobd_connect() time. */
cobd->cache_on = 1;
}
#define COBD_CONNECT (1 << 0)
-#define COBD_DISCON (1 << 1)
-#define COBD_BOTH (1 << 2)
+#define COBD_DISCON (1 << 1)
+#define COBD_SWITCH (1 << 2)
/* magic function for switching cobd between two exports cache and master in
* strong correspondence with passed @cache_on. It also may perform partial
*
* bias == COBD_CONNECT only connect new export (used in cobd_connect())
* bias == COBD_DISCON only disconnect old export (used in cobd_disconnect())
- * bias == COBD_BOTH do both (disconnect old and connect new) (used in
- * cobd_iocontrol())
+ *
+ * bias == COBD_SWITCH do both (disconnect old and connect new). This will also
+ * set ->cache_on to passed @cache_on value.
*/
static int cobd_switch(struct obd_device *obd,
int cache_on, int bias)
}
/* disconnect old export */
- if (bias == COBD_BOTH || bias == COBD_DISCON) {
+ if (bias == COBD_SWITCH || bias == COBD_DISCON) {
if (discon_exp) {
rc = cobd_disconnect_client(obd, discon_exp, 0);
if (rc) {
}
/* connect new export */
- if (bias == COBD_BOTH || bias == COBD_CONNECT) {
- rc = cobd_connect_client(obd, conn_exp, &conn,
- NULL, OBD_OPT_REAL_CLIENT);
- if (rc) {
- CERROR("can't connect export %p, err %d\n",
- conn_exp, rc);
- RETURN(rc);
- }
+ if (bias == COBD_SWITCH || bias == COBD_CONNECT) {
+ int connected;
- if (cache_on) {
- cobd->cache_real_exp = class_conn2export(&conn);
- cli_obd = class_exp2obd(cobd->cache_exp);
- } else {
- cobd->master_real_exp = class_conn2export(&conn);
- cli_obd = class_exp2obd(cobd->master_exp);
- }
- }
+ connected = cache_on ? (cobd->cache_real_exp != NULL) :
+ (cobd->master_real_exp != NULL);
- cobd->cache_on = cache_on;
-
- if (bias == COBD_BOTH || bias == COBD_CONNECT) {
- /* re-init EA size for new selected export. This should be done after
- * assigining new state to @cobd->cache_on to not call not connened
- * already old export. */
- if (obd_md_type(cli_obd)) {
- rc = cobd_init_dt_desc(obd);
- if (rc == 0) {
- rc = cobd_init_ea_size(obd);
- if (rc) {
- CERROR("can't initialize EA size, "
+ /* correct export already may be connected */
+ if (!connected) {
+ rc = cobd_connect_client(obd, conn_exp, &conn,
+ NULL, OBD_OPT_REAL_CLIENT);
+ if (rc) {
+ CERROR("can't connect export %p, err %d\n",
+ conn_exp, rc);
+ RETURN(rc);
+ }
+
+ if (cache_on) {
+ cobd->cache_real_exp = class_conn2export(&conn);
+ cli_obd = class_exp2obd(cobd->cache_exp);
+ } else {
+ cobd->master_real_exp = class_conn2export(&conn);
+ cli_obd = class_exp2obd(cobd->master_exp);
+ }
+
+ /* change flag only if connect is allowed to keep
+ * ->cache_on coherent with real export connected. */
+ cobd->cache_on = cache_on;
+
+ /* re-init EA size for new selected export. This should
+ * be done after assigining new state to @cobd->cache_on
+ * to not call disconnected old export. */
+ if (obd_md_type(cli_obd)) {
+ rc = cobd_init_dt_desc(obd);
+ if (rc == 0) {
+ rc = cobd_init_ea_size(obd);
+ if (rc) {
+ CERROR("can't initialize EA size, "
+ "err %d\n", rc);
+ }
+ } else {
+ CERROR("can't initialize data lovdesc, "
"err %d\n", rc);
+ /* ignore cases when we did not manage
+ * to init lovdesc. This is because some
+ * devices may not know "lovdesc" info
+ * command. */
+ rc = 0;
}
- } else {
- /* ignore cases when we di dnot manage to init
- * lovdesc. This is because some devices may not know
- * "lovdesc" info command. */
- rc = 0;
}
}
}
* cache should be switched after client umount this is not needed.
* --umka. */
cobd = &obd->u.cobd;
- rc = cobd_switch(obd, cobd->cache_on, COBD_DISCON);
+ rc = cobd_switch(obd, !cobd->cache_on, COBD_DISCON);
class_disconnect(exp, flags);
RETURN(rc);
switch (cmd) {
case OBD_IOC_COBD_CON:
if (!cobd->cache_on)
- rc = cobd_switch(obd, 1, COBD_BOTH);
+ rc = cobd_switch(obd, 1, COBD_SWITCH);
break;
case OBD_IOC_COBD_COFF:
if (cobd->cache_on)
- rc = cobd_switch(obd, 0, COBD_BOTH);
+ rc = cobd_switch(obd, 0, COBD_SWITCH);
break;
default:
cobd_exp = cobd_get_exp(obd);
RETURN(rc);
}
+static int cobd_notify(struct obd_device *obd, struct obd_device *watched,
+ int active, void *data)
+{
+ struct obd_export *cobd_exp;
+ int rc = 0;
+ ENTRY;
+
+ cobd_exp = cobd_get_exp(obd);
+ rc = obd_notify(class_exp2obd(cobd_exp), watched, active, data);
+ RETURN(rc);
+}
+
+static int cobd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
+ int type, struct obd_client_handle *handle,
+ int flag)
+{
+ struct obd_device *obd = class_exp2obd(exp);
+ struct obd_export *cobd_exp;
+ int rc = 0;
+ ENTRY;
+
+ if (obd == NULL) {
+ CERROR("invalid client cookie "LPX64"\n",
+ exp->exp_handle.h_cookie);
+ RETURN(-EINVAL);
+ }
+ cobd_exp = cobd_get_exp(obd);
+ rc = obd_pin(cobd_exp, ino, gen, type, handle, flag);
+ RETURN(rc);
+}
+
+static int cobd_unpin(struct obd_export *exp,
+ struct obd_client_handle *handle,
+ int flag)
+{
+ struct obd_device *obd = class_exp2obd(exp);
+ struct obd_export *cobd_exp;
+ int rc = 0;
+ ENTRY;
+
+ if (obd == NULL) {
+ CERROR("invalid client cookie "LPX64"\n",
+ exp->exp_handle.h_cookie);
+ RETURN(-EINVAL);
+ }
+ cobd_exp = cobd_get_exp(obd);
+ rc = obd_unpin(cobd_exp, handle, flag);
+ RETURN(rc);
+}
+
+/* data related stuff */
static int cobd_dt_packmd(struct obd_export *exp,
struct lov_mds_md **disk_tgt,
struct lov_stripe_md *mem_src)
static int cobd_dt_setattr(struct obd_export *exp, struct obdo *obdo,
struct lov_stripe_md *ea,
- struct obd_trans_info *oti)
+ struct obd_trans_info *oti,
+ struct lustre_capa *capa)
{
struct obd_device *obd = class_exp2obd(exp);
struct obd_export *cobd_exp;
RETURN(-EINVAL);
}
cobd_exp = cobd_get_exp(obd);
- rc = obd_setattr(cobd_exp, obdo, ea, oti);
+ rc = obd_setattr(cobd_exp, obdo, ea, oti, capa);
RETURN(rc);
}
RETURN(rc);
}
-static int cobd_dt_notify(struct obd_device *obd, struct obd_device *watched,
- int active, void *data)
-{
- struct obd_export *cobd_exp;
- int rc = 0;
- ENTRY;
-
- cobd_exp = cobd_get_exp(obd);
- rc = obd_notify(class_exp2obd(cobd_exp), watched, active, data);
- RETURN(rc);
-}
-
-static int cobd_dt_pin(struct obd_export *exp, obd_id ino, __u32 gen,
- int type, struct obd_client_handle *handle,
- int flag)
-{
- struct obd_device *obd = class_exp2obd(exp);
- struct obd_export *cobd_exp;
- int rc = 0;
- ENTRY;
-
- if (obd == NULL) {
- CERROR("invalid client cookie "LPX64"\n",
- exp->exp_handle.h_cookie);
- RETURN(-EINVAL);
- }
- cobd_exp = cobd_get_exp(obd);
- rc = obd_pin(cobd_exp, ino, gen, type, handle, flag);
- RETURN(rc);
-}
-
-static int cobd_dt_unpin(struct obd_export *exp,
- struct obd_client_handle *handle,
- int flag)
-{
- struct obd_device *obd = class_exp2obd(exp);
- struct obd_export *cobd_exp;
- int rc = 0;
- ENTRY;
-
- if (obd == NULL) {
- CERROR("invalid client cookie "LPX64"\n",
- exp->exp_handle.h_cookie);
- RETURN(-EINVAL);
- }
- cobd_exp = cobd_get_exp(obd);
- rc = obd_unpin(cobd_exp, handle, flag);
- RETURN(rc);
-}
-
static int cobd_dt_init_ea_size(struct obd_export *exp, int easize,
int cookiesize)
{
RETURN(0);
}
+/* metadata related stuff */
static int cobd_md_getstatus(struct obd_export *exp,
struct lustre_id *rootid)
{
RETURN(rc);
}
-static int cobd_md_close(struct obd_export *exp, struct obdo *obdo,
+static int cobd_md_close(struct obd_export *exp, struct mdc_op_data *op_data,
struct obd_client_handle *och,
struct ptlrpc_request **request)
{
RETURN(-EINVAL);
}
cobd_exp = cobd_get_exp(obd);
- rc = md_close(cobd_exp, obdo, och, request);
+ rc = md_close(cobd_exp, op_data, och, request);
RETURN(rc);
}
.o_get_info = cobd_get_info,
.o_statfs = cobd_statfs,
.o_iocontrol = cobd_iocontrol,
+ .o_notify = cobd_notify,
+ .o_pin = cobd_pin,
+ .o_unpin = cobd_unpin,
.o_packmd = cobd_dt_packmd,
.o_unpackmd = cobd_dt_unpackmd,
.o_commitrw = cobd_dt_commitrw,
.o_llog_init = cobd_dt_llog_init,
.o_llog_finish = cobd_dt_llog_finish,
- .o_notify = cobd_dt_notify,
- .o_pin = cobd_dt_pin,
- .o_unpin = cobd_dt_unpin,
.o_import_event = cobd_dt_import_event,
.o_init_ea_size = cobd_dt_init_ea_size,
.o_adjust_kms = cobd_dt_adjust_kms,