const struct dt_device *dev,
struct dt_device_param *param);
/*
- * used for test purposes to set device RO
+ * handling device state, mostly for tests
*/
- void (*dt_ro_set)(const struct lu_context *ctx,
- const struct dt_device *dev);
+ void (*dt_dev_sync)(const struct lu_context *ctx,
+ struct dt_device *dev);
+ void (*dt_dev_ro)(const struct lu_context *ctx,
+ struct dt_device *dev, int sync);
+
};
struct dt_index_features {
/*
* Create specification
*/
- struct md_create_spec mti_spec;
+ struct md_create_spec mti_spec;
/*
* reint record. contains information for reint operations.
*/
extern struct lu_context_key mdt_thread_key;
/* debug issues helper starts here*/
static inline void mdt_fail_write(const struct lu_context *ctx,
- const struct dt_device *dd, int id)
+ struct dt_device *dd, int id)
{
if (OBD_FAIL_CHECK(id)) {
CERROR(LUSTRE_MDT0_NAME": obd_fail_loc=%x, fail write ops\n",
id);
- dd->dd_ops->dt_ro_set(ctx, dd);
+ dd->dd_ops->dt_dev_ro(ctx, dd, 0);
/* We set FAIL_ONCE because we never "un-fail" a device */
obd_fail_loc |= OBD_FAILED | OBD_FAIL_ONCE;
}
#include <linux/jbd.h>
/* LDISKFS_SB() */
#include <linux/ldiskfs_fs.h>
+#include <linux/ldiskfs_jbd.h>
/* simple_mkdir() */
#include <lvfs.h>
param->ddp_block_shift = osd_sb(osd_dt_dev(dev))->s_blocksize_bits;
}
-static void osd_ro_set(const struct lu_context *ctx,
- const struct dt_device *d)
-{
- struct osd_device *osd = osd_dt_dev(d);
- lvfs_set_rdonly(lvfs_sbdev(osd_sb(osd)));
-}
-
/*
* Journal
*/
EXIT;
}
+static void osd_dev_sync(const struct lu_context *ctx,
+ struct dt_device *d)
+{
+ struct osd_device *osd = osd_dt_dev(d);
+ int rc = 0;
+ ENTRY;
+
+ CDEBUG(D_HA, "syncing OSD %s\n", LUSTRE_OSD0_NAME);
+ ldiskfs_force_commit(osd_sb(osd));
+ EXIT;
+}
+
+static void osd_dev_ro(const struct lu_context *ctx,
+ struct dt_device *d, int sync)
+{
+ struct thandle *th;
+ struct txn_param param = {
+ .tp_credits = 3
+ };
+ int rc = 0;
+ ENTRY;
+
+ CERROR("*** setting device %s read-only ***\n", LUSTRE_OSD0_NAME);
+
+ th = osd_trans_start(ctx, d, ¶m);
+ if (!IS_ERR(th))
+ osd_trans_stop(ctx, th);
+
+ if (sync)
+ osd_dev_sync(ctx, d);
+
+ lvfs_set_rdonly(lvfs_sbdev(osd_sb(osd_dt_dev(d))));
+ EXIT;
+}
+
+
static struct dt_device_operations osd_dt_ops = {
.dt_root_get = osd_root_get,
.dt_statfs = osd_statfs,
.dt_trans_start = osd_trans_start,
.dt_trans_stop = osd_trans_stop,
.dt_conf_get = osd_conf_get,
- .dt_ro_set = osd_ro_set
+ .dt_dev_sync = osd_dev_sync,
+ .dt_dev_ro = osd_dev_ro
};
static void osd_object_read_lock(const struct lu_context *ctx,