From b16356cd4d8f97eb62bcc79e1b336c90b843bac0 Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 5 Sep 2006 17:56:26 +0000 Subject: [PATCH] dt: simplify (and fix) ->dt_{ro,sync}() --- lustre/include/dt_object.h | 6 ++---- lustre/mdt/mdt_handler.c | 18 ++++++------------ lustre/mdt/mdt_internal.h | 16 ++++++++-------- lustre/osd/osd_handler.c | 22 +++------------------- 4 files changed, 19 insertions(+), 43 deletions(-) diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index ca34c76..09ab1c2 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -93,10 +93,8 @@ struct dt_device_operations { /* * handling device state, mostly for tests */ - void (*dt_sync)(const struct lu_context *ctx, - struct dt_device *dev); - void (*dt_ro)(const struct lu_context *ctx, - struct dt_device *dev, int sync); + int (*dt_sync)(const struct lu_context *ctx, struct dt_device *dev); + void (*dt_ro)(const struct lu_context *ctx, struct dt_device *dev); }; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index b37d799..0110a81 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2852,7 +2852,7 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct lu_context ctxt; struct mdt_device *mdt = mdt_dev(exp->exp_obd->obd_lu_dev); struct dt_device *dt = mdt->mdt_bottom; - int rc = 0; + int rc; ENTRY; CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd); @@ -2860,18 +2860,12 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (rc) RETURN(rc); lu_context_enter(&ctxt); - switch (cmd) { - case OBD_IOC_SYNC: - dt->dd_ops->dt_sync(&ctxt, dt); - break; - case OBD_IOC_SET_READONLY: - dt->dd_ops->dt_ro(&ctxt, dt, 1); - break; - default: - CDEBUG(D_INFO, "Trying old MDS iocontrol %x\n", cmd); + if (cmd == OBD_IOC_SYNC || cmd == OBD_IOC_SET_READONLY) { + if (cmd == OBD_IOC_SYNC) + rc = dt->dd_ops->dt_sync(&ctxt, dt); + dt->dd_ops->dt_ro(&ctxt, dt); + } else rc = -EOPNOTSUPP; - break; - } lu_context_exit(&ctxt); lu_context_fini(&ctxt); RETURN(rc); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 1e3f0dd..5d65123 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -71,7 +71,7 @@ struct mdt_client_data { static inline __u64 mcd_last_transno(struct mdt_client_data *mcd) { - return (le64_to_cpu(mcd->mcd_last_transno) > + return (le64_to_cpu(mcd->mcd_last_transno) > le64_to_cpu(mcd->mcd_last_close_transno) ? le64_to_cpu(mcd->mcd_last_transno) : le64_to_cpu(mcd->mcd_last_close_transno)); @@ -79,7 +79,7 @@ static inline __u64 mcd_last_transno(struct mdt_client_data *mcd) static inline __u64 mcd_last_xid(struct mdt_client_data *mcd) { - return (le64_to_cpu(mcd->mcd_last_xid) > + return (le64_to_cpu(mcd->mcd_last_xid) > le64_to_cpu(mcd->mcd_last_close_xid) ? le64_to_cpu(mcd->mcd_last_xid) : le64_to_cpu(mcd->mcd_last_close_xid)); @@ -271,12 +271,12 @@ struct mdt_thread_info { /* opdata for mdt_open(), has the same as ldlm_reply:lock_policy_res1. * mdt_update_last_rcvd() stores this value onto disk for recovery - * when mdt_trans_stop_cb() is called. + * when mdt_trans_stop_cb() is called. */ __u64 mti_opdata; - /* temporary stuff used by thread to save stack consumption. - * if something is in a union, make sure they do not conflict */ + /* temporary stuff used by thread to save stack consumption. + * if something is in a union, make sure they do not conflict */ struct lu_fid mti_tmp_fid1; struct lu_fid mti_tmp_fid2; @@ -289,9 +289,9 @@ struct mdt_thread_info { struct kstatfs ksfs; /* for mdt_statfs() */ struct { /* for mdt_readpage() */ - struct lu_rdpg mti_rdpg; + struct lu_rdpg mti_rdpg; /* for mdt_sendpage() */ - struct l_wait_info mti_wait_info; + struct l_wait_info mti_wait_info; } rdpg; } mti_u; }; @@ -414,7 +414,7 @@ static inline void mdt_fail_write(const struct lu_context *ctx, if (OBD_FAIL_CHECK(id)) { CERROR(LUSTRE_MDT_NAME": obd_fail_loc=%x, fail write ops\n", id); - dd->dd_ops->dt_ro(ctx, dd, 0); + dd->dd_ops->dt_ro(ctx, dd); /* 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 d6a1504..da30ce8 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -566,39 +566,23 @@ static void osd_trans_stop(const struct lu_context *ctx, struct thandle *th) EXIT; } -static void osd_sync(const struct lu_context *ctx, +static int osd_sync(const struct lu_context *ctx, struct dt_device *d) { - struct osd_device *osd = osd_dt_dev(d); - ENTRY; - CDEBUG(D_HA, "syncing OSD %s\n", LUSTRE_OSD_NAME); - ldiskfs_force_commit(osd_sb(osd)); - EXIT; + return ldiskfs_force_commit(osd_sb(osd_dt_dev(d))); } enum { SYNC_DEVICE_CREDITS = 3 }; -static void osd_ro(const struct lu_context *ctx, struct dt_device *d, int sync) +static void osd_ro(const struct lu_context *ctx, struct dt_device *d) { - struct thandle *th; - struct osd_thread_info *oti = lu_context_key_get(ctx, &osd_key); - struct txn_param *param = &oti->oti_txn; ENTRY; CERROR("*** setting device %s read-only ***\n", LUSTRE_OSD_NAME); - param->tp_credits = SYNC_DEVICE_CREDITS; - - th = osd_trans_start(ctx, d, param); - if (!IS_ERR(th)) - osd_trans_stop(ctx, th); - - if (sync) - osd_sync(ctx, d); - lvfs_set_rdonly(lvfs_sbdev(osd_sb(osd_dt_dev(d)))); EXIT; } -- 1.8.3.1