Whamcloud - gitweb
we need start a transaction for every open request and return its transaction number...
authorhuanghua <huanghua>
Thu, 27 Jul 2006 05:51:29 +0000 (05:51 +0000)
committerhuanghua <huanghua>
Thu, 27 Jul 2006 05:51:29 +0000 (05:51 +0000)
lustre/llite/file.c
lustre/mdt/mdt_fs.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c
lustre/ptlrpc/client.c

index 34f4c58..17cdda2 100644 (file)
@@ -122,11 +122,12 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode,
                 rc = ll_extent_unlock(fd, inode, lsm, LCK_GROUP,
                                       &fd->fd_cwlockh);
         }
-        CDEBUG(D_INFO, "closing ino = %lu file = %p has open req = %p:%x"
-                       " handle="LPX64"\n",
+        CDEBUG(D_INFO, "closing ino = %lu file = %p has open req = %p, type = %x, "
+                       "transno = "LPU64", handle = "LPX64"\n",
                        inode->i_ino, file,
                        och->och_mod->mod_open_req,
                        och->och_mod->mod_open_req->rq_type,
+                       och->och_mod->mod_open_req->rq_transno,
                        och->och_fh.cookie);
         
         rc = ll_close_inode_openhandle(md_exp, inode, och);
@@ -317,10 +318,10 @@ int ll_file_open(struct inode *inode, struct file *file)
         rc = ll_local_open(file, it, fd);
         req = it->d.lustre.it_data;
         LASSERTF(rc == 0, "rc = %d\n", rc);
-        CDEBUG(D_INFO, "opening ino = %lu file = %p has open req = %p:%x"
-                       " handle="LPX64"\n",
+        CDEBUG(D_INFO, "opening ino = %lu file = %p has open req = %p, type = %x, "
+                       "transno = "LPU64", handle = "LPX64"\n",
                        inode->i_ino, file, req, req->rq_type, 
-                       fd->fd_mds_och.och_fh.cookie);
+                       req->rq_transno, fd->fd_mds_och.och_fh.cookie);
 
         if (!S_ISREG(inode->i_mode))
                 GOTO(out, rc);
index 97b887f..b1f6e93 100644 (file)
@@ -436,7 +436,7 @@ static int mdt_txn_stop_cb(const struct lu_context *ctx,
         spin_unlock(&mdt->mdt_transno_lock);
         /* save transno for the commit callback */
         txni->txi_transno = mti->mti_transno;
-        CDEBUG(D_HA, "transno "LPD64" stopped\n", txni->txi_transno);
+        CDEBUG(D_INFO, "transno "LPD64" stopped\n", txni->txi_transno);
 /*
         TODO: write last_rcvd
 */
@@ -457,7 +457,7 @@ static int mdt_txn_commit_cb(const struct lu_context *ctx,
                 mdt->mdt_last_committed = txi->txi_transno;
                 ptlrpc_commit_replies(obd);
         }
-        CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
+        CDEBUG(D_INFO, "%s: transno "LPD64" committed\n",
                obd->obd_name, txi->txi_transno);
 
         return 0;
index fec0580..f384b60 100644 (file)
@@ -1128,7 +1128,7 @@ int mdt_update_last_transno(struct mdt_thread_info *info, int rc)
                        libcfs_nid2str(exp->exp_connection->c_peer.nid),
                        info->mti_transno, rc);
         }
-        CDEBUG(D_HA, "last_transno = %llu, last_committed = %llu\n",
+        CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n",
                last_transno, last_committed);
 
         req->rq_repmsg->transno = req->rq_transno = last_transno;
@@ -1663,6 +1663,7 @@ static int mdt_intent_reint(enum mdt_it_code opcode,
                 RETURN(-EFAULT);
         rep->lock_policy_res2 = mdt_reint_internal(info, opc);
         intent_set_disposition(rep, DISP_IT_EXECD);
+
         mdt_update_last_transno(info, rep->lock_policy_res2);
 
         RETURN(ELDLM_LOCK_ABORTED);
index 879f5d4..760002f 100644 (file)
@@ -142,6 +142,25 @@ static int mdt_mfd_open(struct mdt_thread_info *info,
                 /*mds_deny_write_access*/
         }
 
+        /* (1) client wants transno when open to keep a ref count for replay;
+         *     see after_reply() and mdc_close_commit();
+         * (2) we need to record the transaction related stuff onto disk;
+         * But, question is: when do a rean only open, do we still need transno?
+         */
+        if (1) {
+                struct txn_param txn;
+                struct thandle *th;
+                struct dt_device *dt = info->mti_mdt->mdt_bottom;
+                txn.tp_credits = 1;
+
+                LASSERT(dt);
+                th = dt->dd_ops->dt_trans_start(info->mti_ctxt, dt, &txn);
+                if (!IS_ERR(th)) 
+                        dt->dd_ops->dt_trans_stop(info->mti_ctxt, th);
+                else 
+                        RETURN(PTR_ERR(th));
+        }
+
         mfd = mdt_mfd_new();
         if (mfd != NULL) {
                 /* keep a reference on this object for this open,
index b82d5a8..fd74614 100644 (file)
@@ -641,11 +641,12 @@ static int after_reply(struct ptlrpc_request *req)
         }
 
         /* Store transno in reqmsg for replay. */
-        CDEBUG(D_INFO, "req->replayable = %d, transno = "LPU64
-                        " committed = "LPU64"\n",
-                        req->rq_import->imp_replayable,
-                        req->rq_repmsg->transno,
-                        req->rq_repmsg->last_committed);
+        CDEBUG(D_INFO, "req@%p: replayable = %d, transno = "LPU64
+                       " committed = "LPU64"\n",
+                       req,
+                       req->rq_import->imp_replayable,
+                       req->rq_repmsg->transno,
+                       req->rq_repmsg->last_committed);
         req->rq_reqmsg->transno = req->rq_transno = req->rq_repmsg->transno;
 
         if (req->rq_import->imp_replayable) {