+ return ((d->opd_sync_last_processed_id < d->opd_sync_last_used_id) &&
+ (d->opd_sync_last_processed_id < d->opd_sync_last_committed_id))
+ || (d->opd_sync_prev_done == 0);
+}
+
+static inline int osp_sync_in_flight_conflict(struct osp_device *d,
+ struct llog_rec_hdr *h)
+{
+ struct osp_job_req_args *jra;
+ struct ost_id ostid;
+ int conflict = 0;
+
+ if (h == NULL || h->lrh_type == LLOG_GEN_REC ||
+ list_empty(&d->opd_sync_in_flight_list))
+ return conflict;
+
+ memset(&ostid, 0, sizeof(ostid));
+ switch (h->lrh_type) {
+ case MDS_UNLINK_REC: {
+ struct llog_unlink_rec *unlink = (struct llog_unlink_rec *)h;
+
+ ostid_set_seq(&ostid, unlink->lur_oseq);
+ if (ostid_set_id(&ostid, unlink->lur_oid)) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ (unsigned long long)(unlink->lur_oid),
+ POSTID(&ostid));
+ return 1;
+ }
+ }
+ break;
+ case MDS_UNLINK64_REC:
+ fid_to_ostid(&((struct llog_unlink64_rec *)h)->lur_fid, &ostid);
+ break;
+ case MDS_SETATTR64_REC:
+ ostid = ((struct llog_setattr64_rec *)h)->lsr_oi;
+ break;
+ default:
+ LBUG();
+ }
+
+ spin_lock(&d->opd_sync_lock);
+ list_for_each_entry(jra, &d->opd_sync_in_flight_list,
+ jra_in_flight_link) {
+ struct ptlrpc_request *req;
+ struct ost_body *body;
+
+ LASSERT(jra->jra_magic == OSP_JOB_MAGIC);
+
+ req = container_of((void *)jra, struct ptlrpc_request,
+ rq_async_args);
+ body = req_capsule_client_get(&req->rq_pill,
+ &RMF_OST_BODY);
+ LASSERT(body);
+
+ if (memcmp(&ostid, &body->oa.o_oi, sizeof(ostid)) == 0) {
+ conflict = 1;
+ break;
+ }
+ }
+ spin_unlock(&d->opd_sync_lock);
+
+ return conflict;