- * one. We grow the whole request to the next power-of-two
- * size since we get that much from a slab allocation anyways.
- * This avoids an allocation below in the common case where
- * we need to save a default-sized LOV EA for open replay. */
- size[DLM_INTENT_REC_OFF + 2] = max(lmmsize,
- obddev->u.cli.cl_default_mds_easize);
- rc = lustre_msg_size(class_exp2cliimp(exp)->imp_msg_magic, 6,
- size);
- if (rc & (rc - 1))
- size[DLM_INTENT_REC_OFF + 2] =
- min(size[DLM_INTENT_REC_OFF+2]+round_up(rc)-rc,
- obddev->u.cli.cl_max_mds_easize);
-
- if (it->it_flags & O_JOIN_FILE) {
- __u64 head_size = *(__u32*)cb_data;
- __u32 tsize = *(__u32*)lmm;
-
- /* join is like an unlink of the tail */
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
- size[DLM_INTENT_REC_OFF + 3] =
- sizeof(struct mds_rec_join);
- req = ptlrpc_prep_req(class_exp2cliimp(exp),
- LUSTRE_DLM_VERSION, LDLM_ENQUEUE,
- 7, size, NULL);
- /* when joining file, cb_data and lmm args together
- * indicate the head file size*/
- mdc_join_pack(req, DLM_INTENT_REC_OFF + 3, data,
- (head_size << 32) | tsize);
- cb_data = NULL;
- lmm = NULL;
- } else {
- req = ptlrpc_prep_req(class_exp2cliimp(exp),
- LUSTRE_DLM_VERSION, LDLM_ENQUEUE,
- 6, size, NULL);
+ * one.
+ */
+ size[DLM_INTENT_REC_OFF + 4] = max(lmmsize,
+ obddev->u.cli.cl_default_mds_easize);
+
+ /* XXX: openlock is not cancelled for cross-refs. */
+ /* If inode is known, cancel conflicting OPEN locks. */
+ if (fid_is_sane(&op_data->op_fid2)) {
+ if (it->it_flags & (FMODE_WRITE|MDS_OPEN_TRUNC))
+ mode = LCK_CW;
+#ifdef FMODE_EXEC
+ else if (it->it_flags & FMODE_EXEC)
+ mode = LCK_PR;
+#endif
+ else
+ mode = LCK_CR;
+ count = mdc_resource_get_unused(exp, &op_data->op_fid2,
+ &cancels, mode,
+ MDS_INODELOCK_OPEN);