Whamcloud - gitweb
LU-971 mdt: fix open resent issue with last_xid
authorMikhail Pershin <tappro@whamcloud.com>
Mon, 9 Jan 2012 13:46:10 +0000 (17:46 +0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 16 Feb 2012 17:37:13 +0000 (12:37 -0500)
req_xid_is_last() compares xid with one in client data,
but in master it is not updated in case of open without create.
Patch updates export lcd with last xid, transno and rc for open
requests.

Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: I9e769fecc1e93c7a556d4b9eeadc80a70369e901
Reviewed-on: http://review.whamcloud.com/1930
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: Li Wei <liwei@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_open.c

index 2642660..09b0ad2 100644 (file)
@@ -553,10 +553,12 @@ static void mdt_write_allow(struct mdt_object *o)
 }
 
 /* there can be no real transaction so prepare the fake one */
-static void mdt_empty_transno(struct mdt_thread_info* info)
+static void mdt_empty_transno(struct mdt_thread_info *info, int rc)
 {
-        struct mdt_device *mdt = info->mti_mdt;
-        struct ptlrpc_request *req = mdt_info_req(info);
+        struct mdt_device      *mdt = info->mti_mdt;
+        struct ptlrpc_request  *req = mdt_info_req(info);
+        struct tg_export_data  *ted;
+        struct lsd_client_data *lcd;
 
         ENTRY;
         /* transaction has occurred already */
@@ -579,6 +581,35 @@ static void mdt_empty_transno(struct mdt_thread_info* info)
 
         req->rq_transno = info->mti_transno;
         lustre_msg_set_transno(req->rq_repmsg, info->mti_transno);
+
+        /* update lcd in memory only for resent cases */
+        ted = &req->rq_export->exp_target_data;
+        LASSERT(ted);
+        cfs_mutex_down(&ted->ted_lcd_lock);
+        lcd = ted->ted_lcd;
+        if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE ||
+            lustre_msg_get_opc(req->rq_reqmsg) == MDS_DONE_WRITING) {
+                if (info->mti_transno != 0)
+                        lcd->lcd_last_close_transno = info->mti_transno;
+                lcd->lcd_last_close_xid = req->rq_xid;
+                lcd->lcd_last_close_result = rc;
+        } else {
+                /* VBR: save versions in last_rcvd for reconstruct. */
+                __u64 *pre_versions = lustre_msg_get_versions(req->rq_repmsg);
+                if (pre_versions) {
+                        lcd->lcd_pre_versions[0] = pre_versions[0];
+                        lcd->lcd_pre_versions[1] = pre_versions[1];
+                        lcd->lcd_pre_versions[2] = pre_versions[2];
+                        lcd->lcd_pre_versions[3] = pre_versions[3];
+                }
+                if (info->mti_transno != 0)
+                        lcd->lcd_last_transno = info->mti_transno;
+                lcd->lcd_last_xid = req->rq_xid;
+                lcd->lcd_last_result = rc;
+                lcd->lcd_last_data = info->mti_opdata;
+        }
+        cfs_mutex_up(&ted->ted_lcd_lock);
+
         EXIT;
 }
 
@@ -718,7 +749,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p,
                         cfs_spin_unlock(&med->med_open_lock);
                 }
 
-                mdt_empty_transno(info);
+                mdt_empty_transno(info, rc);
         } else
                 rc = -ENOMEM;
 
@@ -1627,7 +1658,7 @@ int mdt_close(struct mdt_thread_info *info)
                 ret = mdt_mfd_close(info, mfd);
                 if (repbody != NULL)
                         rc = mdt_handle_last_unlink(info, o, ma);
-                mdt_empty_transno(info);
+                mdt_empty_transno(info, rc);
                 mdt_object_put(info->mti_env, o);
         }
         if (repbody != NULL) {
@@ -1690,9 +1721,10 @@ int mdt_done_writing(struct mdt_thread_info *info)
                        info->mti_ioepoch->ioepoch);
                 /* If this is a replay, reconstruct the transno. */
                 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
-                        mdt_empty_transno(info);
-                        RETURN(info->mti_ioepoch->flags & MF_SOM_AU ?
-                               -EAGAIN : 0);
+                        rc = info->mti_ioepoch->flags & MF_SOM_AU ?
+                             -EAGAIN : 0;
+                        mdt_empty_transno(info, rc);
+                        RETURN(rc);
                 }
                 RETURN(-ESTALE);
         }
@@ -1715,6 +1747,6 @@ int mdt_done_writing(struct mdt_thread_info *info)
         rc = mdt_mfd_close(info, mfd);
 
         OBD_FREE_LARGE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize);
-        mdt_empty_transno(info);
+        mdt_empty_transno(info, rc);
         RETURN(rc);
 }