Whamcloud - gitweb
LU-14543 target: prevent overflowing of tgd->tgd_tot_granted 29/42129/14
authorVladimir Saveliev <vlaidimir.saveliev@hpe.com>
Fri, 19 Mar 2021 12:08:47 +0000 (15:08 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 30 Sep 2021 13:27:01 +0000 (13:27 +0000)
commitbb5d81ea95502fb5709e176b561b70aa5280ee07
tree1e2b2cdfdfc9ee40c0a15bdb8d82a508dd627c52
parent3fb7b6271855c0b12c5a560c7f6287cdda3d1cd6
LU-14543 target: prevent overflowing of tgd->tgd_tot_granted

If tgd->tgd_tot_granted < ted->ted_grant then there should not be:
   tgd->tgd_tot_granted -= ted->ted_grant;
which breaks tgd->tgd_tot_granted.
In case of obvious ted->ted_grant damage, recalculate
tgd->tgd_tot_granted using list of exports.

The same change is made for tgd->tgd_tot_dirty.

This patch also adds sanity check for exp->exp_target_data.ted_grant
increase in tgt_grant_alloc() to catch grant counting corruption as
soon as it happened. By default, the detected corruption is
CERROR()-ed, if needed that can be switched to LBUG() using lctl
set_param *.*.lbug_on_grant_miscount.
test-framework.sh:init_param_vars() enables LBUG().

Fixes: af2d3ac30e ("LU-11939 tgt: Do not assert during grant cleanup")
Change-Id: I36ba7496f7b72b4881e98c06ec254a8eefd4c13f
Signed-off-by: Vladimir Saveliev <vlaidimir.saveliev@hpe.com>
Cray-bug-id: LUS-9875
Reviewed-on: https://review.whamcloud.com/42129
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lu_target.h
lustre/mdt/mdt_lproc.c
lustre/ofd/lproc_ofd.c
lustre/target/tgt_grant.c
lustre/target/tgt_main.c
lustre/tests/test-framework.sh