struct layout_intent *layout;
struct lu_fid *fid;
struct mdt_object *obj = NULL;
+ int layout_size = 0;
int rc = 0;
ENTRY;
RETURN(-EINVAL);
}
+ layout = req_capsule_client_get(info->mti_pill, &RMF_LAYOUT_INTENT);
+ if (layout == NULL)
+ RETURN(-EPROTO);
+
+ if (layout->li_opc != LAYOUT_INTENT_ACCESS) {
+ CERROR("%s: Unsupported layout intent opc %d\n",
+ mdt_obd_name(info->mti_mdt), layout->li_opc);
+ RETURN(-EINVAL);
+ }
+
fid = &info->mti_tmp_fid2;
fid_extract_from_res_name(fid, &(*lockp)->l_resource->lr_name);
obj = mdt_object_find(info->mti_env, info->mti_mdt, fid);
if (IS_ERR(obj))
- RETURN(PTR_ERR(obj));
+ GOTO(out, rc = PTR_ERR(obj));
if (mdt_object_exists(obj) && !mdt_object_remote(obj)) {
- /* get the length of lsm */
- rc = mdt_attr_get_eabuf_size(info, obj);
- if (rc < 0) {
- mdt_object_put(info->mti_env, obj);
- RETURN(rc);
- }
+ layout_size = mdt_attr_get_eabuf_size(info, obj);
+ if (layout_size < 0)
+ GOTO(out_obj, rc = layout_size);
- if (rc > info->mti_mdt->mdt_max_mdsize)
- info->mti_mdt->mdt_max_mdsize = rc;
+ if (layout_size > info->mti_mdt->mdt_max_mdsize)
+ info->mti_mdt->mdt_max_mdsize = layout_size;
}
- mdt_object_put(info->mti_env, obj);
-
(*lockp)->l_lvb_type = LVB_T_LAYOUT;
- req_capsule_set_size(info->mti_pill, &RMF_DLM_LVB, RCL_SERVER, rc);
+ req_capsule_set_size(info->mti_pill, &RMF_DLM_LVB, RCL_SERVER,
+ layout_size);
rc = req_capsule_server_pack(info->mti_pill);
- if (rc != 0)
- RETURN(-EINVAL);
+ GOTO(out_obj, rc);
+
+out_obj:
+ mdt_object_put(info->mti_env, obj);
- if (lustre_handle_is_used(&lhc->mlh_reg_lh))
+ if (rc == 0 && lustre_handle_is_used(&lhc->mlh_reg_lh))
rc = mdt_intent_lock_replace(info, lockp, lhc, flags);
- layout = req_capsule_client_get(info->mti_pill, &RMF_LAYOUT_INTENT);
- LASSERT(layout != NULL);
- if (layout->li_opc == LAYOUT_INTENT_ACCESS)
- /* return to normal/resent ldlm handling */
- RETURN(rc);
+out:
+ lhc->mlh_reg_lh.cookie = 0;
- CERROR("%s: Unsupported layout intent (%d)\n",
- mdt_obd_name(info->mti_mdt), layout->li_opc);
- RETURN(-EINVAL);
+ return rc;
}
static int mdt_intent_reint(enum mdt_it_code opcode,
test_130_base() {
test_mkdir -p $DIR/$tdir
+ # Prevent interference from layout intent RPCs due to
+ # asynchronous writeback. These will be tested in 130c below.
+ sync
+
# get only LOOKUP lock on $tdir
cancel_lru_locks mdc
ls $DIR/$tdir/$tfile 2>/dev/null
}
run_test 130b "enqueue resend on a stale inode"
+test_130c() {
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+ sync
+ echo XXX > $DIR/$tfile
+
+ cancel_lru_locks mdc
+
+ # Trigger writeback on $tfile.
+ #
+ # we need to race with unlink, unlink must complete before we will
+ # take a DLM lock, otherwise unlink will wait until intent will
+ # complete; but later than intent starts so that intent found
+ # the object
+#define OBD_FAIL_MDS_INTENT_DELAY 0x160
+ set_nodes_failloc "$(mdts_nodes)" 0x80000160
+ sync &
+ T130_PID=$!
+ sleep 2
+
+ rm $DIR/$tfile
+
+ # drop the reply so that resend happens on an unlinked file.
+#define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
+ set_nodes_failloc "$(mdts_nodes)" 0x80000157
+
+ # let the reply to be dropped
+ sleep 10
+
+#define OBD_FAIL_SRV_ENOENT 0x217
+ set_nodes_failloc "$(mdts_nodes)" 0x80000217
+
+ wait $T130_PID
+
+ return 0
+}
+run_test 130c "layout intent resend on a stale inode"
+
complete $SECONDS
check_and_cleanup_lustre
exit_status