Whamcloud - gitweb
LU-15009 ofd: continue precreate if LAST_ID is less on MDT
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index 4858cf5..cb7a1b5 100644 (file)
@@ -1636,7 +1636,7 @@ static int ofd_create_hdl(struct tgt_session_info *tsi)
                                GOTO(out, rc = -EINVAL);
                        }
 
-                       if (diff < 0) {
+                       if (diff <= -OST_MAX_PRECREATE) {
                                /* LU-5648 */
                                CERROR("%s: invalid precreate request for "
                                       DOSTID", last_id %llu. "
@@ -1644,6 +1644,15 @@ static int ofd_create_hdl(struct tgt_session_info *tsi)
                                       ofd_name(ofd), POSTID(&oa->o_oi),
                                       ofd_seq_last_oid(oseq));
                                GOTO(out, rc = -EINVAL);
+                       } else if (diff < 0) {
+                               LCONSOLE(D_INFO,
+                                        "%s: MDS LAST_ID "DFID" (%llu) is %lld behind OST LAST_ID "DFID" (%llu), trust the OST\n",
+                                        ofd_name(ofd), PFID(&oa->o_oi.oi_fid),
+                                        oid, -diff, PFID(&oseq->os_oi.oi_fid),
+                                        ofd_seq_last_oid(oseq));
+                               /* Let MDS know that we are so far ahead. */
+                               rc = ostid_set_id(&rep_oa->o_oi,
+                                                 ofd_seq_last_oid(oseq) + 1);
                        }
                }
        }