* Author: Johann Lombardi <johann.lombardi@intel.com>
*/
-#define DEBUG_SUBSYSTEM S_FILTER
+#define DEBUG_SUBSYSTEM S_CLASS
#include <obd.h>
#include <obd_class.h>
struct tg_export_data *ted = &exp->exp_target_data;
struct obd_device *obd = exp->exp_obd;
struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
- long dirty;
- long dropped;
+ long long dirty, dropped;
ENTRY;
assert_spin_locked(&tgd->tgd_grant_lock);
/* inflate grant counters if required */
if (!exp_grant_param_supp(exp)) {
+ u64 tmp;
oa->o_grant = tgt_grant_inflate(tgd, oa->o_grant);
oa->o_dirty = tgt_grant_inflate(tgd, oa->o_dirty);
- oa->o_dropped = tgt_grant_inflate(tgd, (u64)oa->o_dropped);
- oa->o_undirty = tgt_grant_inflate(tgd, oa->o_undirty);
+ /* inflation can bump client's wish to >4GB which doesn't fit
+ * 32bit o_undirty, limit that .. */
+ tmp = tgt_grant_inflate(tgd, oa->o_undirty);
+ if (tmp >= OBD_MAX_GRANT)
+ tmp = OBD_MAX_GRANT & ~(1ULL << tgd->tgd_blockbits);
+ oa->o_undirty = tmp;
+ tmp = tgt_grant_inflate(tgd, oa->o_dropped);
+ if (tmp >= OBD_MAX_GRANT)
+ tmp = OBD_MAX_GRANT & ~(1ULL << tgd->tgd_blockbits);
+ oa->o_dropped = tmp;
}
dirty = oa->o_dirty;
tgd->tgd_tot_dirty += dirty - ted->ted_dirty;
if (ted->ted_grant < dropped) {
CDEBUG(D_CACHE,
- "%s: cli %s/%p reports %lu dropped > grant %lu\n",
+ "%s: cli %s/%p reports %llu dropped > grant %lu\n",
obd->obd_name, exp->exp_client_uuid.uuid, exp, dropped,
ted->ted_grant);
dropped = 0;
}
if (tgd->tgd_tot_granted < dropped) {
- CERROR("%s: cli %s/%p reports %lu dropped > tot_grant %llu\n",
+ CERROR("%s: cli %s/%p reports %llu dropped > tot_grant %llu\n",
obd->obd_name, exp->exp_client_uuid.uuid, exp,
dropped, tgd->tgd_tot_granted);
dropped = 0;
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;
* client would like to have by more than grants for 2 full
* RPCs
*/
+ if (want + chunk <= ted->ted_grant)
+ RETURN(0);
if (ted->ted_grant + grant > want + chunk)
grant = want + chunk - ted->ted_grant;
void tgt_grant_discard(struct obd_export *exp)
{
struct obd_device *obd = exp->exp_obd;
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct lu_target *lut = class_exp2tgt(exp);
struct tg_export_data *ted = &exp->exp_target_data;
+ struct tg_grants_data *tgd;
+
+ if (!lut)
+ return;
+ 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",