Whamcloud - gitweb
- fixes and cleanups in mdd about txn init. call obd_notify() in mdd_recovery_complet...
authoryury <yury>
Sun, 1 Oct 2006 13:20:18 +0000 (13:20 +0000)
committeryury <yury>
Sun, 1 Oct 2006 13:20:18 +0000 (13:20 +0000)
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mdt/mdt_handler.c
lustre/tests/sanity.sh

index c181b25..16f20d4 100644 (file)
@@ -113,8 +113,9 @@ enum {
         MDD_TXN_CREATE_DATA_CREDITS = 0,
         MDD_TXN_MKDIR_CREDITS = 0
 };
-#define DEFINE_MDD_TXN_OP_ARRAY(opname, base)       \
-[opname ## _OP - base ## _OP]= { \
+
+#define DEFINE_MDD_TXN_OP_ARRAY(opname, base)   \
+[opname ## _OP - base ## _OP]= {                \
         .mod_op      = opname ## _OP,           \
         .mod_credits = opname ## _CREDITS,      \
 }
@@ -141,28 +142,30 @@ static struct mdd_txn_op_descr mdd_txn_descrs[] = {
         DEFINE_MDD_TXN_OP_DESC(MDD_TXN_CREATE_DATA),
         DEFINE_MDD_TXN_OP_DESC(MDD_TXN_MKDIR)
 };
-struct rw_semaphore    mdd_txn_sem;
+
+spinlock_t mdd_txn_lock;
 
 static void mdd_txn_param_build(const struct lu_env *env, int op)
 {
         int num_entries, i;
+        
         /* init credits for each ops */
-        num_entries = sizeof (mdd_txn_descrs) / sizeof(struct mdd_txn_op_descr);
+        num_entries = ARRAY_SIZE(mdd_txn_descrs);
 
         LASSERT(num_entries > 0);
 
-        down_read(&mdd_txn_sem);
-        for (i =0; i < num_entries; i++) {
+        spin_lock(&mdd_txn_lock);
+        for (i = 0; i < num_entries; i++) {
                 if (mdd_txn_descrs[i].mod_op == op) {
                         LASSERT(mdd_txn_descrs[i].mod_credits > 0);
                         mdd_env_info(env)->mti_param.tp_credits = 
                                         mdd_txn_descrs[i].mod_credits;
-                        up_read(&mdd_txn_sem);
+                        spin_unlock(&mdd_txn_lock);
                         return;
                 }
         }
-        up_read(&mdd_txn_sem);
-        CERROR("Wrong operation %d \n", op);
+        spin_unlock(&mdd_txn_lock);
+        CERROR("Wrong txn operation %d\n", op);
         LBUG();
 }
 
@@ -176,28 +179,28 @@ static int mdd_credit_get(const struct lu_env *env, struct mdd_device *mdd,
         return credits;
 }
 
-/* FIXME: we should calculate it by lsm count, 
- * not ost count */
-int mdd_init_txn_credits(const struct lu_env *env, struct mdd_device *mdd)
+/* XXX: we should calculate it by lsm count, not ost count. */
+int mdd_txn_init_credits(const struct lu_env *env, struct mdd_device *mdd)
 {
         struct mds_obd *mds = &mdd->mdd_obd_dev->u.mds;
         int ost_count = mds->mds_lov_desc.ld_tgt_count;
         int iam_credits, xattr_credits, log_credits, create_credits;
         int num_entries, i, attr_credits;
 
-        /* init credits for each ops */
-        num_entries = sizeof (mdd_txn_descrs) / sizeof(struct mdd_txn_op_descr);
+        /* Init credits for each ops. */
+        num_entries = ARRAY_SIZE(mdd_txn_descrs);
         LASSERT(num_entries > 0);
 
-        /* init the basic credits from osd layer */
+        /* Init the basic credits from osd layer. */
         iam_credits = mdd_credit_get(env, mdd, INSERT_IAM);
         log_credits = mdd_credit_get(env, mdd, LOG_REC);
         attr_credits = mdd_credit_get(env, mdd, ATTR_SET);
         xattr_credits = mdd_credit_get(env, mdd, XATTR_SET);
         create_credits = mdd_credit_get(env, mdd, CREATE_OBJECT);
-        /* calculate the mdd credits */
-        down_write(&mdd_txn_sem);
-        for (i =0; i < num_entries; i++) {
+        
+        /* Calculate the mdd credits. */
+        spin_lock(&mdd_txn_lock);
+        for (i = 0; i < num_entries; i++) {
                 int opcode = mdd_txn_descrs[i].mod_op;
                 switch(opcode) {
                         case MDD_TXN_OBJECT_DESTROY_OP:
@@ -252,12 +255,13 @@ int mdd_init_txn_credits(const struct lu_env *env, struct mdd_device *mdd)
                                         2 * iam_credits + create_credits;
                                 break;
                         default:
-                                CERROR("invalid op %d init its credit\n", opcode);
-                                up_write(&mdd_txn_sem);
+                                spin_unlock(&mdd_txn_lock);
+                                CERROR("Invalid op %d init its credit\n",
+                                       opcode);
                                 LBUG();
                 }
         }
-        up_write(&mdd_txn_sem);
+        spin_unlock(&mdd_txn_lock);
         RETURN(0);        
 }
 
@@ -844,7 +848,7 @@ static int mdd_device_init(const struct lu_env *env,
         mdd->mdd_txn_cb.dtc_cookie = mdd;
 
         /* init txn credits */
-        init_rwsem(&mdd_txn_sem);
+        spin_lock_init(&mdd_txn_lock);
         RETURN(rc);
 }
 
@@ -920,6 +924,28 @@ out:
         RETURN(rc);
 }
 
+static int mdd_lov_set_nextid(const struct lu_env *env,
+                              struct mdd_device *mdd)
+{
+        struct mds_obd *mds = &mdd->mdd_obd_dev->u.mds;
+        int rc;
+        ENTRY;
+
+        LASSERT(mds->mds_lov_objids != NULL);
+        rc = obd_set_info_async(mds->mds_osc_exp, strlen(KEY_NEXT_ID),
+                                KEY_NEXT_ID, mds->mds_lov_desc.ld_tgt_count,
+                                mds->mds_lov_objids, NULL);
+
+        RETURN(rc);
+}
+
+static int mdd_cleanup_unlink_llog(const struct lu_env *env,
+                                   struct mdd_device *mdd)
+{
+        /* XXX: to be implemented! */
+        return 0;
+}
+
 static int mdd_recovery_complete(const struct lu_env *env,
                                  struct lu_device *d)
 {
@@ -928,25 +954,35 @@ static int mdd_recovery_complete(const struct lu_env *env,
         struct obd_device *obd = mdd2obd_dev(mdd);
         int rc;
         ENTRY;
-        /* TODO:
+        
+        LASSERT(mdd != NULL);
+        LASSERT(obd != NULL);
+
+        /* XXX: Do we need this in new stack? */
         rc = mdd_lov_set_nextid(env, mdd);
         if (rc) {
-                CERROR("%s: mdd_lov_set_nextid failed %d\n",
-                       obd->obd_name, rc);
-                GOTO(out, rc);
+                CERROR("mdd_lov_set_nextid() failed %d\n",
+                       rc);
+                RETURN(rc);
         }
+
+        /* XXX: cleanup unlink. */
         rc = mdd_cleanup_unlink_llog(env, mdd);
+        if (rc) {
+                CERROR("mdd_cleanup_unlink_llog() failed %d\n",
+                       rc);
+                RETURN(rc);
+        }
 
         obd_notify(obd->u.mds.mds_osc_obd, NULL,
-                   obd->obd_async_recov ? OBD_NOTIFY_SYNC_NONBLOCK :
-                   OBD_NOTIFY_SYNC, NULL);
-        */
-        LASSERT(mdd);
-        LASSERT(obd);
+                   (obd->obd_async_recov ?
+                    OBD_NOTIFY_SYNC_NONBLOCK :
+                    OBD_NOTIFY_SYNC), NULL);
 
         obd->obd_recovering = 0;
         obd->obd_type->typ_dt_ops->o_postrecov(obd);
-        /* TODO: orphans handling */
+        
+        /* XXX: orphans handling. */
         __mdd_orphan_cleanup(env, mdd);
         rc = next->ld_ops->ldo_recovery_complete(env, next);
 
index 6c43c20..ab22611 100644 (file)
@@ -140,7 +140,7 @@ int __mdd_object_kill(const struct lu_env *, struct mdd_object *,
 struct mdd_object *mdd_object_find(const struct lu_env *,
                                    struct mdd_device *,
                                    const struct lu_fid *);
-int mdd_init_txn_credits(const struct lu_env *env, struct mdd_device *mdd);
+int mdd_txn_init_credits(const struct lu_env *env, struct mdd_device *mdd);
 
 static inline void mdd_object_put(const struct lu_env *env,
                                   struct mdd_object *o)
index a5474e9..3b38741 100644 (file)
@@ -63,7 +63,7 @@ static int mdd_lov_update(struct obd_device *host,
         if (rc)
                 RETURN(rc);
         
-        rc = mdd_init_txn_credits(NULL, mdd);
+        rc = mdd_txn_init_credits(NULL, mdd);
         
         RETURN(rc);
 }
index 76cde0d..2aeee54 100644 (file)
@@ -3276,7 +3276,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         if (rc)
                 GOTO(err_stop_service, rc);
 
-        if(obd->obd_recovering == 0)
+        if (obd->obd_recovering == 0)
                 mdt_postrecov(env, m);
 
         RETURN(0);
index 43104b4..36cfef7 100644 (file)
@@ -1146,6 +1146,7 @@ test_29() {
        log 'done'
        LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
        LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
+        
        if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
                echo > $LPROC/ldlm/dump_namespaces
                error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"