grant_shrink = oa->o_grant;
+ if (ted->ted_grant < grant_shrink) {
+ CDEBUG(D_CACHE,
+ "%s: cli %s/%p wants %lu shrinked > grant %lu\n",
+ obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ grant_shrink, ted->ted_grant);
+ grant_shrink = ted->ted_grant;
+ }
+
ted->ted_grant -= grant_shrink;
tgd->tgd_tot_granted -= grant_shrink;
* have
* \param[in] left remaining free space with granted space taken
* out
+ * \param[in] chunk grant allocation unit
* \param[in] conservative if set to true, the server should be cautious
* and limit how much space is granted back to the
* client. Otherwise, the server should try hard to
ENTRY;
+ if (OBD_FAIL_CHECK(OBD_FAIL_TGT_NO_GRANT))
+ RETURN(0);
+
/* When tgd_grant_compat_disable is set, we don't grant any space to
* clients not supporting OBD_CONNECT_GRANT_PARAM.
* Otherwise, space granted to such a client is inflated since it
tgd->tgd_tot_granted += grant;
ted->ted_grant += grant;
- if (ted->ted_grant < 0) {
+ if (unlikely(ted->ted_grant < 0 || ted->ted_grant > want + chunk)) {
CERROR("%s: cli %s/%p grant %ld want %llu current %llu\n",
obd->obd_name, exp->exp_client_uuid.uuid, exp,
ted->ted_grant, want, curgrant);
spin_unlock(&tgd->tgd_grant_lock);
- LBUG();
}
CDEBUG(D_CACHE,
tgd = &lut->lut_tgd;
spin_lock(&tgd->tgd_grant_lock);
- LASSERTF(tgd->tgd_tot_granted >= ted->ted_grant,
- "%s: tot_granted %llu cli %s/%p ted_grant %ld\n",
- obd->obd_name, tgd->tgd_tot_granted,
- exp->exp_client_uuid.uuid, exp, ted->ted_grant);
- tgd->tgd_tot_granted -= ted->ted_grant;
+ if (unlikely(tgd->tgd_tot_granted < ted->ted_grant ||
+ tgd->tgd_tot_dirty < ted->ted_dirty)) {
+ struct obd_export *e;
+ u64 ttg = 0;
+ u64 ttd = 0;
+
+ list_for_each_entry(e, &obd->obd_exports, exp_obd_chain) {
+ LASSERT(exp != e);
+ ttg += e->exp_target_data.ted_grant;
+ ttg += e->exp_target_data.ted_pending;
+ ttd += e->exp_target_data.ted_dirty;
+ }
+ if (tgd->tgd_tot_granted < ted->ted_grant)
+ CERROR("%s: cli %s/%p: tot_granted %llu < ted_grant %ld, corrected to %llu",
+ obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ tgd->tgd_tot_granted, ted->ted_grant, ttg);
+ if (tgd->tgd_tot_dirty < ted->ted_dirty)
+ CERROR("%s: cli %s/%p: tot_dirty %llu < ted_dirty %ld, corrected to %llu",
+ obd->obd_name, exp->exp_client_uuid.uuid, exp,
+ tgd->tgd_tot_dirty, ted->ted_dirty, ttd);
+ tgd->tgd_tot_granted = ttg;
+ tgd->tgd_tot_dirty = ttd;
+ } else {
+ tgd->tgd_tot_granted -= ted->ted_grant;
+ tgd->tgd_tot_dirty -= ted->ted_dirty;
+ }
ted->ted_grant = 0;
- LASSERTF(tgd->tgd_tot_pending >= ted->ted_pending,
- "%s: tot_pending %llu cli %s/%p ted_pending %ld\n",
- obd->obd_name, tgd->tgd_tot_pending,
- exp->exp_client_uuid.uuid, exp, ted->ted_pending);
+ ted->ted_dirty = 0;
+
+ if (tgd->tgd_tot_pending < ted->ted_pending) {
+ CERROR("%s: tot_pending %llu < cli %s/%p ted_pending %ld\n",
+ obd->obd_name, tgd->tgd_tot_pending,
+ exp->exp_client_uuid.uuid, exp, ted->ted_pending);
+ }
/* tgd_tot_pending is handled in tgt_grant_commit as bulk
* commmits */
- LASSERTF(tgd->tgd_tot_dirty >= ted->ted_dirty,
- "%s: tot_dirty %llu cli %s/%p ted_dirty %ld\n",
- obd->obd_name, tgd->tgd_tot_dirty,
- exp->exp_client_uuid.uuid, exp, ted->ted_dirty);
- tgd->tgd_tot_dirty -= ted->ted_dirty;
- ted->ted_dirty = 0;
spin_unlock(&tgd->tgd_grant_lock);
}
EXPORT_SYMBOL(tgt_grant_discard);