From: tappro Date: Thu, 31 Aug 2006 21:34:53 +0000 (+0000) Subject: - add sync and set readonly methods for dt_device. Used for tests X-Git-Tag: v1_8_0_110~486^2~1050 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=85da1d930012b094cd56211b64074d6e4a353305;p=fs%2Flustre-release.git - add sync and set readonly methods for dt_device. Used for tests --- diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 1c93b6c..7fe4462 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -91,10 +91,13 @@ struct dt_device_operations { 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 { diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index e34ed29..27f66eb 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -247,7 +247,7 @@ struct mdt_thread_info { /* * Create specification */ - struct md_create_spec mti_spec; + struct md_create_spec mti_spec; /* * reint record. contains information for reint operations. */ @@ -409,12 +409,12 @@ void mdt_dump_lmm(int level, struct lov_mds_md *lmm); 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; } diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 3866147..51440a4 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -49,6 +49,7 @@ #include /* LDISKFS_SB() */ #include +#include /* simple_mkdir() */ #include @@ -442,13 +443,6 @@ static void osd_conf_get(const struct lu_context *ctx, 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 */ @@ -570,13 +564,50 @@ static void osd_trans_stop(const struct lu_context *ctx, struct thandle *th) 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,