Whamcloud - gitweb
dt: simplify (and fix) ->dt_{ro,sync}()
authornikita <nikita>
Tue, 5 Sep 2006 17:56:26 +0000 (17:56 +0000)
committernikita <nikita>
Tue, 5 Sep 2006 17:56:26 +0000 (17:56 +0000)
lustre/include/dt_object.h
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/osd/osd_handler.c

index ca34c76..09ab1c2 100644 (file)
@@ -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);
 
 };
 
index b37d799..0110a81 100644 (file)
@@ -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);
index 1e3f0dd..5d65123 100644 (file)
@@ -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;
         }
index d6a1504..da30ce8 100644 (file)
@@ -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;
 }