Commit e05ccafd authored by Mikhail Pershin's avatar Mikhail Pershin Committed by Oleg Drokin
Browse files

LU-13763 osc: don't allow negative grants

Add check in the osc_init_grant() to prevent possible
underflow of cl_avail_grant and report error if it happens
Signed-off-by: default avatarMikhail Pershin <>
Change-Id: Idcd25ed427c23735e1cdc70359bace43b5b9d886

Reviewed-by: default avatarAndreas Dilger <>
Tested-by: default avatarjenkins <>
Tested-by: default avatarMaloo <>
Reviewed-by: default avatarOlaf Faaland-LLNL <>
Reviewed-by: default avatarVladimir Saveliev <>
Reviewed-by: default avatarLi Dongyang <>
Reviewed-by: default avatarOleg Drokin <>
parent 2ffd1ca2
......@@ -1023,12 +1023,19 @@ void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
cli->cl_avail_grant = ocd->ocd_grant;
if (cli->cl_import->imp_state != LUSTRE_IMP_EVICTED) {
cli->cl_avail_grant -= cli->cl_reserved_grant;
unsigned long consumed = cli->cl_reserved_grant;
cli->cl_avail_grant -= cli->cl_dirty_grant;
consumed += cli->cl_dirty_grant;
cli->cl_avail_grant -=
cli->cl_dirty_pages << PAGE_SHIFT;
consumed += cli->cl_dirty_pages << PAGE_SHIFT;
if (cli->cl_avail_grant < consumed) {
CERROR("%s: granted %ld but already consumed %ld\n",
cli_name(cli), cli->cl_avail_grant, consumed);
cli->cl_avail_grant = 0;
} else {
cli->cl_avail_grant -= consumed;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment