- if ((oa->o_valid & OBD_MD_FLFLAGS) &&
- (oa->o_flags & OBD_FL_RECREATE_OBJS)) {
- if (!ofd_obd(ofd)->obd_recovering ||
- ostid_id(&oa->o_oi) > ofd_seq_last_oid(oseq)) {
- CERROR("recreate objid "DOSTID" > last id "LPU64"\n",
- POSTID(&oa->o_oi), ofd_seq_last_oid(oseq));
- GOTO(out_nolock, rc = -EINVAL);
- }
- /* do nothing because we create objects during first write */
- GOTO(out_nolock, rc = 0);
- }
- /* former ofd_handle_precreate */
- if ((oa->o_valid & OBD_MD_FLFLAGS) &&
- (oa->o_flags & OBD_FL_DELORPHAN)) {
- /* destroy orphans */
- if (oti->oti_conn_cnt < exp->exp_conn_cnt) {
- CERROR("%s: dropping old orphan cleanup request\n",
- ofd_name(ofd));
- GOTO(out_nolock, rc = 0);
- }
- /* This causes inflight precreates to abort and drop lock */
- oseq->os_destroys_in_progress = 1;
- mutex_lock(&oseq->os_create_lock);
- if (!oseq->os_destroys_in_progress) {
- CERROR("%s:["LPU64"] destroys_in_progress already"
- " cleared\n", exp->exp_obd->obd_name,
- ostid_seq(&oa->o_oi));
- ostid_set_id(&oa->o_oi, ofd_seq_last_oid(oseq));
- GOTO(out, rc = 0);
- }
- diff = ostid_id(&oa->o_oi) - ofd_seq_last_oid(oseq);
- CDEBUG(D_HA, "ofd_last_id() = "LPU64" -> diff = %d\n",
- ofd_seq_last_oid(oseq), diff);
- if (-diff > OST_MAX_PRECREATE) {
- /* FIXME: should reset precreate_next_id on MDS */
- rc = 0;
- } else if (diff < 0) {
- rc = ofd_orphans_destroy(env, exp, ofd, oa);
- oseq->os_destroys_in_progress = 0;
- } else {
- /* XXX: Used by MDS for the first time! */
- oseq->os_destroys_in_progress = 0;
- }
- } else {
- mutex_lock(&oseq->os_create_lock);
- if (oti->oti_conn_cnt < exp->exp_conn_cnt) {
- CERROR("%s: dropping old precreate request\n",
- ofd_obd(ofd)->obd_name);
- GOTO(out, rc = 0);
- }
- /* only precreate if seq is 0, IDIF or normal and also o_id
- * must be specfied */
- if ((!fid_seq_is_mdt(ostid_seq(&oa->o_oi)) &&
- !fid_seq_is_norm(ostid_seq(&oa->o_oi)) &&
- !fid_seq_is_idif(ostid_seq(&oa->o_oi))) ||
- ostid_id(&oa->o_oi) == 0) {
- diff = 1; /* shouldn't we create this right now? */
- } else {
- diff = ostid_id(&oa->o_oi) - ofd_seq_last_oid(oseq);
- /* Do sync create if the seq is about to used up */
- if (fid_seq_is_idif(ostid_seq(&oa->o_oi)) ||
- fid_seq_is_mdt0(ostid_seq(&oa->o_oi))) {
- if (unlikely(ostid_id(&oa->o_oi) >= IDIF_MAX_OID - 1))
- sync_trans = 1;
- } else if (fid_seq_is_norm(ostid_seq(&oa->o_oi))) {
- if (unlikely(ostid_id(&oa->o_oi) >=
- LUSTRE_DATA_SEQ_MAX_WIDTH - 1))
- sync_trans = 1;
- } else {
- CERROR("%s : invalid o_seq "DOSTID": rc = %d\n",
- ofd_name(ofd), POSTID(&oa->o_oi), -EINVAL);
- GOTO(out, rc = -EINVAL);
- }
- }