if (is_grant_shrink) {
body = req_capsule_client_get(tsi->tsi_pill, &RMF_OST_BODY);
+ /*
+ * Because we already sync grant info with client when
+ * reconnect, grant info will be cleared for resent
+ * req, otherwise, outdated grant count in the rpc
+ * would de-sync grant counters
+ */
+ if (lustre_msg_get_flags(req->rq_reqmsg) &
+ (MSG_RESENT | MSG_REPLAY)) {
+ DEBUG_REQ(D_CACHE, req,
+ "clear resent/replay req grant info");
+ body->oa.o_valid &= ~OBD_MD_FLGRANT;
+ }
+
repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY);
*repbody = *body;
GOTO(out_lock, rc = -ETIMEDOUT);
}
+ /*
+ * Because we already sync grant info with client when
+ * reconnect, grant info will be cleared for resent req,
+ * otherwise, outdated grant count in the rpc would de-sync
+ * grant counters in case of shrink
+ */
+ if (lustre_msg_get_flags(req->rq_reqmsg) & (MSG_RESENT | MSG_REPLAY)) {
+ DEBUG_REQ(D_CACHE, req, "clear resent/replay req grant info");
+ body->oa.o_valid &= ~OBD_MD_FLGRANT;
+ }
+
repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
repbody->oa = body->oa;
}
run_test 64h "grant shrink on read"
+test_64i() {
+ (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "need OST at least 2.14.55 to avoid grant shrink on replay"
+
+ [ $PARALLEL == "yes" ] && skip "skip parallel run"
+ remote_ost_nodsh && skip "remote OSTs with nodsh"
+
+ $LFS setstripe -c 1 -i 0 $DIR/$tfile
+
+ dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
+
+ # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
+ local instance=$($LFS getname -i $DIR)
+
+ local osc_tgt="$FSNAME-OST0000-osc-$instance"
+ local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
+
+ # shrink grants and simulate rpc loss
+ #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
+ do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
+ $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
+
+ fail ost1
+
+ dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
+
+ local testid=$(echo $TESTNAME | tr '_' ' ')
+
+ do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
+ grep "GRANT, real grant" &&
+ error "client has more grants then it owns" || true
+}
+run_test 64i "shrink on reconnect"
+
# bug 1414 - set/get directories' stripe info
test_65a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run"