Whamcloud - gitweb
LU-9753 ofd: 64-bits diff variable to avoid overflow
[fs/lustre-release.git] / lustre / target / tgt_grant.c
index 8a513ed..1caad7c 100644 (file)
@@ -90,9 +90,7 @@ static inline u64 tgt_grant_inflate(struct tg_grants_data *tgd, u64 val)
                 * is thus inflated. We already significantly overestimate
                 * overhead, no need to add the extent tax in this case */
                return val << (tgd->tgd_blockbits - COMPAT_BSIZE_SHIFT);
-       /* client can deal with the block size, but does not support per-extent
-        * grant accounting, inflate grant by 100% for such clients */
-       return val << 1;
+       return val;
 }
 
 /* Companion of tgt_grant_inflate() */
@@ -100,7 +98,7 @@ static inline u64 tgt_grant_deflate(struct tg_grants_data *tgd, u64 val)
 {
        if (tgd->tgd_blockbits > COMPAT_BSIZE_SHIFT)
                return val >> (tgd->tgd_blockbits - COMPAT_BSIZE_SHIFT);
-       return val >> 1;
+       return val;
 }
 
 /* Grant chunk is used as a unit for grant allocation. It should be inflated
@@ -121,8 +119,8 @@ static inline u64 tgt_grant_chunk(struct obd_export *exp,
 
        if ((data == NULL && !(exp_grant_param_supp(exp))) ||
            (data != NULL && !OCD_HAS_FLAG(data, GRANT_PARAM)))
-               /* Try to grant enough space to send a full-size RPC */
-               return tgt_grant_inflate(tgd, chunk);
+               /* Try to grant enough space to send 2 full-size RPCs */
+               return tgt_grant_inflate(tgd, chunk) << 1;
 
        /* Try to return enough to send two full-size RPCs
         * = 2 * (BRW_size + #extents_in_BRW * grant_tax) */
@@ -1273,7 +1271,7 @@ EXPORT_SYMBOL(tgt_grant_prepare_write);
  * \retval >= 0                amount of grant space allocated to the precreate request
  * \retval -ENOSPC     on failure
  */
-long tgt_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr)
+long tgt_grant_create(const struct lu_env *env, struct obd_export *exp, s64 *nr)
 {
        struct lu_target        *lut = exp->exp_obd->u.obt.obt_lut;
        struct tg_grants_data   *tgd = &lut->lut_tgd;